Fix: getResponseHeaders() returns empty struct after setup()#641
Merged
lmajano merged 3 commits intoColdBox:developmentfrom Mar 19, 2026
Merged
Conversation
MockRequestContext.getResponseHeaders() always returns an empty struct {} in integration tests, even after calling setHTTPHeader() with named headers. This causes test assertions on response headers to fail unexpectedly when setup() is called between tests.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in MockRequestContext where getResponseHeaders() always returns an empty struct even after setHTTPHeader() is called. The issue occurs because MockRequestContext's overridden setHTTPHeader() method only updates the mock-specific cbox_headers collection but doesn't update the variables.responseHeaders that getResponseHeaders() reads from.
Changes:
- Updated MockRequestContext.setHTTPHeader() to populate variables.responseHeaders when headers are set
- Added test coverage to verify getResponseHeaders() returns headers set via setHTTPHeader()
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| system/testing/mock/web/context/MockRequestContext.cfc | Added line to sync responseHeaders when setHTTPHeader() is called with a header name |
| tests/specs/web/context/RequestContextTest.cfc | Added test case to verify MockRequestContext populates responseHeaders correctly |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Member
|
gracias amigo |
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.
MockRequestContext.getResponseHeaders() always returns an empty struct {} in integration tests, even after calling setHTTPHeader(). This causes test assertions on response headers to fail unexpectedly when setup() is called between tests.
Note: I didn't see a specific test file for MockRequestContext, so I added my test to RequestContextTest.
Jira Issues
https://ortussolutions.atlassian.net/browse/COLDBOX-1380
Type of change
Please delete options that are not relevant.
Checklist