Completed
Push — master ( 0c48af...84ef19 )
by Johannes
02:34
created

SaveContentConfigObserverTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 43
rs 10
c 1
b 0
f 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\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;
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
48
        $expected = [
49
            'markdown_cms' => [
50
                'content' => $config
51
            ]
52
        ];
53
54
        $this->observer->__invoke($config);
55
        $this->assertFileExists($targetPath);
56
        $this->assertEquals($expected, include $targetPath);
57
    }
58
}