Completed
Push — master ( 1daec9...23ac06 )
by Johannes
03:41
created

SingleBlogEntryActionFactoryTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testContainerHasService() 0 4 1
B testCreateService() 0 25 1
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\Action;
11
12
use Reddogs\Test\ServiceManagerAwareTestCase;
13
use Jolicht\MarkdownCms\Action\SingleBlogEntryActionFactory;
14
use Jolicht\MarkdownCms\Action\SingleBlogEntryAction;
15
use Jolicht\MarkdownCms\ModuleConfig;
16
use Zend\Expressive\Template\TemplateRendererInterface;
17
use Jolicht\MarkdownCms\ContentType\ContentCreator;
18
use Jolicht\MarkdownCms\Markdown\MarkdownDocumentParser;
19
20
class SingleBlogEntryActionFactoryTest extends ServiceManagerAwareTestCase
21
{
22
    private $factory;
23
24
    protected function setUp()
25
    {
26
        $this->setConfigProviders([ModuleConfig::class]);
27
        parent::setUp();
28
        $this->factory = new SingleBlogEntryActionFactory();
29
    }
30
31
    public function testContainerHasService()
32
    {
33
        $this->assertTrue($this->getContainer()->has(SingleBlogEntryAction::class));
34
    }
35
36
    public function testCreateService()
37
    {
38
        $container = $this->getContainer();
39
40
        $renderer = $this->createMock(TemplateRendererInterface::class);
41
        $contentCreator = $this->createMock(ContentCreator::class);
42
        $parser = $this->createMock(MarkdownDocumentParser::class);
43
        $config = [
44
            'markdown_cms' => ['testconfig']
45
        ];
46
47
        $container->setAllowOverride(true);
48
        $container->setService(TemplateRendererInterface::class, $renderer);
49
        $container->setService(ContentCreator::class, $contentCreator);
50
        $container->setService(MarkdownDocumentParser::class, $parser);
51
        $container->setService('config', $config);
52
        $container->setAllowOverride(false);
53
54
        $action = $this->factory->__invoke($container, SingleBlogEntryAction::class);
55
        $this->assertInstanceOf(SingleBlogEntryAction::class, $action);
56
        $this->assertSame($renderer, $action->getTemplateRenderer());
57
        $this->assertSame($contentCreator, $action->getContentCreator());
58
        $this->assertSame($parser, $action->getMarkdownDocumentParser());
59
        $this->assertSame(['testconfig'], $action->getMarkdownCmsConfig());
60
    }
61
}