Passed
Push — main ( 3b40c1...b711d3 )
by Peter
07:24
created

MigrationsBootstrapperTest::testRegisterBindings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 16
rs 9.9666
1
<?php
2
3
namespace AbterPhp\Framework\Bootstrappers\Databases;
4
5
use AbterPhp\Framework\Module\Manager;
6
use Opulence\Databases\IConnection;
7
use Opulence\Databases\Migrations\IMigrator;
8
use Opulence\Framework\Databases\Console\Commands\FixMigrationsCommand;
9
use Opulence\Ioc\Container;
10
use PHPUnit\Framework\TestCase;
11
12
class MigrationsBootstrapperTest extends TestCase
13
{
14
    protected MigrationsBootstrapper $sut;
15
16
    protected Manager $moduleManagerMock;
17
18
    public function setUp(): void
19
    {
20
        global $abterModuleManager;
21
22
        $this->sut = new MigrationsBootstrapper();
23
24
        $this->moduleManagerMock = $this->getMockBuilder(Manager::class)->disableOriginalConstructor()->getMock();
25
26
        $abterModuleManager = $this->moduleManagerMock;
27
    }
28
29
    public function tearDown(): void
30
    {
31
        global $abterModuleManager;
32
33
        $abterModuleManager = null;
34
    }
35
36
    public function testRegisterBindings()
37
    {
38
        $connectionMock = $this->getMockBuilder(IConnection::class)->getMock();
39
40
        $this->moduleManagerMock->expects($this->any())->method('getMigrationPaths')->willReturn([]);
0 ignored issues
show
Bug introduced by
The method expects() does not exist on AbterPhp\Framework\Module\Manager. ( Ignorable by Annotation )

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

40
        $this->moduleManagerMock->/** @scrutinizer ignore-call */ 
41
                                  expects($this->any())->method('getMigrationPaths')->willReturn([]);

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...
41
42
        $container = new Container();
43
        $container->bindInstance(IConnection::class, $connectionMock);
44
45
        $this->sut->registerBindings($container);
46
47
        $actual = $container->resolve(IMigrator::class);
48
        $this->assertInstanceOf(IMigrator::class, $actual);
49
50
        $actual = $container->resolve(FixMigrationsCommand::class);
51
        $this->assertInstanceOf(FixMigrationsCommand::class, $actual);
52
    }
53
}
54