|
29 | 29 | use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\TestClientPass; |
30 | 30 | use ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler\TestMercureHubPass; |
31 | 31 | use PHPUnit\Framework\TestCase; |
32 | | -use Prophecy\Argument; |
33 | | -use Prophecy\PhpUnit\ProphecyTrait; |
34 | | -use Symfony\Component\DependencyInjection\Compiler\PassConfig; |
35 | 32 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
36 | 33 |
|
37 | 34 | /** |
38 | 35 | * @author Kévin Dunglas <dunglas@gmail.com> |
39 | 36 | */ |
40 | 37 | class ApiPlatformBundleTest extends TestCase |
41 | 38 | { |
42 | | - use ProphecyTrait; |
43 | | - |
44 | 39 | public function testBuild(): void |
45 | 40 | { |
46 | | - $containerProphecy = $this->prophesize(ContainerBuilder::class); |
47 | | - // TODO: remove in 5.x |
48 | | - $containerProphecy->addCompilerPass(Argument::type(DataProviderPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
49 | | - $containerProphecy->addCompilerPass(Argument::type(AttributeFilterPass::class), PassConfig::TYPE_BEFORE_OPTIMIZATION, 101)->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
50 | | - $containerProphecy->addCompilerPass(Argument::type(AttributeResourcePass::class))->shouldBeCalled()->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
51 | | - $containerProphecy->addCompilerPass(Argument::type(FilterPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
52 | | - $containerProphecy->addCompilerPass(Argument::type(ElasticsearchClientPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
53 | | - $containerProphecy->addCompilerPass(Argument::type(GraphQlTypePass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
54 | | - $containerProphecy->addCompilerPass(Argument::type(GraphQlResolverPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
55 | | - $containerProphecy->addCompilerPass(Argument::type(MetadataAwareNameConverterPass::class), PassConfig::TYPE_BEFORE_OPTIMIZATION, 100)->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
56 | | - $containerProphecy->addCompilerPass(Argument::type(TestClientPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
57 | | - $containerProphecy->addCompilerPass(Argument::type(TestMercureHubPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
58 | | - $containerProphecy->addCompilerPass(Argument::type(AuthenticatorManagerPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
59 | | - $containerProphecy->addCompilerPass(Argument::type(SerializerMappingLoaderPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
60 | | - $containerProphecy->addCompilerPass(Argument::type(MutatorPass::class))->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
61 | | - $containerProphecy->addCompilerPass(Argument::type(JsonStreamerTransformerPass::class), PassConfig::TYPE_BEFORE_OPTIMIZATION, -10)->willReturn($containerProphecy->reveal())->shouldBeCalled(); |
62 | | - |
| 41 | + $container = new ContainerBuilder(); |
63 | 42 | $bundle = new ApiPlatformBundle(); |
64 | | - $bundle->build($containerProphecy->reveal()); |
| 43 | + $bundle->build($container); |
| 44 | + |
| 45 | + $passes = $container->getCompilerPassConfig()->getBeforeOptimizationPasses(); |
| 46 | + $passClasses = array_map(static fn (object $p): string => $p::class, $passes); |
| 47 | + |
| 48 | + // TODO: remove in 5.x |
| 49 | + $this->assertContains(DataProviderPass::class, $passClasses); |
| 50 | + $this->assertContains(AttributeFilterPass::class, $passClasses); |
| 51 | + $this->assertContains(AttributeResourcePass::class, $passClasses); |
| 52 | + $this->assertContains(FilterPass::class, $passClasses); |
| 53 | + $this->assertContains(ElasticsearchClientPass::class, $passClasses); |
| 54 | + $this->assertContains(GraphQlTypePass::class, $passClasses); |
| 55 | + $this->assertContains(GraphQlResolverPass::class, $passClasses); |
| 56 | + $this->assertContains(MetadataAwareNameConverterPass::class, $passClasses); |
| 57 | + $this->assertContains(TestClientPass::class, $passClasses); |
| 58 | + $this->assertContains(TestMercureHubPass::class, $passClasses); |
| 59 | + $this->assertContains(AuthenticatorManagerPass::class, $passClasses); |
| 60 | + $this->assertContains(SerializerMappingLoaderPass::class, $passClasses); |
| 61 | + $this->assertContains(MutatorPass::class, $passClasses); |
| 62 | + $this->assertContains(JsonStreamerTransformerPass::class, $passClasses); |
65 | 63 | } |
66 | 64 | } |
0 commit comments