Test Failed
Push — master ( d3e9ef...1b9271 )
by Johannes
04:34
created

ParseContentExecutorTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A testGetContentParser() 0 4 1
A testGetObservers() 0 4 1
A testAddObserver() 0 6 1
A testNotifyObservers() 0 19 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 JolichtTeset\MarkdownCms\Parser;
11
12
use PHPUnit\Framework\TestCase;
13
use Jolicht\MarkdownCms\Parser\ParseContentExecutor;
14
use Jolicht\MarkdownCms\Parser\ContentParser;
15
use Jolicht\MarkdownCms\Parser\Observer\ParsedContentObserverInterface;
16
17
class ParseContentExecutorTest extends TestCase
18
{
19
    private $executor, $contentParser;
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...
20
21
    protected function setUp()
22
    {
23
        $this->contentParser = $this->getMockBuilder(ContentParser::class)
24
            ->setMethods(['__invoke'])
25
            ->disableOriginalConstructor()
26
            ->getMock();
27
        $this->executor = new ParseContentExecutor($this->contentParser);
28
    }
29
30
    public function testGetContentParser()
31
    {
32
        $this->assertSame($this->contentParser, $this->executor->getContentParser());
33
    }
34
35
    public function testGetObservers()
36
    {
37
        $this->assertSame([], $this->executor->getObservers());
38
    }
39
40
    public function testAddObserver()
41
    {
42
        $observer = $this->getMockBuilder(ParsedContentObserverInterface::class)->getMock();
43
        $this->executor->addObserver($observer);
44
        $this->assertSame([$observer], $this->executor->getObservers());
45
    }
46
47
    public function testNotifyObservers()
48
    {
49
        $observer = $this->getMockBuilder(ParsedContentObserverInterface::class)
50
            ->setMethods(['__invoke'])
51
            ->getMock();
52
53
        $config = ['testConfig'];
54
55
        $this->contentParser->expects($this->once())
56
            ->method('__invoke')
57
            ->will($this->returnValue($config));
58
59
        $observer->expects(($this->once()))
60
            ->method('__invoke')
61
            ->with($this->equalTo($config));
62
63
        $this->executor->addObserver($observer);
64
        $this->executor->__invoke();
65
    }
66
}