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
|
|
|
} |