@@ 79-98 (lines=20) @@ | ||
76 | /** |
|
77 | * @test |
|
78 | */ |
|
79 | public function shouldOverrideSuccessResponse() |
|
80 | { |
|
81 | $controller = new GenericExceptionResponseController($this->controllerHelper, $this->argumentBuilder, [ |
|
82 | 'inner-controller' => $this->innerController, |
|
83 | 'inner-controller-method' => "serialize", |
|
84 | 'success-response' => "Some success!", |
|
85 | 'success-response-code' => 234, |
|
86 | ]); |
|
87 | ||
88 | $this->innerController->method("serialize")->willReturn(new Response("foo", 205)); |
|
89 | ||
90 | /** @var Request $request */ |
|
91 | $request = $this->createMock(Request::class); |
|
92 | ||
93 | /** @var Response $response */ |
|
94 | $response = $controller->executeInnerControllerSafely($request); |
|
95 | ||
96 | $this->assertEquals("Some success!", $response->getContent()); |
|
97 | $this->assertEquals(234, $response->getStatusCode()); |
|
98 | } |
|
99 | ||
100 | /** |
|
101 | * @test |
|
@@ 103-121 (lines=19) @@ | ||
100 | /** |
|
101 | * @test |
|
102 | */ |
|
103 | public function shouldOverrideSuccessResponseWithDefaultResponseCode() |
|
104 | { |
|
105 | $controller = new GenericExceptionResponseController($this->controllerHelper, $this->argumentBuilder, [ |
|
106 | 'inner-controller' => $this->innerController, |
|
107 | 'inner-controller-method' => "serialize", |
|
108 | 'success-response' => "Some success!", |
|
109 | ]); |
|
110 | ||
111 | $this->innerController->method("serialize")->willReturn(new Response("foo", 205)); |
|
112 | ||
113 | /** @var Request $request */ |
|
114 | $request = $this->createMock(Request::class); |
|
115 | ||
116 | /** @var Response $response */ |
|
117 | $response = $controller->executeInnerControllerSafely($request); |
|
118 | ||
119 | $this->assertEquals("Some success!", $response->getContent()); |
|
120 | $this->assertEquals(200, $response->getStatusCode()); |
|
121 | } |
|
122 | ||
123 | /** |
|
124 | * @test |
|
@@ 57-74 (lines=18) @@ | ||
54 | /** |
|
55 | * @test |
|
56 | */ |
|
57 | public function shouldexecuteInnerControllerSafely() |
|
58 | { |
|
59 | $controller = new GenericExceptionResponseController($this->controllerHelper, $this->argumentBuilder, [ |
|
60 | 'inner-controller' => $this->innerController, |
|
61 | 'inner-controller-method' => "serialize", |
|
62 | ]); |
|
63 | ||
64 | $this->innerController->method("serialize")->willReturn(new Response("foo", 205)); |
|
65 | ||
66 | /** @var Request $request */ |
|
67 | $request = $this->createMock(Request::class); |
|
68 | ||
69 | /** @var Response $response */ |
|
70 | $response = $controller->executeInnerControllerSafely($request); |
|
71 | ||
72 | $this->assertEquals("foo", $response->getContent()); |
|
73 | $this->assertEquals(205, $response->getStatusCode()); |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * @test |