5 * @TODO: fix empty dir leakage
7 class FileBackendTest
extends MediaWikiTestCase
{
8 private $backend, $multiBackend;
9 private $filesToPrune, $pathsToPrune;
13 $tmpDir = wfTempDir() . '/' . time() . '-' . mt_rand();
14 $this->singleBackend
= new FSFileBackend( array(
15 'name' => 'localtesting',
16 'lockManager' => 'fsLockManager',
17 'containerPaths' => array(
18 'cont1' => "$tmpDir/localtesting/cont1",
19 'cont2' => "$tmpDir/localtesting/cont2" )
21 $this->multiBackend
= new FileBackendMultiWrite( array(
22 'name' => 'localtesting',
23 'lockManager' => 'fsLockManager',
26 'name' => 'localmutlitesting1',
27 'class' => 'FSFileBackend',
28 'lockManager' => 'nullLockManager',
29 'containerPaths' => array(
30 'cont1' => "$tmpDir/localtestingmulti1/cont1",
31 'cont2' => "$tmpDir/localtestingmulti1/cont2" ),
32 'isMultiMaster' => false
35 'name' => 'localmutlitesting2',
36 'class' => 'FSFileBackend',
37 'lockManager' => 'nullLockManager',
38 'containerPaths' => array(
39 'cont1' => "$tmpDir/localtestingmulti2/cont1",
40 'cont2' => "$tmpDir/localtestingmulti2/cont2" ),
41 'isMultiMaster' => true
45 $this->filesToPrune
= $this->pathsToPrune
= array();
48 private function baseStorePath() {
49 return 'mwstore://localtesting';
52 private function backendClass() {
53 return get_class( $this->backend
);
57 * @dataProvider provider_testStore
59 public function testStore( $op, $source, $dest ) {
60 $this->filesToPrune
[] = $source;
61 $this->pathsToPrune
[] = $dest;
63 $this->backend
= $this->singleBackend
;
64 $this->doTestStore( $op, $source, $dest );
65 $this->tearDownFiles();
67 $this->backend
= $this->multiBackend
;
68 $this->doTestStore( $op, $source, $dest );
69 $this->tearDownFiles();
72 function doTestStore( $op, $source, $dest ) {
73 $backendName = $this->backendClass();
75 file_put_contents( $source, "Unit test file" );
76 $status = $this->backend
->doOperation( $op );
78 $this->assertEquals( array(), $status->errors
,
79 "Store from $source to $dest succeeded without warnings ($backendName)." );
80 $this->assertEquals( true, $status->isOK(),
81 "Store from $source to $dest succeeded ($backendName)." );
82 $this->assertEquals( array( 0 => true ), $status->success
,
83 "Store from $source to $dest has proper 'success' field in Status ($backendName)." );
84 $this->assertEquals( true, file_exists( $source ),
85 "Source file $source still exists ($backendName)." );
86 $this->assertEquals( true, $this->backend
->fileExists( array( 'src' => $dest ) ),
87 "Destination file $dest exists ($backendName)." );
89 $this->assertEquals( filesize( $source ),
90 $this->backend
->getFileSize( array( 'src' => $dest ) ),
91 "Destination file $dest has correct size ($backendName)." );
93 $props1 = FSFile
::getPropsFromPath( $source );
94 $props2 = $this->backend
->getFileProps( array( 'src' => $dest ) );
95 $this->assertEquals( $props1, $props2,
96 "Source and destination have the same props ($backendName)." );
99 public function provider_testStore() {
102 $tmpName = TempFSFile
::factory( "unittests_", 'txt' )->getPath();
103 $toPath = $this->baseStorePath() . '/cont1/fun/obj1.txt';
104 $op = array( 'op' => 'store', 'src' => $tmpName, 'dst' => $toPath );
111 $op['overwriteDest'] = true;
122 * @dataProvider provider_testCopy
124 public function testCopy( $op, $source, $dest ) {
125 $this->pathsToPrune
[] = $source;
126 $this->pathsToPrune
[] = $dest;
128 $this->backend
= $this->singleBackend
;
129 $this->doTestCopy( $op, $source, $dest );
130 $this->tearDownFiles();
132 $this->backend
= $this->multiBackend
;
133 $this->doTestCopy( $op, $source, $dest );
134 $this->tearDownFiles();
137 function doTestCopy( $op, $source, $dest ) {
138 $backendName = $this->backendClass();
140 $status = $this->backend
->doOperation(
141 array( 'op' => 'create', 'content' => 'blahblah', 'dst' => $source ) );
142 $this->assertEquals( true, $status->isOK(),
143 "Creation of file at $source succeeded ($backendName)." );
145 $status = $this->backend
->doOperation( $op );
146 $this->assertEquals( array(), $status->errors
,
147 "Copy from $source to $dest succeeded without warnings ($backendName)." );
148 $this->assertEquals( true, $status->isOK(),
149 "Copy from $source to $dest succeeded ($backendName)." );
150 $this->assertEquals( array( 0 => true ), $status->success
,
151 "Copy from $source to $dest has proper 'success' field in Status ($backendName)." );
152 $this->assertEquals( true, $this->backend
->fileExists( array( 'src' => $source ) ),
153 "Source file $source still exists ($backendName)." );
154 $this->assertEquals( true, $this->backend
->fileExists( array( 'src' => $dest ) ),
155 "Destination file $dest exists after copy ($backendName)." );
158 $this->backend
->getFileSize( array( 'src' => $source ) ),
159 $this->backend
->getFileSize( array( 'src' => $dest ) ),
160 "Destination file $dest has correct size ($backendName)." );
162 $props1 = $this->backend
->getFileProps( array( 'src' => $source ) );
163 $props2 = $this->backend
->getFileProps( array( 'src' => $dest ) );
164 $this->assertEquals( $props1, $props2,
165 "Source and destination have the same props ($backendName)." );
168 public function provider_testCopy() {
171 $source = $this->baseStorePath() . '/cont1/file.txt';
172 $dest = $this->baseStorePath() . '/cont2/fileMoved.txt';
174 $op = array( 'op' => 'copy', 'src' => $source, 'dst' => $dest );
181 $op['overwriteDest'] = true;
192 * @dataProvider provider_testMove
194 public function testMove( $op, $source, $dest ) {
195 $this->pathsToPrune
[] = $source;
196 $this->pathsToPrune
[] = $dest;
198 $this->backend
= $this->singleBackend
;
199 $this->doTestMove( $op, $source, $dest );
200 $this->tearDownFiles();
202 $this->backend
= $this->multiBackend
;
203 $this->doTestMove( $op, $source, $dest );
204 $this->tearDownFiles();
207 public function doTestMove( $op, $source, $dest ) {
208 $backendName = $this->backendClass();
210 $status = $this->backend
->doOperation(
211 array( 'op' => 'create', 'content' => 'blahblah', 'dst' => $source ) );
212 $this->assertEquals( true, $status->isOK(),
213 "Creation of file at $source succeeded ($backendName)." );
215 $status = $this->backend
->doOperation( $op );
216 $this->assertEquals( array(), $status->errors
,
217 "Move from $source to $dest succeeded without warnings ($backendName)." );
218 $this->assertEquals( true, $status->isOK(),
219 "Move from $source to $dest succeeded ($backendName)." );
220 $this->assertEquals( array( 0 => true ), $status->success
,
221 "Move from $source to $dest has proper 'success' field in Status ($backendName)." );
222 $this->assertEquals( false, $this->backend
->fileExists( array( 'src' => $source ) ),
223 "Source file $source does not still exists ($backendName)." );
224 $this->assertEquals( true, $this->backend
->fileExists( array( 'src' => $dest ) ),
225 "Destination file $dest exists after move ($backendName)." );
227 $this->assertNotEquals(
228 $this->backend
->getFileSize( array( 'src' => $source ) ),
229 $this->backend
->getFileSize( array( 'src' => $dest ) ),
230 "Destination file $dest has correct size ($backendName)." );
232 $props1 = $this->backend
->getFileProps( array( 'src' => $source ) );
233 $props2 = $this->backend
->getFileProps( array( 'src' => $dest ) );
234 $this->assertEquals( false, $props1['fileExists'],
235 "Source file does not exist accourding to props ($backendName)." );
236 $this->assertEquals( true, $props2['fileExists'],
237 "Destination file exists accourding to props ($backendName)." );
240 public function provider_testMove() {
243 $source = $this->baseStorePath() . '/cont1/file.txt';
244 $dest = $this->baseStorePath() . '/cont2/fileMoved.txt';
246 $op = array( 'op' => 'move', 'src' => $source, 'dst' => $dest );
253 $op['overwriteDest'] = true;
264 * @dataProvider provider_testDelete
266 public function testDelete( $op, $source, $withSource, $okStatus ) {
267 $this->pathsToPrune
[] = $source;
269 $this->backend
= $this->singleBackend
;
270 $this->doTestDelete( $op, $source, $withSource, $okStatus );
271 $this->tearDownFiles();
273 $this->backend
= $this->multiBackend
;
274 $this->doTestDelete( $op, $source, $withSource, $okStatus );
275 $this->tearDownFiles();
278 public function doTestDelete( $op, $source, $withSource, $okStatus ) {
279 $backendName = $this->backendClass();
282 $status = $this->backend
->doOperation(
283 array( 'op' => 'create', 'content' => 'blahblah', 'dst' => $source ) );
284 $this->assertEquals( true, $status->isOK(),
285 "Creation of file at $source succeeded ($backendName)." );
288 $status = $this->backend
->doOperation( $op );
290 $this->assertEquals( array(), $status->errors
,
291 "Deletion of file at $source succeeded without warnings ($backendName)." );
292 $this->assertEquals( true, $status->isOK(),
293 "Deletion of file at $source succeeded ($backendName)." );
294 $this->assertEquals( array( 0 => true ), $status->success
,
295 "Deletion of file at $source has proper 'success' field in Status ($backendName)." );
297 $this->assertEquals( false, $status->isOK(),
298 "Deletion of file at $source failed ($backendName)." );
301 $this->assertEquals( false, $this->backend
->fileExists( array( 'src' => $source ) ),
302 "Source file $source does not exist after move ($backendName)." );
305 $this->backend
->getFileSize( array( 'src' => $source ) ),
306 "Source file $source has correct size (false) ($backendName)." );
308 $props1 = $this->backend
->getFileProps( array( 'src' => $source ) );
309 $this->assertFalse( $props1['fileExists'],
310 "Source file $source does not exist according to props ($backendName)." );
313 public function provider_testDelete() {
316 $source = $this->baseStorePath() . '/cont1/myfacefile.txt';
318 $op = array( 'op' => 'delete', 'src' => $source );
329 false, // without source
333 $op['ignoreMissingSource'] = true;
337 false, // without source
345 * @dataProvider provider_testCreate
347 public function testCreate( $op, $dest, $alreadyExists, $okStatus, $newSize ) {
348 $this->pathsToPrune
[] = $dest;
350 $this->backend
= $this->singleBackend
;
351 $this->doTestCreate( $op, $dest, $alreadyExists, $okStatus, $newSize );
352 $this->tearDownFiles();
354 $this->backend
= $this->multiBackend
;
355 $this->doTestCreate( $op, $dest, $alreadyExists, $okStatus, $newSize );
356 $this->tearDownFiles();
359 public function doTestCreate( $op, $dest, $alreadyExists, $okStatus, $newSize ) {
360 $backendName = $this->backendClass();
362 $oldText = 'blah...blah...waahwaah';
363 if ( $alreadyExists ) {
364 $status = $this->backend
->doOperation(
365 array( 'op' => 'create', 'content' => $oldText, 'dst' => $dest ) );
366 $this->assertEquals( true, $status->isOK(),
367 "Creation of file at $dest succeeded ($backendName)." );
370 $status = $this->backend
->doOperation( $op );
372 $this->assertEquals( array(), $status->errors
,
373 "Creation of file at $dest succeeded without warnings ($backendName)." );
374 $this->assertEquals( true, $status->isOK(),
375 "Creation of file at $dest succeeded ($backendName)." );
376 $this->assertEquals( array( 0 => true ), $status->success
,
377 "Creation of file at $dest has proper 'success' field in Status ($backendName)." );
379 $this->assertEquals( false, $status->isOK(),
380 "Creation of file at $dest failed ($backendName)." );
383 $this->assertEquals( true, $this->backend
->fileExists( array( 'src' => $dest ) ),
384 "Destination file $dest exists after creation ($backendName)." );
386 $props1 = $this->backend
->getFileProps( array( 'src' => $dest ) );
387 $this->assertEquals( true, $props1['fileExists'],
388 "Destination file $dest exists according to props ($backendName)." );
389 if ( $okStatus ) { // file content is what we saved
390 $this->assertEquals( $newSize, $props1['size'],
391 "Destination file $dest has expected size according to props ($backendName)." );
392 $this->assertEquals( $newSize,
393 $this->backend
->getFileSize( array( 'src' => $dest ) ),
394 "Destination file $dest has correct size ($backendName)." );
395 } else { // file content is some other previous text
396 $this->assertEquals( strlen( $oldText ), $props1['size'],
397 "Destination file $dest has original size according to props ($backendName)." );
398 $this->assertEquals( strlen( $oldText ),
399 $this->backend
->getFileSize( array( 'src' => $dest ) ),
400 "Destination file $dest has original size according to props ($backendName)." );
405 * @dataProvider provider_testCreate
407 public function provider_testCreate() {
410 $source = $this->baseStorePath() . '/cont2/myspacefile.txt';
412 $dummyText = 'hey hey';
413 $op = array( 'op' => 'create', 'content' => $dummyText, 'dst' => $source );
417 false, // no dest already exists
425 true, // dest already exists
430 $op['overwriteDest'] = true;
434 true, // dest already exists
443 * @dataProvider provider_testConcatenate
445 public function testConcatenate( $op, $srcs, $srcsContent, $alreadyExists, $okStatus ) {
446 $this->pathsToPrune
= array_merge( $this->pathsToPrune
, $srcs );
447 $this->filesToPrune
[] = $op['dst'];
449 $this->backend
= $this->singleBackend
;
450 $this->doTestConcatenate( $op, $srcs, $srcsContent, $alreadyExists, $okStatus );
451 $this->tearDownFiles();
453 $this->backend
= $this->multiBackend
;
454 $this->doTestConcatenate( $op, $srcs, $srcsContent, $alreadyExists, $okStatus );
455 $this->tearDownFiles();
458 public function doTestConcatenate( $params, $srcs, $srcsContent, $alreadyExists, $okStatus ) {
459 $backendName = $this->backendClass();
464 foreach ( $srcs as $i => $source ) {
466 'op' => 'create', // operation
467 'dst' => $source, // source
468 'content' => $srcsContent[$i]
470 $expContent .= $srcsContent[$i];
472 $status = $this->backend
->doOperations( $ops );
474 $this->assertEquals( true, $status->isOK(),
475 "Creation of source files succeeded ($backendName)." );
477 $dest = $params['dst'];
478 if ( $alreadyExists ) {
479 $ok = file_put_contents( $dest, 'blah...blah...waahwaah' ) !== false;
480 $this->assertEquals( true, $ok,
481 "Creation of file at $dest succeeded ($backendName)." );
483 $ok = file_put_contents( $dest, '' ) !== false;
484 $this->assertEquals( true, $ok,
485 "Creation of 0-byte file at $dest succeeded ($backendName)." );
488 // Combine the files into one
489 $status = $this->backend
->concatenate( $params );
491 $this->assertEquals( array(), $status->errors
,
492 "Creation of concat file at $dest succeeded without warnings ($backendName)." );
493 $this->assertEquals( true, $status->isOK(),
494 "Creation of concat file at $dest succeeded ($backendName)." );
496 $this->assertEquals( false, $status->isOK(),
497 "Creation of concat file at $dest failed ($backendName)." );
501 $this->assertEquals( true, is_file( $dest ),
502 "Dest concat file $dest exists after creation ($backendName)." );
504 $this->assertEquals( true, is_file( $dest ),
505 "Dest concat file $dest exists after failed creation ($backendName)." );
508 $contents = file_get_contents( $dest );
509 $this->assertNotEquals( false, $contents, "File at $dest exists ($backendName)." );
512 $this->assertEquals( $expContent, $contents,
513 "Concat file at $dest has correct contents ($backendName)." );
515 $this->assertNotEquals( $expContent, $contents,
516 "Concat file at $dest has correct contents ($backendName)." );
520 function provider_testConcatenate() {
523 $rand = mt_rand( 0, 2000000000 ) . time();
524 $dest = wfTempDir() . "/randomfile!$rand.txt";
526 $this->baseStorePath() . '/cont1/file1.txt',
527 $this->baseStorePath() . '/cont1/file2.txt',
528 $this->baseStorePath() . '/cont1/file3.txt',
529 $this->baseStorePath() . '/cont1/file4.txt',
530 $this->baseStorePath() . '/cont1/file5.txt',
531 $this->baseStorePath() . '/cont1/file6.txt',
532 $this->baseStorePath() . '/cont1/file7.txt',
533 $this->baseStorePath() . '/cont1/file8.txt',
534 $this->baseStorePath() . '/cont1/file9.txt',
535 $this->baseStorePath() . '/cont1/file10.txt'
549 $params = array( 'srcs' => $srcs, 'dst' => $dest );
552 $params, // operation
554 $content, // content for each source
555 false, // no dest already exists
560 $params, // operation
562 $content, // content for each source
563 true, // dest already exists
571 * @dataProvider provider_testGetFileContents
573 public function testGetFileContents( $src, $content ) {
574 $this->pathsToPrune
[] = $src;
576 $this->backend
= $this->singleBackend
;
577 $this->doTestGetFileContents( $src, $content );
578 $this->tearDownFiles();
580 $this->backend
= $this->multiBackend
;
581 $this->doTestGetFileContents( $src, $content );
582 $this->tearDownFiles();
586 * @dataProvider provider_testGetFileContents
588 public function doTestGetFileContents( $src, $content ) {
589 $backendName = $this->backendClass();
591 $status = $this->backend
->doOperation(
592 array( 'op' => 'create', 'content' => $content, 'dst' => $src ) );
593 $this->assertEquals( true, $status->isOK(),
594 "Creation of file at $src succeeded ($backendName)." );
596 $newContents = $this->backend
->getFileContents( array( 'src' => $src ) );
597 $this->assertNotEquals( false, $newContents,
598 "Read of file at $src succeeded ($backendName)." );
600 $this->assertEquals( $content, $newContents,
601 "Contents read match data at $src ($backendName)." );
604 function provider_testGetFileContents() {
607 $base = $this->baseStorePath();
608 $cases[] = array( "$base/cont1/b/z/some_file.txt", "some file contents" );
609 $cases[] = array( "$base/cont1/b/some-other_file.txt", "more file contents" );
615 * @dataProvider provider_testGetLocalCopy
617 public function testGetLocalCopy( $src, $content ) {
618 $this->pathsToPrune
[] = $src;
620 $this->backend
= $this->singleBackend
;
621 $this->doTestGetLocalCopy( $src, $content );
622 $this->tearDownFiles();
624 $this->backend
= $this->multiBackend
;
625 $this->doTestGetLocalCopy( $src, $content );
626 $this->tearDownFiles();
629 public function doTestGetLocalCopy( $src, $content ) {
630 $backendName = $this->backendClass();
632 $status = $this->backend
->doOperation(
633 array( 'op' => 'create', 'content' => $content, 'dst' => $src ) );
634 $this->assertEquals( true, $status->isOK(),
635 "Creation of file at $src succeeded ($backendName)." );
637 $tmpFile = $this->backend
->getLocalCopy( array( 'src' => $src ) );
638 $this->assertNotNull( $tmpFile,
639 "Creation of local copy of $src succeeded ($backendName)." );
641 $contents = file_get_contents( $tmpFile->getPath() );
642 $this->assertNotEquals( false, $contents, "Local copy of $src exists ($backendName)." );
645 function provider_testGetLocalCopy() {
648 $base = $this->baseStorePath();
649 $cases[] = array( "$base/cont1/a/z/some_file.txt", "some file contents" );
650 $cases[] = array( "$base/cont1/a/some-other_file.txt", "more file contents" );
656 * @dataProvider provider_testGetLocalReference
658 public function testGetLocalReference( $src, $content ) {
659 $this->pathsToPrune
[] = $src;
661 $this->backend
= $this->singleBackend
;
662 $this->doTestGetLocalReference( $src, $content );
663 $this->tearDownFiles();
665 $this->backend
= $this->multiBackend
;
666 $this->doTestGetLocalReference( $src, $content );
667 $this->tearDownFiles();
670 public function doTestGetLocalReference( $src, $content ) {
671 $backendName = $this->backendClass();
673 $status = $this->backend
->doOperation(
674 array( 'op' => 'create', 'content' => $content, 'dst' => $src ) );
675 $this->assertEquals( true, $status->isOK(),
676 "Creation of file at $src succeeded ($backendName)." );
678 $tmpFile = $this->backend
->getLocalReference( array( 'src' => $src ) );
679 $this->assertNotNull( $tmpFile,
680 "Creation of local copy of $src succeeded ($backendName)." );
682 $contents = file_get_contents( $tmpFile->getPath() );
683 $this->assertNotEquals( false, $contents, "Local copy of $src exists ($backendName)." );
686 function provider_testGetLocalReference() {
689 $base = $this->baseStorePath();
690 $cases[] = array( "$base/cont1/a/z/some_file.txt", "some file contents" );
691 $cases[] = array( "$base/cont1/a/some-other_file.txt", "more file contents" );
697 * @dataProvider provider_testPrepareAndClean
699 public function testPrepareAndClean( $path, $isOK ) {
700 $this->backend
= $this->singleBackend
;
701 $this->doTestPrepareAndClean( $path, $isOK );
703 $this->backend
= $this->multiBackend
;
704 $this->doTestPrepareAndClean( $path, $isOK );
707 function provider_testPrepareAndClean() {
708 $base = $this->baseStorePath();
710 array( "$base/cont1/a/z/some_file1.txt", true ),
711 array( "$base/cont2/a/z/some_file2.txt", true ),
712 array( "$base/cont3/a/z/some_file3.txt", false ),
716 function doTestPrepareAndClean( $path, $isOK ) {
717 $backendName = $this->backendClass();
719 $status = $this->backend
->prepare( array( 'dir' => $path ) );
721 $this->assertEquals( array(), $status->errors
,
722 "Preparing dir $path succeeded without warnings ($backendName)." );
723 $this->assertEquals( true, $status->isOK(),
724 "Preparing dir $path succeeded ($backendName)." );
726 $this->assertEquals( false, $status->isOK(),
727 "Preparing dir $path failed ($backendName)." );
730 $status = $this->backend
->clean( array( 'dir' => $path ) );
732 $this->assertEquals( array(), $status->errors
,
733 "Cleaning dir $path succeeded without warnings ($backendName)." );
734 $this->assertEquals( true, $status->isOK(),
735 "Cleaning dir $path succeeded ($backendName)." );
737 $this->assertEquals( false, $status->isOK(),
738 "Cleaning dir $path failed ($backendName)." );
744 // @TODO: testDoOperations
746 public function testGetFileList() {
747 $this->backend
= $this->singleBackend
;
748 $this->doTestGetFileList();
749 $this->tearDownFiles();
751 $this->backend
= $this->multiBackend
;
752 $this->doTestGetFileList();
753 $this->tearDownFiles();
756 public function doTestGetFileList() {
757 $backendName = $this->backendClass();
759 $base = $this->baseStorePath();
761 "$base/cont1/test1.txt",
762 "$base/cont1/test2.txt",
763 "$base/cont1/test3.txt",
764 "$base/cont1/subdir1/test1.txt",
765 "$base/cont1/subdir1/test2.txt",
766 "$base/cont1/subdir2/test3.txt",
767 "$base/cont1/subdir2/test4.txt",
768 "$base/cont1/subdir2/subdir/test1.txt",
769 "$base/cont1/subdir2/subdir/test2.txt",
770 "$base/cont1/subdir2/subdir/test3.txt",
771 "$base/cont1/subdir2/subdir/test4.txt",
772 "$base/cont1/subdir2/subdir/test5.txt",
773 "$base/cont1/subdir2/subdir/sub/test0.txt",
774 "$base/cont1/subdir2/subdir/sub/120-px-file.txt",
776 $this->pathsToPrune
= array_merge( $this->pathsToPrune
, $files );
780 foreach ( $files as $file ) {
781 $ops[] = array( 'op' => 'create', 'content' => 'xxy', 'dst' => $file );
783 $status = $this->backend
->doOperations( $ops );
784 $this->assertEquals( true, $status->isOK(),
785 "Creation of files succeeded ($backendName)." );
796 "subdir2/subdir/test1.txt",
797 "subdir2/subdir/test2.txt",
798 "subdir2/subdir/test3.txt",
799 "subdir2/subdir/test4.txt",
800 "subdir2/subdir/test5.txt",
801 "subdir2/subdir/sub/test0.txt",
802 "subdir2/subdir/sub/120-px-file.txt",
806 // Actual listing (no trailing slash)
808 $iter = $this->backend
->getFileList( array( 'dir' => "$base/cont1" ) );
809 foreach ( $iter as $file ) {
814 $this->assertEquals( $expected, $list, "Correct file listing ($backendName)." );
816 // Actual listing (with trailing slash)
818 $iter = $this->backend
->getFileList( array( 'dir' => "$base/cont1/" ) );
819 foreach ( $iter as $file ) {
824 $this->assertEquals( $expected, $list, "Correct file listing ($backendName)." );
826 foreach ( $files as $file ) {
827 $this->backend
->doOperation( array( 'op' => 'delete', 'src' => "$base/$file" ) );
830 $iter = $this->backend
->getFileList( array( 'dir' => "$base/cont1/not/exists" ) );
831 foreach ( $iter as $iter ) {} // no errors
834 function tearDownFiles() {
835 foreach ( $this->filesToPrune
as $file ) {
838 foreach ( $this->pathsToPrune
as $file ) {
839 $this->backend
->doOperation( array( 'op' => 'delete', 'src' => $file ) );
843 function tearDown() {