Skip to content

feat: add response header and body assertion steps#111

Merged
vitormattos merged 4 commits intomainfrom
feat/response-header-body-assertions
Apr 11, 2026
Merged

feat: add response header and body assertion steps#111
vitormattos merged 4 commits intomainfrom
feat/response-header-body-assertions

Conversation

@vitormattos
Copy link
Copy Markdown
Member

What

Adds three composable step definitions to NextcloudApiContext:

Then the response header "Content-Type" should contain "application/json"
And the response body should not be empty
And the response body should match the regular expression "^%PDF"

Why

These were implemented in the consumer app (libresign) as local FeatureContext steps. 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 definitions
  • features/bootstrap/FeatureContext.php — new helper step to set mock response headers for test isolation
  • features/test.feature — three scenarios covering the new steps

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>
@vitormattos vitormattos merged commit 617ffaa into main Apr 11, 2026
10 checks passed
@vitormattos vitormattos deleted the feat/response-header-body-assertions branch April 11, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant