public function run() { $view = new View('/'); $children = $view->getDirectoryContent('/'); foreach ($children as $child) { if ($view->is_dir($child->getPath())) { $thumbnailsFolder = $child->getPath() . '/thumbnails'; if ($view->is_dir($thumbnailsFolder)) { $view->rmdir($thumbnailsFolder); } } } }
/** * Delete should fail is the source folder cant be deleted */ public function testSingleStorageDeleteFolderFail() { /** * @var \OC\Files\Storage\Temporary | \PHPUnit_Framework_MockObject_MockObject $storage */ $storage = $this->getMockBuilder('\\OC\\Files\\Storage\\Temporary')->setConstructorArgs([[]])->setMethods(['rename', 'unlink', 'rmdir'])->getMock(); $storage->expects($this->any())->method('rmdir')->will($this->returnValue(false)); $cache = $storage->getCache(); Filesystem::mount($storage, [], '/' . $this->user . '/files'); $this->userView->mkdir('folder'); $this->userView->file_put_contents('folder/test.txt', 'foo'); $this->assertTrue($storage->file_exists('folder/test.txt')); $this->assertFalse($this->userView->rmdir('folder')); $this->assertTrue($storage->file_exists('folder')); $this->assertTrue($storage->file_exists('folder/test.txt')); $this->assertTrue($cache->inCache('folder')); $this->assertTrue($cache->inCache('folder/test.txt')); // file should not be in the trashbin $results = $this->rootView->getDirectoryContent($this->user . '/files_trashbin/files/'); $this->assertEquals(0, count($results)); }
public static function rmdir($path) { return self::$defaultInstance->rmdir($path); }