2017-11-11 07:22:27 +01:00
|
|
|
<?php
|
|
|
|
namespace Todaymade\Daux\Tree;
|
2016-07-04 20:33:44 +02:00
|
|
|
|
|
|
|
use org\bovigo\vfs\vfsStream;
|
|
|
|
use org\bovigo\vfs\vfsStreamDirectory;
|
2019-12-05 21:25:58 +01:00
|
|
|
use Todaymade\Daux\ConfigBuilder;
|
2016-07-04 20:33:44 +02:00
|
|
|
use Todaymade\Daux\Daux;
|
2017-11-11 07:22:27 +01:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-07-04 20:33:44 +02:00
|
|
|
|
2017-11-11 07:22:27 +01:00
|
|
|
class BuilderIntegrationTest extends TestCase
|
2016-07-04 20:33:44 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var vfsStreamDirectory
|
|
|
|
*/
|
|
|
|
private $root;
|
|
|
|
|
2019-11-28 22:36:26 +01:00
|
|
|
public function setUp(): void
|
2016-07-04 20:33:44 +02:00
|
|
|
{
|
|
|
|
$structure = [
|
|
|
|
'Contents' => [
|
|
|
|
'Page.md' => 'some text content',
|
|
|
|
],
|
|
|
|
'Widgets' => [
|
|
|
|
'Page.md' => 'another page',
|
|
|
|
'Button.md' => 'another page',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
$this->root = vfsStream::setup('root', null, $structure);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreateHierarchy()
|
|
|
|
{
|
2019-12-05 21:25:58 +01:00
|
|
|
$config = ConfigBuilder::withMode()
|
|
|
|
->withDocumentationDirectory($this->root->url())
|
|
|
|
->withValidContentExtensions(['md'])
|
|
|
|
->build();
|
2016-07-04 20:33:44 +02:00
|
|
|
|
2016-07-27 23:27:51 +02:00
|
|
|
$tree = new Root($config);
|
2016-07-04 20:33:44 +02:00
|
|
|
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']);
|
|
|
|
}
|
|
|
|
}
|