@@ 179-217 (lines=39) @@ | ||
176 | } |
|
177 | ||
178 | ||
179 | public function testMissingParameters() |
|
180 | { |
|
181 | $request = new ParameterBag(); |
|
182 | $query = new ParameterBag(); |
|
183 | $rawRequest = new ArrayCollection(); |
|
184 | ||
185 | $object = new testObject(); |
|
186 | $method = 'annotatedResponseFunction'; |
|
187 | ||
188 | $annotationsReader = ShortifyPunit::mock('Doctrine\Common\Annotations\AnnotationReader'); |
|
189 | ||
190 | $responseObj = new \StdClass(); |
|
191 | $responseObj->parameters = [['name'=>'some_parameter', 'required'=>true]]; |
|
192 | $responseObj->type = 'json'; |
|
193 | $responseObj->responseCode = 200; |
|
194 | ||
195 | $responseObj->multiResponse = [ |
|
196 | [ |
|
197 | 'resource' => '@SandboxBundle/Resources/responses/token.json', |
|
198 | 'caseParams' => ['some_parameter'=>3, 'some_parameter2'=>4] |
|
199 | ] |
|
200 | ]; |
|
201 | ||
202 | $responseObj->responseFallback = [ |
|
203 | 'responseCode' => 404, |
|
204 | ]; |
|
205 | ||
206 | ShortifyPunit::when($annotationsReader)-> |
|
207 | getMethodAnnotation(anInstanceOf('ReflectionMethod'), 'danrevah\SandboxBundle\Annotation\ApiSandboxResponse')-> |
|
208 | returns(false); |
|
209 | ||
210 | ShortifyPunit::when($annotationsReader)-> |
|
211 | getMethodAnnotation(anInstanceOf('ReflectionMethod'), 'danrevah\SandboxBundle\Annotation\ApiSandboxMultiResponse')-> |
|
212 | returns($responseObj); |
|
213 | ||
214 | $this->setExpectedException('\InvalidArgumentException'); |
|
215 | $sandboxResponseManager = $this->createManager(true, $annotationsReader); |
|
216 | $sandboxResponseManager->getResponseController($object, $method, $request, $query, $rawRequest); |
|
217 | } |
|
218 | ||
219 | public function testConfigurationResourceFallbackException() |
|
220 | { |
|
@@ 219-254 (lines=36) @@ | ||
216 | $sandboxResponseManager->getResponseController($object, $method, $request, $query, $rawRequest); |
|
217 | } |
|
218 | ||
219 | public function testConfigurationResourceFallbackException() |
|
220 | { |
|
221 | $request = new ParameterBag(['some_parameter' => 1, 'some_parameter2'=>2]); |
|
222 | $query = new ParameterBag(); |
|
223 | $rawRequest = new ArrayCollection(); |
|
224 | ||
225 | $object = new testObject(); |
|
226 | $method = 'annotatedResponseFunction'; |
|
227 | ||
228 | $annotationsReader = ShortifyPunit::mock('Doctrine\Common\Annotations\AnnotationReader'); |
|
229 | ||
230 | $responseObj = new \StdClass(); |
|
231 | $responseObj->parameters = [['name'=>'some_parameter', 'required'=>true]]; |
|
232 | $responseObj->type = 'json'; |
|
233 | $responseObj->responseCode = 200; |
|
234 | ||
235 | $responseObj->multiResponse = [ |
|
236 | [ |
|
237 | 'resource' => '@SandboxBundle/Resources/responses/token.json', |
|
238 | 'caseParams' => ['some_parameter'=>3, 'some_parameter2'=>4] |
|
239 | ] |
|
240 | ]; |
|
241 | ||
242 | ShortifyPunit::when($annotationsReader)-> |
|
243 | getMethodAnnotation(anInstanceOf('ReflectionMethod'), 'danrevah\SandboxBundle\Annotation\ApiSandboxResponse')-> |
|
244 | returns(false); |
|
245 | ||
246 | ShortifyPunit::when($annotationsReader)-> |
|
247 | getMethodAnnotation(anInstanceOf('ReflectionMethod'), 'danrevah\SandboxBundle\Annotation\ApiSandboxMultiResponse')-> |
|
248 | returns($responseObj); |
|
249 | ||
250 | $this->setExpectedException('\RuntimeException'); |
|
251 | $sandboxResponseManager = $this->createManager(true, $annotationsReader); |
|
252 | $sandboxResponseManager->getResponseController($object, $method, $request, $query, $rawRequest); |
|
253 | ||
254 | } |
|
255 | ||
256 | public function testSandboxResponseForceException() |
|
257 | { |