# 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: 1. **A single Object** (associative array) in the `data` field when a record is found. 2. **Null** in the `data` field 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 the `data` field is strictly `null`. ## How to Run Ensure your test database is configured in `phpunit.xml` or `.env`. Run the following command from the project root: ```bash 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.