Completed
Push — master ( 23ac06...7a1773 )
by Johannes
02:19
created

BlogOverviewActionTest::testGetMardownCmsConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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 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;
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...
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
}