echo '<br/>'; echo 'File is' . ($fileObject->isWritable() ? '' : ' not') . ' writeable.'; echo '<br/>'; echo 'File permission: ' . $fileObject->getPermission(); echo '<br/>'; echo '<br/>'; echo 'Remove file'; echo '<br/>'; $deletePath = __DIR__ . '/tmp/example.txt'; $fileObject = new File($deletePath); $fileObject->delete(); echo 'Remove directories'; echo '<br/>'; $deletePath = __DIR__ . '/tmp/target/'; $fileObject = new File($deletePath); $fileObject->deleteAll(); $examplePath = __DIR__ . '/ExampleDir'; $fileObject = new File($examplePath); echo '<br/>'; $iteratorObject = $fileObject->listAll(); echo 'Iterate * <strong>' . $fileObject->getBasename() . '</strong>'; echo '<br/>'; echo '<ul>'; echo '<li>' . $fileObject->getBasename(); echo '<ul>'; foreach ($iteratorObject as $subFileObject) { echo '<li>' . $subFileObject->getBasename() . '</li>'; if ($subFileObject->isDir()) { echo '<ul>'; foreach ($subFileObject->listAll() as $subChildFileObject) { echo '<li>' . $subChildFileObject->getBasename() . '</li>';
/** * @depends testExist * @depends testMkdir * @depends testMkdirs * @return void */ public function testDeleteAll() { $filePath = __DIR__ . '/tmp/example_delete.txt'; if (!is_file($filePath)) { // create file fclose(fopen($filePath, 'x')); } $fileObject = new File($filePath); $this->assertTrue($fileObject->isFile()); $this->assertTrue($fileObject->isWritable()); $this->assertTrue($fileObject->deleteAll()); $filePath = __DIR__ . '/tmp/foo/'; if (!is_dir($filePath)) { // create directories mkdir($filePath, 0777, true); } $fileObject = new File($filePath); $this->assertTrue($fileObject->isDir()); $this->assertTrue($fileObject->isWritable()); $this->assertTrue($fileObject->deleteAll()); $filePath = __DIR__ . '/tmp/bar/'; if (!is_dir($filePath)) { // create directories mkdir($filePath, 0777, true); } $fileObject = new File($filePath); $this->assertTrue($fileObject->isDir()); $this->assertTrue($fileObject->isWritable()); $this->assertTrue($fileObject->deleteAll()); }