0dbfbb6c25d28764b5b635860cc437f625a12015
[yaffs-website] / vendor / mikey179 / vfsStream / src / test / php / org / bovigo / vfs / vfsStreamTestCase.php
1 <?php
2 /**
3  * This file is part of vfsStream.
4  *
5  * For the full copyright and license information, please view the LICENSE
6  * file that was distributed with this source code.
7  *
8  * @package  org\bovigo\vfs
9  */
10 namespace org\bovigo\vfs;
11
12 use org\bovigo\vfs\content\LargeFileContent;
13
14 /**
15  * Test for org\bovigo\vfs\vfsStream.
16  */
17 class vfsStreamTestCase extends \PHPUnit_Framework_TestCase
18 {
19     /**
20      * set up test environment
21      */
22     public function setUp()
23     {
24         vfsStreamWrapper::register();
25     }
26
27     /**
28      * assure that path2url conversion works correct
29      *
30      * @test
31      */
32     public function url()
33     {
34         $this->assertEquals('vfs://foo', vfsStream::url('foo'));
35         $this->assertEquals('vfs://foo/bar.baz', vfsStream::url('foo/bar.baz'));
36         $this->assertEquals('vfs://foo/bar.baz', vfsStream::url('foo\bar.baz'));
37     }
38
39     /**
40      * assure that url2path conversion works correct
41      *
42      * @test
43      */
44     public function path()
45     {
46         $this->assertEquals('foo', vfsStream::path('vfs://foo'));
47         $this->assertEquals('foo/bar.baz', vfsStream::path('vfs://foo/bar.baz'));
48         $this->assertEquals('foo/bar.baz', vfsStream::path('vfs://foo\bar.baz'));
49     }
50
51     /**
52      * windows directory separators are converted into default separator
53      *
54      * @author  Gabriel Birke
55      * @test
56      */
57     public function pathConvertsWindowsDirectorySeparators()
58     {
59         $this->assertEquals('foo/bar', vfsStream::path('vfs://foo\\bar'));
60     }
61
62     /**
63      * trailing whitespace should be removed
64      *
65      * @author  Gabriel Birke
66      * @test
67      */
68     public function pathRemovesTrailingWhitespace()
69     {
70         $this->assertEquals('foo/bar', vfsStream::path('vfs://foo/bar '));
71     }
72
73     /**
74      * trailing slashes are removed
75      *
76      * @author  Gabriel Birke
77      * @test
78      */
79     public function pathRemovesTrailingSlash()
80     {
81         $this->assertEquals('foo/bar', vfsStream::path('vfs://foo/bar/'));
82     }
83
84     /**
85      * trailing slash and whitespace should be removed
86      *
87      * @author  Gabriel Birke
88      * @test
89      */
90     public function pathRemovesTrailingSlashAndWhitespace()
91     {
92         $this->assertEquals('foo/bar', vfsStream::path('vfs://foo/bar/ '));
93     }
94
95     /**
96      * double slashes should be replaced by single slash
97      *
98      * @author  Gabriel Birke
99      * @test
100      */
101     public function pathRemovesDoubleSlashes()
102     {
103         // Regular path
104         $this->assertEquals('my/path', vfsStream::path('vfs://my/path'));
105         // Path with double slashes
106         $this->assertEquals('my/path', vfsStream::path('vfs://my//path'));
107     }
108
109     /**
110      * test to create a new file
111      *
112      * @test
113      */
114     public function newFile()
115     {
116         $file = vfsStream::newFile('filename.txt');
117         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamFile', $file);
118         $this->assertEquals('filename.txt', $file->getName());
119         $this->assertEquals(0666, $file->getPermissions());
120     }
121
122     /**
123      * test to create a new file with non-default permissions
124      *
125      * @test
126      * @group  permissions
127      */
128     public function newFileWithDifferentPermissions()
129     {
130         $file = vfsStream::newFile('filename.txt', 0644);
131         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamFile', $file);
132         $this->assertEquals('filename.txt', $file->getName());
133         $this->assertEquals(0644, $file->getPermissions());
134     }
135
136     /**
137      * test to create a new directory structure
138      *
139      * @test
140      */
141     public function newSingleDirectory()
142     {
143         $foo = vfsStream::newDirectory('foo');
144         $this->assertEquals('foo', $foo->getName());
145         $this->assertEquals(0, count($foo->getChildren()));
146         $this->assertEquals(0777, $foo->getPermissions());
147     }
148
149     /**
150      * test to create a new directory structure with non-default permissions
151      *
152      * @test
153      * @group  permissions
154      */
155     public function newSingleDirectoryWithDifferentPermissions()
156     {
157         $foo = vfsStream::newDirectory('foo', 0755);
158         $this->assertEquals('foo', $foo->getName());
159         $this->assertEquals(0, count($foo->getChildren()));
160         $this->assertEquals(0755, $foo->getPermissions());
161     }
162
163     /**
164      * test to create a new directory structure
165      *
166      * @test
167      */
168     public function newDirectoryStructure()
169     {
170         $foo = vfsStream::newDirectory('foo/bar/baz');
171         $this->assertEquals('foo', $foo->getName());
172         $this->assertEquals(0777, $foo->getPermissions());
173         $this->assertTrue($foo->hasChild('bar'));
174         $this->assertTrue($foo->hasChild('bar/baz'));
175         $this->assertFalse($foo->hasChild('baz'));
176         $bar = $foo->getChild('bar');
177         $this->assertEquals('bar', $bar->getName());
178         $this->assertEquals(0777, $bar->getPermissions());
179         $this->assertTrue($bar->hasChild('baz'));
180         $baz1 = $bar->getChild('baz');
181         $this->assertEquals('baz', $baz1->getName());
182         $this->assertEquals(0777, $baz1->getPermissions());
183         $baz2 = $foo->getChild('bar/baz');
184         $this->assertSame($baz1, $baz2);
185     }
186
187     /**
188      * test that correct directory structure is created
189      *
190      * @test
191      */
192     public function newDirectoryWithSlashAtStart()
193     {
194         $foo = vfsStream::newDirectory('/foo/bar/baz', 0755);
195         $this->assertEquals('foo', $foo->getName());
196         $this->assertEquals(0755, $foo->getPermissions());
197         $this->assertTrue($foo->hasChild('bar'));
198         $this->assertTrue($foo->hasChild('bar/baz'));
199         $this->assertFalse($foo->hasChild('baz'));
200         $bar = $foo->getChild('bar');
201         $this->assertEquals('bar', $bar->getName());
202         $this->assertEquals(0755, $bar->getPermissions());
203         $this->assertTrue($bar->hasChild('baz'));
204         $baz1 = $bar->getChild('baz');
205         $this->assertEquals('baz', $baz1->getName());
206         $this->assertEquals(0755, $baz1->getPermissions());
207         $baz2 = $foo->getChild('bar/baz');
208         $this->assertSame($baz1, $baz2);
209     }
210
211     /**
212      * @test
213      * @group  setup
214      * @since  0.7.0
215      */
216     public function setupRegistersStreamWrapperAndCreatesRootDirectoryWithDefaultNameAndPermissions()
217     {
218         $root = vfsStream::setup();
219         $this->assertSame($root, vfsStreamWrapper::getRoot());
220         $this->assertEquals('root', $root->getName());
221         $this->assertEquals(0777, $root->getPermissions());
222     }
223
224     /**
225      * @test
226      * @group  setup
227      * @since  0.7.0
228      */
229     public function setupRegistersStreamWrapperAndCreatesRootDirectoryWithGivenNameAndDefaultPermissions()
230     {
231         $root = vfsStream::setup('foo');
232         $this->assertSame($root, vfsStreamWrapper::getRoot());
233         $this->assertEquals('foo', $root->getName());
234         $this->assertEquals(0777, $root->getPermissions());
235     }
236
237     /**
238      * @test
239      * @group  setup
240      * @since  0.7.0
241      */
242     public function setupRegistersStreamWrapperAndCreatesRootDirectoryWithGivenNameAndPermissions()
243     {
244         $root = vfsStream::setup('foo', 0444);
245         $this->assertSame($root, vfsStreamWrapper::getRoot());
246         $this->assertEquals('foo', $root->getName());
247         $this->assertEquals(0444, $root->getPermissions());
248     }
249
250     /**
251      * @test
252      * @group  issue_14
253      * @group  issue_20
254      * @since  0.10.0
255      */
256     public function setupWithEmptyArrayIsEqualToSetup()
257     {
258         $root = vfsStream::setup('example',
259                                  0755,
260                                  array()
261                 );
262         $this->assertEquals('example', $root->getName());
263         $this->assertEquals(0755, $root->getPermissions());
264         $this->assertFalse($root->hasChildren());
265     }
266
267     /**
268      * @test
269      * @group  issue_14
270      * @group  issue_20
271      * @since  0.10.0
272      */
273     public function setupArraysAreTurnedIntoSubdirectories()
274     {
275         $root = vfsStream::setup('root',
276                                  null,
277                                  array('test' => array())
278                 );
279         $this->assertTrue($root->hasChildren());
280         $this->assertTrue($root->hasChild('test'));
281         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory',
282                                 $root->getChild('test')
283         );
284         $this->assertFalse($root->getChild('test')->hasChildren());
285     }
286
287     /**
288      * @test
289      * @group  issue_14
290      * @group  issue_20
291      * @since  0.10.0
292      */
293     public function setupStringsAreTurnedIntoFilesWithContent()
294     {
295         $root = vfsStream::setup('root',
296                                  null,
297                                  array('test.txt' => 'some content')
298                 );
299         $this->assertTrue($root->hasChildren());
300         $this->assertTrue($root->hasChild('test.txt'));
301         $this->assertVfsFile($root->getChild('test.txt'), 'some content');
302     }
303
304     /**
305      * @test
306      * @group  issue_14
307      * @group  issue_20
308      * @since  0.10.0
309      */
310     public function setupWorksRecursively()
311     {
312         $root = vfsStream::setup('root',
313                                  null,
314                                  array('test' => array('foo'     => array('test.txt' => 'hello'),
315                                                        'baz.txt' => 'world'
316                                                  )
317                                  )
318                 );
319         $this->assertTrue($root->hasChildren());
320         $this->assertTrue($root->hasChild('test'));
321         $test = $root->getChild('test');
322         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $test);
323         $this->assertTrue($test->hasChildren());
324         $this->assertTrue($test->hasChild('baz.txt'));
325         $this->assertVfsFile($test->getChild('baz.txt'), 'world');
326
327         $this->assertTrue($test->hasChild('foo'));
328         $foo = $test->getChild('foo');
329         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $foo);
330         $this->assertTrue($foo->hasChildren());
331         $this->assertTrue($foo->hasChild('test.txt'));
332         $this->assertVfsFile($foo->getChild('test.txt'), 'hello');
333     }
334
335     /**
336     * @test
337     * @group  issue_17
338     * @group  issue_20
339     */
340     public function setupCastsNumericDirectoriesToStrings()
341     {
342         $root = vfsStream::setup('root',
343                                  null,
344                                  array(2011 => array ('test.txt' => 'some content'))
345                 );
346         $this->assertTrue($root->hasChild('2011'));
347
348         $directory = $root->getChild('2011');
349         $this->assertVfsFile($directory->getChild('test.txt'), 'some content');
350
351         $this->assertTrue(file_exists('vfs://root/2011/test.txt'));
352     }
353
354     /**
355      * @test
356      * @group  issue_20
357      * @since  0.11.0
358      */
359     public function createArraysAreTurnedIntoSubdirectories()
360     {
361         $baseDir = vfsStream::create(array('test' => array()), new vfsStreamDirectory('baseDir'));
362         $this->assertTrue($baseDir->hasChildren());
363         $this->assertTrue($baseDir->hasChild('test'));
364         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory',
365                                 $baseDir->getChild('test')
366         );
367         $this->assertFalse($baseDir->getChild('test')->hasChildren());
368     }
369
370     /**
371      * @test
372      * @group  issue_20
373      * @since  0.11.0
374      */
375     public function createArraysAreTurnedIntoSubdirectoriesOfRoot()
376     {
377         $root = vfsStream::setup();
378         $this->assertSame($root, vfsStream::create(array('test' => array())));
379         $this->assertTrue($root->hasChildren());
380         $this->assertTrue($root->hasChild('test'));
381         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory',
382                                 $root->getChild('test')
383         );
384         $this->assertFalse($root->getChild('test')->hasChildren());
385     }
386
387     /**
388      * @test
389      * @group  issue_20
390      * @expectedException  \InvalidArgumentException
391      * @since  0.11.0
392      */
393     public function createThrowsExceptionIfNoBaseDirGivenAndNoRootSet()
394     {
395         vfsStream::create(array('test' => array()));
396     }
397
398     /**
399      * @test
400      * @group  issue_20
401      * @since  0.11.0
402      */
403     public function createWorksRecursively()
404     {
405         $baseDir = vfsStream::create(array('test' => array('foo'     => array('test.txt' => 'hello'),
406                                                            'baz.txt' => 'world'
407                                                      )
408                                      ),
409                                      new vfsStreamDirectory('baseDir')
410                    );
411         $this->assertTrue($baseDir->hasChildren());
412         $this->assertTrue($baseDir->hasChild('test'));
413         $test = $baseDir->getChild('test');
414         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $test);
415         $this->assertTrue($test->hasChildren());
416         $this->assertTrue($test->hasChild('baz.txt'));
417         $this->assertVfsFile($test->getChild('baz.txt'), 'world');
418
419         $this->assertTrue($test->hasChild('foo'));
420         $foo = $test->getChild('foo');
421         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $foo);
422         $this->assertTrue($foo->hasChildren());
423         $this->assertTrue($foo->hasChild('test.txt'));
424         $this->assertVfsFile($foo->getChild('test.txt'), 'hello');
425     }
426
427     /**
428      * @test
429      * @group  issue_20
430      * @since  0.11.0
431      */
432     public function createWorksRecursivelyWithRoot()
433     {
434         $root = vfsStream::setup();
435         $this->assertSame($root,
436                           vfsStream::create(array('test' => array('foo'     => array('test.txt' => 'hello'),
437                                                                   'baz.txt' => 'world'
438                                                             )
439                                             )
440                           )
441         );
442         $this->assertTrue($root->hasChildren());
443         $this->assertTrue($root->hasChild('test'));
444         $test = $root->getChild('test');
445         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $test);
446         $this->assertTrue($test->hasChildren());
447         $this->assertTrue($test->hasChild('baz.txt'));
448         $this->assertVfsFile($test->getChild('baz.txt'), 'world');
449
450         $this->assertTrue($test->hasChild('foo'));
451         $foo = $test->getChild('foo');
452         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $foo);
453         $this->assertTrue($foo->hasChildren());
454         $this->assertTrue($foo->hasChild('test.txt'));
455         $this->assertVfsFile($foo->getChild('test.txt'), 'hello');
456     }
457
458     /**
459      * @test
460      * @group  issue_20
461      * @since  0.10.0
462      */
463     public function createStringsAreTurnedIntoFilesWithContent()
464     {
465         $baseDir = vfsStream::create(array('test.txt' => 'some content'), new vfsStreamDirectory('baseDir'));
466         $this->assertTrue($baseDir->hasChildren());
467         $this->assertTrue($baseDir->hasChild('test.txt'));
468         $this->assertVfsFile($baseDir->getChild('test.txt'), 'some content');
469     }
470
471     /**
472      * @test
473      * @group  issue_20
474      * @since  0.11.0
475      */
476     public function createStringsAreTurnedIntoFilesWithContentWithRoot()
477     {
478         $root = vfsStream::setup();
479         $this->assertSame($root,
480                           vfsStream::create(array('test.txt' => 'some content'))
481         );
482         $this->assertTrue($root->hasChildren());
483         $this->assertTrue($root->hasChild('test.txt'));
484         $this->assertVfsFile($root->getChild('test.txt'), 'some content');
485     }
486
487     /**
488     * @test
489     * @group  issue_20
490     * @since  0.11.0
491     */
492     public function createCastsNumericDirectoriesToStrings()
493     {
494         $baseDir = vfsStream::create(array(2011 => array ('test.txt' => 'some content')), new vfsStreamDirectory('baseDir'));
495         $this->assertTrue($baseDir->hasChild('2011'));
496
497         $directory = $baseDir->getChild('2011');
498         $this->assertVfsFile($directory->getChild('test.txt'), 'some content');
499     }
500
501     /**
502     * @test
503     * @group  issue_20
504     * @since  0.11.0
505     */
506     public function createCastsNumericDirectoriesToStringsWithRoot()
507     {
508         $root = vfsStream::setup();
509         $this->assertSame($root,
510                           vfsStream::create(array(2011 => array ('test.txt' => 'some content')))
511         );
512         $this->assertTrue($root->hasChild('2011'));
513
514         $directory = $root->getChild('2011');
515         $this->assertVfsFile($directory->getChild('test.txt'), 'some content');
516     }
517
518     /**
519      * helper function for assertions on vfsStreamFile
520      *
521      * @param  vfsStreamFile  $file
522      * @param  string         $content
523      */
524     protected function assertVfsFile(vfsStreamFile $file, $content)
525     {
526         $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamFile',
527                                 $file
528         );
529         $this->assertEquals($content,
530                             $file->getContent()
531         );
532     }
533
534     /**
535      * @test
536      * @group  issue_10
537      * @since  0.10.0
538      */
539     public function inspectWithContentGivesContentToVisitor()
540     {
541         $mockContent = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
542         $mockVisitor = $this->getMock('org\\bovigo\\vfs\\visitor\\vfsStreamVisitor');
543         $mockVisitor->expects($this->once())
544                     ->method('visit')
545                     ->with($this->equalTo($mockContent))
546                     ->will($this->returnValue($mockVisitor));
547         $this->assertSame($mockVisitor, vfsStream::inspect($mockVisitor, $mockContent));
548     }
549
550     /**
551      * @test
552      * @group  issue_10
553      * @since  0.10.0
554      */
555     public function inspectWithoutContentGivesRootToVisitor()
556     {
557         $root = vfsStream::setup();
558         $mockVisitor = $this->getMock('org\\bovigo\\vfs\\visitor\\vfsStreamVisitor');
559         $mockVisitor->expects($this->once())
560                     ->method('visitDirectory')
561                     ->with($this->equalTo($root))
562                     ->will($this->returnValue($mockVisitor));
563         $this->assertSame($mockVisitor, vfsStream::inspect($mockVisitor));
564     }
565
566     /**
567      * @test
568      * @group  issue_10
569      * @expectedException  \InvalidArgumentException
570      * @since  0.10.0
571      */
572     public function inspectWithoutContentAndWithoutRootThrowsInvalidArgumentException()
573     {
574         $mockVisitor = $this->getMock('org\\bovigo\\vfs\\visitor\\vfsStreamVisitor');
575         $mockVisitor->expects($this->never())
576                     ->method('visit');
577         $mockVisitor->expects($this->never())
578                     ->method('visitDirectory');
579         vfsStream::inspect($mockVisitor);
580     }
581
582     /**
583      * returns path to file system copy resource directory
584      *
585      * @return  string
586      */
587     protected function getFileSystemCopyDir()
588     {
589         return realpath(dirname(__FILE__) . '/../../../../resources/filesystemcopy');
590     }
591
592     /**
593      * @test
594      * @group  issue_4
595      * @expectedException  \InvalidArgumentException
596      * @since  0.11.0
597      */
598     public function copyFromFileSystemThrowsExceptionIfNoBaseDirGivenAndNoRootSet()
599     {
600         vfsStream::copyFromFileSystem($this->getFileSystemCopyDir());
601     }
602
603     /**
604      * @test
605      * @group  issue_4
606      * @since  0.11.0
607      */
608     public function copyFromEmptyFolder()
609     {
610         $baseDir = vfsStream::copyFromFileSystem($this->getFileSystemCopyDir() . '/emptyFolder',
611                                                  vfsStream::newDirectory('test')
612                    );
613         $baseDir->removeChild('.gitignore');
614         $this->assertFalse($baseDir->hasChildren());
615     }
616
617     /**
618      * @test
619      * @group  issue_4
620      * @since  0.11.0
621      */
622     public function copyFromEmptyFolderWithRoot()
623     {
624         $root = vfsStream::setup();
625         $this->assertEquals($root,
626                             vfsStream::copyFromFileSystem($this->getFileSystemCopyDir() . '/emptyFolder')
627         );
628         $root->removeChild('.gitignore');
629         $this->assertFalse($root->hasChildren());
630     }
631
632     /**
633      * @test
634      * @group  issue_4
635      * @since  0.11.0
636      */
637     public function copyFromWithSubFolders()
638     {
639         $baseDir = vfsStream::copyFromFileSystem($this->getFileSystemCopyDir(),
640                                                  vfsStream::newDirectory('test'),
641                                                  3
642                    );
643         $this->assertTrue($baseDir->hasChildren());
644         $this->assertTrue($baseDir->hasChild('emptyFolder'));
645         $this->assertTrue($baseDir->hasChild('withSubfolders'));
646         $subfolderDir = $baseDir->getChild('withSubfolders');
647         $this->assertTrue($subfolderDir->hasChild('subfolder1'));
648         $this->assertTrue($subfolderDir->getChild('subfolder1')->hasChild('file1.txt'));
649         $this->assertVfsFile($subfolderDir->getChild('subfolder1/file1.txt'), '      ');
650         $this->assertTrue($subfolderDir->hasChild('subfolder2'));
651         $this->assertTrue($subfolderDir->hasChild('aFile.txt'));
652         $this->assertVfsFile($subfolderDir->getChild('aFile.txt'), 'foo');
653     }
654
655     /**
656      * @test
657      * @group  issue_4
658      * @since  0.11.0
659      */
660     public function copyFromWithSubFoldersWithRoot()
661     {
662         $root = vfsStream::setup();
663         $this->assertEquals($root,
664                             vfsStream::copyFromFileSystem($this->getFileSystemCopyDir(),
665                                                           null,
666                                                           3
667                             )
668         );
669         $this->assertTrue($root->hasChildren());
670         $this->assertTrue($root->hasChild('emptyFolder'));
671         $this->assertTrue($root->hasChild('withSubfolders'));
672         $subfolderDir = $root->getChild('withSubfolders');
673         $this->assertTrue($subfolderDir->hasChild('subfolder1'));
674         $this->assertTrue($subfolderDir->getChild('subfolder1')->hasChild('file1.txt'));
675         $this->assertVfsFile($subfolderDir->getChild('subfolder1/file1.txt'), '      ');
676         $this->assertTrue($subfolderDir->hasChild('subfolder2'));
677         $this->assertTrue($subfolderDir->hasChild('aFile.txt'));
678         $this->assertVfsFile($subfolderDir->getChild('aFile.txt'), 'foo');
679     }
680
681     /**
682      * @test
683      * @group  issue_4
684      * @group  issue_29
685      * @since  0.11.2
686      */
687     public function copyFromPreservesFilePermissions()
688     {
689         if (DIRECTORY_SEPARATOR !== '/') {
690             $this->markTestSkipped('Only applicable on Linux style systems.');
691         }
692
693         $copyDir = $this->getFileSystemCopyDir();
694         $root    = vfsStream::setup();
695         $this->assertEquals($root,
696                             vfsStream::copyFromFileSystem($copyDir,
697                                                           null
698                             )
699         );
700         $this->assertEquals(fileperms($copyDir . '/withSubfolders') - vfsStreamContent::TYPE_DIR,
701                             $root->getChild('withSubfolders')
702                                  ->getPermissions()
703         );
704         $this->assertEquals(fileperms($copyDir . '/withSubfolders/aFile.txt') - vfsStreamContent::TYPE_FILE,
705                             $root->getChild('withSubfolders/aFile.txt')
706                                  ->getPermissions()
707         );
708     }
709
710     /**
711      * To test this the max file size is reduced to something reproduceable.
712      *
713      * @test
714      * @group  issue_91
715      * @since  1.5.0
716      */
717     public function copyFromFileSystemMocksLargeFiles()
718     {
719         if (DIRECTORY_SEPARATOR !== '/') {
720             $this->markTestSkipped('Only applicable on Linux style systems.');
721         }
722
723         $copyDir = $this->getFileSystemCopyDir();
724         $root    = vfsStream::setup();
725         vfsStream::copyFromFileSystem($copyDir, $root, 3);
726         $this->assertEquals(
727                 '      ',
728                 $root->getChild('withSubfolders/subfolder1/file1.txt')->getContent()
729         );
730     }
731
732     /**
733      * @test
734      * @group  issue_121
735      * @since  1.6.1
736      */
737     public function createDirectoryWithTrailingSlashShouldNotCreateSubdirectoryWithEmptyName()
738     {
739         $directory = vfsStream::newDirectory('foo/');
740         $this->assertFalse($directory->hasChildren());
741     }
742
743     /**
744      * @test
745      * @group  issue_149
746      */
747     public function addStructureHandlesVfsStreamFileObjects()
748     {
749         $structure = array(
750             'topLevel' => array(
751                 'thisIsAFile' => 'file contents',
752                 vfsStream::newFile('anotherFile'),
753             ),
754         );
755
756         vfsStream::setup();
757         $root = vfsStream::create($structure);
758
759         $this->assertTrue($root->hasChild('topLevel/anotherFile'));
760     }
761
762     /**
763      * @test
764      * @group  issue_149
765      */
766     public function createHandlesLargeFileContentObjects()
767     {
768         $structure = array(
769             'topLevel' => array(
770                 'thisIsAFile' => 'file contents',
771                 'anotherFile' => LargeFileContent::withMegabytes(2),
772             ),
773         );
774
775         vfsStream::setup();
776         $root = vfsStream::create($structure);
777
778         $this->assertTrue($root->hasChild('topLevel/anotherFile'));
779     }
780 }