| @@ 45-56 (lines=12) @@ | ||
| 42 | /** |
|
| 43 | * @test |
|
| 44 | */ |
|
| 45 | public function canDecodeValidJson() |
|
| 46 | { |
|
| 47 | $content = '{ "foo": "bar" }'; |
|
| 48 | $request = TestRequestFactory::create($content); |
|
| 49 | $request->headers->set('Content-Type', 'application/json'); |
|
| 50 | ||
| 51 | $operationObject = OperationObject::createFromOperationDefinition((object)[]); |
|
| 52 | ||
| 53 | $actual = $this->contentDecoder->decodeContent($request, $operationObject); |
|
| 54 | $expected = ['foo' => 'bar']; |
|
| 55 | $this->assertSame($expected, $actual); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * @test |
|
| @@ 101-113 (lines=13) @@ | ||
| 98 | /** |
|
| 99 | * @test |
|
| 100 | */ |
|
| 101 | public function willPassWithoutParameters() |
|
| 102 | { |
|
| 103 | $coercer = new RequestCoercer($this->contentDecoderMock); |
|
| 104 | $content = '[1,2,3]'; |
|
| 105 | $request = TestRequestFactory::create($content); |
|
| 106 | ||
| 107 | $operationDefinition = (object)[]; |
|
| 108 | ||
| 109 | $operationObject = OperationObject::createFromOperationDefinition((object)$operationDefinition); |
|
| 110 | $coercer->coerceRequest($request, $operationObject); |
|
| 111 | ||
| 112 | $this->assertSame([1, 2, 3], $request->attributes->get('myContent')); |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||