| Total Complexity | 5 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 10 | class JsonResponseTest extends TestCase |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Setup the test environment. |
||
| 14 | * |
||
| 15 | * @return void |
||
| 16 | */ |
||
| 17 | public function setUp(): void |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @test |
||
| 24 | */ |
||
| 25 | public function it_builds_default_json() |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @test |
||
| 38 | */ |
||
| 39 | public function it_returns_with_response_structure() |
||
| 40 | { |
||
| 41 | $responseStructure = (array) JsonResponse::json()->getData(); |
||
| 42 | $builderStructure = JsonResponse::structure(); |
||
| 43 | |||
| 44 | $this->assertEquals(array_keys($responseStructure), array_keys($builderStructure)); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @test |
||
| 49 | */ |
||
| 50 | public function it_returns_with_error_structure() |
||
| 51 | { |
||
| 52 | // Enable debugging mode. |
||
| 53 | Config::set('json-response.debug', true); |
||
| 54 | |||
| 55 | // Disable internal code builder. |
||
| 56 | Config::set('json-response.attributes.code.builder', null); |
||
| 57 | |||
| 58 | $responseStructure = (array) JsonResponse::error(new Exception('Some throwable object.'))->getData(); |
||
| 59 | |||
| 60 | $builderStructure = JsonResponse::structure(true); |
||
| 61 | |||
| 62 | $this->assertEquals(array_keys($responseStructure), array_keys($builderStructure)); |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @test |
||
| 67 | */ |
||
| 68 | public function it_returns_with_certain_headers() |
||
| 75 | } |
||
| 76 | } |
||
| 77 |