public function it_only_presents_files_during_iteration() { $fs = new FileSystem(); $fs->createDirectory('/foo'); $fs->createDirectory('/foo/bar'); $fs->createFile('/foo/baz'); $filePath = $fs->path('/foo/baz'); $dir = new \SplFileInfo($fs->path('/foo')); $this->beConstructedThrough('fromPath', [$dir]); $this->shouldIterateLike([$filePath => new \SplFileInfo($filePath)]); }
/** * @test */ public function testGetConfigReader() { $fs = new FileSystem(); $fs->createDirectory("/test/app/etc", true); $fs->createFile("/test/app/etc/local.xml", "example"); $rootDiscovery = new RootDiscovery($fs->path("/test")); $this->assertEquals($fs->path("/test"), $rootDiscovery->getRootDirectory()); $this->assertInstanceOf('Meanbee\\LibMageConf\\ConfigReader', $rootDiscovery->getConfigReader()); }
public function it_can_be_constructed_from_a_directory_path() { $fs = new FileSystem(); $fs->createDirectory('/props'); $fs->createFile('/props/block.php'); $dbPath = new \SplFileInfo($fs->path('/props')); $this->beConstructedThrough('fromPath', [$dbPath]); $this->shouldImplement(PHPPropertyFileDirectory::class); }
public function it_can_be_constructed_from_a_directory_path() { $fs = new FileSystem(); $fs->createDirectory('/db'); $fs->createFile('/db/00000001-00000010!0010.php'); $dbPath = new \SplFileInfo($fs->path('/db')); $this->beConstructedThrough('fromPath', [$dbPath]); $this->shouldImplement(PHPRangeFileDirectory::class); $this->getFiles()->shouldHaveCount(1); }
public function testRmDirNotAllowedWhenDirectoryNotWritable() { $fs = new FileSystem(); $dir = $fs->createDirectory('/dir'); $wr = new Wrapper(); $dir->chmod(00); $this->assertFalse(@$wr->rmdir($fs->path('/dir')), 'Directory not removed with no permissions'); $dir->chmod(0100); $this->assertFalse(@$wr->rmdir($fs->path('/dir')), 'Directory not removed with exec only'); $dir->chmod(0200); $this->assertFalse(@$wr->rmdir($fs->path('/dir')), 'Directory not removed with write'); $error = error_get_last(); $this->assertStringMatchesFormat('rmdir: %s: Permission denied', $error['message']); $dir->chmod(0400); $this->assertTrue($wr->rmdir($fs->path('/dir')), 'Directory removed with read permission, yes that is how it normally behaves ;)'); }