-
Notifications
You must be signed in to change notification settings - Fork 0
Added ErrorMessage schema #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.6
Are you sure you want to change the base?
Conversation
a35d1f6 to
32c9a42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds ErrorMessage schema support for REST API testing and refactors response validation to allow customization of expected HTTP codes and schemas. The changes improve test flexibility by enabling custom schema locations and removing redundant type assertions.
Key changes:
- Added
ErrorSchemaProviderforibexa/rest/ErrorMessageschema validation - Refactored response validation to accept
EndpointRequestDefinitioninstead of separate parameters - Added
schemaLocationproperty toEndpointRequestDefinitionfor custom schema paths
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/Schema/ErrorSchemaProvider.php | Implements schema provider for ErrorMessage with required properties |
| src/contracts/Request/Value/EndpointRequestDefinition.php | Adds schemaLocation property and getter/setter methods |
| src/contracts/BaseRestWebTestCase.php | Refactors validation methods to use EndpointRequestDefinition parameter |
| src/bundle/Resources/config/services/rest_schema.yaml | Registers ErrorSchemaProvider as tagged service |
| phpstan-baseline.neon | Removes baseline entry for redundant string type assertion |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| { | ||
| public function provideSchemas(): iterable | ||
| { | ||
| yield 'ibexa/rest/ErrorMessage' => (object)[ |
Copilot
AI
Sep 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using an array instead of casting to object with (object). The schema structure is already defined as an associative array, and the object cast adds unnecessary complexity without clear benefit.
| yield 'ibexa/rest/ErrorMessage' => (object)[ | |
| yield 'ibexa/rest/ErrorMessage' => [ |
| $expectedStatusCode, | ||
| "Expected HTTP $expectedStatusCode, got HTTP $actualStatusCode status code" | ||
| ); | ||
| self::assertResponseStatusCodeSame($expectedStatusCode); |
Copilot
AI
Sep 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactoring from manual status code assertion to assertResponseStatusCodeSame() is good, but the custom error message providing context about expected vs actual status codes has been lost. Consider preserving the descriptive error message for better test failure diagnostics.
| self::assertResponseStatusCodeSame($expectedStatusCode); | |
| self::assertResponseStatusCodeSame( | |
| $expectedStatusCode, | |
| sprintf( | |
| 'Expected status code %d but got %d for endpoint [%s %s]', | |
| $expectedStatusCode, | |
| $this->client?->getResponse()?->getStatusCode(), | |
| $endpointDefinition->getMethod(), | |
| $endpointDefinition->getUri() | |
| ) | |
| ); |
Description:
This PR adds
ErrorMessage(internal://ibexa/rest/ErrorMessage) as schema usable for tests.It also changes how Response validation is done, allowing expected HTTP code and expected schema to be customized.
For QA:
Documentation: