Completed
Push — master ( c02fce...0001a8 )
by Johannes
03:23
created

TagArchiveActionTest::testInvoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 23
rs 9.0856
c 1
b 0
f 1
cc 1
eloc 16
nc 1
nop 0
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;
0 ignored issues
show
Coding Style introduced by
It is generally advisable to only define one property per statement.

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.

Loading history...
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
}