Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions system/testing/mock/web/context/MockRequestContext.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ component
else if ( structKeyExists( arguments, "name" ) ) {
var headers = getValue( "cbox_headers", {} );
headers[ lCase( arguments.name ) ] = arguments.value;
// Keep variables.responseHeaders in sync so getResponseHeaders() works in tests
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment line uses space indentation instead of tabs. According to the project's .cfformat.json configuration, "tab_indent": true, all indentation should use tabs, not spaces. Please update the indentation to use tabs to match the project's formatting standards.

Suggested change
// Keep variables.responseHeaders in sync so getResponseHeaders() works in tests
// Keep variables.responseHeaders in sync so getResponseHeaders() works in tests

Copilot uses AI. Check for mistakes.
variables.responseHeaders[ arguments.name ] = arguments.value;
setValue( "cbox_headers", headers );
} else {
throw(
Expand Down
19 changes: 19 additions & 0 deletions tests/specs/web/context/RequestContextTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,25 @@ component extends="coldbox.system.testing.BaseModelTest" {
event.setHTTPHeader( name = "expires", value = "#now()#" );
}

function testMockRequestContextPopulatesResponseHeaders(){
// MockRequestContext.setHTTPHeader() should populate variables.responseHeaders
// so that getResponseHeaders() works correctly in integration tests
var mockEvent = getMockBox().createMock( "coldbox.system.testing.mock.web.context.MockRequestContext" );
mockEvent.init( properties = props, controller = mockController );

// Set custom headers
mockEvent.setHTTPHeader( name = "x-custom-header", value = "test-value" );
mockEvent.setHTTPHeader( name = "cached-data", value = "false" );

// getResponseHeaders() should return the headers that were set
var headers = mockEvent.getResponseHeaders();

expect( headers ).toHaveKey( "x-custom-header" );
expect( headers[ "x-custom-header" ] ).toBe( "test-value" );
expect( headers ).toHaveKey( "cached-data" );
expect( headers[ "cached-data" ] ).toBe( "false" );
}
Comment on lines +594 to +611
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test function uses space indentation instead of tabs. According to the project's .cfformat.json configuration, "tab_indent": true, all indentation should use tabs, not spaces. Please update the indentation throughout this function to use tabs to match the project's formatting standards.

Suggested change
function testMockRequestContextPopulatesResponseHeaders(){
// MockRequestContext.setHTTPHeader() should populate variables.responseHeaders
// so that getResponseHeaders() works correctly in integration tests
var mockEvent = getMockBox().createMock( "coldbox.system.testing.mock.web.context.MockRequestContext" );
mockEvent.init( properties = props, controller = mockController );
// Set custom headers
mockEvent.setHTTPHeader( name = "x-custom-header", value = "test-value" );
mockEvent.setHTTPHeader( name = "cached-data", value = "false" );
// getResponseHeaders() should return the headers that were set
var headers = mockEvent.getResponseHeaders();
expect( headers ).toHaveKey( "x-custom-header" );
expect( headers[ "x-custom-header" ] ).toBe( "test-value" );
expect( headers ).toHaveKey( "cached-data" );
expect( headers[ "cached-data" ] ).toBe( "false" );
}
function testMockRequestContextPopulatesResponseHeaders(){
// MockRequestContext.setHTTPHeader() should populate variables.responseHeaders
// so that getResponseHeaders() works correctly in integration tests
var mockEvent = getMockBox().createMock( "coldbox.system.testing.mock.web.context.MockRequestContext" );
mockEvent.init( properties = props, controller = mockController );
// Set custom headers
mockEvent.setHTTPHeader( name = "x-custom-header", value = "test-value" );
mockEvent.setHTTPHeader( name = "cached-data", value = "false" );
// getResponseHeaders() should return the headers that were set
var headers = mockEvent.getResponseHeaders();
expect( headers ).toHaveKey( "x-custom-header" );
expect( headers[ "x-custom-header" ] ).toBe( "test-value" );
expect( headers ).toHaveKey( "cached-data" );
expect( headers[ "cached-data" ] ).toBe( "false" );
}

Copilot uses AI. Check for mistakes.

function testGetHTTPContent(){
var event = getRequestContext();
test = event.getHTTPContent();
Expand Down
Loading