| @@ 71-98 (lines=28) @@ | ||
| 68 | /** |
|
| 69 | * @test |
|
| 70 | */ |
|
| 71 | public function canDeserializeIntoObject() |
|
| 72 | { |
|
| 73 | $content = [ |
|
| 74 | 'foo' => 'bar' |
|
| 75 | ]; |
|
| 76 | $request = TestRequestFactory::create(json_encode($content), [], 'faux'); |
|
| 77 | $request->headers->set('Content-Type', 'application/json'); |
|
| 78 | ||
| 79 | $operationDefinition = (object)[ |
|
| 80 | 'parameters' => [ |
|
| 81 | (object)[ |
|
| 82 | "in" => "body", |
|
| 83 | "name" => "body", |
|
| 84 | "schema" => (object)[ |
|
| 85 | '$ref' => "#/definitions/JmsAnnotatedResourceStub" |
|
| 86 | ] |
|
| 87 | ] |
|
| 88 | ] |
|
| 89 | ]; |
|
| 90 | ||
| 91 | $operationObject = Operation::createFromOperationDefinition((object)$operationDefinition); |
|
| 92 | ||
| 93 | $actual = $this->contentDecoder->decodeContent($request, $operationObject); |
|
| 94 | ||
| 95 | $expected = (new JmsAnnotatedResourceStub)->setFoo('bar'); |
|
| 96 | ||
| 97 | $this->assertEquals($expected, $actual); |
|
| 98 | } |
|
| 99 | ||
| 100 | /** |
|
| 101 | * @test |
|
| @@ 121-144 (lines=24) @@ | ||
| 118 | * |
|
| 119 | * @param string $contentType |
|
| 120 | */ |
|
| 121 | public function willAlwaysDecodeJson($contentType) |
|
| 122 | { |
|
| 123 | $content = '{ "foo": "bar" }'; |
|
| 124 | $request = TestRequestFactory::create($content, [], 'faux'); |
|
| 125 | $request->headers->set('Content-Type', $contentType); |
|
| 126 | ||
| 127 | $operationDefinition = (object)[ |
|
| 128 | 'parameters' => [ |
|
| 129 | (object)[ |
|
| 130 | "in" => "body", |
|
| 131 | "name" => "body", |
|
| 132 | "schema" => (object)[ |
|
| 133 | '$ref' => "#/definitions/JmsAnnotatedResourceStub" |
|
| 134 | ] |
|
| 135 | ] |
|
| 136 | ] |
|
| 137 | ]; |
|
| 138 | ||
| 139 | $operationObject = Operation::createFromOperationDefinition((object)$operationDefinition); |
|
| 140 | ||
| 141 | $actual = $this->contentDecoder->decodeContent($request, $operationObject); |
|
| 142 | $expected = (new JmsAnnotatedResourceStub)->setFoo('bar'); |
|
| 143 | $this->assertEquals($expected, $actual); |
|
| 144 | } |
|
| 145 | ||
| 146 | /** |
|
| 147 | * @return array |
|