Author: Ross Perkins (ross@vubeology.com)
 public function testDirectoryScanEmpty()
 {
     $dir = vfsStream::url("root/docroot/empty");
     $scanner = new DirectoryScan($dir);
     $result = $scanner->scan();
     $this->assertArrayHasKey('dirs', $result);
     $this->assertArrayHasKey('boxes', $result);
     $this->assertArrayHasKey('metadata', $result);
     $this->assertSame(array(), $result['dirs'], "Unexpected dirs result for {$dir}");
     $this->assertSame(array(), $result['boxes'], "Unexpected boxes result for {$dir}");
     $this->assertNull($result['metadata']);
 }
Example #2
0
 public function execIndexRoute()
 {
     $currentDir = $this->config['metadata-root'] . $this->pathInfo;
     $smarty = new Smarty($this->baseDir);
     $smarty->assign('BASE_URI', $this->baseUri);
     $smarty->assign('CATALOG_URI', $this->baseUri . '/' . $this->config['catalog-uri']);
     $smarty->assign('pathInfo', $this->pathInfo);
     $relativePathInfo = $this->computeRelativePathInfo($this->pathInfo);
     $smarty->assign('relativePathInfo', $relativePathInfo);
     $backDirs = $this->computeBreadcrumb($relativePathInfo);
     $smarty->assign('relativeBackDirs', $backDirs);
     $scanner = new DirectoryScan($currentDir);
     $dirInfo = $scanner->scan();
     // If there is a metadata.json in this directory, read it in
     $metadata = null;
     $json = null;
     if ($dirInfo['metadata'] !== null) {
         $template = @file_get_contents($dirInfo['metadata']);
         $metadata = $this->parseMetadataTemplate($template);
         $json = json_decode($metadata, true);
     }
     $smarty->assign('directories', $dirInfo['dirs']);
     $smarty->assign('boxes', $dirInfo['boxes']);
     $smarty->assign('metadata', $metadata);
     $smarty->assign('json', $json);
     $result = array('headers' => array('Content-Type: text/html'), 'content' => $smarty->fetch('index.tpl'));
     return $result;
 }