assertEquals($expected, Builder::removeSortingInformations($value)); } public function testGetOrCreateDirNew() { $root = new Root(new Config(), ''); $dir = Builder::getOrCreateDir($root, 'directory'); $this->assertSame($root, $dir->getParent()); $this->assertEquals('directory', $dir->getTitle()); $this->assertEquals('directory', $dir->getUri()); } public function testGetOrCreateDirExisting() { $root = new Root(new Config(), ''); $directory = new Directory($root, 'directory'); $directory->setTitle('directory'); $dir = Builder::getOrCreateDir($root, 'directory'); $this->assertSame($root, $dir->getParent()); $this->assertEquals('directory', $dir->getTitle()); $this->assertEquals('directory', $dir->getUri()); $this->assertSame($directory, $dir); } public function getStaticRoot() { $config = new Config(); $config['mode'] = Daux::STATIC_MODE; $config['index_key'] = 'index.html'; $config['valid_content_extensions'] = ['md']; return new Root($config, ''); } public function testGetOrCreatePage() { $directory = new Directory($this->getStaticRoot(), 'dir'); $entry = Builder::getOrCreatePage($directory, 'A Page.md'); $this->assertSame($directory, $entry->getParent()); $this->assertEquals('dir/A_Page.html', $entry->getUrl()); $this->assertEquals('A_Page.html', $entry->getUri()); $this->assertEquals('A Page', $entry->getTitle()); $this->assertInstanceOf('Todaymade\Daux\Tree\Content', $entry); } public function testGetOrCreatePageAutoMarkdown() { $directory = new Directory($this->getStaticRoot(), 'dir'); $entry = Builder::getOrCreatePage($directory, 'A Page'); $this->assertSame($directory, $entry->getParent()); $this->assertEquals('dir/A_Page.html', $entry->getUrl()); $this->assertEquals('A_Page.html', $entry->getUri()); $this->assertEquals('A Page', $entry->getTitle()); $this->assertInstanceOf('Todaymade\Daux\Tree\Content', $entry); } public function testGetOrCreateIndexPage() { $directory = new Directory($this->getStaticRoot(), 'dir'); $directory->setTitle('Tutorials'); $entry = Builder::getOrCreatePage($directory, 'index.md'); $this->assertSame($directory, $entry->getParent()); $this->assertEquals('dir/index.html', $entry->getUrl()); $this->assertEquals('Tutorials', $entry->getTitle()); $this->assertInstanceOf('Todaymade\Daux\Tree\Content', $entry); } public function testGetOrCreatePageExisting() { $directory = new Directory($this->getStaticRoot(), 'dir'); $existingEntry = new Content($directory, 'A_Page.html'); $existingEntry->setContent('-'); $entry = Builder::getOrCreatePage($directory, 'A Page.md'); $this->assertSame($directory, $entry->getParent()); $this->assertSame($existingEntry, $entry); $this->assertEquals('dir/A_Page.html', $entry->getUrl()); $this->assertEquals('A_Page.html', $entry->getUri()); $this->assertInstanceOf('Todaymade\Daux\Tree\Content', $entry); } public function testGetOrCreateRawPage() { $directory = new Directory($this->getStaticRoot(), 'dir'); $entry = Builder::getOrCreatePage($directory, 'file.json'); $this->assertSame($directory, $entry->getParent()); $this->assertEquals('dir/file.json', $entry->getUrl()); $this->assertEquals('file.json', $entry->getUri()); $this->assertInstanceOf('Todaymade\Daux\Tree\ComputedRaw', $entry); } }