1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Lichtenwallner (https://lichtenwallner.at) |
4
|
|
|
* |
5
|
|
|
* @see https://github.com/jolicht/markdown-cms for the canonical source repository |
6
|
|
|
* @license https://github.com/jolicht/markdown-cms/blob/master/LICENSE MIT |
7
|
|
|
* @copyright Copyright (c) Johannes Lichtenwallner |
8
|
|
|
*/ |
9
|
|
|
declare(strict_types = 1); |
10
|
|
|
namespace JolichtTest\MarkdownCms\Action; |
11
|
|
|
|
12
|
|
|
use Reddogs\Test\ServiceManagerAwareTestCase; |
13
|
|
|
use Jolicht\MarkdownCms\ModuleConfig; |
14
|
|
|
use Jolicht\MarkdownCms\Action\BlogOverviewAction; |
15
|
|
|
use Zend\Expressive\Template\TemplateRendererInterface; |
16
|
|
|
use Jolicht\MarkdownCms\ContentType\ContentCreator; |
17
|
|
|
use Jolicht\MarkdownCms\Markdown\MarkdownDocumentParser; |
18
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
19
|
|
|
use Psr\Http\Message\ResponseInterface; |
20
|
|
|
use Prophecy\Argument; |
21
|
|
|
use Zend\Diactoros\Response\HtmlResponse; |
22
|
|
|
|
23
|
|
|
class BlogOverviewActionTest extends ServiceManagerAwareTestCase |
24
|
|
|
{ |
25
|
|
|
private $action, $templateRenderer, $contentCreator, $markdownDocumentParser, $markdownCmsConfig; |
|
|
|
|
26
|
|
|
|
27
|
|
|
public function setUp() |
28
|
|
|
{ |
29
|
|
|
$this->setConfigProviders([ModuleConfig::class]); |
30
|
|
|
parent::setUp(); |
31
|
|
|
|
32
|
|
|
$this->templateRenderer = $this->createMock(TemplateRendererInterface::class); |
33
|
|
|
$this->contentCreator = $this->createMock(ContentCreator::class); |
34
|
|
|
$this->markdownDocumentParser = $this->createMock(MarkdownDocumentParser::class); |
35
|
|
|
$this->markdownCmsConfig = [ |
36
|
|
|
'options' => [ |
37
|
|
|
|
38
|
|
|
], |
39
|
|
|
'content' => [ |
40
|
|
|
'content_types' => [ |
41
|
|
|
'blogEntry' => [ |
42
|
|
|
'all' => [ |
43
|
|
|
|
44
|
|
|
] |
45
|
|
|
] |
46
|
|
|
] |
47
|
|
|
] |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
$this->action = new BlogOverviewAction($this->templateRenderer, $this->contentCreator, |
51
|
|
|
$this->markdownDocumentParser, $this->markdownCmsConfig); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testGetTemplateRenderer() |
55
|
|
|
{ |
56
|
|
|
$this->assertSame($this->templateRenderer, $this->action->getTemplateRenderer()); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function testGetContentCreator() |
60
|
|
|
{ |
61
|
|
|
$this->assertSame($this->contentCreator, $this->action->getContentCreator()); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testGetMarkdownDocumentParser() |
65
|
|
|
{ |
66
|
|
|
$this->assertSame($this->markdownDocumentParser, $this->action->getMarkdownDocumentParser()); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function testGetMardownCmsConfig() |
70
|
|
|
{ |
71
|
|
|
$this->assertSame($this->markdownCmsConfig, $this->action->getMarkdownCmsConfig()); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function testInvoke() |
75
|
|
|
{ |
76
|
|
|
$templateRenderer = $this->prophesize(TemplateRendererInterface::class); |
77
|
|
|
$action = new BlogOverviewAction($templateRenderer->reveal(), $this->contentCreator, |
78
|
|
|
$this->markdownDocumentParser, $this->markdownCmsConfig); |
79
|
|
|
$request = $this->prophesize(ServerRequestInterface::class); |
80
|
|
|
|
81
|
|
|
$templateRenderer |
82
|
|
|
->render('app::blog-overwiew.twig', Argument::type('array')) |
83
|
|
|
->willReturn(''); |
84
|
|
|
|
85
|
|
|
$response = $action( |
86
|
|
|
$request->reveal(), |
87
|
|
|
$this->prophesize(ResponseInterface::class)->reveal() |
88
|
|
|
); |
89
|
|
|
$this->assertInstanceOf(HtmlResponse::class, $response); |
90
|
|
|
} |
91
|
|
|
} |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.