ConfigurationTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 9 1
A testInject() 0 15 1
A testLoadMigrationsFromSubdirs() 0 5 1
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);
0 ignored issues
show
Bug introduced by
The property someService does not seem to exist in Doctrine\DBAL\Migrations\AbstractMigration.

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.

Loading history...
50
	}
51
52
53
	public function testLoadMigrationsFromSubdirs()
54
	{
55
		$migrations = $this->configuration->getMigrations();
56
		$this->assertCount(2, $migrations);
57
	}
58
59
}
60