| Conditions | 1 |
| Paths | 1 |
| Total Lines | 31 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | public function testRepresentation() |
||
| 13 | { |
||
| 14 | $stream = Stream::factory('{ |
||
| 15 | "errors": { |
||
| 16 | "contact": [ |
||
| 17 | { |
||
| 18 | "error": { |
||
| 19 | "code": "E0001", |
||
| 20 | "field": "last_name", |
||
| 21 | "description": "Please provide contact\'s last name." |
||
| 22 | } |
||
| 23 | } |
||
| 24 | ] |
||
| 25 | } |
||
| 26 | }'); |
||
| 27 | $response = new Response(422, [], $stream); |
||
| 28 | |||
| 29 | $exception = new RepresentationErrorException('', new Request('POST', ''), $response); |
||
| 30 | |||
| 31 | $this->assertTrue($exception->hasErrors()); |
||
| 32 | $this->assertTrue($exception->hasErrors('last_name')); |
||
| 33 | $this->assertFalse($exception->hasErrors('non_existing')); |
||
| 34 | |||
| 35 | $this->assertCount(1, $exception->getErrors()); |
||
| 36 | $this->assertCount(1, $exception->getErrors('last_name')); |
||
| 37 | $this->assertCount(0, $exception->getErrors('non_existing')); |
||
| 38 | |||
| 39 | $this->assertEquals('E0001', $exception->getErrors()[0]->getCode()); |
||
| 40 | $this->assertEquals('last_name', $exception->getErrors()[0]->getField()); |
||
| 41 | $this->assertEquals('Please provide contact\'s last name.', $exception->getErrors()[0]->getDescription()); |
||
| 42 | } |
||
| 43 | } |
||
| 44 |