Completed
Pull Request — master (#602)
by Tom
07:01
created

MigrationsCommandFactoryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 43
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
8
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
9
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
10
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
11
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
12
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
13
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
14
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
16
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17
 *
18
 * This software consists of voluntary contributions made by many individuals
19
 * and is licensed under the MIT license.
20
 */
21
22
namespace DoctrineORMModuleTest\Service;
23
24
use Doctrine\Migrations\Tools\Console\Command\DiffCommand;
25
use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand;
26
use DoctrineORMModule\Service\MigrationsCommandFactory;
27
use DoctrineORMModuleTest\ServiceManagerFactory;
28
use InvalidArgumentException;
29
use Laminas\ServiceManager\ServiceManager;
30
use PHPUnit\Framework\TestCase;
31
32
/**
33
 * Tests for {@see \DoctrineORMModule\Service\MigrationsCommandFactory}
34
 *
35
 * @covers \DoctrineORMModule\Service\MigrationsCommandFactory
36
 */
37
class MigrationsCommandFactoryTest extends TestCase
38
{
39
    private ServiceManager $serviceLocator;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
40
41
    protected function setUp() : void
42
    {
43
        $this->serviceLocator = ServiceManagerFactory::getServiceManager();
44
    }
45
46
    public function testExecuteFactory() : void
47
    {
48
        $factory = new MigrationsCommandFactory('execute');
49
50
        $this->assertInstanceOf(
51
            ExecuteCommand::class,
52
            $factory->createService($this->serviceLocator)
53
        );
54
    }
55
56
    public function testDiffFactory() : void
57
    {
58
        $factory = new MigrationsCommandFactory('diff');
59
60
        $this->assertInstanceOf(
61
            DiffCommand::class,
62
            $factory->createService($this->serviceLocator)
63
        );
64
    }
65
66
    public function testThrowException() : void
67
    {
68
        $factory = new MigrationsCommandFactory('unknowncommand');
69
70
        $this->expectException(InvalidArgumentException::class);
71
        $factory->createService($this->serviceLocator);
72
    }
73
}
74