/** * Set Up */ public function setUp() { $testDirPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'corgi_file' . DIRECTORY_SEPARATOR . 'test'; $this->testFilePath = $testDirPath . DIRECTORY_SEPARATOR . 'test.txt'; $this->directory = new Directory($testDirPath); $this->directory->create(true); parent::setUp(); }
/** * Creates a new subdirectory in the current directory * @param string|IStringBehaviour|Directory $directory * @param int $fileMask * @return Directory * @throws CreateDirectoryException * @throws NotWritableException * @throws OverwriteException */ public function addSubDirectory($directory, $fileMask = 0755) { $newDirectory = $directory instanceof Directory ? $directory : new Directory($this->getDirectory() . DIRECTORY_SEPARATOR . $directory); if (FileSystemHelper::isReadable($newDirectory)) { throw new OverwriteException($newDirectory); } return $directory->create(false, $fileMask); }
/** * @covers Corgi\File\Base\FileSystemNode::rename */ public function testRename() { $file = new File($this->fullTestFilePath); $copyPath = $this->getCopyPath($file); $file->touch(); $file->rename($copyPath); $this->assertEquals($copyPath, $file->getPath()); $file->delete(); $directory = new Directory($this->fullTestFilePath); $copyPath = $this->getCopyPath($file); $directory->create(); $directory->rename($copyPath); $this->assertEquals($copyPath, $directory->getPath()); $directory->delete(); }
/** * @covers Corgi\File\Directory::safeDelete * @depends testCreate */ public function testSafeDelete() { $directory = new Directory($this->baseDirPath); $directory->create(); $this->assertTrue(file_exists($directory) && is_dir($directory)); $directory->safeDelete(); $this->assertFalse(is_dir($directory)); }