Completed
Push — master ( 55fdf1...0c48af )
by Johannes
02:35
created

SingleBlogEntryActionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 50
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 16 1
B testInvoke() 0 27 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 PHPUnit\Framework\TestCase;
13
use Jolicht\MarkdownCms\Action\SingleBlogEntryAction;
14
use Zend\Expressive\Template\TemplateRendererInterface;
15
use Psr\Http\Message\ServerRequestInterface;
16
use Psr\Http\Message\ResponseInterface;
17
use Jolicht\MarkdownCms\ContentType\ContentTypeInterface;
18
use Zend\Diactoros\Response\HtmlResponse;
19
use Jolicht\MarkdownCms\ContentType\EntryParser;
20
21
class SingleBlogEntryActionTest extends TestCase
22
{
23
    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...
24
25
    protected function setUp()
26
    {
27
        $this->templateRenderer = $this->prophesize(TemplateRendererInterface::class);
28
        $this->entryParser = $this->prophesize(EntryParser::class);
29
        $this->markdownCmsConfig = [
30
            'options' => [
31
                'content_dir' => 'testContentDir'
32
            ],
33
        ];
34
35
        $this->action = new SingleBlogEntryAction(
36
            $this->templateRenderer->reveal(),
37
            $this->entryParser->reveal(),
38
            $this->markdownCmsConfig
39
        );
40
    }
41
42
43
    public function testInvoke()
44
    {
45
        $request = $this->prophesize(ServerRequestInterface::class);
46
        $request
47
            ->getAttribute('id')
48
            ->willReturn('testId');
49
50
        $entry = $this->prophesize(ContentTypeInterface::class);
51
        $entry
52
            ->getTemplate()
53
            ->willReturn('app::template.twig');
54
55
        $this->entryParser
56
            ->__invoke('testId')
57
            ->willReturn($entry->reveal());
58
59
        $this->templateRenderer
60
            ->render('app::template.twig', ['entry' => $entry->reveal()])
61
            ->willReturn('');
62
63
        $response = ($this->action)(
64
            $request->reveal(),
65
            $this->prophesize(ResponseInterface::class)->reveal()
66
        );
67
68
        $this->assertInstanceOf(HtmlResponse::class, $response);
69
    }
70
}