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 Jolicht\MarkdownCms\Action\BlogOverviewAction; |
13
|
|
|
use Zend\Expressive\Template\TemplateRendererInterface; |
14
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
15
|
|
|
use Psr\Http\Message\ResponseInterface; |
16
|
|
|
use Zend\Diactoros\Response\HtmlResponse; |
17
|
|
|
use PHPUnit\Framework\TestCase; |
18
|
|
|
use Jolicht\MarkdownCms\ContentType\EntryParser; |
19
|
|
|
use Jolicht\MarkdownCms\ContentType\ContentTypeInterface; |
20
|
|
|
|
21
|
|
|
class BlogOverviewActionTest extends TestCase |
22
|
|
|
{ |
23
|
|
|
private $action, $templateRenderer, $entryParser, $markdownCmsConfig; |
|
|
|
|
24
|
|
|
|
25
|
|
|
public function setUp() |
26
|
|
|
{ |
27
|
|
|
$this->templateRenderer = $this->prophesize(TemplateRendererInterface::class); |
28
|
|
|
$this->entryParser = $this->prophesize(EntryParser::class); |
29
|
|
|
$this->markdownCmsConfig = [ |
30
|
|
|
'content' => [ |
31
|
|
|
'content_types' => [ |
32
|
|
|
'blogEntry' => [ |
33
|
|
|
'all' => [ |
34
|
|
|
'testDate' => 'testId' |
35
|
|
|
] |
36
|
|
|
] |
37
|
|
|
] |
38
|
|
|
] |
39
|
|
|
]; |
40
|
|
|
|
41
|
|
|
$this->action = new BlogOverviewAction( |
42
|
|
|
$this->templateRenderer->reveal(), |
43
|
|
|
$this->entryParser->reveal(), |
44
|
|
|
$this->markdownCmsConfig |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
public function testInvoke() |
50
|
|
|
{ |
51
|
|
|
$entry = $this->prophesize(ContentTypeInterface::class); |
52
|
|
|
|
53
|
|
|
$this->entryParser |
54
|
|
|
->__invoke('testId') |
55
|
|
|
->willReturn($entry->reveal()); |
56
|
|
|
|
57
|
|
|
$this->templateRenderer |
58
|
|
|
->render('app::blog-overwiew.twig', ['entries' => [$entry->reveal()]]) |
59
|
|
|
->willReturn(''); |
60
|
|
|
|
61
|
|
|
$response = ($this->action)( |
62
|
|
|
$this->prophesize(ServerRequestInterface::class)->reveal(), |
63
|
|
|
$this->prophesize(ResponseInterface::class)->reveal() |
64
|
|
|
); |
65
|
|
|
$this->assertInstanceOf(HtmlResponse::class, $response); |
66
|
|
|
} |
67
|
|
|
} |
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.