df9651d78bfca74a27cc9221ba768266dcc85260
3 // @TODO: fix empty dir leakage
4 class FileBackendTest
extends MediaWikiTestCase
{
5 private $backend, $multiBackend;
6 private $filesToPrune, $pathsToPrune;
10 $tmpDir = wfTempDir() . '/' . time() . '-' . mt_rand();
11 $this->singleBackend
= new FSFileBackend( array(
12 'name' => 'localtesting',
13 'lockManager' => 'fsLockManager',
14 'containerPaths' => array(
15 'cont1' => "$tmpDir/localtesting/cont1",
16 'cont2' => "$tmpDir/localtesting/cont2" )
18 $this->multiBackend
= new FileBackendMultiWrite( array(
19 'name' => 'localtesting',
20 'lockManager' => 'fsLockManager',
23 'name' => 'localmutlitesting1',
24 'class' => 'FSFileBackend',
25 'lockManager' => 'nullLockManager',
26 'containerPaths' => array(
27 'cont1' => "$tmpDir/localtestingmulti1/cont1",
28 'cont2' => "$tmpDir/localtestingmulti1/cont2" ),
29 'isMultiMaster' => false
32 'name' => 'localmutlitesting2',
33 'class' => 'FSFileBackend',
34 'lockManager' => 'nullLockManager',
35 'containerPaths' => array(
36 'cont1' => "$tmpDir/localtestingmulti2/cont1",
37 'cont2' => "$tmpDir/localtestingmulti2/cont2" ),
38 'isMultiMaster' => true
42 $this->filesToPrune
= $this->pathsToPrune
= array();
45 private function baseStorePath() {
46 return 'mwstore://localtesting';
49 private function backendClass() {
50 return get_class( $this->backend
);
54 * @dataProvider provider_testStore
56 public function testStore( $op, $source, $dest ) {
57 $this->filesToPrune
[] = $source;
58 $this->pathsToPrune
[] = $dest;
60 $this->backend
= $this->singleBackend
;
61 $this->doTestStore( $op, $source, $dest );
62 $this->tearDownFiles();
64 $this->backend
= $this->multiBackend
;
65 $this->doTestStore( $op, $source, $dest );
66 $this->tearDownFiles();
69 function doTestStore( $op, $source, $dest ) {
70 $backendName = $this->backendClass();
72 file_put_contents( $source, "Unit test file" );
73 $status = $this->backend
->doOperation( $op );
75 $this->assertEquals( array(), $status->errors
,
76 "Store from $source to $dest succeeded without warnings ($backendName)." );
77 $this->assertEquals( true, $status->isOK(),
78 "Store from $source to $dest succeeded ($backendName)." );
79 $this->assertEquals( array( 0 => true ), $status->success
,
80 "Store from $source to $dest has proper 'success' field in Status ($backendName)." );
81 $this->assertEquals( true, file_exists( $source ),
82 "Source file $source still exists ($backendName)." );
83 $this->assertEquals( true, $this->backend
->fileExists( array( 'src' => $dest ) ),
84 "Destination file $dest exists ($backendName)." );
86 $this->assertEquals( filesize( $source ),
87 $this->backend
->getFileSize( array( 'src' => $dest ) ),
88 "Destination file $dest has correct size ($backendName)." );
90 $props1 = FSFile
::getPropsFromPath( $source );
91 $props2 = $this->backend
->getFileProps( array( 'src' => $dest ) );
92 $this->assertEquals( $props1, $props2,
93 "Source and destination have the same props ($backendName)." );
96 public function provider_testStore() {
99 $tmpName = TempFSFile
::factory( "unittests_", 'txt' )->getPath();
100 $toPath = $this->baseStorePath() . '/cont1/fun/obj1.txt';
101 $op = array( 'op' => 'store', 'src' => $tmpName, 'dst' => $toPath );
108 $op['overwriteDest'] = true;
119 * @dataProvider provider_testCopy
121 public function testCopy( $op, $source, $dest ) {
122 $this->pathsToPrune
[] = $source;
123 $this->pathsToPrune
[] = $dest;
125 $this->backend
= $this->singleBackend
;
126 $this->doTestCopy( $op, $source, $dest );
127 $this->tearDownFiles();
129 $this->backend
= $this->multiBackend
;
130 $this->doTestCopy( $op, $source, $dest );
131 $this->tearDownFiles();
134 function doTestCopy( $op, $source, $dest ) {
135 $backendName = $this->backendClass();
137 $status = $this->backend
->doOperation(
138 array( 'op' => 'create', 'content' => 'blahblah', 'dst' => $source ) );
139 $this->assertEquals( true, $status->isOK(),
140 "Creation of file at $source succeeded ($backendName)." );
142 $status = $this->backend
->doOperation( $op );
143 $this->assertEquals( array(), $status->errors
,
144 "Copy from $source to $dest succeeded without warnings ($backendName)." );
145 $this->assertEquals( true, $status->isOK(),
146 "Copy from $source to $dest succeeded ($backendName)." );
147 $this->assertEquals( array( 0 => true ), $status->success
,
148 "Copy from $source to $dest has proper 'success' field in Status ($backendName)." );
149 $this->assertEquals( true, $this->backend
->fileExists( array( 'src' => $source ) ),
150 "Source file $source still exists ($backendName)." );
151 $this->assertEquals( true, $this->backend
->fileExists( array( 'src' => $dest ) ),
152 "Destination file $dest exists after copy ($backendName)." );
155 $this->backend
->getFileSize( array( 'src' => $source ) ),
156 $this->backend
->getFileSize( array( 'src' => $dest ) ),
157 "Destination file $dest has correct size ($backendName)." );
159 $props1 = $this->backend
->getFileProps( array( 'src' => $source ) );
160 $props2 = $this->backend
->getFileProps( array( 'src' => $dest ) );
161 $this->assertEquals( $props1, $props2,
162 "Source and destination have the same props ($backendName)." );
165 public function provider_testCopy() {
168 $source = $this->baseStorePath() . '/cont1/file.txt';
169 $dest = $this->baseStorePath() . '/cont2/fileMoved.txt';
171 $op = array( 'op' => 'copy', 'src' => $source, 'dst' => $dest );
178 $op['overwriteDest'] = true;
189 * @dataProvider provider_testMove
191 public function testMove( $op, $source, $dest ) {
192 $this->pathsToPrune
[] = $source;
193 $this->pathsToPrune
[] = $dest;
195 $this->backend
= $this->singleBackend
;
196 $this->doTestMove( $op, $source, $dest );
197 $this->tearDownFiles();
199 $this->backend
= $this->multiBackend
;
200 $this->doTestMove( $op, $source, $dest );
201 $this->tearDownFiles();
204 public function doTestMove( $op, $source, $dest ) {
205 $backendName = $this->backendClass();
207 $status = $this->backend
->doOperation(
208 array( 'op' => 'create', 'content' => 'blahblah', 'dst' => $source ) );
209 $this->assertEquals( true, $status->isOK(),
210 "Creation of file at $source succeeded ($backendName)." );
212 $status = $this->backend
->doOperation( $op );
213 $this->assertEquals( array(), $status->errors
,
214 "Move from $source to $dest succeeded without warnings ($backendName)." );
215 $this->assertEquals( true, $status->isOK(),
216 "Move from $source to $dest succeeded ($backendName)." );
217 $this->assertEquals( array( 0 => true ), $status->success
,
218 "Move from $source to $dest has proper 'success' field in Status ($backendName)." );
219 $this->assertEquals( false, $this->backend
->fileExists( array( 'src' => $source ) ),
220 "Source file $source does not still exists ($backendName)." );
221 $this->assertEquals( true, $this->backend
->fileExists( array( 'src' => $dest ) ),
222 "Destination file $dest exists after move ($backendName)." );
224 $this->assertNotEquals(
225 $this->backend
->getFileSize( array( 'src' => $source ) ),
226 $this->backend
->getFileSize( array( 'src' => $dest ) ),
227 "Destination file $dest has correct size ($backendName)." );
229 $props1 = $this->backend
->getFileProps( array( 'src' => $source ) );
230 $props2 = $this->backend
->getFileProps( array( 'src' => $dest ) );
231 $this->assertEquals( false, $props1['fileExists'],
232 "Source file does not exist accourding to props ($backendName)." );
233 $this->assertEquals( true, $props2['fileExists'],
234 "Destination file exists accourding to props ($backendName)." );
237 public function provider_testMove() {
240 $source = $this->baseStorePath() . '/cont1/file.txt';
241 $dest = $this->baseStorePath() . '/cont2/fileMoved.txt';
243 $op = array( 'op' => 'move', 'src' => $source, 'dst' => $dest );
250 $op['overwriteDest'] = true;
261 * @dataProvider provider_testDelete
263 public function testDelete( $op, $source, $withSource, $okStatus ) {
264 $this->pathsToPrune
[] = $source;
266 $this->backend
= $this->singleBackend
;
267 $this->doTestDelete( $op, $source, $withSource, $okStatus );
268 $this->tearDownFiles();
270 $this->backend
= $this->multiBackend
;
271 $this->doTestDelete( $op, $source, $withSource, $okStatus );
272 $this->tearDownFiles();
275 public function doTestDelete( $op, $source, $withSource, $okStatus ) {
276 $backendName = $this->backendClass();
279 $status = $this->backend
->doOperation(
280 array( 'op' => 'create', 'content' => 'blahblah', 'dst' => $source ) );
281 $this->assertEquals( true, $status->isOK(),
282 "Creation of file at $source succeeded ($backendName)." );
285 $status = $this->backend
->doOperation( $op );
287 $this->assertEquals( array(), $status->errors
,
288 "Deletion of file at $source succeeded without warnings ($backendName)." );
289 $this->assertEquals( true, $status->isOK(),
290 "Deletion of file at $source succeeded ($backendName)." );
291 $this->assertEquals( array( 0 => true ), $status->success
,
292 "Deletion of file at $source has proper 'success' field in Status ($backendName)." );
294 $this->assertEquals( false, $status->isOK(),
295 "Deletion of file at $source failed ($backendName)." );
298 $this->assertEquals( false, $this->backend
->fileExists( array( 'src' => $source ) ),
299 "Source file $source does not exist after move ($backendName)." );
302 $this->backend
->getFileSize( array( 'src' => $source ) ),
303 "Source file $source has correct size (false) ($backendName)." );
305 $props1 = $this->backend
->getFileProps( array( 'src' => $source ) );
306 $this->assertFalse( $props1['fileExists'],
307 "Source file $source does not exist according to props ($backendName)." );
310 public function provider_testDelete() {
313 $source = $this->baseStorePath() . '/cont1/myfacefile.txt';
315 $op = array( 'op' => 'delete', 'src' => $source );
326 false, // without source
330 $op['ignoreMissingSource'] = true;
334 false, // without source
342 * @dataProvider provider_testCreate
344 public function testCreate( $op, $dest, $alreadyExists, $okStatus, $newSize ) {
345 $this->pathsToPrune
[] = $dest;
347 $this->backend
= $this->singleBackend
;
348 $this->doTestCreate( $op, $dest, $alreadyExists, $okStatus, $newSize );
349 $this->tearDownFiles();
351 $this->backend
= $this->multiBackend
;
352 $this->doTestCreate( $op, $dest, $alreadyExists, $okStatus, $newSize );
353 $this->tearDownFiles();
356 public function doTestCreate( $op, $dest, $alreadyExists, $okStatus, $newSize ) {
357 $backendName = $this->backendClass();
359 $oldText = 'blah...blah...waahwaah';
360 if ( $alreadyExists ) {
361 $status = $this->backend
->doOperation(
362 array( 'op' => 'create', 'content' => $oldText, 'dst' => $dest ) );
363 $this->assertEquals( true, $status->isOK(),
364 "Creation of file at $dest succeeded ($backendName)." );
367 $status = $this->backend
->doOperation( $op );
369 $this->assertEquals( array(), $status->errors
,
370 "Creation of file at $dest succeeded without warnings ($backendName)." );
371 $this->assertEquals( true, $status->isOK(),
372 "Creation of file at $dest succeeded ($backendName)." );
373 $this->assertEquals( array( 0 => true ), $status->success
,
374 "Creation of file at $dest has proper 'success' field in Status ($backendName)." );
376 $this->assertEquals( false, $status->isOK(),
377 "Creation of file at $dest failed ($backendName)." );
380 $this->assertEquals( true, $this->backend
->fileExists( array( 'src' => $dest ) ),
381 "Destination file $dest exists after creation ($backendName)." );
383 $props1 = $this->backend
->getFileProps( array( 'src' => $dest ) );
384 $this->assertEquals( true, $props1['fileExists'],
385 "Destination file $dest exists according to props ($backendName)." );
386 if ( $okStatus ) { // file content is what we saved
387 $this->assertEquals( $newSize, $props1['size'],
388 "Destination file $dest has expected size according to props ($backendName)." );
389 $this->assertEquals( $newSize,
390 $this->backend
->getFileSize( array( 'src' => $dest ) ),
391 "Destination file $dest has correct size ($backendName)." );
392 } else { // file content is some other previous text
393 $this->assertEquals( strlen( $oldText ), $props1['size'],
394 "Destination file $dest has original size according to props ($backendName)." );
395 $this->assertEquals( strlen( $oldText ),
396 $this->backend
->getFileSize( array( 'src' => $dest ) ),
397 "Destination file $dest has original size according to props ($backendName)." );
402 * @dataProvider provider_testCreate
404 public function provider_testCreate() {
407 $source = $this->baseStorePath() . '/cont2/myspacefile.txt';
409 $dummyText = 'hey hey';
410 $op = array( 'op' => 'create', 'content' => $dummyText, 'dst' => $source );
414 false, // no dest already exists
422 true, // dest already exists
427 $op['overwriteDest'] = true;
431 true, // dest already exists
440 * @dataProvider provider_testConcatenate
442 public function testConcatenate( $op, $srcs, $srcsContent, $alreadyExists, $okStatus ) {
443 $this->pathsToPrune
= array_merge( $this->pathsToPrune
, $srcs );
444 $this->filesToPrune
[] = $op['dst'];
446 $this->backend
= $this->singleBackend
;
447 $this->doTestConcatenate( $op, $srcs, $srcsContent, $alreadyExists, $okStatus );
448 $this->tearDownFiles();
450 $this->backend
= $this->multiBackend
;
451 $this->doTestConcatenate( $op, $srcs, $srcsContent, $alreadyExists, $okStatus );
452 $this->tearDownFiles();
455 public function doTestConcatenate( $params, $srcs, $srcsContent, $alreadyExists, $okStatus ) {
456 $backendName = $this->backendClass();
461 foreach ( $srcs as $i => $source ) {
463 'op' => 'create', // operation
464 'dst' => $source, // source
465 'content' => $srcsContent[$i]
467 $expContent .= $srcsContent[$i];
469 $status = $this->backend
->doOperations( $ops );
471 $this->assertEquals( true, $status->isOK(),
472 "Creation of source files succeeded ($backendName)." );
474 $dest = $params['dst'];
475 if ( $alreadyExists ) {
476 $ok = file_put_contents( $dest, 'blah...blah...waahwaah' ) !== false;
477 $this->assertEquals( true, $ok,
478 "Creation of file at $dest succeeded ($backendName)." );
480 $ok = file_put_contents( $dest, '' ) !== false;
481 $this->assertEquals( true, $ok,
482 "Creation of 0-byte file at $dest succeeded ($backendName)." );
485 // Combine the files into one
486 $status = $this->backend
->concatenate( $params );
488 $this->assertEquals( array(), $status->errors
,
489 "Creation of concat file at $dest succeeded without warnings ($backendName)." );
490 $this->assertEquals( true, $status->isOK(),
491 "Creation of concat file at $dest succeeded ($backendName)." );
493 $this->assertEquals( false, $status->isOK(),
494 "Creation of concat file at $dest failed ($backendName)." );
498 $this->assertEquals( true, is_file( $dest ),
499 "Dest concat file $dest exists after creation ($backendName)." );
501 $this->assertEquals( true, is_file( $dest ),
502 "Dest concat file $dest exists after failed creation ($backendName)." );
505 $contents = file_get_contents( $dest );
506 $this->assertNotEquals( false, $contents, "File at $dest exists ($backendName)." );
509 $this->assertEquals( $expContent, $contents,
510 "Concat file at $dest has correct contents ($backendName)." );
512 $this->assertNotEquals( $expContent, $contents,
513 "Concat file at $dest has correct contents ($backendName)." );
517 function provider_testConcatenate() {
520 $rand = mt_rand( 0, 2000000000 ) . time();
521 $dest = wfTempDir() . "/randomfile!$rand.txt";
523 $this->baseStorePath() . '/cont1/file1.txt',
524 $this->baseStorePath() . '/cont1/file2.txt',
525 $this->baseStorePath() . '/cont1/file3.txt',
526 $this->baseStorePath() . '/cont1/file4.txt',
527 $this->baseStorePath() . '/cont1/file5.txt',
528 $this->baseStorePath() . '/cont1/file6.txt',
529 $this->baseStorePath() . '/cont1/file7.txt',
530 $this->baseStorePath() . '/cont1/file8.txt',
531 $this->baseStorePath() . '/cont1/file9.txt',
532 $this->baseStorePath() . '/cont1/file10.txt'
546 $params = array( 'srcs' => $srcs, 'dst' => $dest );
549 $params, // operation
551 $content, // content for each source
552 false, // no dest already exists
557 $params, // operation
559 $content, // content for each source
560 true, // dest already exists
568 * @dataProvider provider_testGetFileContents
570 public function testGetFileContents( $src, $content ) {
571 $this->pathsToPrune
[] = $src;
573 $this->backend
= $this->singleBackend
;
574 $this->doTestGetFileContents( $src, $content );
575 $this->tearDownFiles();
577 $this->backend
= $this->multiBackend
;
578 $this->doTestGetFileContents( $src, $content );
579 $this->tearDownFiles();
583 * @dataProvider provider_testGetFileContents
585 public function doTestGetFileContents( $src, $content ) {
586 $backendName = $this->backendClass();
588 $status = $this->backend
->doOperation(
589 array( 'op' => 'create', 'content' => $content, 'dst' => $src ) );
590 $this->assertEquals( true, $status->isOK(),
591 "Creation of file at $src succeeded ($backendName)." );
593 $newContents = $this->backend
->getFileContents( array( 'src' => $src ) );
594 $this->assertNotEquals( false, $newContents,
595 "Read of file at $src succeeded ($backendName)." );
597 $this->assertEquals( $content, $newContents,
598 "Contents read match data at $src ($backendName)." );
601 function provider_testGetFileContents() {
604 $base = $this->baseStorePath();
605 $cases[] = array( "$base/cont1/b/z/some_file.txt", "some file contents" );
606 $cases[] = array( "$base/cont1/b/some-other_file.txt", "more file contents" );
612 * @dataProvider provider_testGetLocalCopy
614 public function testGetLocalCopy( $src, $content ) {
615 $this->pathsToPrune
[] = $src;
617 $this->backend
= $this->singleBackend
;
618 $this->doTestGetLocalCopy( $src, $content );
619 $this->tearDownFiles();
621 $this->backend
= $this->multiBackend
;
622 $this->doTestGetLocalCopy( $src, $content );
623 $this->tearDownFiles();
626 public function doTestGetLocalCopy( $src, $content ) {
627 $backendName = $this->backendClass();
629 $status = $this->backend
->doOperation(
630 array( 'op' => 'create', 'content' => $content, 'dst' => $src ) );
631 $this->assertEquals( true, $status->isOK(),
632 "Creation of file at $src succeeded ($backendName)." );
634 $tmpFile = $this->backend
->getLocalCopy( array( 'src' => $src ) );
635 $this->assertNotNull( $tmpFile,
636 "Creation of local copy of $src succeeded ($backendName)." );
638 $contents = file_get_contents( $tmpFile->getPath() );
639 $this->assertNotEquals( false, $contents, "Local copy of $src exists ($backendName)." );
642 function provider_testGetLocalCopy() {
645 $base = $this->baseStorePath();
646 $cases[] = array( "$base/cont1/a/z/some_file.txt", "some file contents" );
647 $cases[] = array( "$base/cont1/a/some-other_file.txt", "more file contents" );
653 * @dataProvider provider_testGetLocalReference
655 public function testGetLocalReference( $src, $content ) {
656 $this->pathsToPrune
[] = $src;
658 $this->backend
= $this->singleBackend
;
659 $this->doTestGetLocalReference( $src, $content );
660 $this->tearDownFiles();
662 $this->backend
= $this->multiBackend
;
663 $this->doTestGetLocalReference( $src, $content );
664 $this->tearDownFiles();
667 public function doTestGetLocalReference( $src, $content ) {
668 $backendName = $this->backendClass();
670 $status = $this->backend
->doOperation(
671 array( 'op' => 'create', 'content' => $content, 'dst' => $src ) );
672 $this->assertEquals( true, $status->isOK(),
673 "Creation of file at $src succeeded ($backendName)." );
675 $tmpFile = $this->backend
->getLocalReference( array( 'src' => $src ) );
676 $this->assertNotNull( $tmpFile,
677 "Creation of local copy of $src succeeded ($backendName)." );
679 $contents = file_get_contents( $tmpFile->getPath() );
680 $this->assertNotEquals( false, $contents, "Local copy of $src exists ($backendName)." );
683 function provider_testGetLocalReference() {
686 $base = $this->baseStorePath();
687 $cases[] = array( "$base/cont1/a/z/some_file.txt", "some file contents" );
688 $cases[] = array( "$base/cont1/a/some-other_file.txt", "more file contents" );
694 * @dataProvider provider_testPrepareAndClean
696 public function testPrepareAndClean( $path, $isOK ) {
697 $this->backend
= $this->singleBackend
;
698 $this->doTestPrepareAndClean( $path, $isOK );
700 $this->backend
= $this->multiBackend
;
701 $this->doTestPrepareAndClean( $path, $isOK );
704 function provider_testPrepareAndClean() {
705 $base = $this->baseStorePath();
707 array( "$base/cont1/a/z/some_file1.txt", true ),
708 array( "$base/cont2/a/z/some_file2.txt", true ),
709 array( "$base/cont3/a/z/some_file3.txt", false ),
713 function doTestPrepareAndClean( $path, $isOK ) {
714 $backendName = $this->backendClass();
716 $status = $this->backend
->prepare( array( 'dir' => $path ) );
718 $this->assertEquals( array(), $status->errors
,
719 "Preparing dir $path succeeded without warnings ($backendName)." );
720 $this->assertEquals( true, $status->isOK(),
721 "Preparing dir $path succeeded ($backendName)." );
723 $this->assertEquals( false, $status->isOK(),
724 "Preparing dir $path failed ($backendName)." );
727 $status = $this->backend
->clean( array( 'dir' => $path ) );
729 $this->assertEquals( array(), $status->errors
,
730 "Cleaning dir $path succeeded without warnings ($backendName)." );
731 $this->assertEquals( true, $status->isOK(),
732 "Cleaning dir $path succeeded ($backendName)." );
734 $this->assertEquals( false, $status->isOK(),
735 "Cleaning dir $path failed ($backendName)." );
741 // @TODO: testDoOperations
743 public function testGetFileList() {
744 $this->backend
= $this->singleBackend
;
745 $this->doTestGetFileList();
746 $this->tearDownFiles();
748 $this->backend
= $this->multiBackend
;
749 $this->doTestGetFileList();
750 $this->tearDownFiles();
753 public function doTestGetFileList() {
754 $backendName = $this->backendClass();
756 $base = $this->baseStorePath();
758 "$base/cont1/test1.txt",
759 "$base/cont1/test2.txt",
760 "$base/cont1/test3.txt",
761 "$base/cont1/subdir1/test1.txt",
762 "$base/cont1/subdir1/test2.txt",
763 "$base/cont1/subdir2/test3.txt",
764 "$base/cont1/subdir2/test4.txt",
765 "$base/cont1/subdir2/subdir/test1.txt",
766 "$base/cont1/subdir2/subdir/test2.txt",
767 "$base/cont1/subdir2/subdir/test3.txt",
768 "$base/cont1/subdir2/subdir/test4.txt",
769 "$base/cont1/subdir2/subdir/test5.txt",
770 "$base/cont1/subdir2/subdir/sub/test0.txt",
771 "$base/cont1/subdir2/subdir/sub/120-px-file.txt",
773 $this->pathsToPrune
= array_merge( $this->pathsToPrune
, $files );
777 foreach ( $files as $file ) {
778 $ops[] = array( 'op' => 'create', 'content' => 'xxy', 'dst' => $file );
780 $status = $this->backend
->doOperations( $ops );
781 $this->assertEquals( true, $status->isOK(),
782 "Creation of files succeeded ($backendName)." );
793 "subdir2/subdir/test1.txt",
794 "subdir2/subdir/test2.txt",
795 "subdir2/subdir/test3.txt",
796 "subdir2/subdir/test4.txt",
797 "subdir2/subdir/test5.txt",
798 "subdir2/subdir/sub/test0.txt",
799 "subdir2/subdir/sub/120-px-file.txt",
803 // Actual listing (no trailing slash)
805 $iter = $this->backend
->getFileList( array( 'dir' => "$base/cont1" ) );
806 foreach ( $iter as $file ) {
811 $this->assertEquals( $expected, $list, "Correct file listing ($backendName)." );
813 // Actual listing (with trailing slash)
815 $iter = $this->backend
->getFileList( array( 'dir' => "$base/cont1/" ) );
816 foreach ( $iter as $file ) {
821 $this->assertEquals( $expected, $list, "Correct file listing ($backendName)." );
823 foreach ( $files as $file ) {
824 $this->backend
->doOperation( array( 'op' => 'delete', 'src' => "$base/$file" ) );
827 $iter = $this->backend
->getFileList( array( 'dir' => "$base/cont1/not/exists" ) );
828 foreach ( $iter as $iter ) {} // no errors
831 function tearDownFiles() {
832 foreach ( $this->filesToPrune
as $file ) {
835 foreach ( $this->pathsToPrune
as $file ) {
836 $this->backend
->doOperation( array( 'op' => 'delete', 'src' => $file ) );
840 function tearDown() {