Completed
Pull Request — master (#4)
by Timothy
08:23
created

testNotAddUpToDateCommandToInvalidSymfonyConsole()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 14
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace Abacaphiliac\DoctrineORMDiagnosticsModuleTest;
4
5
use Abacaphiliac\DoctrineORMDiagnosticsModule\Module;
6
use Symfony\Component\Console\Application;
7
use Symfony\Component\Console\Command\Command;
8
use Zend\EventManager\Event;
9
use Zend\ServiceManager\ServiceManager;
10
11
/**
12
 * @covers \Abacaphiliac\DoctrineORMDiagnosticsModule\Module
13
 */
14
class ModuleTest extends \PHPUnit_Framework_TestCase
15
{
16
    /** @var Module */
17
    private $sut;
18
19
    protected function setUp()
20
    {
21
        parent::setUp();
22
23
        $this->sut = new Module();
24
    }
25
    
26
    public function testGetConfig()
27
    {
28
        $actual = $this->sut->getConfig();
29
        
30
        self::assertInternalType('array', unserialize(serialize($actual)));
31
    }
32
    
33
    public function testGetModuleDependencies()
34
    {
35
        $actual = $this->sut->getModuleDependencies();
36
        
37
        self::assertContains('DoctrineModule', $actual);
38
        self::assertContains('DoctrineORMModule', $actual);
39
        self::assertContains('ZFTool', $actual);
40
    }
41
    
42
    public function testAddUpToDateCommandToSymfonyConsole()
43
    {
44
        $cli = new Application();
45
        self::assertFalse($cli->has($name = 'migrations:up-to-date'));
46
        
47
        $command = new Command($name);
48
        
49
        $serviceManager = new ServiceManager();
50
        $serviceManager->setService('doctrine.migrations_cmd.uptodate', $command);
51
52
        $event = new Event(__METHOD__, $cli, [
53
            'ServiceManager' => $serviceManager,
54
        ]);
55
56
        $actual = $this->sut->initializeConsole($event);
57
58
        self::assertTrue($actual);
59
        
60
        self::assertSame($command, $cli->get($name));
61
    }
62
    
63
    public function testNotAddUpToDateCommandToInvalidSymfonyConsole()
64
    {
65
        $cli = null;
66
        
67
        $serviceManager = new ServiceManager();
68
        
69
        $event = new Event(__METHOD__, $cli, [
70
            'ServiceManager' => $serviceManager,
71
        ]);
72
        
73
        $actual = $this->sut->initializeConsole($event);
74
        
75
        self::assertFalse($actual);
76
    }
77
    
78
    public function testNotAddUpToDateCommandToInvalidServiceManager()
79
    {
80
        $cli = new Application();
81
        
82
        $event = new Event(__METHOD__, $cli, [
83
            
84
        ]);
85
86
        $actual = $this->sut->initializeConsole($event);
87
88
        self::assertFalse($actual);
89
    }
90
}
91