| Total Complexity | 3 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class ResponseBuilderTest extends MockeryTestCase |
||
| 13 | { |
||
| 14 | /** @var ResponseBuilder|null */ |
||
| 15 | private ResponseBuilder $subject; |
||
| 16 | |||
| 17 | public function setUp(): void |
||
| 18 | { |
||
| 19 | $this->subject = new ResponseBuilder(); |
||
| 20 | } |
||
| 21 | |||
| 22 | public function testBuildErrorResponseReturnsData(): void |
||
| 23 | { |
||
| 24 | $message = 'some-error'; |
||
| 25 | $code = 666; |
||
| 26 | $uuidValue = 'some-uuid'; |
||
| 27 | $error = new Exception($message, $code); |
||
| 28 | |||
| 29 | $uuid = Mockery::mock(UuidInterface::class); |
||
| 30 | |||
| 31 | $uuid->shouldReceive('toString') |
||
| 32 | ->withNoArgs() |
||
| 33 | ->once() |
||
| 34 | ->andReturn($uuidValue); |
||
| 35 | |||
| 36 | $this->assertSame( |
||
| 37 | [ |
||
| 38 | 'error' => [ |
||
| 39 | 'message' => $message, |
||
| 40 | 'code' => $code, |
||
| 41 | 'id' => $uuidValue |
||
| 42 | ] |
||
| 43 | ], |
||
| 44 | $this->subject->buildErrorResponse($error, $uuid) |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function testBuildResponseReturnsResponse(): void |
||
| 49 | { |
||
| 50 | $data = ['some-data']; |
||
| 51 | |||
| 52 | $this->assertSame( |
||
| 53 | ['data' => $data], |
||
| 54 | $this->subject->buildResponse($data) |
||
| 55 | ); |
||
| 58 |