|
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\TagArchiveAction; |
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
14
|
|
|
use Zend\Expressive\Template\TemplateRendererInterface; |
|
15
|
|
|
use Jolicht\MarkdownCms\ContentType\EntryParser; |
|
16
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
17
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
18
|
|
|
use Jolicht\MarkdownCms\ContentType\ContentTypeInterface; |
|
19
|
|
|
use Prophecy\Argument; |
|
20
|
|
|
use Zend\Diactoros\Response\HtmlResponse; |
|
21
|
|
|
|
|
22
|
|
|
class TagArchiveActionTest extends TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
private $action, $templateRenderer, $entryParser, $markdownCmsConfig; |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
protected function setUp() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->templateRenderer = $this->prophesize(TemplateRendererInterface::class); |
|
29
|
|
|
$this->entryParser = $this->prophesize(EntryParser::class); |
|
30
|
|
|
$this->markdownCmsConfig = [ |
|
31
|
|
|
'options' => [ |
|
32
|
|
|
'content_dir' => 'testContentDir' |
|
33
|
|
|
], |
|
34
|
|
|
'content' => [ |
|
35
|
|
|
'content_types' => [ |
|
36
|
|
|
'blogEntry' => [ |
|
37
|
|
|
'tags' => [ |
|
38
|
|
|
'tag1' => [ |
|
39
|
|
|
'testDate1' => 'testId1', |
|
40
|
|
|
] |
|
41
|
|
|
] |
|
42
|
|
|
] |
|
43
|
|
|
] |
|
44
|
|
|
] |
|
45
|
|
|
]; |
|
46
|
|
|
|
|
47
|
|
|
$this->action = new TagArchiveAction( |
|
48
|
|
|
$this->templateRenderer->reveal(), |
|
49
|
|
|
$this->entryParser->reveal(), |
|
50
|
|
|
$this->markdownCmsConfig |
|
51
|
|
|
); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function testInvoke() |
|
55
|
|
|
{ |
|
56
|
|
|
$request = $this->prophesize(ServerRequestInterface::class); |
|
57
|
|
|
$request |
|
58
|
|
|
->getAttribute('id') |
|
59
|
|
|
->willReturn('tag1'); |
|
60
|
|
|
|
|
61
|
|
|
$entry = $this->prophesize(ContentTypeInterface::class); |
|
62
|
|
|
|
|
63
|
|
|
$this->entryParser |
|
64
|
|
|
->__invoke('testId1') |
|
65
|
|
|
->willReturn($entry->reveal()); |
|
66
|
|
|
|
|
67
|
|
|
$this->templateRenderer |
|
68
|
|
|
->render('app::tag-archive.twig', Argument::type('array')) |
|
69
|
|
|
->willReturn(''); |
|
70
|
|
|
|
|
71
|
|
|
$response = ($this->action)( |
|
72
|
|
|
$request->reveal(), |
|
73
|
|
|
$this->prophesize(ResponseInterface::class)->reveal() |
|
74
|
|
|
); |
|
75
|
|
|
$this->assertInstanceOf(HtmlResponse::class, $response); |
|
76
|
|
|
} |
|
77
|
|
|
} |
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.