diff --git a/tests/Templates/TemplateManagerTest.php b/tests/Templates/TemplateManagerTest.php new file mode 100644 index 0000000..4cac660 --- /dev/null +++ b/tests/Templates/TemplateManagerTest.php @@ -0,0 +1,68 @@ +container->get(CollectionManagerInterface::class); + $this->collection = $collectionManager->getCollection('posts'); + $this->templateManager = $this->container->get(TemplateManagerInterface::class); + } + + public function testRenderCollection() + { + $html = $this->templateManager->renderCollection($this->collection, 1); + + $this->assertStringContainsString('

Hello World 1

', $html); + $this->assertStringContainsString('← Older', $html); + $this->assertStringNotContainsString('Hello World 11', $html); + $this->assertStringNotContainsString('Newer →', $html); + + $html = $this->templateManager->renderCollection($this->collection, 2); + + $this->assertStringContainsString('

Hello World 11

', $html); + $this->assertStringContainsString('Newer →', $html); + $this->assertStringNotContainsString('Hello World 5', $html); + $this->assertStringNotContainsString('← Older', $html); + } + + public function testRenderEntry() + { + $entryManager = $this->container->get(EntryManagerInterface::class); + $entryManager->setCollection($this->collection); + $entry = $entryManager->getEntry('example-post-1'); + + $html = $this->templateManager->renderEntry($entry); + + $this->assertStringContainsString('

Hello World 1

', $html); + $this->assertStringContainsString('

Lorem ipsum dolor sit amet.

', $html); + } + + public function testRenderError() + { + $html = $this->templateManager->renderError('Not Found', 404); + + $this->assertStringContainsString('

404

', $html); + $this->assertStringContainsString('
Not Found
', $html); + } +}