public function getStaticRoot() { $config = new Config(); $config->setDocumentationDirectory(''); $config['mode'] = Daux::STATIC_MODE; $config['index_key'] = 'index.html'; $config['valid_content_extensions'] = ['md']; return new Root($config); }
protected function createContent($content) { $config = new Config(); $config->setDocumentationDirectory(''); $dir = new Directory(new Root($config), ''); $obj = new Content($dir, ''); $obj->setContent($content); return $obj; }
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; }
/** * @dataProvider providerSort */ public function testSort($list, $expected) { shuffle($list); $config = new Config(); $config->setDocumentationDirectory(''); $directory = new Directory(new Root($config), 'dir'); foreach ($list as $value) { $entry = new Content($directory, $value); $entry->setName($value); } $directory->sort(); $final = []; foreach ($directory->getEntries() as $obj) { $final[] = $obj->getName(); } $this->assertEquals($expected, $final); }
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']); }