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
|
|
|
|