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

SaveContentConfigObserverTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testGetConfigWriter() 0 4 1
A testGetTargetPath() 0 4 1
A testInvoke() 0 15 2
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\Parser\Observer;
11
12
use PHPUnit\Framework\TestCase;
13
use Jolicht\MarkdownCms\Parser\Observer\SaveContentConfigObserver;
14
use Zend\Config\Writer\PhpArray;
15
16
class SaveContentConfigObserverTest extends TestCase
17
{
18
    private $observer, $configWriter;
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...
19
20
    protected function setUp()
21
    {
22
        $this->configWriter = new PhpArray();
23
        $this->observer = new SaveContentConfigObserver($this->configWriter, __DIR__ . '/_files/markdown-cms.global.php');
24
    }
25
26
    public function testGetConfigWriter()
27
    {
28
        $this->assertSame($this->configWriter, $this->observer->getConfigWriter());
29
    }
30
31
    public function testGetTargetPath()
32
    {
33
        $this->assertSame(__DIR__ . '/_files/markdown-cms.global.php', $this->observer->getTargetPath());
34
    }
35
36
    public function testInvoke()
37
    {
38
        $targetPath  =$this->observer->getTargetPath();
39
        if (file_exists($targetPath)) {
40
            unlink($targetPath);
41
        }
42
        $config = [
43
            'markdown_cms' => [
44
                'testKey' => 'testEntry'
45
            ]
46
        ];
47
        $this->observer->__invoke($config);
48
        $this->assertFileExists($targetPath);
49
        $this->assertEquals($config, include $targetPath);
50
    }
51
}