Completed
Push — master ( 280ca2...4c75e7 )
by Johannes
02:18
created

SitemapObserverFactoryTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 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 Reddogs\Test\ServiceManagerAwareTestCase;
13
use Jolicht\MarkdownCms\ModuleConfig;
14
use Jolicht\MarkdownCms\Parser\Observer\SitemapObserver;
15
use Jolicht\MarkdownCms\Parser\Observer\SitemapObserverFactory;
16
use Sabre\Xml\Writer as XmlWriter;
17
18
class SitemapObserverFactoryTest extends ServiceManagerAwareTestCase
19
{
20
    private $factory;
21
22
    protected function setUp()
23
    {
24
        $this->setConfigProviders([ModuleConfig::class]);
25
        parent::setUp();
26
27
        $this->factory = new SitemapObserverFactory();
28
    }
29
30
    public function testContainerHasService()
31
    {
32
        $this->assertTrue($this->getContainer()->has(SitemapObserver::class));
33
    }
34
35
    public function testCreateService()
36
    {
37
        $container = $this->getContainer();
38
        $config = $container->get('config');
39
        $config['markdown_cms']['options']['base_url'] = 'http://test.at';
40
        $config['markdown_cms']['options']['sitemap_path'] = 'testPath';
41
42
        $container->setAllowOverride(true);
43
        $container->setService('config', $config);
44
        $container->setAllowOverride(false);
45
46
        $observer = $this->factory->__invoke($this->getContainer(), SitemapObserver::class);
47
        $this->assertInstanceOf(SitemapObserver::class, $observer);
48
        $this->assertInstanceOf(XmlWriter::class, $observer->getXmlWriter());
49
        $this->assertSame('http://test.at', $observer->getBaseUrl());
50
        $this->assertSame('testPath', $observer->getSitemapPath());
51
    }
52
}