|
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\AdminBundle\Tests; |
|
15
|
|
|
|
|
16
|
|
|
use PHPUnit\Framework\TestCase; |
|
17
|
|
|
use Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass; |
|
18
|
|
|
use Sonata\AdminBundle\DependencyInjection\Compiler\AddFilterTypeCompilerPass; |
|
19
|
|
|
use Sonata\AdminBundle\DependencyInjection\Compiler\ExtensionCompilerPass; |
|
20
|
|
|
use Sonata\AdminBundle\DependencyInjection\Compiler\GlobalVariablesCompilerPass; |
|
21
|
|
|
use Sonata\AdminBundle\DependencyInjection\Compiler\ModelManagerCompilerPass; |
|
22
|
|
|
use Sonata\AdminBundle\DependencyInjection\Compiler\ObjectAclManipulatorCompilerPass; |
|
23
|
|
|
use Sonata\AdminBundle\SonataAdminBundle; |
|
24
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
25
|
|
|
use Symfony\Component\DependencyInjection\Compiler\PassConfig; |
|
26
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @author Andrej Hudec <[email protected]> |
|
30
|
|
|
*/ |
|
31
|
|
|
class SonataAdminBundleTest extends TestCase |
|
32
|
|
|
{ |
|
33
|
|
|
public function testBuild(): void |
|
34
|
|
|
{ |
|
35
|
|
|
$containerBuilder = $this->getMockBuilder(ContainerBuilder::class) |
|
36
|
|
|
->setMethods(['addCompilerPass']) |
|
37
|
|
|
->getMock(); |
|
38
|
|
|
|
|
39
|
|
|
$containerBuilder->expects($this->exactly(6)) |
|
40
|
|
|
->method('addCompilerPass') |
|
41
|
|
|
->willReturnCallback(function (CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION): void { |
|
|
|
|
|
|
42
|
|
|
if ($pass instanceof AddDependencyCallsCompilerPass) { |
|
43
|
|
|
return; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
if ($pass instanceof AddFilterTypeCompilerPass) { |
|
47
|
|
|
return; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
if ($pass instanceof ExtensionCompilerPass) { |
|
51
|
|
|
return; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
if ($pass instanceof GlobalVariablesCompilerPass) { |
|
55
|
|
|
return; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
if ($pass instanceof ModelManagerCompilerPass) { |
|
59
|
|
|
return; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
if ($pass instanceof ObjectAclManipulatorCompilerPass) { |
|
63
|
|
|
return; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
$this->fail(sprintf( |
|
67
|
|
|
'CompilerPass is not one of the expected types. Expects "%s", "%s", "%s", "%s", "%s" or "%s", but got "%s".', |
|
68
|
|
|
AddDependencyCallsCompilerPass::class, |
|
69
|
|
|
AddFilterTypeCompilerPass::class, |
|
70
|
|
|
ExtensionCompilerPass::class, |
|
71
|
|
|
GlobalVariablesCompilerPass::class, |
|
72
|
|
|
ModelManagerCompilerPass::class, |
|
73
|
|
|
ObjectAclManipulatorCompilerPass::class, |
|
74
|
|
|
\get_class($pass) |
|
75
|
|
|
)); |
|
76
|
|
|
}); |
|
77
|
|
|
|
|
78
|
|
|
$bundle = new SonataAdminBundle(); |
|
79
|
|
|
$bundle->build($containerBuilder); |
|
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.