1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Povs\ListerBundle; |
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
6
|
|
|
use Povs\ListerBundle\Declaration\ListInterface; |
7
|
|
|
use Povs\ListerBundle\DependencyInjection\Compiler\ListCompilerPass; |
8
|
|
|
use Povs\ListerBundle\Type\FieldType\FieldTypeInterface; |
9
|
|
|
use Povs\ListerBundle\Type\FilterType\FilterTypeInterface; |
10
|
|
|
use Povs\ListerBundle\Type\ListType\ListTypeInterface; |
11
|
|
|
use Povs\ListerBundle\Type\QueryType\QueryTypeInterface; |
12
|
|
|
use Povs\ListerBundle\Type\SelectorType\SelectorTypeInterface; |
13
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @author Povilas Margaiatis <[email protected]> |
17
|
|
|
*/ |
18
|
|
|
class PovsListerBundleTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
private $bundle; |
21
|
|
|
private $container; |
22
|
|
|
|
23
|
|
|
public function setUp() |
24
|
|
|
{ |
25
|
|
|
$this->container = new ContainerBuilder(); |
26
|
|
|
$this->bundle = new PovsListerBundle(); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testBuildTagsAdded(): void |
30
|
|
|
{ |
31
|
|
|
$tagged = [ |
32
|
|
|
'povs_lister.list' => ListInterface::class, |
33
|
|
|
'povs_lister.query_type' => QueryTypeInterface::class, |
34
|
|
|
'povs_lister.field_type' => FieldTypeInterface::class, |
35
|
|
|
'povs_lister.list_type' => ListTypeInterface::class, |
36
|
|
|
'povs_lister.filter_type' => FilterTypeInterface::class, |
37
|
|
|
'povs_lister.selector_type' => SelectorTypeInterface::class, |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
$this->bundle->build($this->container); |
41
|
|
|
$configuredInstanceOf = $this->container->getAutoconfiguredInstanceof(); |
42
|
|
|
|
43
|
|
|
foreach ($tagged as $tag => $instanceOf) { |
44
|
|
|
$this->assertArrayHasKey($instanceOf, $configuredInstanceOf); |
45
|
|
|
$this->assertArrayHasKey($tag, $configuredInstanceOf[$instanceOf]->getTags()); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testBuildListCompilerPassAdded(): void |
50
|
|
|
{ |
51
|
|
|
$this->bundle->build($this->container); |
52
|
|
|
$passes = $this->container->getCompiler()->getPassConfig()->getBeforeOptimizationPasses(); |
53
|
|
|
$hasPass = false; |
54
|
|
|
|
55
|
|
|
foreach ($passes as $pass) { |
56
|
|
|
if ($pass instanceof ListCompilerPass) { |
57
|
|
|
$hasPass = true; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$this->assertTrue($hasPass); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|