@@ -34,33 +34,13 @@ public function testConstruct(): void
34
34
$ this ->assertInstanceOf (CompilerPassInterface::class, new MetadataAwareNameConverterPass ());
35
35
}
36
36
37
- public function testProcessFirstArgumentConfigured (): void
38
- {
39
- $ pass = new MetadataAwareNameConverterPass ();
40
-
41
- $ definition = $ this ->prophesize (Definition::class);
42
- $ definition ->getArguments ()->willReturn ([0 , 1 ])->shouldBeCalled ();
43
- $ definition ->getArgument (1 )->willReturn (new Reference ('app.name_converter ' ))->shouldBeCalled ();
44
-
45
- $ containerBuilderProphecy = $ this ->prophesize (ContainerBuilder::class);
46
- $ containerBuilderProphecy ->hasAlias ('api_platform.name_converter ' )->shouldBeCalled ()->willReturn (true );
47
- $ containerBuilderProphecy ->getAlias ('api_platform.name_converter ' )->shouldBeCalled ()->willReturn (new Alias ('api_platform.name_converter ' ));
48
- $ containerBuilderProphecy ->hasDefinition ('serializer.name_converter.metadata_aware ' )->willReturn (true )->shouldBeCalled ();
49
- $ containerBuilderProphecy ->getDefinition ('serializer.name_converter.metadata_aware ' )->willReturn ($ definition )->shouldBeCalled ();
50
- $ containerBuilderProphecy ->setAlias ('api_platform.name_converter ' , 'serializer.name_converter.metadata_aware ' )->shouldBeCalled ();
51
-
52
- $ pass ->process ($ containerBuilderProphecy ->reveal ());
53
- }
54
-
55
37
public function testProcessWithNameConverter (): void
56
38
{
57
39
$ pass = new MetadataAwareNameConverterPass ();
58
40
59
41
$ reference = new Reference ('app.name_converter ' );
60
42
61
43
$ definition = $ this ->prophesize (Definition::class);
62
- $ definition ->getArguments ()->willReturn ([0 , 1 ])->shouldBeCalled ();
63
- $ definition ->getArgument (1 )->willReturn (null )->shouldBeCalled ();
64
44
$ definition ->setArgument (1 , $ reference )->shouldBeCalled ()->willReturn ($ definition );
65
45
66
46
$ containerBuilderProphecy = $ this ->prophesize (ContainerBuilder::class);
@@ -69,54 +49,30 @@ public function testProcessWithNameConverter(): void
69
49
$ containerBuilderProphecy ->hasDefinition ('serializer.name_converter.metadata_aware ' )->shouldBeCalled ()->willReturn (true );
70
50
$ containerBuilderProphecy ->getDefinition ('serializer.name_converter.metadata_aware ' )->shouldBeCalled ()->willReturn ($ definition );
71
51
$ containerBuilderProphecy ->setAlias ('api_platform.name_converter ' , 'serializer.name_converter.metadata_aware ' )->shouldBeCalled ();
52
+ $ containerBuilderProphecy ->setParameter ('.serializer.name_converter ' , 'app.name_converter ' )->shouldBeCalled ();
72
53
73
54
$ pass ->process ($ containerBuilderProphecy ->reveal ());
74
55
}
75
56
76
- public function testProcessWithoutMetadataAwareDefinition (): void
57
+ public function testProcessWithoutNameConverter (): void
77
58
{
78
59
$ pass = new MetadataAwareNameConverterPass ();
79
60
80
61
$ containerBuilderProphecy = $ this ->prophesize (ContainerBuilder::class);
81
- $ containerBuilderProphecy ->hasDefinition ('serializer.name_converter.metadata_aware ' )->willReturn (false )->shouldBeCalled ();
82
- $ containerBuilderProphecy ->setAlias ('api_platform.name_converter ' , 'serializer.name_converter.metadata_aware ' )->shouldNotBeCalled ();
83
-
84
- $ pass ->process ($ containerBuilderProphecy ->reveal ());
85
- }
86
-
87
- public function testProcessOnlyOneArg (): void
88
- {
89
- $ pass = new MetadataAwareNameConverterPass ();
90
-
91
- $ definition = $ this ->prophesize (Definition::class);
92
- $ definition ->getArguments ()->willReturn ([0 ])->shouldBeCalled ();
93
- $ definition ->addArgument (new Reference ('app.name_converter ' ))->willReturn ($ definition )->shouldBeCalled ();
94
-
95
- $ containerBuilderProphecy = $ this ->prophesize (ContainerBuilder::class);
96
- $ containerBuilderProphecy ->hasDefinition ('serializer.name_converter.metadata_aware ' )->willReturn (true )->shouldBeCalled ();
97
- $ containerBuilderProphecy ->hasAlias ('api_platform.name_converter ' )->shouldBeCalled ()->willReturn (true );
98
- $ containerBuilderProphecy ->getAlias ('api_platform.name_converter ' )->shouldBeCalled ()->willReturn (new Alias ('app.name_converter ' ));
62
+ $ containerBuilderProphecy ->hasAlias ('api_platform.name_converter ' )->willReturn (false )->shouldBeCalled ();
63
+ $ containerBuilderProphecy ->hasDefinition ('serializer.name_converter.metadata_aware ' )->shouldBeCalled ()->willReturn (true );
99
64
$ containerBuilderProphecy ->setAlias ('api_platform.name_converter ' , 'serializer.name_converter.metadata_aware ' )->shouldBeCalled ();
100
- $ containerBuilderProphecy ->getDefinition ('serializer.name_converter.metadata_aware ' )->shouldBeCalled ()->willReturn ($ definition );
101
65
102
66
$ pass ->process ($ containerBuilderProphecy ->reveal ());
103
67
}
104
68
105
- public function testProcessWithAbstractMetadataAware (): void
69
+ public function testProcessWithoutMetadataAwareDefinition (): void
106
70
{
107
71
$ pass = new MetadataAwareNameConverterPass ();
108
72
109
- $ definition = $ this ->prophesize (Definition::class);
110
- $ definition ->getArguments ()->willReturn (['$metadataFactory ' => [], '$fallbackNameConverter ' => null ])->shouldBeCalled ();
111
- $ definition ->getArgument ('$fallbackNameConverter ' )->willReturn (null )->shouldBeCalled ();
112
- $ definition ->setArgument ('$fallbackNameConverter ' , new Reference ('app.name_converter ' ))->willReturn ($ definition )->shouldBeCalled ();
113
-
114
73
$ containerBuilderProphecy = $ this ->prophesize (ContainerBuilder::class);
115
- $ containerBuilderProphecy ->hasDefinition ('serializer.name_converter.metadata_aware ' )->willReturn (true )->shouldBeCalled ();
116
- $ containerBuilderProphecy ->hasAlias ('api_platform.name_converter ' )->shouldBeCalled ()->willReturn (true );
117
- $ containerBuilderProphecy ->getAlias ('api_platform.name_converter ' )->shouldBeCalled ()->willReturn (new Alias ('app.name_converter ' ));
118
- $ containerBuilderProphecy ->setAlias ('api_platform.name_converter ' , 'serializer.name_converter.metadata_aware ' )->shouldBeCalled ();
119
- $ containerBuilderProphecy ->getDefinition ('serializer.name_converter.metadata_aware ' )->shouldBeCalled ()->willReturn ($ definition );
74
+ $ containerBuilderProphecy ->hasDefinition ('serializer.name_converter.metadata_aware ' )->willReturn (false )->shouldBeCalled ();
75
+ $ containerBuilderProphecy ->setAlias ('api_platform.name_converter ' , 'serializer.name_converter.metadata_aware ' )->shouldNotBeCalled ();
120
76
121
77
$ pass ->process ($ containerBuilderProphecy ->reveal ());
122
78
}
0 commit comments