Normalize formatting/line endings across configs, controllers, models, tests, and OpenAPI specs. Update rule expression/rule engine implementation and remove obsolete RuleAction controller/model. Add unit tests for rule expression syntax and multi-action behavior, and include docs updates.
1.4 KiB
1.4 KiB
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.