vfs = vfsStream::setup('root'); $this->vfsPath = vfsStream::url('root'); $this->fs = new Filesystem(); clearstatcache(); } /** * @return void * @covers ::mkdir */ public function testMkdir() { $path = $this->vfsPath . DS . 'tests' . DS . 'first' . DS . 'second' . DS . 'third'; $this->fs->mkdir($path); $this->assertTrue(is_dir($path)); } /** * @return void * @covers ::dumpFile */ public function testDumpFile() { $path = $this->vfsPath . DS . 'foo.txt'; $this->fs->dumpFile($path, 'bar'); $this->assertEquals(file_get_contents($path), 'bar'); $path = $this->vfsPath . DS . 'empty.txt'; $this->fs->dumpFile($path, ''); $this->assertSame(file_get_contents($path), ''); } /** * @return void * @covers ::copyDir */ public function testCopyDir() { $return = $this->fs->copyDir(WWW_ROOT, $this->vfsPath . DS . 'dest'); $this->assertTrue($return); } /** * @return void * @covers ::deleteDir */ public function testDeleteDir() { $structure = [ 'Core' => [ 'AbstractFactory' => [ 'test.php' => 'some text content', 'other.php' => 'Some more text content', 'Invalid.csv' => 'Something else', ], 'AnEmptyFolder' => [], 'badlocation.php' => 'some bad content', ], ]; vfsStream::create($structure); $return = $this->fs->deleteDir($this->vfsPath . DS . 'Core'); $this->assertTrue($return); } }