Passed
Push — master ( 7a7cfe...9ace4b )
by Mark
35:26
created

ConsoleTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 66
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetCommunicationFactoryShouldReturnInstanceIfSet() 0 10 1
A testGetQueryContainerShouldReturnNullIfNotSet() 0 6 1
A testGetQueryContainerShouldReturnInstanceIfSet() 0 10 1
A getCommunicationFactoryMock() 0 4 1
A getQueryContainerMock() 0 4 1
A getConsole() 0 4 1
1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerTest\Zed\Console\Business\Model;
9
10
use Codeception\Test\Unit;
11
use Spryker\Zed\Kernel\Communication\AbstractCommunicationFactory;
12
use Spryker\Zed\Kernel\Persistence\AbstractQueryContainer;
13
use SprykerTest\Zed\Console\Business\Model\Fixtures\ConsoleMock;
14
15
/**
16
 * Auto-generated group annotations
17
 * @group SprykerTest
18
 * @group Zed
19
 * @group Console
20
 * @group Business
21
 * @group Model
22
 * @group ConsoleTest
23
 * Add your own group annotations below this line
24
 */
25
class ConsoleTest extends Unit
26
{
27
28
    /**
29
     * @return void
30
     */
31
    public function testGetCommunicationFactoryShouldReturnInstanceIfSet()
32
    {
33
        $console = $this->getConsole();
34
        $console->setFactory($this->getCommunicationFactoryMock());
35
36
        $this->assertInstanceOf(
37
            'Spryker\Zed\Kernel\Communication\AbstractCommunicationFactory',
38
            $console->getFactory()
39
        );
40
    }
41
42
    /**
43
     * @return void
44
     */
45
    public function testGetQueryContainerShouldReturnNullIfNotSet()
46
    {
47
        $console = $this->getConsole();
48
49
        $this->assertNull($console->getQueryContainer());
50
    }
51
52
    /**
53
     * @return void
54
     */
55
    public function testGetQueryContainerShouldReturnInstanceIfSet()
56
    {
57
        $console = $this->getConsole();
58
        $console->setQueryContainer($this->getQueryContainerMock());
59
60
        $this->assertInstanceOf(
61
            AbstractQueryContainer::class,
62
            $console->getQueryContainer()
63
        );
64
    }
65
66
    /**
67
     * @return \Spryker\Zed\Kernel\Communication\AbstractCommunicationFactory
68
     */
69
    private function getCommunicationFactoryMock()
70
    {
71
        return $this->getMockBuilder(AbstractCommunicationFactory::class)->disableOriginalConstructor()->getMock();
72
    }
73
74
    /**
75
     * @return \Spryker\Zed\Kernel\Persistence\AbstractQueryContainer
76
     */
77
    private function getQueryContainerMock()
78
    {
79
        return $this->getMockBuilder(AbstractQueryContainer::class)->disableOriginalConstructor()->getMock();
80
    }
81
82
    /**
83
     * @return \Unit\Spryker\Zed\Console\Business\Model\Fixtures\ConsoleMock
84
     */
85
    private function getConsole()
86
    {
87
        return new ConsoleMock('TestCommand');
88
    }
89
90
}
91