- Implemented dynamic VID retrieval from ValueSetModel for all test definitions - Aligned ResultType, RefType, and SpcType with the valueset table - Updated sample data for Hematology, Chemistry, and Urinalysis tests - Ensured consistency between ValueSetSeeder and TestSeeder data
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.