protected function getTree(Config $config) { $structure = ['Content' => ['Page.md' => 'some text content'], 'Widgets' => ['Page.md' => 'another page', 'Button.md' => 'another page']]; $root = vfsStream::setup('root', null, $structure); $config->setDocumentationDirectory($root->url()); $config['valid_content_extensions'] = ['md']; $config['mode'] = Daux::STATIC_MODE; $config['index_key'] = 'index.html'; $tree = new Root($config); Builder::build($tree, []); return $tree; }
public function testCreateHierarchy() { $config = new Config(); $config->setDocumentationDirectory($this->root->url()); $config['valid_content_extensions'] = ['md']; $config['mode'] = Daux::STATIC_MODE; $config['index_key'] = 'index.html'; $tree = new Root($config); Builder::build($tree, []); $this->assertCount(2, $tree); $this->assertTrue(array_key_exists('Contents', $tree->getEntries())); $this->assertInstanceOf(Directory::class, $tree['Contents']); $this->assertTrue(array_key_exists('Widgets', $tree->getEntries())); $this->assertInstanceOf(Directory::class, $tree['Widgets']); // TODO :: should not be Page.html, this should not depend on the mode $this->assertEquals('Page', $tree['Contents']['Page.html']->getTitle()); $this->assertInstanceOf(Content::class, $tree['Contents']['Page.html']); }
/** * Generate the tree that will be used */ public function generateTree() { $this->options['valid_content_extensions'] = $this->getContentExtensions(); $this->tree = new Root($this->getParams()); Builder::build($this->tree, $this->options['ignore']); if (!empty($this->options['languages'])) { foreach ($this->options['languages'] as $key => $node) { $this->tree->getEntries()[$key]->setTitle($node); } } // Enhance the tree with processors $this->getProcessor()->manipulateTree($this->tree); // Sort the tree one last time before it is finalized $this->sortTree($this->tree); $this->finalizeTree($this->tree); }