本文整理汇总了PHP中FileBackend::getTopDirectoryList方法的典型用法代码示例。如果您正苦于以下问题:PHP FileBackend::getTopDirectoryList方法的具体用法?PHP FileBackend::getTopDirectoryList怎么用?PHP FileBackend::getTopDirectoryList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileBackend
的用法示例。
在下文中一共展示了FileBackend::getTopDirectoryList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doTestGetDirectoryList
private function doTestGetDirectoryList()
{
$backendName = $this->backendClass();
$base = self::baseStorePath();
$files = array("{$base}/unittest-cont1/e/test1.txt", "{$base}/unittest-cont1/e/test2.txt", "{$base}/unittest-cont1/e/test3.txt", "{$base}/unittest-cont1/e/subdir1/test1.txt", "{$base}/unittest-cont1/e/subdir1/test2.txt", "{$base}/unittest-cont1/e/subdir2/test3.txt", "{$base}/unittest-cont1/e/subdir2/test4.txt", "{$base}/unittest-cont1/e/subdir2/subdir/test1.txt", "{$base}/unittest-cont1/e/subdir3/subdir/test2.txt", "{$base}/unittest-cont1/e/subdir4/subdir/test3.txt", "{$base}/unittest-cont1/e/subdir4/subdir/test4.txt", "{$base}/unittest-cont1/e/subdir4/subdir/test5.txt", "{$base}/unittest-cont1/e/subdir4/subdir/sub/test0.txt", "{$base}/unittest-cont1/e/subdir4/subdir/sub/120-px-file.txt");
// Add the files
$ops = array();
foreach ($files as $file) {
$this->prepare(array('dir' => dirname($file)));
$ops[] = array('op' => 'create', 'content' => 'xxy', 'dst' => $file);
}
$status = $this->backend->doQuickOperations($ops);
$this->assertGoodStatus($status, "Creation of files succeeded ({$backendName}).");
$this->assertEquals(true, $status->isOK(), "Creation of files succeeded with OK status ({$backendName}).");
$this->assertEquals(true, $this->backend->directoryExists(array('dir' => "{$base}/unittest-cont1/e/subdir1")), "Directory exists in ({$backendName}).");
$this->assertEquals(true, $this->backend->directoryExists(array('dir' => "{$base}/unittest-cont1/e/subdir2/subdir")), "Directory exists in ({$backendName}).");
$this->assertEquals(false, $this->backend->directoryExists(array('dir' => "{$base}/unittest-cont1/e/subdir2/test1.txt")), "Directory does not exists in ({$backendName}).");
// Expected listing
$expected = array("e");
sort($expected);
// Actual listing (no trailing slash)
$list = array();
$iter = $this->backend->getTopDirectoryList(array('dir' => "{$base}/unittest-cont1"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}).");
// Expected listing
$expected = array("subdir1", "subdir2", "subdir3", "subdir4");
sort($expected);
// Actual listing (no trailing slash)
$list = array();
$iter = $this->backend->getTopDirectoryList(array('dir' => "{$base}/unittest-cont1/e"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}).");
// Actual listing (with trailing slash)
$list = array();
$iter = $this->backend->getTopDirectoryList(array('dir' => "{$base}/unittest-cont1/e/"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}).");
// Expected listing
$expected = array("subdir");
sort($expected);
// Actual listing (no trailing slash)
$list = array();
$iter = $this->backend->getTopDirectoryList(array('dir' => "{$base}/unittest-cont1/e/subdir2"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}).");
// Actual listing (with trailing slash)
$list = array();
$iter = $this->backend->getTopDirectoryList(array('dir' => "{$base}/unittest-cont1/e/subdir2/"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}).");
// Actual listing (using iterator second time)
$list = array();
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct top dir listing ({$backendName}), second iteration.");
// Expected listing (recursive)
$expected = array("e", "e/subdir1", "e/subdir2", "e/subdir3", "e/subdir4", "e/subdir2/subdir", "e/subdir3/subdir", "e/subdir4/subdir", "e/subdir4/subdir/sub");
sort($expected);
// Actual listing (recursive)
$list = array();
$iter = $this->backend->getDirectoryList(array('dir' => "{$base}/unittest-cont1/"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct dir listing ({$backendName}).");
// Expected listing (recursive)
$expected = array("subdir", "subdir/sub");
sort($expected);
// Actual listing (recursive)
$list = array();
$iter = $this->backend->getDirectoryList(array('dir' => "{$base}/unittest-cont1/e/subdir4"));
foreach ($iter as $file) {
$list[] = $file;
}
sort($list);
$this->assertEquals($expected, $list, "Correct dir listing ({$backendName}).");
// Actual listing (recursive, second time)
$list = array();
foreach ($iter as $file) {
$list[] = $file;
}
//.........这里部分代码省略.........