Completed
Push — master ( 90700d...2d56b7 )
by Amy
03:23
created

ContainerAwareMigrationServiceTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 6
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 11 1
A testContainerInjectedToAwareMigration() 0 14 1
1
<?php
2
3
namespace Mongrate\MongrateBundle\Tests\Service;
4
5
use Mongrate\Configuration;
6
use Mongrate\Model\Migration;
7
use Mongrate\Model\Name;
8
use Mongrate\MongrateBundle\Service\ContainerAwareMigrationService;
9
use Symfony\Component\Console\Output\NullOutput;
10
use Symfony\Component\DependencyInjection\Container;
11
use Symfony\Component\DependencyInjection\ContainerInterface;
12
13
class ContainerAwareMigrationServiceTest extends \PHPUnit_Framework_TestCase
14
{
15
    /**
16
     * @var ContainerAwareMigrationService
17
     */
18
    protected $service;
19
20
    public function setUp()
21
    {
22
        $config = [
23
            'migrations_directory' => 'src/Mongrate/MongrateBundle/Tests/Fixtures/',
24
            'mongodb_server' => 'localhost',
25
            'mongodb_db' => 'test'
26
        ];
27
28
        $this->service = new ContainerAwareMigrationService(new Configuration($config));
29
        $this->service->setContainer(new Container());
30
    }
31
32
    public function testContainerInjectedToAwareMigration ()
33
    {
34
        $migration = $this->service->createMigrationInstance(
35
            new Name('ContainerAwareMigration'),
36
            new NullOutput()
37
        );
38
39
        self::assertAttributeInstanceOf(
40
            ContainerInterface::class,
41
            'container',
42
            $migration,
43
            'Container wasn\'t injected to a Migration by the Service'
44
        );
45
    }
46
}
47