1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Zenify\DoctrineMigrations\Tests\Configuration; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Migrations\AbstractMigration; |
8
|
|
|
use Doctrine\DBAL\Migrations\Configuration\Configuration; |
9
|
|
|
use Doctrine\DBAL\Migrations\Version; |
10
|
|
|
use PHPUnit\Framework\TestCase; |
11
|
|
|
use Zenify\DoctrineMigrations\Tests\Configuration\ConfigurationSource\SomeService; |
12
|
|
|
use Zenify\DoctrineMigrations\Tests\ContainerFactory; |
13
|
|
|
use Zenify\DoctrineMigrations\Tests\Migrations\Version123; |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
final class ConfigurationTest extends TestCase |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var Configuration |
21
|
|
|
*/ |
22
|
|
|
private $configuration; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
protected function setUp() |
26
|
|
|
{ |
27
|
|
|
$container = (new ContainerFactory)->create(); |
28
|
|
|
$this->configuration = $container->getByType(Configuration::class); |
29
|
|
|
|
30
|
|
|
$this->configuration->registerMigrationsFromDirectory( |
31
|
|
|
$this->configuration->getMigrationsDirectory() |
32
|
|
|
); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
public function testInject() |
37
|
|
|
{ |
38
|
|
|
$migrations = $this->configuration->getMigrationsToExecute('up', 123); |
39
|
|
|
$this->assertCount(1, $migrations); |
40
|
|
|
|
41
|
|
|
/** @var Version $version */ |
42
|
|
|
$version = $migrations[123]; |
43
|
|
|
$this->assertInstanceOf(Version::class, $version); |
44
|
|
|
|
45
|
|
|
/** @var AbstractMigration|Version123 $migration */ |
46
|
|
|
$migration = $version->getMigration(); |
47
|
|
|
$this->assertInstanceOf(AbstractMigration::class, $migration); |
48
|
|
|
|
49
|
|
|
$this->assertInstanceOf(SomeService::class, $migration->someService); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
public function testLoadMigrationsFromSubdirs() |
54
|
|
|
{ |
55
|
|
|
$migrations = $this->configuration->getMigrations(); |
56
|
|
|
$this->assertCount(2, $migrations); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.