X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fmikey179%2FvfsStream%2Fsrc%2Ftest%2Fphp%2Forg%2Fbovigo%2Fvfs%2Fvisitor%2FvfsStreamPrintVisitorTestCase.php;fp=vendor%2Fmikey179%2FvfsStream%2Fsrc%2Ftest%2Fphp%2Forg%2Fbovigo%2Fvfs%2Fvisitor%2FvfsStreamPrintVisitorTestCase.php;h=f227e0b885ed52ad9f90cfb799dc2d387b4a44d5;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitorTestCase.php b/vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitorTestCase.php new file mode 100644 index 000000000..f227e0b88 --- /dev/null +++ b/vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitorTestCase.php @@ -0,0 +1,102 @@ +at(vfsStream::setup()); + $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb')); + $this->assertSame($printVisitor, + $printVisitor->visitFile(vfsStream::newFile('bar.txt')) + ); + $this->assertEquals("- bar.txt\n", $output->getContent()); + } + + /** + * @test + */ + public function visitFileWritesBlockDeviceToStream() + { + $output = vfsStream::newFile('foo.txt') + ->at(vfsStream::setup()); + $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb')); + $this->assertSame($printVisitor, + $printVisitor->visitBlockDevice(vfsStream::newBlock('bar')) + ); + $this->assertEquals("- [bar]\n", $output->getContent()); + } + + /** + * @test + */ + public function visitDirectoryWritesDirectoryNameToStream() + { + $output = vfsStream::newFile('foo.txt') + ->at(vfsStream::setup()); + $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb')); + $this->assertSame($printVisitor, + $printVisitor->visitDirectory(vfsStream::newDirectory('baz')) + ); + $this->assertEquals("- baz\n", $output->getContent()); + } + + /** + * @test + */ + public function visitRecursiveDirectoryStructure() + { + $root = vfsStream::setup('root', + null, + array('test' => array('foo' => array('test.txt' => 'hello'), + 'baz.txt' => 'world' + ), + 'foo.txt' => '' + ) + ); + $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb')); + $this->assertSame($printVisitor, + $printVisitor->visitDirectory($root) + ); + $this->assertEquals("- root\n - test\n - foo\n - test.txt\n - baz.txt\n - foo.txt\n", file_get_contents('vfs://root/foo.txt')); + } +}