| @@ 118-165 (lines=48) @@ | ||
| 115 | * |
|
| 116 | * @return void |
|
| 117 | */ |
|
| 118 | public function testPostWithoutFieldInOptionalHash() |
|
| 119 | { |
|
| 120 | $data = [ |
|
| 121 | 'name' => __METHOD__, |
|
| 122 | 'optionalHash' => [ |
|
| 123 | 'name' => 'abc', |
|
| 124 | ], |
|
| 125 | 'requiredHash' => [ |
|
| 126 | 'name' => 'abc', |
|
| 127 | 'value' => 123, |
|
| 128 | 'optional' => '2015-09-03T12:00:00+0000', |
|
| 129 | ||
| 130 | 'optionalSubHash' => [ |
|
| 131 | 'name' => 'abc', |
|
| 132 | ], |
|
| 133 | 'requiredSubHash' => [ |
|
| 134 | 'name' => 'abc', |
|
| 135 | 'value' => 123, |
|
| 136 | 'optional' => '2015-09-03T12:00:00+0000', |
|
| 137 | ], |
|
| 138 | ], |
|
| 139 | ]; |
|
| 140 | ||
| 141 | $client = static::createRestClient(); |
|
| 142 | $client->post('/testcase/requiredhash/', $data); |
|
| 143 | $this->assertEquals(Response::HTTP_BAD_REQUEST, $client->getResponse()->getStatusCode()); |
|
| 144 | $this->assertEquals( |
|
| 145 | [ |
|
| 146 | (object) [ |
|
| 147 | 'propertyPath' => 'data.optionalHash.value', |
|
| 148 | 'message' => 'This value should not be blank.', |
|
| 149 | ], |
|
| 150 | (object) [ |
|
| 151 | 'propertyPath' => 'data.optionalHash.requiredSubHash.name', |
|
| 152 | 'message' => 'This value should not be blank.', |
|
| 153 | ], |
|
| 154 | (object) [ |
|
| 155 | 'propertyPath' => 'data.optionalHash.requiredSubHash.value', |
|
| 156 | 'message' => 'This value should not be blank.', |
|
| 157 | ], |
|
| 158 | (object) [ |
|
| 159 | 'propertyPath' => 'data.requiredHash.optionalSubHash.value', |
|
| 160 | 'message' => 'This value should not be blank.', |
|
| 161 | ], |
|
| 162 | ], |
|
| 163 | $client->getResults() |
|
| 164 | ); |
|
| 165 | } |
|
| 166 | ||
| 167 | /** |
|
| 168 | * Test POST method without required hash |
|
| @@ 115-161 (lines=47) @@ | ||
| 112 | * |
|
| 113 | * @return void |
|
| 114 | */ |
|
| 115 | public function testEmptyAllFields() |
|
| 116 | { |
|
| 117 | $document = [ |
|
| 118 | 'anotherInt' => 6555488894525, |
|
| 119 | 'testField' => ['en' => 'a test string'], |
|
| 120 | 'aBoolean' => '', |
|
| 121 | 'contactCode' => [ |
|
| 122 | 'text' => ['en' => 'Some Text'], |
|
| 123 | 'someDate' => '1984-05-01T00:00:00+0000', |
|
| 124 | ], |
|
| 125 | 'contact' => [ |
|
| 126 | 'type' => '', |
|
| 127 | 'value' => '', |
|
| 128 | 'protocol' => '', |
|
| 129 | ], |
|
| 130 | ]; |
|
| 131 | ||
| 132 | $client = static::createRestClient(); |
|
| 133 | $client->post('/hans/showcase', $document); |
|
| 134 | ||
| 135 | $this->assertEquals( |
|
| 136 | Response::HTTP_BAD_REQUEST, |
|
| 137 | $client->getResponse()->getStatusCode() |
|
| 138 | ); |
|
| 139 | ||
| 140 | $this->assertEquals( |
|
| 141 | [ |
|
| 142 | (object) [ |
|
| 143 | 'propertyPath' => 'data.aBoolean', |
|
| 144 | 'message' => 'The value "" is not a valid boolean.', |
|
| 145 | ], |
|
| 146 | (object) [ |
|
| 147 | 'propertyPath' => 'data.contact.type', |
|
| 148 | 'message' => 'This value should not be blank.', |
|
| 149 | ], |
|
| 150 | (object) [ |
|
| 151 | 'propertyPath' => 'data.contact.protocol', |
|
| 152 | 'message' => 'This value should not be blank.', |
|
| 153 | ], |
|
| 154 | (object) [ |
|
| 155 | 'propertyPath' => 'data.contact.value', |
|
| 156 | 'message' => 'This value should not be blank.', |
|
| 157 | ], |
|
| 158 | ], |
|
| 159 | $client->getResults() |
|
| 160 | ); |
|
| 161 | } |
|
| 162 | ||
| 163 | /** |
|
| 164 | * see how our empty fields are explained to us |
|