Completed
Pull Request — master (#4)
by Timothy
04:00
created

testValidUpToDateCommandFromServiceLocator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
namespace Abacaphiliac\DoctrineORMDiagnosticsModuleTest\ModuleCollaboration;
20
21
use Doctrine\DBAL\Migrations\Tools\Console\Command\UpToDateCommand;
22
use Symfony\Component\Console\Application as SymfonyConsoleApplication;
23
use Zend\EventManager\SharedEventManagerInterface;
24
use Zend\Mvc\Application;
25
use Zend\ServiceManager\ServiceLocatorInterface;
26
use Zend\Test\Util\ModuleLoader;
27
28
class ModuleCollaborationTest extends \PHPUnit_Framework_TestCase
29
{
30
    /** @var Application */
31
    private $application;
32
    
33
    /** @var ServiceLocatorInterface */
34
    private $serviceLocator;
35
    
36
    /** @var SymfonyConsoleApplication */
37
    protected $cli;
38
39
    /**
40
     * @return void
41
     */
42
    protected function setUp()
43
    {
44
        $loader = new ModuleLoader([
45
            'modules' => [
46
                'DoctrineModule',
47
                'DoctrineORMModule',
48
                'ZFTool',
49
                'Abacaphiliac\DoctrineORMDiagnosticsModule',
50
            ],
51
            'module_listener_options' => [
52
                'config_static_paths' => [
53
                    __DIR__ . '/test.config.php',
54
                ],
55
                'module_paths' => [],
56
            ],
57
        ]);
58
        
59
        $this->serviceLocator = $loader->getServiceManager();
60
        \PHPUnit_Framework_Assert::assertInstanceOf(ServiceLocatorInterface::class, $this->serviceLocator);
61
        
62
        /* @var $sharedEventManager SharedEventManagerInterface */
63
        $sharedEventManager = $this->serviceLocator->get('SharedEventManager');
64
        \PHPUnit_Framework_Assert::assertInstanceOf(SharedEventManagerInterface::class, $sharedEventManager);
65
        
66
        $this->application = $loader->getApplication();
67
        \PHPUnit_Framework_Assert::assertInstanceOf(Application::class, $this->application);
68
        $this->application->bootstrap();
69
        
70
        $this->cli = $this->serviceLocator->get('doctrine.cli');
71
        \PHPUnit_Framework_Assert::assertInstanceOf(SymfonyConsoleApplication::class, $this->cli);
72
    }
73
    
74
    public function testValidUpToDateCommandFromServiceLocator()
75
    {
76
        $actual = $this->serviceLocator->get('doctrine.migrations_cmd.uptodate');
77
        
78
        self::assertInstanceOf(UpToDateCommand::class, $actual);
79
    }
80
    
81
    public function testValidUpToDateCommandFromSymfonyConsole()
82
    {
83
        $actual = $this->cli->get('migrations:up-to-date');
84
        
85
        self::assertInstanceOf(UpToDateCommand::class, $actual);
86
    }
87
}
88