Completed
Pull Request — master (#228)
by Jonathan
02:55
created

DoctrineCommandTest::testConfigureMigrations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 49
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 34
nc 1
nop 0
dl 0
loc 49
rs 9.2258
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Bundle\MigrationsBundle\Tests\Command;
6
7
use Doctrine\Bundle\MigrationsBundle\Command\DoctrineCommand;
8
use Doctrine\Migrations\Configuration\Configuration;
9
use org\bovigo\vfs\vfsStream;
10
use PHPUnit\Framework\MockObject\MockObject;
11
use PHPUnit\Framework\TestCase;
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
14
15
class DoctrineCommandTest extends TestCase
16
{
17
    /** @var string */
18
    private $migrationsDirectory;
19
20
    protected function setUp() : void
21
    {
22
        vfsStream::setup('migrations_directory');
23
24
        $this->migrationsDirectory = vfsStream::url('migrations_directory');
25
    }
26
27
    public function testConfigureMigrations() : void
28
    {
29
        /** @var Configuration|MockObject $configurationMock */
30
        $configurationMock = $this->createMock(Configuration::class);
31
32
        $configurationMock->method('getMigrations')
0 ignored issues
show
Bug introduced by
The method method() does not exist on Doctrine\Migrations\Configuration\Configuration. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $configurationMock->/** @scrutinizer ignore-call */ 
33
                            method('getMigrations')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
            ->willReturn([]);
34
35
        $configurationMock->expects($this->once())
36
            ->method('setMigrationsDirectory')
37
            ->with($this->migrationsDirectory);
38
39
        $configurationMock->expects($this->once())
40
            ->method('setMigrationsNamespace')
41
            ->with('test');
42
43
        $configurationMock->expects($this->once())
44
            ->method('setName')
45
            ->with('test');
46
47
        $configurationMock->expects($this->once())
48
            ->method('setMigrationsTableName')
49
            ->with('test');
50
51
        $configurationMock->expects($this->once())
52
            ->method('setMigrationsColumnName')
53
            ->with('version');
54
55
        $configurationMock->expects($this->once())
56
            ->method('setMigrationsColumnLength')
57
            ->with(255);
58
59
        $configurationMock->expects($this->once())
60
            ->method('setMigrationsColumnLength')
61
            ->with(255);
62
63
        $configurationMock->expects($this->once())
64
            ->method('setMigrationsExecutedAtColumnName')
65
            ->with('executed_at');
66
67
        $configurationMock->expects($this->once())
68
            ->method('setMigrationsAreOrganizedByYear')
69
            ->with(true);
70
71
        $configurationMock->expects($this->once())
72
            ->method('setAllOrNothing')
73
            ->with(false);
74
75
        DoctrineCommand::configureMigrations($this->getContainer(), $configurationMock);
76
    }
77
78
    private function getContainer() : ContainerBuilder
79
    {
80
        return new ContainerBuilder(new ParameterBag([
81
            'doctrine_migrations.dir_name' => $this->migrationsDirectory,
82
            'doctrine_migrations.namespace' => 'test',
83
            'doctrine_migrations.name' => 'test',
84
            'doctrine_migrations.table_name' => 'test',
85
            'doctrine_migrations.column_name' => 'version',
86
            'doctrine_migrations.column_length' => 255,
87
            'doctrine_migrations.executed_at_column_name' => 'executed_at',
88
            'doctrine_migrations.organize_migrations' => Configuration::VERSIONS_ORGANIZATION_BY_YEAR,
89
            'doctrine_migrations.custom_template' => null,
90
            'doctrine_migrations.all_or_nothing' => false,
91
        ]));
92
    }
93
}
94