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; |
11
|
|
|
|
12
|
|
|
use Reddogs\Test\ServiceManagerAwareTestCase; |
13
|
|
|
use Jolicht\MarkdownCms\ModuleConfig; |
14
|
|
|
use Jolicht\MarkdownCms\Parser\ParseContentExecutor; |
15
|
|
|
use Jolicht\MarkdownCms\Parser\ParseContentExecutorFactory; |
16
|
|
|
use Jolicht\MarkdownCms\Parser\ContentParser; |
17
|
|
|
use Jolicht\MarkdownCms\Parser\Observer\SaveContentConfigObserver; |
18
|
|
|
|
19
|
|
|
class ParseContentExecutorFactoryTest extends ServiceManagerAwareTestCase |
20
|
|
|
{ |
21
|
|
|
private $factory; |
22
|
|
|
|
23
|
|
|
protected function setUp() |
24
|
|
|
{ |
25
|
|
|
$this->setConfigProviders([ModuleConfig::class]); |
26
|
|
|
parent::setUp(); |
27
|
|
|
|
28
|
|
|
$this->factory = new ParseContentExecutorFactory(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function testContainerHasService() |
32
|
|
|
{ |
33
|
|
|
$this->assertTrue($this->getContainer()->has(ParseContentExecutor::class)); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function testCreateService() |
37
|
|
|
{ |
38
|
|
|
$container = $this->getContainer(); |
39
|
|
|
$contentParser = $this->getMockBuilder(ContentParser::class)->disableOriginalConstructor()->getMock(); |
40
|
|
|
$container->setAllowOverride(true); |
41
|
|
|
$container->setService(ContentParser::class, $contentParser); |
42
|
|
|
$container->setAllowOverride(false); |
43
|
|
|
|
44
|
|
|
$executor = $this->factory->__invoke($container, ParseContentExecutor::class); |
45
|
|
|
$this->assertInstanceOf(ParseContentExecutor::class, $executor); |
46
|
|
|
$this->assertSame($contentParser, $executor->getContentParser()); |
47
|
|
|
$observers = $executor->getObservers(); |
48
|
|
|
$this->assertInstanceOf(SaveContentConfigObserver::class, $observers[0]); |
49
|
|
|
} |
50
|
|
|
} |