Test Failed
Push — master ( c81326...794fe0 )
by Johannes
03:04
created

ContentParserFactoryTest::testCreateService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
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;
11
12
use Reddogs\Test\ServiceManagerAwareTestCase;
13
use Jolicht\MarkdownCms\ModuleConfig;
14
use Jolicht\MarkdownCms\Parser\ContentParserFactory;
15
use Jolicht\MarkdownCms\Parser\ContentParser;
16
use Jolicht\MarkdownCms\ContentType\ContentCreator;
17
use Jolicht\MarkdownCms\Iterator\MarkdownFileIterator;
18
use Jolicht\MarkdownCms\Markdown\MarkdownDocumentParser;
19
20
class ContentParserFactoryTest extends ServiceManagerAwareTestCase
21
{
22
    private $factory;
23
24
    protected function setUp()
25
    {
26
        $this->setConfigProviders([ModuleConfig::class]);
27
        parent::setUp();
28
        $this->factory = new ContentParserFactory();
29
    }
30
31
    public function testContainerHasService()
32
    {
33
        $this->assertTrue($this->getContainer()->has(ContentParser::class));
34
    }
35
36
    public function testCreateService()
37
    {
38
        $container = $this->getContainer();
39
40
        $markdownFileIterator = $this->getMockBuilder(MarkdownFileIterator::class)->disableOriginalConstructor()->getMock();
41
        $container->setAllowOverride(true);
42
        $container->setService(MarkdownFileIterator::class, $markdownFileIterator);
43
        $container->setAllowOverride(false);
44
45
        $config = $container->get('config');
46
47
        $parser = $this->factory->__invoke($container, ContentParser::class);
48
        $this->assertInstanceOf(ContentParser::class, $parser);
49
50
        $this->assertSame($markdownFileIterator, $parser->getMarkdownFileIterator());
51
        $this->assertSame($container->get(ContentCreator::class), $parser->getContentCreator());
52
        $this->assertSame($container->get(MarkdownDocumentParser::class), $parser->getMarkdownDocumentParser());
53
        $this->assertEquals($config['markdown_cms']['options'], $parser->getMarkdownOptions());
54
    }
55
}