19 protected function setUp() {
22 $uniqueId = time() .
'-' . mt_rand();
23 $tmpPrefix =
wfTempDir() .
'/filebackend-unittest-' . $uniqueId;
24 if ( $this->
getCliArg(
'use-filebackend=' ) ) {
25 if ( self::$backendToUse ) {
30 foreach ( $wgFileBackends
as $conf ) {
31 if ( $conf[
'name'] ==
$name ) {
36 $useConfig[
'name'] =
'localtesting';
37 $useConfig[
'shardViaHashLevels'] =
array(
38 'unittest-cont1' =>
array(
'levels' => 1,
'base' => 16,
'repeat' => 1 )
40 if ( isset( $useConfig[
'fileJournal'] ) ) {
44 $class = $useConfig[
'class'];
45 self::$backendToUse =
new $class( $useConfig );
50 'name' =>
'localtesting',
53 'containerPaths' =>
array(
54 'unittest-cont1' =>
"{$tmpPrefix}-localtesting-cont1",
55 'unittest-cont2' =>
"{$tmpPrefix}-localtesting-cont2" )
59 'name' =>
'localtesting',
61 'parallelize' =>
'implicit',
62 'wikiId' => wfWikiId() . $uniqueId,
65 'name' =>
'localmultitesting1',
66 'class' =>
'FSFileBackend',
67 'containerPaths' =>
array(
68 'unittest-cont1' =>
"{$tmpPrefix}-localtestingmulti1-cont1",
69 'unittest-cont2' =>
"{$tmpPrefix}-localtestingmulti1-cont2" ),
70 'isMultiMaster' =>
false
73 'name' =>
'localmultitesting2',
74 'class' =>
'FSFileBackend',
75 'containerPaths' =>
array(
76 'unittest-cont1' =>
"{$tmpPrefix}-localtestingmulti2-cont1",
77 'unittest-cont2' =>
"{$tmpPrefix}-localtestingmulti2-cont2" ),
78 'isMultiMaster' =>
true
86 return 'mwstore://localtesting';
90 return get_class( $this->backend );
99 "FileBackend::isStoragePath on path '$path'" );
104 array(
'mwstore://',
true ),
105 array(
'mwstore://backend',
true ),
106 array(
'mwstore://backend/container',
true ),
107 array(
'mwstore://backend/container/',
true ),
108 array(
'mwstore://backend/container/path',
true ),
109 array(
'mwstore://backend//container/',
true ),
110 array(
'mwstore://backend//container//',
true ),
111 array(
'mwstore://backend//container//path',
true ),
112 array(
'mwstore:///',
true ),
113 array(
'mwstore:/',
false ),
114 array(
'mwstore:',
false ),
124 "FileBackend::splitStoragePath on path '$path'" );
129 array(
'mwstore://backend/container',
array(
'backend',
'container',
'' ) ),
130 array(
'mwstore://backend/container/',
array(
'backend',
'container',
'' ) ),
131 array(
'mwstore://backend/container/path',
array(
'backend',
'container',
'path' ) ),
132 array(
'mwstore://backend/container//path',
array(
'backend',
'container',
'/path' ) ),
133 array(
'mwstore://backend//container/path',
array(
null,
null,
null ) ),
134 array(
'mwstore://backend//container//path',
array(
null,
null,
null ) ),
135 array(
'mwstore://',
array(
null,
null,
null ) ),
136 array(
'mwstore://backend',
array(
null,
null,
null ) ),
137 array(
'mwstore:///',
array(
null,
null,
null ) ),
138 array(
'mwstore:/',
array(
null,
null,
null ) ),
139 array(
'mwstore:',
array(
null,
null,
null ) )
149 "FileBackend::normalizeStoragePath on path '$path'" );
154 array(
'mwstore://backend/container',
'mwstore://backend/container' ),
155 array(
'mwstore://backend/container/',
'mwstore://backend/container' ),
156 array(
'mwstore://backend/container/path',
'mwstore://backend/container/path' ),
157 array(
'mwstore://backend/container//path',
'mwstore://backend/container/path' ),
158 array(
'mwstore://backend/container///path',
'mwstore://backend/container/path' ),
159 array(
'mwstore://backend/container///path//to///obj',
'mwstore://backend/container/path/to/obj' ),
160 array(
'mwstore://',
null ),
161 array(
'mwstore://backend',
null ),
162 array(
'mwstore://backend//container/path',
null ),
163 array(
'mwstore://backend//container//path',
null ),
164 array(
'mwstore:///',
null ),
165 array(
'mwstore:/',
null ),
166 array(
'mwstore:',
null ),
176 "FileBackend::parentStoragePath on path '$path'" );
181 array(
'mwstore://backend/container/path/to/obj',
'mwstore://backend/container/path/to' ),
182 array(
'mwstore://backend/container/path/to',
'mwstore://backend/container/path' ),
183 array(
'mwstore://backend/container/path',
'mwstore://backend/container' ),
184 array(
'mwstore://backend/container',
null ),
185 array(
'mwstore://backend/container/path/to/obj/',
'mwstore://backend/container/path/to' ),
186 array(
'mwstore://backend/container/path/to/',
'mwstore://backend/container/path' ),
187 array(
'mwstore://backend/container/path/',
'mwstore://backend/container' ),
188 array(
'mwstore://backend/container/',
null ),
198 "FileBackend::extensionFromPath on path '$path'" );
203 array(
'mwstore://backend/container/path.txt',
'txt' ),
204 array(
'mwstore://backend/container/path.svg.png',
'png' ),
205 array(
'mwstore://backend/container/path',
'' ),
206 array(
'mwstore://backend/container/path.',
'' ),
214 $this->filesToPrune[] = $op[
'src'];
224 $this->filesToPrune[] = $op[
'src']; # avoid
file leaking
238 file_put_contents(
$source,
"Unit test file" );
240 if ( isset( $op[
'overwrite'] ) || isset( $op[
'overwriteSame'] ) ) {
241 $this->backend->store( $op );
244 $status = $this->backend->doOperation( $op );
247 "Store from $source to $dest succeeded without warnings ($backendName)." );
248 $this->assertEquals(
true, $status->isOK(),
249 "Store from $source to $dest succeeded ($backendName)." );
250 $this->assertEquals(
array( 0 =>
true ), $status->success,
251 "Store from $source to $dest has proper 'success' field in Status ($backendName)." );
252 $this->assertEquals(
true, file_exists(
$source ),
253 "Source file $source still exists ($backendName)." );
254 $this->assertEquals(
true, $this->backend->fileExists(
array(
'src' => $dest ) ),
255 "Destination file $dest exists ($backendName)." );
257 $this->assertEquals( filesize(
$source ),
258 $this->backend->getFileSize(
array(
'src' => $dest ) ),
259 "Destination file $dest has correct size ($backendName)." );
262 $props2 = $this->backend->getFileProps(
array(
'src' => $dest ) );
263 $this->assertEquals( $props1, $props2,
264 "Source and destination have the same props ($backendName)." );
274 $op =
array(
'op' =>
'store',
'src' => $tmpName,
'dst' => $toPath );
282 $op2[
'overwrite'] =
true;
290 $op2[
'overwriteSame'] =
true;
324 if ( isset( $op[
'ignoreMissingSource'] ) ) {
325 $status = $this->backend->doOperation( $op );
327 "Move from $source to $dest succeeded without warnings ($backendName)." );
328 $this->assertEquals(
array( 0 =>
true ), $status->success,
329 "Move from $source to $dest has proper 'success' field in Status ($backendName)." );
330 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' =>
$source ) ),
331 "Source file $source does not exist ($backendName)." );
332 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' => $dest ) ),
333 "Destination file $dest does not exist ($backendName)." );
338 $status = $this->backend->doOperation(
339 array(
'op' =>
'create',
'content' =>
'blahblah',
'dst' =>
$source ) );
341 "Creation of file at $source succeeded ($backendName)." );
343 if ( isset( $op[
'overwrite'] ) || isset( $op[
'overwriteSame'] ) ) {
344 $this->backend->copy( $op );
347 $status = $this->backend->doOperation( $op );
350 "Copy from $source to $dest succeeded without warnings ($backendName)." );
351 $this->assertEquals(
true, $status->isOK(),
352 "Copy from $source to $dest succeeded ($backendName)." );
353 $this->assertEquals(
array( 0 =>
true ), $status->success,
354 "Copy from $source to $dest has proper 'success' field in Status ($backendName)." );
355 $this->assertEquals(
true, $this->backend->fileExists(
array(
'src' =>
$source ) ),
356 "Source file $source still exists ($backendName)." );
357 $this->assertEquals(
true, $this->backend->fileExists(
array(
'src' => $dest ) ),
358 "Destination file $dest exists after copy ($backendName)." );
361 $this->backend->getFileSize(
array(
'src' =>
$source ) ),
362 $this->backend->getFileSize(
array(
'src' => $dest ) ),
363 "Destination file $dest has correct size ($backendName)." );
365 $props1 = $this->backend->getFileProps(
array(
'src' =>
$source ) );
366 $props2 = $this->backend->getFileProps(
array(
'src' => $dest ) );
367 $this->assertEquals( $props1, $props2,
368 "Source and destination have the same props ($backendName)." );
379 $op =
array(
'op' =>
'copy',
'src' =>
$source,
'dst' => $dest );
387 $op2[
'overwrite'] =
true;
395 $op2[
'overwriteSame'] =
true;
403 $op2[
'ignoreMissingSource'] =
true;
411 $op2[
'ignoreMissingSource'] =
true;
414 self::baseStorePath() .
'/unittest-cont-bad/e/file.txt',
445 if ( isset( $op[
'ignoreMissingSource'] ) ) {
446 $status = $this->backend->doOperation( $op );
448 "Move from $source to $dest succeeded without warnings ($backendName)." );
449 $this->assertEquals(
array( 0 =>
true ), $status->success,
450 "Move from $source to $dest has proper 'success' field in Status ($backendName)." );
451 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' =>
$source ) ),
452 "Source file $source does not exist ($backendName)." );
453 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' => $dest ) ),
454 "Destination file $dest does not exist ($backendName)." );
459 $status = $this->backend->doOperation(
460 array(
'op' =>
'create',
'content' =>
'blahblah',
'dst' =>
$source ) );
462 "Creation of file at $source succeeded ($backendName)." );
464 if ( isset( $op[
'overwrite'] ) || isset( $op[
'overwriteSame'] ) ) {
465 $this->backend->copy( $op );
468 $status = $this->backend->doOperation( $op );
470 "Move from $source to $dest succeeded without warnings ($backendName)." );
471 $this->assertEquals(
true, $status->isOK(),
472 "Move from $source to $dest succeeded ($backendName)." );
473 $this->assertEquals(
array( 0 =>
true ), $status->success,
474 "Move from $source to $dest has proper 'success' field in Status ($backendName)." );
475 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' =>
$source ) ),
476 "Source file $source does not still exists ($backendName)." );
477 $this->assertEquals(
true, $this->backend->fileExists(
array(
'src' => $dest ) ),
478 "Destination file $dest exists after move ($backendName)." );
480 $this->assertNotEquals(
481 $this->backend->getFileSize(
array(
'src' =>
$source ) ),
482 $this->backend->getFileSize(
array(
'src' => $dest ) ),
483 "Destination file $dest has correct size ($backendName)." );
485 $props1 = $this->backend->getFileProps(
array(
'src' =>
$source ) );
486 $props2 = $this->backend->getFileProps(
array(
'src' => $dest ) );
487 $this->assertEquals(
false, $props1[
'fileExists'],
488 "Source file does not exist accourding to props ($backendName)." );
489 $this->assertEquals(
true, $props2[
'fileExists'],
490 "Destination file exists accourding to props ($backendName)." );
501 $op =
array(
'op' =>
'move',
'src' =>
$source,
'dst' => $dest );
509 $op2[
'overwrite'] =
true;
517 $op2[
'overwriteSame'] =
true;
525 $op2[
'ignoreMissingSource'] =
true;
533 $op2[
'ignoreMissingSource'] =
true;
536 self::baseStorePath() .
'/unittest-cont-bad/e/file.txt',
547 public function testDelete( $op, $withSource, $okStatus ) {
559 private function doTestDelete( $op, $withSource, $okStatus ) {
566 $status = $this->backend->doOperation(
567 array(
'op' =>
'create',
'content' =>
'blahblah',
'dst' =>
$source ) );
569 "Creation of file at $source succeeded ($backendName)." );
572 $status = $this->backend->doOperation( $op );
575 "Deletion of file at $source succeeded without warnings ($backendName)." );
576 $this->assertEquals(
true, $status->isOK(),
577 "Deletion of file at $source succeeded ($backendName)." );
578 $this->assertEquals(
array( 0 =>
true ), $status->success,
579 "Deletion of file at $source has proper 'success' field in Status ($backendName)." );
581 $this->assertEquals(
false, $status->isOK(),
582 "Deletion of file at $source failed ($backendName)." );
585 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' =>
$source ) ),
586 "Source file $source does not exist after move ($backendName)." );
589 $this->backend->getFileSize(
array(
'src' =>
$source ) ),
590 "Source file $source has correct size (false) ($backendName)." );
592 $props1 = $this->backend->getFileProps(
array(
'src' =>
$source ) );
593 $this->assertFalse( $props1[
'fileExists'],
594 "Source file $source does not exist according to props ($backendName)." );
617 $op[
'ignoreMissingSource'] =
true;
624 $op[
'ignoreMissingSource'] =
true;
639 public function testDescribe( $op, $withSource, $okStatus ) {
658 $status = $this->backend->doOperation(
659 array(
'op' =>
'create',
'content' =>
'blahblah',
'dst' =>
$source,
660 'headers' =>
array(
'Content-Disposition' =>
'xxx' ) ) );
662 "Creation of file at $source succeeded ($backendName)." );
664 $attr = $this->backend->getFileXAttributes(
array(
'src' =>
$source ) );
668 $status = $this->backend->describe(
array(
'src' =>
$source,
669 'headers' =>
array(
'Content-Disposition' =>
'' ) ) );
671 "Removal of header for $source succeeded ($backendName)." );
674 $attr = $this->backend->getFileXAttributes(
array(
'src' =>
$source ) );
675 $this->assertFalse( isset( $attr[
'headers'][
'content-disposition'] ),
676 "File 'Content-Disposition' header removed." );
680 $status = $this->backend->doOperation( $op );
683 "Describe of file at $source succeeded without warnings ($backendName)." );
684 $this->assertEquals(
true, $status->isOK(),
685 "Describe of file at $source succeeded ($backendName)." );
686 $this->assertEquals(
array( 0 =>
true ), $status->success,
687 "Describe of file at $source has proper 'success' field in Status ($backendName)." );
692 $this->assertEquals(
false, $status->isOK(),
693 "Describe of file at $source failed ($backendName)." );
700 foreach ( $headers
as $n => $v ) {
702 $this->assertTrue( isset( $attr[
'headers'][strtolower(
$n )] ),
703 "File has '$n' header." );
704 $this->assertEquals( $v, $attr[
'headers'][strtolower(
$n )],
705 "File has '$n' header value." );
707 $this->assertFalse( isset( $attr[
'headers'][strtolower(
$n )] ),
708 "File does not have '$n' header." );
719 'headers' =>
array(
'Content-Disposition' =>
'inline' ), );
739 public function testCreate( $op, $alreadyExists, $okStatus, $newSize ) {
742 $this->
doTestCreate( $op, $alreadyExists, $okStatus, $newSize );
747 $this->
doTestCreate( $op, $alreadyExists, $okStatus, $newSize );
751 private function doTestCreate( $op, $alreadyExists, $okStatus, $newSize ) {
757 $oldText =
'blah...blah...waahwaah';
758 if ( $alreadyExists ) {
759 $status = $this->backend->doOperation(
760 array(
'op' =>
'create',
'content' => $oldText,
'dst' => $dest ) );
762 "Creation of file at $dest succeeded ($backendName)." );
765 $status = $this->backend->doOperation( $op );
768 "Creation of file at $dest succeeded without warnings ($backendName)." );
769 $this->assertEquals(
true, $status->isOK(),
770 "Creation of file at $dest succeeded ($backendName)." );
771 $this->assertEquals(
array( 0 =>
true ), $status->success,
772 "Creation of file at $dest has proper 'success' field in Status ($backendName)." );
774 $this->assertEquals(
false, $status->isOK(),
775 "Creation of file at $dest failed ($backendName)." );
778 $this->assertEquals(
true, $this->backend->fileExists(
array(
'src' => $dest ) ),
779 "Destination file $dest exists after creation ($backendName)." );
781 $props1 = $this->backend->getFileProps(
array(
'src' => $dest ) );
782 $this->assertEquals(
true, $props1[
'fileExists'],
783 "Destination file $dest exists according to props ($backendName)." );
785 $this->assertEquals( $newSize, $props1[
'size'],
786 "Destination file $dest has expected size according to props ($backendName)." );
787 $this->assertEquals( $newSize,
788 $this->backend->getFileSize(
array(
'src' => $dest ) ),
789 "Destination file $dest has correct size ($backendName)." );
791 $this->assertEquals( strlen( $oldText ), $props1[
'size'],
792 "Destination file $dest has original size according to props ($backendName)." );
793 $this->assertEquals( strlen( $oldText ),
794 $this->backend->getFileSize(
array(
'src' => $dest ) ),
795 "Destination file $dest has original size according to props ($backendName)." );
809 $op =
array(
'op' =>
'create',
'content' =>
'test test testing',
'dst' => $dest );
814 strlen( $op[
'content'] )
818 $op2[
'content'] =
"\n";
823 strlen( $op2[
'content'] )
827 $op2[
'content'] =
"fsf\n waf 3kt";
832 strlen( $op2[
'content'] )
836 $op2[
'content'] =
"egm'g gkpe gpqg eqwgwqg";
837 $op2[
'overwrite'] =
true;
842 strlen( $op2[
'content'] )
846 $op2[
'content'] =
"39qjmg3-qg";
847 $op2[
'overwriteSame'] =
true;
852 strlen( $op2[
'content'] )
876 "$base/unittest-cont1/e/fileA.a",
877 "$base/unittest-cont1/e/fileB.a",
878 "$base/unittest-cont1/e/fileC.a"
880 $createOps =
array();
885 "Preparing $path succeeded without warnings ($backendName)." );
886 $createOps[] =
array(
'op' =>
'create',
'dst' =>
$path,
'content' => mt_rand( 0, 50000 ) );
887 $copyOps[] =
array(
'op' =>
'copy',
'src' =>
$path,
'dst' =>
"$path-2" );
888 $moveOps[] =
array(
'op' =>
'move',
'src' =>
"$path-2",
'dst' =>
"$path-3" );
889 $purgeOps[] =
array(
'op' =>
'delete',
'src' =>
$path );
890 $purgeOps[] =
array(
'op' =>
'delete',
'src' =>
"$path-3" );
892 $purgeOps[] =
array(
'op' =>
'null' );
895 $this->backend->doQuickOperations( $createOps ),
896 "Creation of source files succeeded ($backendName)." );
898 $this->assertTrue( $this->backend->fileExists(
array(
'src' =>
$file ) ),
899 "File $file exists." );
903 $this->backend->doQuickOperations( $copyOps ),
904 "Quick copy of source files succeeded ($backendName)." );
906 $this->assertTrue( $this->backend->fileExists(
array(
'src' =>
"$file-2" ) ),
907 "File $file-2 exists." );
911 $this->backend->doQuickOperations( $moveOps ),
912 "Quick move of source files succeeded ($backendName)." );
914 $this->assertTrue( $this->backend->fileExists(
array(
'src' =>
"$file-3" ) ),
915 "File $file-3 move in." );
916 $this->assertFalse( $this->backend->fileExists(
array(
'src' =>
"$file-2" ) ),
917 "File $file-2 moved away." );
922 "Copy of file {$files[0]} over itself succeeded ($backendName)." );
923 $this->assertTrue( $this->backend->fileExists(
array(
'src' =>
$files[0] ) ),
924 "File {$files[0]} still exists." );
928 "Move of file {$files[0]} over itself succeeded ($backendName)." );
929 $this->assertTrue( $this->backend->fileExists(
array(
'src' =>
$files[0] ) ),
930 "File {$files[0]} still exists." );
933 $this->backend->doQuickOperations( $purgeOps ),
934 "Quick deletion of source files succeeded ($backendName)." );
936 $this->assertFalse( $this->backend->fileExists(
array(
'src' =>
$file ) ),
937 "File $file purged." );
938 $this->assertFalse( $this->backend->fileExists(
array(
'src' =>
"$file-3" ) ),
939 "File $file-3 purged." );
946 public function testConcatenate( $op, $srcs, $srcsContent, $alreadyExists, $okStatus ) {
947 $this->filesToPrune[] = $op[
'dst'];
952 $this->filesToPrune[] = $op[
'dst']; # avoid
file leaking
958 $this->filesToPrune[] = $op[
'dst']; # avoid
file leaking
973 'content' => $srcsContent[$i]
975 $expContent .= $srcsContent[$i];
977 $status = $this->backend->doOperations( $ops );
980 "Creation of source files succeeded ($backendName)." );
983 if ( $alreadyExists ) {
984 $ok = file_put_contents( $dest,
'blah...blah...waahwaah' ) !==
false;
985 $this->assertEquals(
true,
$ok,
986 "Creation of file at $dest succeeded ($backendName)." );
988 $ok = file_put_contents( $dest,
'' ) !==
false;
989 $this->assertEquals(
true,
$ok,
990 "Creation of 0-byte file at $dest succeeded ($backendName)." );
994 $status = $this->backend->concatenate(
$params );
997 "Creation of concat file at $dest succeeded without warnings ($backendName)." );
998 $this->assertEquals(
true, $status->isOK(),
999 "Creation of concat file at $dest succeeded ($backendName)." );
1001 $this->assertEquals(
false, $status->isOK(),
1002 "Creation of concat file at $dest failed ($backendName)." );
1006 $this->assertEquals(
true, is_file( $dest ),
1007 "Dest concat file $dest exists after creation ($backendName)." );
1009 $this->assertEquals(
true, is_file( $dest ),
1010 "Dest concat file $dest exists after failed creation ($backendName)." );
1013 $contents = file_get_contents( $dest );
1014 $this->assertNotEquals(
false, $contents,
"File at $dest exists ($backendName)." );
1017 $this->assertEquals( $expContent, $contents,
1018 "Concat file at $dest has correct contents ($backendName)." );
1020 $this->assertNotEquals( $expContent, $contents,
1021 "Concat file at $dest has correct contents ($backendName)." );
1028 $rand = mt_rand( 0, 2000000000 ) . time();
1029 $dest =
wfTempDir() .
"/randomfile!$rand.txt";
1031 self::baseStorePath() .
'/unittest-cont1/e/file1.txt',
1032 self::baseStorePath() .
'/unittest-cont1/e/file2.txt',
1033 self::baseStorePath() .
'/unittest-cont1/e/file3.txt',
1034 self::baseStorePath() .
'/unittest-cont1/e/file4.txt',
1035 self::baseStorePath() .
'/unittest-cont1/e/file5.txt',
1036 self::baseStorePath() .
'/unittest-cont1/e/file6.txt',
1037 self::baseStorePath() .
'/unittest-cont1/e/file7.txt',
1038 self::baseStorePath() .
'/unittest-cont1/e/file8.txt',
1039 self::baseStorePath() .
'/unittest-cont1/e/file9.txt',
1040 self::baseStorePath() .
'/unittest-cont1/e/file10.txt'
1094 if ( $alreadyExists ) {
1096 $status = $this->
create(
array(
'dst' => $path,
'content' => $content ) );
1098 "Creation of file at $path succeeded ($backendName)." );
1102 $stat = $this->backend->getFileStat(
array(
'src' =>
$path ) );
1104 $this->assertEquals( strlen( $content ),
$size,
1105 "Correct file size of '$path'" );
1107 "Correct file timestamp of '$path'" );
1109 $size = $stat[
'size'];
1110 $time = $stat[
'mtime'];
1111 $this->assertEquals( strlen( $content ),
$size,
1112 "Correct file size of '$path'" );
1114 "Correct file timestamp of '$path'" );
1116 $this->backend->clearCache(
array(
$path ) );
1120 $this->assertEquals( strlen( $content ),
$size,
1121 "Correct file size of '$path'" );
1123 $this->backend->preloadCache(
array(
$path ) );
1127 $this->assertEquals( strlen( $content ),
$size,
1128 "Correct file size of '$path'" );
1132 $stat = $this->backend->getFileStat(
array(
'src' =>
$path ) );
1134 $this->assertFalse(
$size,
"Correct file size of '$path'" );
1135 $this->assertFalse(
$time,
"Correct file timestamp of '$path'" );
1136 $this->assertFalse( $stat,
"Correct file stat of '$path'" );
1144 $cases[] =
array(
"$base/unittest-cont1/e/b/z/some_file.txt",
"some file contents",
true );
1145 $cases[] =
array(
"$base/unittest-cont1/e/b/some-other_file.txt",
"",
true );
1146 $cases[] =
array(
"$base/unittest-cont1/e/b/some-diff_file.txt",
null,
false );
1166 $class =
new ReflectionClass( $this->backend );
1167 $method = $class->getMethod(
'doStreamFile' );
1168 $method->setAccessible(
true );
1170 if ( $content !==
null ) {
1172 $status = $this->
create(
array(
'dst' => $path,
'content' => $content ) );
1174 "Creation of file at $path succeeded ($backendName)." );
1177 $method->invokeArgs( $this->backend,
array(
array(
'src' =>
$path ) ) );
1178 $data = ob_get_contents();
1181 $this->assertEquals( $content, $data,
"Correct content streamed from '$path'" );
1184 $method->invokeArgs( $this->backend,
array(
array(
'src' =>
$path ) ) );
1185 $data = ob_get_contents();
1188 $this->assertEquals(
'', $data,
"Correct content streamed from '$path' ($backendName)" );
1196 $cases[] =
array(
"$base/unittest-cont1/e/b/z/some_file.txt",
"some file contents" );
1197 $cases[] =
array(
"$base/unittest-cont1/e/b/some-other_file.txt",
null );
1223 $content = (
array)$content;
1224 foreach ( $srcs
as $i => $src ) {
1226 $status = $this->backend->doOperation(
1227 array(
'op' =>
'create',
'content' => $content[$i],
'dst' => $src ) );
1229 "Creation of file at $src succeeded ($backendName)." );
1233 $contents = $this->backend->getFileContentsMulti(
array(
'srcs' =>
$source ) );
1234 foreach ( $contents
as $path => $data ) {
1235 $this->assertNotEquals(
false, $data,
"Contents of $path exists ($backendName)." );
1236 $this->assertEquals( current( $content ), $data,
"Contents of $path is correct ($backendName)." );
1239 $this->assertEquals(
$source, array_keys( $contents ),
"Contents in right order ($backendName)." );
1240 $this->assertEquals( count(
$source ), count( $contents ),
"Contents array size correct ($backendName)." );
1242 $data = $this->backend->getFileContents(
array(
'src' =>
$source ) );
1243 $this->assertNotEquals(
false, $data,
"Contents of $source exists ($backendName)." );
1244 $this->assertEquals( $content[0], $data,
"Contents of $source is correct ($backendName)." );
1252 $cases[] =
array(
"$base/unittest-cont1/e/b/z/some_file.txt",
"some file contents" );
1253 $cases[] =
array(
"$base/unittest-cont1/e/b/some-other_file.txt",
"more file contents" );
1255 array(
"$base/unittest-cont1/e/a/x.txt",
"$base/unittest-cont1/e/a/y.txt",
1256 "$base/unittest-cont1/e/a/z.txt" ),
1257 array(
"contents xx",
"contents xy",
"contents xz" )
1283 $content = (
array)$content;
1284 foreach ( $srcs
as $i => $src ) {
1286 $status = $this->backend->doOperation(
1287 array(
'op' =>
'create',
'content' => $content[$i],
'dst' => $src ) );
1289 "Creation of file at $src succeeded ($backendName)." );
1295 $this->assertNotNull( $tmpFile,
1296 "Creation of local copy of $path succeeded ($backendName)." );
1297 $contents = file_get_contents( $tmpFile->getPath() );
1298 $this->assertNotEquals(
false, $contents,
"Local copy of $path exists ($backendName)." );
1299 $this->assertEquals( current( $content ), $contents,
"Local copy of $path is correct ($backendName)." );
1302 $this->assertEquals(
$source, array_keys(
$tmpFiles ),
"Local copies in right order ($backendName)." );
1303 $this->assertEquals( count(
$source ), count(
$tmpFiles ),
"Local copies array size correct ($backendName)." );
1305 $tmpFile = $this->backend->getLocalCopy(
array(
'src' =>
$source ) );
1306 $this->assertNotNull( $tmpFile,
1307 "Creation of local copy of $source succeeded ($backendName)." );
1308 $contents = file_get_contents( $tmpFile->getPath() );
1309 $this->assertNotEquals(
false, $contents,
"Local copy of $source exists ($backendName)." );
1310 $this->assertEquals( $content[0], $contents,
"Local copy of $source is correct ($backendName)." );
1313 $obj =
new stdClass();
1314 $tmpFile->bind( $obj );
1321 $cases[] =
array(
"$base/unittest-cont1/e/a/z/some_file.txt",
"some file contents" );
1322 $cases[] =
array(
"$base/unittest-cont1/e/a/some-other_file.txt",
"more file contents" );
1323 $cases[] =
array(
"$base/unittest-cont1/e/a/\$odd&.txt",
"test file contents" );
1325 array(
"$base/unittest-cont1/e/a/x.txt",
"$base/unittest-cont1/e/a/y.txt",
1326 "$base/unittest-cont1/e/a/z.txt" ),
1327 array(
"contents xx $",
"contents xy 111",
"contents xz" )
1353 $content = (
array)$content;
1354 foreach ( $srcs
as $i => $src ) {
1356 $status = $this->backend->doOperation(
1357 array(
'op' =>
'create',
'content' => $content[$i],
'dst' => $src ) );
1359 "Creation of file at $src succeeded ($backendName)." );
1365 $this->assertNotNull( $tmpFile,
1366 "Creation of local copy of $path succeeded ($backendName)." );
1367 $contents = file_get_contents( $tmpFile->getPath() );
1368 $this->assertNotEquals(
false, $contents,
"Local ref of $path exists ($backendName)." );
1369 $this->assertEquals( current( $content ), $contents,
"Local ref of $path is correct ($backendName)." );
1372 $this->assertEquals(
$source, array_keys(
$tmpFiles ),
"Local refs in right order ($backendName)." );
1373 $this->assertEquals( count(
$source ), count(
$tmpFiles ),
"Local refs array size correct ($backendName)." );
1375 $tmpFile = $this->backend->getLocalReference(
array(
'src' =>
$source ) );
1376 $this->assertNotNull( $tmpFile,
1377 "Creation of local copy of $source succeeded ($backendName)." );
1378 $contents = file_get_contents( $tmpFile->getPath() );
1379 $this->assertNotEquals(
false, $contents,
"Local ref of $source exists ($backendName)." );
1380 $this->assertEquals( $content[0], $contents,
"Local ref of $source is correct ($backendName)." );
1388 $cases[] =
array(
"$base/unittest-cont1/e/a/z/some_file.txt",
"some file contents" );
1389 $cases[] =
array(
"$base/unittest-cont1/e/a/some-other_file.txt",
"more file contents" );
1390 $cases[] =
array(
"$base/unittest-cont1/e/a/\$odd&.txt",
"test file contents" );
1392 array(
"$base/unittest-cont1/e/a/x.txt",
"$base/unittest-cont1/e/a/y.txt",
1393 "$base/unittest-cont1/e/a/z.txt" ),
1394 array(
"contents xx 1111",
"contents xy %",
"contents xz $" )
1421 $tmpFile = $this->backend->getLocalCopy(
array(
1422 'src' =>
"$base/unittest-cont1/not-there" ) );
1423 $this->assertEquals(
null, $tmpFile,
"Local copy of not existing file is null ($backendName)." );
1425 $tmpFile = $this->backend->getLocalReference(
array(
1426 'src' =>
"$base/unittest-cont1/not-there" ) );
1427 $this->assertEquals(
null, $tmpFile,
"Local ref of not existing file is null ($backendName)." );
1450 $status = $this->backend->doOperation(
1451 array(
'op' =>
'create',
'content' => $content,
'dst' =>
$source ) );
1453 "Creation of file at $source succeeded ($backendName)." );
1455 $url = $this->backend->getFileHttpUrl(
array(
'src' =>
$source ) );
1457 if ( $url !==
null ) {
1459 $this->assertEquals( $content, $data,
1460 "HTTP GET of URL has right contents ($backendName)." );
1468 $cases[] =
array(
"$base/unittest-cont1/e/a/z/some_file.txt",
"some file contents" );
1469 $cases[] =
array(
"$base/unittest-cont1/e/a/some-other_file.txt",
"more file contents" );
1470 $cases[] =
array(
"$base/unittest-cont1/e/a/\$odd&.txt",
"test file contents" );
1494 array(
"$base/unittest-cont1/e/a/z/some_file1.txt",
true ),
1495 array(
"$base/unittest-cont2/a/z/some_file2.txt",
true ),
1496 # Specific to FS backend with no basePath field
set
1497 #
array(
"$base/unittest-cont3/a/z/some_file3.txt",
false ),
1507 "Preparing dir $path succeeded without warnings ($backendName)." );
1508 $this->assertEquals(
true, $status->isOK(),
1509 "Preparing dir $path succeeded ($backendName)." );
1511 $this->assertEquals(
false, $status->isOK(),
1512 "Preparing dir $path failed ($backendName)." );
1515 $status = $this->backend->secure(
array(
'dir' => dirname(
$path ) ) );
1518 "Securing dir $path succeeded without warnings ($backendName)." );
1519 $this->assertEquals(
true, $status->isOK(),
1520 "Securing dir $path succeeded ($backendName)." );
1522 $this->assertEquals(
false, $status->isOK(),
1523 "Securing dir $path failed ($backendName)." );
1526 $status = $this->backend->publish(
array(
'dir' => dirname(
$path ) ) );
1529 "Publishing dir $path succeeded without warnings ($backendName)." );
1530 $this->assertEquals(
true, $status->isOK(),
1531 "Publishing dir $path succeeded ($backendName)." );
1533 $this->assertEquals(
false, $status->isOK(),
1534 "Publishing dir $path failed ($backendName)." );
1537 $status = $this->backend->clean(
array(
'dir' => dirname(
$path ) ) );
1540 "Cleaning dir $path succeeded without warnings ($backendName)." );
1541 $this->assertEquals(
true, $status->isOK(),
1542 "Cleaning dir $path succeeded ($backendName)." );
1544 $this->assertEquals(
false, $status->isOK(),
1545 "Cleaning dir $path failed ($backendName)." );
1567 "$base/unittest-cont1",
1568 "$base/unittest-cont1/e",
1569 "$base/unittest-cont1/e/a",
1570 "$base/unittest-cont1/e/a/b",
1571 "$base/unittest-cont1/e/a/b/c",
1572 "$base/unittest-cont1/e/a/b/c/d0",
1573 "$base/unittest-cont1/e/a/b/c/d1",
1574 "$base/unittest-cont1/e/a/b/c/d2",
1575 "$base/unittest-cont1/e/a/b/c/d0/1",
1576 "$base/unittest-cont1/e/a/b/c/d0/2",
1577 "$base/unittest-cont1/e/a/b/c/d1/3",
1578 "$base/unittest-cont1/e/a/b/c/d1/4",
1579 "$base/unittest-cont1/e/a/b/c/d2/5",
1580 "$base/unittest-cont1/e/a/b/c/d2/6"
1585 "Preparing dir $dir succeeded without warnings ($backendName)." );
1590 $this->assertEquals(
true, $this->backend->directoryExists(
array(
'dir' =>
$dir ) ),
1591 "Dir $dir exists ($backendName)." );
1595 $status = $this->backend->clean(
1596 array(
'dir' =>
"$base/unittest-cont1",
'recursive' => 1 ) );
1598 "Recursive cleaning of dir $dir succeeded without warnings ($backendName)." );
1601 $this->assertEquals(
false, $this->backend->directoryExists(
array(
'dir' =>
$dir ) ),
1602 "Dir $dir no longer exists ($backendName)." );
1624 $fileA =
"$base/unittest-cont1/e/a/b/fileA.txt";
1625 $fileAContents =
'3tqtmoeatmn4wg4qe-mg3qt3 tq';
1626 $fileB =
"$base/unittest-cont1/e/a/b/fileB.txt";
1627 $fileBContents =
'g-jmq3gpqgt3qtg q3GT ';
1628 $fileC =
"$base/unittest-cont1/e/a/b/fileC.txt";
1629 $fileCContents =
'eigna[ogmewt 3qt g3qg flew[ag';
1630 $fileD =
"$base/unittest-cont1/e/a/b/fileD.txt";
1633 $this->
create(
array(
'dst' => $fileA,
'content' => $fileAContents ) );
1635 $this->
create(
array(
'dst' => $fileB,
'content' => $fileBContents ) );
1637 $this->
create(
array(
'dst' => $fileC,
'content' => $fileCContents ) );
1640 $status = $this->backend->doOperations(
array(
1641 array(
'op' =>
'describe',
'src' => $fileA,
1642 'headers' =>
array(
'X-Content-Length' =>
'91.3' ),
'disposition' =>
'inline' ),
1643 array(
'op' =>
'copy',
'src' => $fileA,
'dst' => $fileC,
'overwrite' => 1 ),
1645 array(
'op' =>
'copy',
'src' => $fileC,
'dst' => $fileA,
'overwriteSame' => 1 ),
1647 array(
'op' =>
'move',
'src' => $fileC,
'dst' => $fileD,
'overwrite' => 1 ),
1649 array(
'op' =>
'move',
'src' => $fileB,
'dst' => $fileC ),
1651 array(
'op' =>
'move',
'src' => $fileD,
'dst' => $fileA,
'overwriteSame' => 1 ),
1653 array(
'op' =>
'move',
'src' => $fileC,
'dst' => $fileA,
'overwrite' => 1 ),
1655 array(
'op' =>
'copy',
'src' => $fileA,
'dst' => $fileC ),
1657 array(
'op' =>
'move',
'src' => $fileA,
'dst' => $fileC,
'overwriteSame' => 1 ),
1659 array(
'op' =>
'copy',
'src' => $fileC,
'dst' => $fileC,
'overwrite' => 1 ),
1661 array(
'op' =>
'copy',
'src' => $fileC,
'dst' => $fileC,
'overwriteSame' => 1 ),
1663 array(
'op' =>
'move',
'src' => $fileC,
'dst' => $fileC,
'overwrite' => 1 ),
1665 array(
'op' =>
'move',
'src' => $fileC,
'dst' => $fileC,
'overwriteSame' => 1 ),
1667 array(
'op' =>
'null' ),
1672 $this->assertEquals(
true, $status->isOK(),
"Operation batch succeeded" );
1673 $this->assertEquals( 14, count( $status->success ),
1674 "Operation batch has correct success array" );
1676 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' => $fileA ) ),
1677 "File does not exist at $fileA" );
1678 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' => $fileB ) ),
1679 "File does not exist at $fileB" );
1680 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' => $fileD ) ),
1681 "File does not exist at $fileD" );
1683 $this->assertEquals(
true, $this->backend->fileExists(
array(
'src' => $fileC ) ),
1684 "File exists at $fileC" );
1685 $this->assertEquals( $fileBContents,
1686 $this->backend->getFileContents(
array(
'src' => $fileC ) ),
1687 "Correct file contents of $fileC" );
1688 $this->assertEquals( strlen( $fileBContents ),
1689 $this->backend->getFileSize(
array(
'src' => $fileC ) ),
1690 "Correct file size of $fileC" );
1691 $this->assertEquals(
wfBaseConvert( sha1( $fileBContents ), 16, 36, 31 ),
1692 $this->backend->getFileSha1Base36(
array(
'src' => $fileC ) ),
1693 "Correct file SHA-1 of $fileC" );
1715 $fileAContents =
'3tqtmoeatmn4wg4qe-mg3qt3 tq';
1716 $fileBContents =
'g-jmq3gpqgt3qtg q3GT ';
1717 $fileCContents =
'eigna[ogmewt 3qt g3qg flew[ag';
1720 file_put_contents( $tmpNameA, $fileAContents );
1722 file_put_contents( $tmpNameB, $fileBContents );
1724 file_put_contents( $tmpNameC, $fileCContents );
1726 $this->filesToPrune[] = $tmpNameA; # avoid
file leaking
1727 $this->filesToPrune[] = $tmpNameB; # avoid
file leaking
1728 $this->filesToPrune[] = $tmpNameC; # avoid
file leaking
1730 $fileA =
"$base/unittest-cont1/e/a/b/fileA.txt";
1731 $fileB =
"$base/unittest-cont1/e/a/b/fileB.txt";
1732 $fileC =
"$base/unittest-cont1/e/a/b/fileC.txt";
1733 $fileD =
"$base/unittest-cont1/e/a/b/fileD.txt";
1736 $this->
create(
array(
'dst' => $fileA,
'content' => $fileAContents ) );
1741 $status = $this->backend->doOperations(
array(
1742 array(
'op' =>
'store',
'src' => $tmpNameA,
'dst' => $fileA,
'overwriteSame' => 1 ),
1743 array(
'op' =>
'store',
'src' => $tmpNameB,
'dst' => $fileB,
'overwrite' => 1 ),
1744 array(
'op' =>
'store',
'src' => $tmpNameC,
'dst' => $fileC,
'overwrite' => 1 ),
1745 array(
'op' =>
'copy',
'src' => $fileA,
'dst' => $fileC,
'overwrite' => 1 ),
1747 array(
'op' =>
'copy',
'src' => $fileC,
'dst' => $fileA,
'overwriteSame' => 1 ),
1749 array(
'op' =>
'move',
'src' => $fileC,
'dst' => $fileD,
'overwrite' => 1 ),
1751 array(
'op' =>
'move',
'src' => $fileB,
'dst' => $fileC ),
1753 array(
'op' =>
'move',
'src' => $fileD,
'dst' => $fileA,
'overwriteSame' => 1 ),
1755 array(
'op' =>
'move',
'src' => $fileC,
'dst' => $fileA,
'overwrite' => 1 ),
1757 array(
'op' =>
'copy',
'src' => $fileA,
'dst' => $fileC ),
1759 array(
'op' =>
'move',
'src' => $fileA,
'dst' => $fileC,
'overwriteSame' => 1 ),
1761 array(
'op' =>
'copy',
'src' => $fileC,
'dst' => $fileC,
'overwrite' => 1 ),
1763 array(
'op' =>
'copy',
'src' => $fileC,
'dst' => $fileC,
'overwriteSame' => 1 ),
1765 array(
'op' =>
'move',
'src' => $fileC,
'dst' => $fileC,
'overwrite' => 1 ),
1767 array(
'op' =>
'move',
'src' => $fileC,
'dst' => $fileC,
'overwriteSame' => 1 ),
1769 array(
'op' =>
'null' ),
1774 $this->assertEquals(
true, $status->isOK(),
"Operation batch succeeded" );
1775 $this->assertEquals( 16, count( $status->success ),
1776 "Operation batch has correct success array" );
1778 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' => $fileA ) ),
1779 "File does not exist at $fileA" );
1780 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' => $fileB ) ),
1781 "File does not exist at $fileB" );
1782 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' => $fileD ) ),
1783 "File does not exist at $fileD" );
1785 $this->assertEquals(
true, $this->backend->fileExists(
array(
'src' => $fileC ) ),
1786 "File exists at $fileC" );
1787 $this->assertEquals( $fileBContents,
1788 $this->backend->getFileContents(
array(
'src' => $fileC ) ),
1789 "Correct file contents of $fileC" );
1790 $this->assertEquals( strlen( $fileBContents ),
1791 $this->backend->getFileSize(
array(
'src' => $fileC ) ),
1792 "Correct file size of $fileC" );
1793 $this->assertEquals(
wfBaseConvert( sha1( $fileBContents ), 16, 36, 31 ),
1794 $this->backend->getFileSha1Base36(
array(
'src' => $fileC ) ),
1795 "Correct file SHA-1 of $fileC" );
1816 $fileA =
"$base/unittest-cont2/a/b/fileA.txt";
1817 $fileAContents =
'3tqtmoeatmn4wg4qe-mg3qt3 tq';
1818 $fileB =
"$base/unittest-cont2/a/b/fileB.txt";
1819 $fileBContents =
'g-jmq3gpqgt3qtg q3GT ';
1820 $fileC =
"$base/unittest-cont2/a/b/fileC.txt";
1821 $fileCContents =
'eigna[ogmewt 3qt g3qg flew[ag';
1822 $fileD =
"$base/unittest-cont2/a/b/fileD.txt";
1825 $this->
create(
array(
'dst' => $fileA,
'content' => $fileAContents ) );
1827 $this->
create(
array(
'dst' => $fileB,
'content' => $fileBContents ) );
1829 $this->
create(
array(
'dst' => $fileC,
'content' => $fileCContents ) );
1831 $status = $this->backend->doOperations(
array(
1832 array(
'op' =>
'copy',
'src' => $fileA,
'dst' => $fileC,
'overwrite' => 1 ),
1834 array(
'op' =>
'copy',
'src' => $fileC,
'dst' => $fileA,
'overwriteSame' => 1 ),
1836 array(
'op' =>
'copy',
'src' => $fileB,
'dst' => $fileD,
'overwrite' => 1 ),
1838 array(
'op' =>
'move',
'src' => $fileC,
'dst' => $fileD ),
1840 array(
'op' =>
'move',
'src' => $fileB,
'dst' => $fileC,
'overwriteSame' => 1 ),
1842 array(
'op' =>
'move',
'src' => $fileB,
'dst' => $fileA,
'overwrite' => 1 ),
1844 array(
'op' =>
'delete',
'src' => $fileD ),
1846 array(
'op' =>
'null' ),
1848 ),
array(
'force' => 1 ) );
1850 $this->assertNotEquals(
array(), $status->errors,
"Operation had warnings" );
1851 $this->assertEquals(
true, $status->isOK(),
"Operation batch succeeded" );
1852 $this->assertEquals( 8, count( $status->success ),
1853 "Operation batch has correct success array" );
1855 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' => $fileB ) ),
1856 "File does not exist at $fileB" );
1857 $this->assertEquals(
false, $this->backend->fileExists(
array(
'src' => $fileD ) ),
1858 "File does not exist at $fileD" );
1860 $this->assertEquals(
true, $this->backend->fileExists(
array(
'src' => $fileA ) ),
1861 "File does not exist at $fileA" );
1862 $this->assertEquals(
true, $this->backend->fileExists(
array(
'src' => $fileC ) ),
1863 "File exists at $fileC" );
1864 $this->assertEquals( $fileBContents,
1865 $this->backend->getFileContents(
array(
'src' => $fileA ) ),
1866 "Correct file contents of $fileA" );
1867 $this->assertEquals( strlen( $fileBContents ),
1868 $this->backend->getFileSize(
array(
'src' => $fileA ) ),
1869 "Correct file size of $fileA" );
1870 $this->assertEquals(
wfBaseConvert( sha1( $fileBContents ), 16, 36, 31 ),
1871 $this->backend->getFileSha1Base36(
array(
'src' => $fileA ) ),
1872 "Correct file SHA-1 of $fileA" );
1895 $iter = $this->backend->getFileList(
array(
'dir' =>
"$base/unittest-cont-notexists" ) );
1898 "$base/unittest-cont1/e/test1.txt",
1899 "$base/unittest-cont1/e/test2.txt",
1900 "$base/unittest-cont1/e/test3.txt",
1901 "$base/unittest-cont1/e/subdir1/test1.txt",
1902 "$base/unittest-cont1/e/subdir1/test2.txt",
1903 "$base/unittest-cont1/e/subdir2/test3.txt",
1904 "$base/unittest-cont1/e/subdir2/test4.txt",
1905 "$base/unittest-cont1/e/subdir2/subdir/test1.txt",
1906 "$base/unittest-cont1/e/subdir2/subdir/test2.txt",
1907 "$base/unittest-cont1/e/subdir2/subdir/test3.txt",
1908 "$base/unittest-cont1/e/subdir2/subdir/test4.txt",
1909 "$base/unittest-cont1/e/subdir2/subdir/test5.txt",
1910 "$base/unittest-cont1/e/subdir2/subdir/sub/test0.txt",
1911 "$base/unittest-cont1/e/subdir2/subdir/sub/120-px-file.txt",
1918 $ops[] =
array(
'op' =>
'create',
'content' =>
'xxy',
'dst' =>
$file );
1920 $status = $this->backend->doQuickOperations( $ops );
1922 "Creation of files succeeded ($backendName)." );
1923 $this->assertEquals(
true, $status->isOK(),
1924 "Creation of files succeeded with OK status ($backendName)." );
1931 "e/subdir1/test1.txt",
1932 "e/subdir1/test2.txt",
1933 "e/subdir2/test3.txt",
1934 "e/subdir2/test4.txt",
1935 "e/subdir2/subdir/test1.txt",
1936 "e/subdir2/subdir/test2.txt",
1937 "e/subdir2/subdir/test3.txt",
1938 "e/subdir2/subdir/test4.txt",
1939 "e/subdir2/subdir/test5.txt",
1940 "e/subdir2/subdir/sub/test0.txt",
1941 "e/subdir2/subdir/sub/120-px-file.txt",
1946 $iter = $this->backend->getFileList(
array(
'dir' =>
"$base/unittest-cont1" ) );
1949 $this->assertEquals( $expected, $list,
"Correct file listing ($backendName)." );
1952 $iter = $this->backend->getFileList(
array(
'dir' =>
"$base/unittest-cont1",
'adviseStat' => 1 ) );
1955 $this->assertEquals( $expected, $list,
"Correct file listing ($backendName)." );
1959 $iter = $this->backend->getFileList(
array(
'dir' =>
"$base/unittest-cont1/" ) );
1964 $this->assertEquals( $expected, $list,
"Correct file listing ($backendName)." );
1974 "sub/120-px-file.txt",
1979 $iter = $this->backend->getFileList(
array(
'dir' =>
"$base/unittest-cont1/e/subdir2/subdir" ) );
1982 $this->assertEquals( $expected, $list,
"Correct file listing ($backendName)." );
1985 $iter = $this->backend->getFileList(
array(
'dir' =>
"$base/unittest-cont1/e/subdir2/subdir",
'adviseStat' => 1 ) );
1988 $this->assertEquals( $expected, $list,
"Correct file listing ($backendName)." );
1992 $iter = $this->backend->getFileList(
array(
'dir' =>
"$base/unittest-cont1/e/subdir2/subdir/" ) );
1997 $this->assertEquals( $expected, $list,
"Correct file listing ($backendName)." );
2002 $this->assertEquals( $expected, $list,
"Correct file listing ($backendName), second iteration." );
2005 $iter = $this->backend->getTopFileList(
array(
'dir' =>
"$base/unittest-cont1" ) );
2008 $this->assertEquals(
array(), $list,
"Correct top file listing ($backendName)." );
2021 $iter = $this->backend->getTopFileList(
array(
'dir' =>
"$base/unittest-cont1/e/subdir2/subdir" ) );
2024 $this->assertEquals( $expected, $list,
"Correct top file listing ($backendName)." );
2027 $iter = $this->backend->getTopFileList(
array(
'dir' =>
"$base/unittest-cont1/e/subdir2/subdir",
'adviseStat' => 1 ) );
2030 $this->assertEquals( $expected, $list,
"Correct top file listing ($backendName)." );
2033 $this->backend->doOperation(
array(
'op' =>
'delete',
'src' =>
$file ) );
2036 $iter = $this->backend->getFileList(
array(
'dir' =>
"$base/unittest-cont1/not/exists" ) );
2037 foreach ( $iter
as $iter ) {
2063 "$base/unittest-cont1/e/test1.txt",
2064 "$base/unittest-cont1/e/test2.txt",
2065 "$base/unittest-cont1/e/test3.txt",
2066 "$base/unittest-cont1/e/subdir1/test1.txt",
2067 "$base/unittest-cont1/e/subdir1/test2.txt",
2068 "$base/unittest-cont1/e/subdir2/test3.txt",
2069 "$base/unittest-cont1/e/subdir2/test4.txt",
2070 "$base/unittest-cont1/e/subdir2/subdir/test1.txt",
2071 "$base/unittest-cont1/e/subdir3/subdir/test2.txt",
2072 "$base/unittest-cont1/e/subdir4/subdir/test3.txt",
2073 "$base/unittest-cont1/e/subdir4/subdir/test4.txt",
2074 "$base/unittest-cont1/e/subdir4/subdir/test5.txt",
2075 "$base/unittest-cont1/e/subdir4/subdir/sub/test0.txt",
2076 "$base/unittest-cont1/e/subdir4/subdir/sub/120-px-file.txt",
2083 $ops[] =
array(
'op' =>
'create',
'content' =>
'xxy',
'dst' =>
$file );
2085 $status = $this->backend->doQuickOperations( $ops );
2087 "Creation of files succeeded ($backendName)." );
2088 $this->assertEquals(
true, $status->isOK(),
2089 "Creation of files succeeded with OK status ($backendName)." );
2091 $this->assertEquals(
true,
2092 $this->backend->directoryExists(
array(
'dir' =>
"$base/unittest-cont1/e/subdir1" ) ),
2093 "Directory exists in ($backendName)." );
2094 $this->assertEquals(
true,
2095 $this->backend->directoryExists(
array(
'dir' =>
"$base/unittest-cont1/e/subdir2/subdir" ) ),
2096 "Directory exists in ($backendName)." );
2097 $this->assertEquals(
false,
2098 $this->backend->directoryExists(
array(
'dir' =>
"$base/unittest-cont1/e/subdir2/test1.txt" ) ),
2099 "Directory does not exists in ($backendName)." );
2109 $iter = $this->backend->getTopDirectoryList(
array(
'dir' =>
"$base/unittest-cont1" ) );
2115 $this->assertEquals( $expected, $list,
"Correct top dir listing ($backendName)." );
2128 $iter = $this->backend->getTopDirectoryList(
array(
'dir' =>
"$base/unittest-cont1/e" ) );
2134 $this->assertEquals( $expected, $list,
"Correct top dir listing ($backendName)." );
2138 $iter = $this->backend->getTopDirectoryList(
array(
'dir' =>
"$base/unittest-cont1/e/" ) );
2144 $this->assertEquals( $expected, $list,
"Correct top dir listing ($backendName)." );
2154 $iter = $this->backend->getTopDirectoryList(
array(
'dir' =>
"$base/unittest-cont1/e/subdir2" ) );
2160 $this->assertEquals( $expected, $list,
"Correct top dir listing ($backendName)." );
2164 $iter = $this->backend->getTopDirectoryList(
array(
'dir' =>
"$base/unittest-cont1/e/subdir2/" ) );
2170 $this->assertEquals( $expected, $list,
"Correct top dir listing ($backendName)." );
2179 $this->assertEquals( $expected, $list,
"Correct top dir listing ($backendName), second iteration." );
2191 "e/subdir4/subdir/sub",
2197 $iter = $this->backend->getDirectoryList(
array(
'dir' =>
"$base/unittest-cont1/" ) );
2203 $this->assertEquals( $expected, $list,
"Correct dir listing ($backendName)." );
2214 $iter = $this->backend->getDirectoryList(
array(
'dir' =>
"$base/unittest-cont1/e/subdir4" ) );
2220 $this->assertEquals( $expected, $list,
"Correct dir listing ($backendName)." );
2229 $this->assertEquals( $expected, $list,
"Correct dir listing ($backendName)." );
2231 $iter = $this->backend->getDirectoryList(
array(
'dir' =>
"$base/unittest-cont1/e/subdir1" ) );
2233 $this->assertEquals(
array(), $items,
"Directory listing is empty." );
2236 $this->backend->doOperation(
array(
'op' =>
'delete',
'src' =>
$file ) );
2239 $iter = $this->backend->getDirectoryList(
array(
'dir' =>
"$base/unittest-cont1/not/exists" ) );
2245 $this->assertEquals(
array(), $items,
"Directory listing is empty." );
2247 $iter = $this->backend->getDirectoryList(
array(
'dir' =>
"$base/unittest-cont1/e/not/exists" ) );
2249 $this->assertEquals(
array(), $items,
"Directory listing is empty." );
2270 "subdir1/test1.txt",
2271 "subdir1/test2.txt",
2274 "subdir2/test3.txt",
2275 "subdir2/test4.txt",
2277 "subdir2/subdir/test1.txt",
2278 "subdir2/subdir/test2.txt",
2279 "subdir2/subdir/test3.txt",
2280 "subdir2/subdir/test4.txt",
2281 "subdir2/subdir/test5.txt",
2282 "subdir2/subdir/sub",
2283 "subdir2/subdir/sub/test0.txt",
2284 "subdir2/subdir/sub/120-px-file.txt",
2287 for ( $i = 0; $i < 25; $i++ ) {
2289 $this->assertEquals( print_r(
array(),
true ), print_r( $status->errors,
true ),
2290 "Locking of files succeeded ($backendName) ($i)." );
2291 $this->assertEquals(
true, $status->isOK(),
2292 "Locking of files succeeded with OK status ($backendName) ($i)." );
2295 $this->assertEquals( print_r(
array(),
true ), print_r( $status->errors,
true ),
2296 "Locking of files succeeded ($backendName) ($i)." );
2297 $this->assertEquals(
true, $status->isOK(),
2298 "Locking of files succeeded with OK status ($backendName) ($i)." );
2301 $this->assertEquals( print_r(
array(),
true ), print_r( $status->errors,
true ),
2302 "Locking of files succeeded ($backendName) ($i)." );
2303 $this->assertEquals(
true, $status->isOK(),
2304 "Locking of files succeeded with OK status ($backendName) ($i)." );
2307 $this->assertEquals( print_r(
array(),
true ), print_r( $status->errors,
true ),
2308 "Locking of files succeeded ($backendName). ($i)" );
2309 $this->assertEquals(
true, $status->isOK(),
2310 "Locking of files succeeded with OK status ($backendName) ($i)." );
2312 ## Flip the acquire/release ordering around ##
2315 $this->assertEquals( print_r(
array(),
true ), print_r( $status->errors,
true ),
2316 "Locking of files succeeded ($backendName) ($i)." );
2317 $this->assertEquals(
true, $status->isOK(),
2318 "Locking of files succeeded with OK status ($backendName) ($i)." );
2321 $this->assertEquals( print_r(
array(),
true ), print_r( $status->errors,
true ),
2322 "Locking of files succeeded ($backendName) ($i)." );
2323 $this->assertEquals(
true, $status->isOK(),
2324 "Locking of files succeeded with OK status ($backendName) ($i)." );
2327 $this->assertEquals( print_r(
array(),
true ), print_r( $status->errors,
true ),
2328 "Locking of files succeeded ($backendName). ($i)" );
2329 $this->assertEquals(
true, $status->isOK(),
2330 "Locking of files succeeded with OK status ($backendName) ($i)." );
2333 $this->assertEquals( print_r(
array(),
true ), print_r( $status->errors,
true ),
2334 "Locking of files succeeded ($backendName) ($i)." );
2335 $this->assertEquals(
true, $status->isOK(),
2336 "Locking of files succeeded with OK status ($backendName) ($i)." );
2342 "Scoped locking of files succeeded ($backendName)." );
2343 $this->assertEquals(
array(), $status->errors,
2344 "Scoped locking of files succeeded ($backendName)." );
2345 $this->assertEquals(
true, $status->isOK(),
2346 "Scoped locking of files succeeded with OK status ($backendName)." );
2349 $this->assertEquals(
null, $sl,
2350 "Scoped unlocking of files succeeded ($backendName)." );
2351 $this->assertEquals(
array(), $status->errors,
2352 "Scoped unlocking of files succeeded ($backendName)." );
2353 $this->assertEquals(
true, $status->isOK(),
2354 "Scoped unlocking of files succeeded with OK status ($backendName)." );
2359 return is_array( $iter ) ? $iter : iterator_to_array( $iter );
2364 return $this->backend->prepare(
$params );
2375 foreach ( $this->filesToPrune
as $file ) {
2376 if ( is_file(
$file ) ) {
2380 $containers =
array(
'unittest-cont1',
'unittest-cont2',
'unittest-cont-bad' );
2381 foreach ( $containers
as $container ) {
2389 $iter = $this->backend->getFileList(
array(
'dir' =>
"$base/$container" ) );
2392 $this->backend->quickDelete(
array(
'src' =>
"$base/$container/$file" ) );
2397 $this->backend->clean(
array(
'dir' =>
"$base/$container",
'recursive' => 1 ) );
2402 $status = $this->backend->consistencyCheck( $paths );
2403 $this->
assertGoodStatus( $status,
"Files synced: " . implode(
',', $paths ) );
2408 $this->assertEquals( print_r(
array(), 1 ), print_r( $status->errors, 1 ), $msg );