@@ -32,7 +32,7 @@ class SerializeListenerTest extends TestCase
32
32
public function testDoNotSerializeResponse ()
33
33
{
34
34
$ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
35
- $ serializerProphecy ->serialize ()->shouldNotBeCalled ();
35
+ $ serializerProphecy ->serialize (Argument:: cetera () )->shouldNotBeCalled ();
36
36
37
37
$ request = new Request ();
38
38
$ request ->setRequestFormat ('xml ' );
@@ -42,61 +42,25 @@ public function testDoNotSerializeResponse()
42
42
$ eventProphecy ->getRequest ()->willReturn ($ request )->shouldBeCalled ();
43
43
44
44
$ serializerContextBuilderProphecy = $ this ->prophesize (SerializerContextBuilderInterface::class);
45
- $ serializerContextBuilderProphecy ->createFromRequest ()->shouldNotBeCalled ();
45
+ $ serializerContextBuilderProphecy ->createFromRequest (Argument:: cetera () )->shouldNotBeCalled ();
46
46
47
47
$ listener = new SerializeListener ($ serializerProphecy ->reveal (), $ serializerContextBuilderProphecy ->reveal ());
48
48
$ listener ->onKernelView ($ eventProphecy ->reveal ());
49
49
}
50
50
51
- public function testDoNotSerializeWhenFormatNotSet ()
51
+ public function testDoNotSerializeWhenRespondFlagIsFalse ()
52
52
{
53
53
$ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
54
- $ serializerProphecy ->serialize ()->shouldNotBeCalled ();
55
-
56
- $ eventProphecy = $ this ->prophesize (GetResponseForControllerResultEvent::class);
57
- $ eventProphecy ->getControllerResult ()->willReturn (new \stdClass ())->shouldBeCalled ();
58
- $ eventProphecy ->getRequest ()->willReturn (new Request ())->shouldBeCalled ();
59
-
60
- $ serializerContextBuilderProphecy = $ this ->prophesize (SerializerContextBuilderInterface::class);
61
- $ serializerContextBuilderProphecy ->createFromRequest ()->shouldNotBeCalled ();
62
-
63
- $ listener = new SerializeListener ($ serializerProphecy ->reveal (), $ serializerContextBuilderProphecy ->reveal ());
64
- $ listener ->onKernelView ($ eventProphecy ->reveal ());
65
- }
66
-
67
- public function testDoNotSerializeWhenResourceClassNotSet ()
68
- {
69
- $ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
70
- $ serializerProphecy ->serialize ()->shouldNotBeCalled ();
71
-
72
- $ request = new Request ([], [], ['_api_collection_operation_name ' => 'get ' ]);
73
- $ request ->setRequestFormat ('xml ' );
74
-
75
- $ eventProphecy = $ this ->prophesize (GetResponseForControllerResultEvent::class);
76
- $ eventProphecy ->getControllerResult ()->willReturn (new \stdClass ())->shouldBeCalled ();
77
- $ eventProphecy ->getRequest ()->willReturn ($ request )->shouldBeCalled ();
54
+ $ serializerProphecy ->serialize (Argument::cetera ())->shouldNotBeCalled ();
78
55
79
56
$ serializerContextBuilderProphecy = $ this ->prophesize (SerializerContextBuilderInterface::class);
80
- $ serializerContextBuilderProphecy ->createFromRequest ()->shouldNotBeCalled ();
81
57
82
- $ listener = new SerializeListener ($ serializerProphecy ->reveal (), $ serializerContextBuilderProphecy ->reveal ());
83
- $ listener ->onKernelView ($ eventProphecy ->reveal ());
84
- }
85
-
86
- public function testDoNotSerializeWhenOperationNotSet ()
87
- {
88
- $ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
89
- $ serializerProphecy ->serialize ()->shouldNotBeCalled ();
90
-
91
- $ request = new Request ([], [], ['_api_resource_class ' => 'Foo ' ]);
92
- $ request ->setRequestFormat ('xml ' );
58
+ $ request = new Request ([], [], ['_api_respond ' => false ]);
93
59
94
60
$ eventProphecy = $ this ->prophesize (GetResponseForControllerResultEvent::class);
95
- $ eventProphecy ->getControllerResult ()->willReturn (new \stdClass ())->shouldBeCalled ();
96
- $ eventProphecy ->getRequest ()->willReturn ($ request )->shouldBeCalled ();
97
-
98
- $ serializerContextBuilderProphecy = $ this ->prophesize (SerializerContextBuilderInterface::class);
99
- $ serializerContextBuilderProphecy ->createFromRequest ()->shouldNotBeCalled ();
61
+ $ eventProphecy ->getControllerResult ()->willReturn (new \stdClass ());
62
+ $ eventProphecy ->getRequest ()->willReturn ($ request );
63
+ $ eventProphecy ->setControllerResult (Argument::any ())->shouldNotBeCalled ();
100
64
101
65
$ listener = new SerializeListener ($ serializerProphecy ->reveal (), $ serializerContextBuilderProphecy ->reveal ());
102
66
$ listener ->onKernelView ($ eventProphecy ->reveal ());
@@ -198,7 +162,7 @@ public function testEncode()
198
162
$ serializerProphecy = $ this ->prophesize (SerializerInterface::class);
199
163
$ serializerProphecy ->willImplement (EncoderInterface::class);
200
164
$ serializerProphecy ->encode (Argument::any (), 'xml ' )->willReturn ('bar ' )->shouldBeCalled ();
201
- $ serializerProphecy ->serialize ()->shouldNotBeCalled ();
165
+ $ serializerProphecy ->serialize (Argument:: cetera () )->shouldNotBeCalled ();
202
166
203
167
$ request = new Request ([], [], ['_api_respond ' => true ]);
204
168
$ request ->setRequestFormat ('xml ' );
0 commit comments