Re-synced controllers, configs, libraries, seeds, and docs with the latest API expectations and response helpers.
1.4 KiB
Executable File
1.4 KiB
Executable File
Uniform Show Endpoints Testing
This document describes the testing strategy and execution for ensuring all API show endpoints follow a uniform response structure.
Requirement
All show endpoints (e.g., /api/location/1, /api/patient/1, etc.) must return:
- A single Object (associative array) in the
datafield when a record is found. - Null in the
datafield when a record is not found.
Previously, some endpoints returned a sequential array with one item, which was inconsistent for frontend development.
Test Suite
The test suite is located at: tests/feature/UniformShowTest.php
What it tests:
testShowEndpointsReturnObjectWhenFound: Iterates through a list of known endpoints and verifies that if data is returned, it is an associative array (object) and not a sequential array.testShowEndpointsReturnNullWhenNotFound: Iterates through endpoints with non-existent IDs and verifies that thedatafield is strictlynull.
How to Run
Ensure your test database is configured in phpunit.xml or .env.
Run the following command from the project root:
vendor/bin/phpunit tests/feature/UniformShowTest.php
Maintenance
If you add a new resource with a show method, add its endpoint to the $endpoints array in tests/feature/UniformShowTest.php to ensure it remains compliant with the uniformity requirement.