From c3e2cb9b6fe072dcc7ec909e922aa664cfa2a5a3 Mon Sep 17 00:00:00 2001 From: Gilbert Pellegrom Date: Tue, 27 Oct 2020 16:35:10 +0000 Subject: [PATCH] Create TemplateManagerTest.php --- tests/Templates/TemplateManagerTest.php | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/Templates/TemplateManagerTest.php 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); + } +}