#171 Redo the configuration layer to add a ConfigBuilder and group configuration parts

This commit is contained in:
Stéphane Goetz
2019-12-05 21:25:58 +01:00
parent 688de1d5b9
commit b5633e93c7
47 changed files with 1177 additions and 710 deletions

View File

@ -3,6 +3,7 @@ namespace Todaymade\Daux\ContentTypes\Markdown;
use org\bovigo\vfs\vfsStream;
use Todaymade\Daux\Config;
use Todaymade\Daux\ConfigBuilder;
use Todaymade\Daux\Daux;
use Todaymade\Daux\DauxHelper;
use Todaymade\Daux\Tree\Builder;
@ -13,27 +14,7 @@ class LinkRendererTest extends TestCase
{
protected function getTree(Config $config)
{
$structure = [
'Content' => [
'Page.md' => 'some text content',
],
'Widgets' => [
'Page.md' => 'another page',
'Button.md' => 'another page',
'Page_with_#_hash.md' => 'page with hash',
],
];
$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 providerRenderLink()
@ -70,11 +51,33 @@ class LinkRendererTest extends TestCase
*/
public function testRenderLink($expected, $string, $current)
{
$config = new Config();
$config['base_url'] = '';
$structure = [
'Content' => [
'Page.md' => 'some text content',
],
'Widgets' => [
'Page.md' => 'another page',
'Button.md' => 'another page',
'Page_with_#_hash.md' => 'page with hash',
],
];
$root = vfsStream::setup('root', null, $structure);
$config['tree'] = $this->getTree($config);
$config->setCurrentPage(DauxHelper::getFile($config['tree'], $current));
$config = ConfigBuilder::withMode()
->withDocumentationDirectory($root->url())
->withValidContentExtensions(['md'])
->with([
'base_url' => ''
])
->build();
$tree = new Root($config);
Builder::build($tree, []);
$config = ConfigBuilder::withMode()->build();
$config->setTree($tree);
$config->setCurrentPage(DauxHelper::getFile($config->getTree(), $current));
$converter = new CommonMarkConverter(['daux' => $config]);