|
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([]); |
|
|
|
|
|
|
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
|
|
|
|
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.