feat: add response header and body assertion steps#111
Merged
vitormattos merged 4 commits intomainfrom Apr 11, 2026
Merged
Conversation
Add three new composable step definitions to NextcloudApiContext: - 'the response header :header should contain :value' Asserts that the given response header contains the expected substring (case-insensitive). - 'the response body should not be empty' Asserts that the response body is non-empty. - 'the response body should match the regular expression :pattern' Asserts that the response body matches the given regex pattern. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add 'set the response with :header header :value to:' step to the test FeatureContext so scenarios can control the Content-Type (or any other header) of the mock server response, making header assertion scenarios deterministic. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add three scenarios to features/test.feature: - Response header assertion with explicit Content-Type - Response body is not empty - Response body matches a regular expression Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
getHeaderLine() already returns string per PSR-7; Psalm flags the (string) cast as RedundantCast. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds three composable step definitions to
NextcloudApiContext:Why
These were implemented in the consumer app (
libresign) as localFeatureContextsteps. Since they are generic enough to be useful to any Nextcloud app using this library, they belong here.Changes
src/NextcloudApiContext.php— three new step definitionsfeatures/bootstrap/FeatureContext.php— new helper step to set mock response headers for test isolationfeatures/test.feature— three scenarios covering the new steps