Completed
Push — master ( d7e590...c64771 )
by Johannes
02:22
created

BlogOverviewActionTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 66
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 23 1
A testGetTemplateRenderer() 0 4 1
A testGetContentCreator() 0 4 1
A testGetMarkdownDocumentParser() 0 4 1
A testGetMardownCmsConfig() 0 4 1
A testInvoke() 0 17 1
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
use PHPUnit\Framework\TestCase;
23
24
class BlogOverviewActionTest extends TestCase
25
{
26
    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...
27
28
    public function setUp()
29
    {
30
        $this->templateRenderer = $this->createMock(TemplateRendererInterface::class);
31
        $this->contentCreator = $this->createMock(ContentCreator::class);
32
        $this->markdownDocumentParser = $this->createMock(MarkdownDocumentParser::class);
33
        $this->markdownCmsConfig = [
34
            'options' => [
35
36
            ],
37
            'content' => [
38
                'content_types' => [
39
                    'blogEntry' => [
40
                        'all' => [
41
42
                        ]
43
                    ]
44
                ]
45
            ]
46
        ];
47
48
        $this->action = new BlogOverviewAction($this->templateRenderer, $this->contentCreator,
49
            $this->markdownDocumentParser, $this->markdownCmsConfig);
50
    }
51
52
    public function testGetTemplateRenderer()
53
    {
54
        $this->assertSame($this->templateRenderer, $this->action->getTemplateRenderer());
55
    }
56
57
    public function testGetContentCreator()
58
    {
59
        $this->assertSame($this->contentCreator, $this->action->getContentCreator());
60
    }
61
62
    public function testGetMarkdownDocumentParser()
63
    {
64
        $this->assertSame($this->markdownDocumentParser, $this->action->getMarkdownDocumentParser());
65
    }
66
67
    public function testGetMardownCmsConfig()
68
    {
69
        $this->assertSame($this->markdownCmsConfig, $this->action->getMarkdownCmsConfig());
70
    }
71
72
    public function testInvoke()
73
    {
74
        $templateRenderer = $this->prophesize(TemplateRendererInterface::class);
75
        $action = new BlogOverviewAction($templateRenderer->reveal(), $this->contentCreator,
76
            $this->markdownDocumentParser, $this->markdownCmsConfig);
77
        $request = $this->prophesize(ServerRequestInterface::class);
78
79
        $templateRenderer
80
            ->render('app::blog-overwiew.twig', Argument::type('array'))
81
            ->willReturn('');
82
83
        $response = $action(
84
            $request->reveal(),
85
            $this->prophesize(ResponseInterface::class)->reveal()
86
        );
87
        $this->assertInstanceOf(HtmlResponse::class, $response);
88
    }
89
}