testGetContainerExtension()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Skrz\Bundle\AutowiringBundle\Tests;
3
4
use PHPUnit\Framework\TestCase;
5
use Skrz\Bundle\AutowiringBundle\DependencyInjection\Compiler\AutowiringCompilerPass;
6
use Skrz\Bundle\AutowiringBundle\DependencyInjection\Compiler\ClassMapBuildCompilerPass;
7
use Skrz\Bundle\AutowiringBundle\DependencyInjection\SkrzAutowiringExtension;
8
use Skrz\Bundle\AutowiringBundle\SkrzAutowiringBundle;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
11
class SkrzAutowiringBundleTest extends TestCase
12
{
13
14
	/** @var SkrzAutowiringBundle */
15
	private $bundle;
16
17
	protected function setUp()
18
	{
19
		$this->bundle = new SkrzAutowiringBundle();
20
	}
21
22
	public function testGetContainerExtension()
23
	{
24
		$this->assertInstanceOf(SkrzAutowiringExtension::class, $this->bundle->getContainerExtension());
25
	}
26
27
	public function testBuild()
28
	{
29
		$containerBuilder = new ContainerBuilder();
30
		$this->bundle->build($containerBuilder);
31
		$passConfig = $containerBuilder->getCompiler()->getPassConfig();
32
33
		$passes = $passConfig->getOptimizationPasses();
34
35
		$classMapBuilderFound = 0;
36
		$autowiringCompilerPassFound = 0;
37
		foreach ($passes as $pass) {
38
			if ($pass instanceof AutowiringCompilerPass) {
39
				++$autowiringCompilerPassFound;
40
			} else if ($pass instanceof ClassMapBuildCompilerPass) {
41
				++$classMapBuilderFound;
42
			}
43
		}
44
45
		$this->assertEquals(1, $classMapBuilderFound, sprintf("Compiler pass [%s] should be registered.", ClassMapBuildCompilerPass::class));
46
		$this->assertEquals(1, $autowiringCompilerPassFound, sprintf("Compiler pass [%s] should be registered.", AutowiringCompilerPass::class));
47
	}
48
49
}
50