1 | <?php |
||
21 | class SingleBlogEntryActionTest extends TestCase |
||
22 | { |
||
23 | private $action, $templateRenderer, $entryParser, $markdownCmsConfig; |
||
24 | |||
25 | protected function setUp() |
||
26 | { |
||
27 | $this->templateRenderer = $this->prophesize(TemplateRendererInterface::class); |
||
28 | $this->entryParser = $this->prophesize(EntryParser::class); |
||
29 | $this->markdownCmsConfig = [ |
||
30 | 'options' => [ |
||
31 | 'content_dir' => 'testContentDir' |
||
32 | ], |
||
33 | ]; |
||
34 | |||
35 | $this->action = new SingleBlogEntryAction( |
||
36 | $this->templateRenderer->reveal(), |
||
37 | $this->entryParser->reveal(), |
||
38 | $this->markdownCmsConfig |
||
39 | ); |
||
40 | } |
||
41 | |||
42 | |||
43 | public function testInvoke() |
||
44 | { |
||
45 | $request = $this->prophesize(ServerRequestInterface::class); |
||
46 | $request |
||
47 | ->getAttribute('id') |
||
48 | ->willReturn('testId'); |
||
49 | |||
50 | $entry = $this->prophesize(ContentTypeInterface::class); |
||
51 | $entry |
||
52 | ->getTemplate() |
||
53 | ->willReturn('app::template.twig'); |
||
54 | |||
55 | $this->entryParser |
||
56 | ->__invoke('testId') |
||
57 | ->willReturn($entry->reveal()); |
||
58 | |||
59 | $this->templateRenderer |
||
60 | ->render('app::template.twig', ['entry' => $entry->reveal()]) |
||
61 | ->willReturn(''); |
||
62 | |||
63 | $response = ($this->action)( |
||
64 | $request->reveal(), |
||
65 | $this->prophesize(ResponseInterface::class)->reveal() |
||
66 | ); |
||
67 | |||
68 | $this->assertInstanceOf(HtmlResponse::class, $response); |
||
69 | } |
||
70 | } |