/** * @depends testDeleteAll * @return void */ public function testDeleteFiles() { $filePath = __DIR__ . '/tmp/foo2'; // create directories $createDirs = array($filePath, $filePath . '/bar2', $filePath . '/bar3'); foreach ($createDirs as $createDir) { if (!is_dir($createDir)) { mkdir($createDir, 0777, true); } } // create file $createFiles = array($filePath . '/example_file_delete1.txt', $filePath . '/example_file_delete2.txt', $filePath . '/bar2/example_file_delete3.txt', $filePath . '/bar2/example_file_delete4.txt', $filePath . '/bar3/example_file_delete5.txt', $filePath . '/bar3/example_file_delete6.txt'); foreach ($createFiles as $createFile) { if (!is_file($createFile)) { fclose(fopen($createFile, 'x')); } } $fileObject = new File($filePath); $this->assertTrue($fileObject->isDir()); $this->assertTrue($fileObject->isWritable()); $this->assertTrue($fileObject->deleteFiles()); $subPaths = array_diff(scandir($filePath), array('..', '.')); $this->assertEquals(2, count($subPaths)); }