当前位置: 首页>>代码示例>>PHP>>正文


PHP FileBackend::getTopFileList方法代码示例

本文整理汇总了PHP中FileBackend::getTopFileList方法的典型用法代码示例。如果您正苦于以下问题:PHP FileBackend::getTopFileList方法的具体用法?PHP FileBackend::getTopFileList怎么用?PHP FileBackend::getTopFileList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileBackend的用法示例。


在下文中一共展示了FileBackend::getTopFileList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doTestGetFileList

 private function doTestGetFileList()
 {
     $backendName = $this->backendClass();
     $base = self::baseStorePath();
     // Should have no errors
     $iter = $this->backend->getFileList(array('dir' => "{$base}/unittest-cont-notexists"));
     $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/subdir2/subdir/test2.txt", "{$base}/unittest-cont1/e/subdir2/subdir/test3.txt", "{$base}/unittest-cont1/e/subdir2/subdir/test4.txt", "{$base}/unittest-cont1/e/subdir2/subdir/test5.txt", "{$base}/unittest-cont1/e/subdir2/subdir/sub/test0.txt", "{$base}/unittest-cont1/e/subdir2/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}).");
     // Expected listing at root
     $expected = array("e/test1.txt", "e/test2.txt", "e/test3.txt", "e/subdir1/test1.txt", "e/subdir1/test2.txt", "e/subdir2/test3.txt", "e/subdir2/test4.txt", "e/subdir2/subdir/test1.txt", "e/subdir2/subdir/test2.txt", "e/subdir2/subdir/test3.txt", "e/subdir2/subdir/test4.txt", "e/subdir2/subdir/test5.txt", "e/subdir2/subdir/sub/test0.txt", "e/subdir2/subdir/sub/120-px-file.txt");
     sort($expected);
     // Actual listing (no trailing slash) at root
     $iter = $this->backend->getFileList(array('dir' => "{$base}/unittest-cont1"));
     $list = $this->listToArray($iter);
     sort($list);
     $this->assertEquals($expected, $list, "Correct file listing ({$backendName}).");
     // Actual listing (no trailing slash) at root with advise
     $iter = $this->backend->getFileList(array('dir' => "{$base}/unittest-cont1", 'adviseStat' => 1));
     $list = $this->listToArray($iter);
     sort($list);
     $this->assertEquals($expected, $list, "Correct file listing ({$backendName}).");
     // Actual listing (with trailing slash) at root
     $list = array();
     $iter = $this->backend->getFileList(array('dir' => "{$base}/unittest-cont1/"));
     foreach ($iter as $file) {
         $list[] = $file;
     }
     sort($list);
     $this->assertEquals($expected, $list, "Correct file listing ({$backendName}).");
     // Expected listing at subdir
     $expected = array("test1.txt", "test2.txt", "test3.txt", "test4.txt", "test5.txt", "sub/test0.txt", "sub/120-px-file.txt");
     sort($expected);
     // Actual listing (no trailing slash) at subdir
     $iter = $this->backend->getFileList(array('dir' => "{$base}/unittest-cont1/e/subdir2/subdir"));
     $list = $this->listToArray($iter);
     sort($list);
     $this->assertEquals($expected, $list, "Correct file listing ({$backendName}).");
     // Actual listing (no trailing slash) at subdir with advise
     $iter = $this->backend->getFileList(array('dir' => "{$base}/unittest-cont1/e/subdir2/subdir", 'adviseStat' => 1));
     $list = $this->listToArray($iter);
     sort($list);
     $this->assertEquals($expected, $list, "Correct file listing ({$backendName}).");
     // Actual listing (with trailing slash) at subdir
     $list = array();
     $iter = $this->backend->getFileList(array('dir' => "{$base}/unittest-cont1/e/subdir2/subdir/"));
     foreach ($iter as $file) {
         $list[] = $file;
     }
     sort($list);
     $this->assertEquals($expected, $list, "Correct file listing ({$backendName}).");
     // Actual listing (using iterator second time)
     $list = $this->listToArray($iter);
     sort($list);
     $this->assertEquals($expected, $list, "Correct file listing ({$backendName}), second iteration.");
     // Actual listing (top files only) at root
     $iter = $this->backend->getTopFileList(array('dir' => "{$base}/unittest-cont1"));
     $list = $this->listToArray($iter);
     sort($list);
     $this->assertEquals(array(), $list, "Correct top file listing ({$backendName}).");
     // Expected listing (top files only) at subdir
     $expected = array("test1.txt", "test2.txt", "test3.txt", "test4.txt", "test5.txt");
     sort($expected);
     // Actual listing (top files only) at subdir
     $iter = $this->backend->getTopFileList(array('dir' => "{$base}/unittest-cont1/e/subdir2/subdir"));
     $list = $this->listToArray($iter);
     sort($list);
     $this->assertEquals($expected, $list, "Correct top file listing ({$backendName}).");
     // Actual listing (top files only) at subdir with advise
     $iter = $this->backend->getTopFileList(array('dir' => "{$base}/unittest-cont1/e/subdir2/subdir", 'adviseStat' => 1));
     $list = $this->listToArray($iter);
     sort($list);
     $this->assertEquals($expected, $list, "Correct top file listing ({$backendName}).");
     foreach ($files as $file) {
         // clean up
         $this->backend->doOperation(array('op' => 'delete', 'src' => $file));
     }
     $iter = $this->backend->getFileList(array('dir' => "{$base}/unittest-cont1/not/exists"));
     foreach ($iter as $iter) {
         // no errors
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:89,代码来源:FileBackendTest.php


注:本文中的FileBackend::getTopFileList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。