1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zenify\DoctrineMigrations\Tests\Configuration; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Connection; |
6
|
|
|
use Doctrine\DBAL\Migrations\AbstractMigration; |
7
|
|
|
use Doctrine\DBAL\Migrations\Configuration\Configuration; |
8
|
|
|
use Doctrine\DBAL\Migrations\Version; |
9
|
|
|
use Nette\DI\Container; |
10
|
|
|
use PHPUnit_Framework_TestCase; |
11
|
|
|
use Zenify\DoctrineMigrations\Configuration\Configuration as ZenifyConfiguration; |
12
|
|
|
use Zenify\DoctrineMigrations\Exception\Configuration\MigrationClassNotFoundException; |
13
|
|
|
use Zenify\DoctrineMigrations\Tests\Configuration\ConfigurationSource\SomeService; |
14
|
|
|
use Zenify\DoctrineMigrations\Tests\ContainerFactory; |
15
|
|
|
use Zenify\DoctrineMigrations\Tests\Migrations\Version123; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
final class ConfigurationTest extends PHPUnit_Framework_TestCase |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var Configuration |
23
|
|
|
*/ |
24
|
|
|
private $configuration; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
protected function setUp() |
28
|
|
|
{ |
29
|
|
|
$container = (new ContainerFactory)->create(); |
30
|
|
|
$this->configuration = $container->getByType(Configuration::class); |
31
|
|
|
|
32
|
|
|
$this->configuration->registerMigrationsFromDirectory( |
33
|
|
|
$this->configuration->getMigrationsDirectory() |
34
|
|
|
); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
public function testInject() |
39
|
|
|
{ |
40
|
|
|
$migrations = $this->configuration->getMigrationsToExecute('up', 123); |
41
|
|
|
$this->assertCount(1, $migrations); |
42
|
|
|
|
43
|
|
|
/** @var Version $version */ |
44
|
|
|
$version = $migrations[123]; |
45
|
|
|
$this->assertInstanceOf(Version::class, $version); |
46
|
|
|
|
47
|
|
|
/** @var AbstractMigration|Version123 $migration */ |
48
|
|
|
$migration = $version->getMigration(); |
49
|
|
|
$this->assertInstanceOf(AbstractMigration::class, $migration); |
50
|
|
|
|
51
|
|
|
$this->assertInstanceOf(SomeService::class, $migration->someService); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
public function testLoadMigrationsFromSubdirs() |
56
|
|
|
{ |
57
|
|
|
$migrations = $this->configuration->getMigrations(); |
58
|
|
|
$this->assertCount(2, $migrations); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
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.