|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Sonata Project package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Sonata\DoctrineMongoDBAdminBundle\Tests\DependencyInjection\Compiler; |
|
15
|
|
|
|
|
16
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; |
|
17
|
|
|
use Sonata\DoctrineMongoDBAdminBundle\DependencyInjection\Compiler\AddGuesserCompilerPass; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
20
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
21
|
|
|
|
|
22
|
|
|
final class AddGuesserCompilerPassTest extends AbstractCompilerPassTestCase |
|
23
|
|
|
{ |
|
24
|
|
|
/** @dataProvider getBuilders */ |
|
25
|
|
|
public function testAddsGuessers(string $builderServiceId, string $guesserTag): void |
|
26
|
|
|
{ |
|
27
|
|
|
$builderService = new Definition(null, [[]]); |
|
28
|
|
|
$this->setDefinition($builderServiceId, $builderService); |
|
29
|
|
|
|
|
30
|
|
|
$builderGuesserService = new Definition(); |
|
31
|
|
|
$builderGuesserService->addTag($guesserTag); |
|
32
|
|
|
$this->setDefinition('builder_guesser_id', $builderGuesserService); |
|
33
|
|
|
|
|
34
|
|
|
$this->compile(); |
|
35
|
|
|
|
|
36
|
|
|
$this->assertContainerBuilderHasServiceDefinitionWithArgument( |
|
37
|
|
|
$builderServiceId, |
|
38
|
|
|
0, |
|
39
|
|
|
[ |
|
40
|
|
|
new Reference('builder_guesser_id'), |
|
41
|
|
|
] |
|
42
|
|
|
); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function getBuilders(): array |
|
46
|
|
|
{ |
|
47
|
|
|
return [ |
|
48
|
|
|
'list_builder' => [ |
|
49
|
|
|
'sonata.admin.guesser.doctrine_mongodb_list_chain', |
|
50
|
|
|
'sonata.admin.guesser.doctrine_mongodb_list', |
|
51
|
|
|
], |
|
52
|
|
|
'datagrid_builder' => [ |
|
53
|
|
|
'sonata.admin.guesser.doctrine_mongodb_datagrid_chain', |
|
54
|
|
|
'sonata.admin.guesser.doctrine_mongodb_datagrid', |
|
55
|
|
|
], 'show_builder' => [ |
|
56
|
|
|
'sonata.admin.guesser.doctrine_mongodb_show_chain', |
|
57
|
|
|
'sonata.admin.guesser.doctrine_mongodb_show', |
|
58
|
|
|
], |
|
59
|
|
|
]; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
protected function registerCompilerPass(ContainerBuilder $container): void |
|
63
|
|
|
{ |
|
64
|
|
|
$container->addCompilerPass(new AddGuesserCompilerPass()); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|