Completed
Pull Request — master (#28)
by Jáchym
05:05 queued 03:02
created

ConfigurationTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

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
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);
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...
52
	}
53
54
55
	public function testLoadMigrationsFromSubdirs()
56
	{
57
		$migrations = $this->configuration->getMigrations();
58
		$this->assertCount(2, $migrations);
59
	}
60
61
}
62