Skip to content

Commit

Permalink
Use a callback to handle dynamic getHttpHeader calls in testing (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpickin authored Jan 20, 2025
1 parent 17cb642 commit 47a1cd0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions system/testing/BaseTestCase.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -601,14 +601,18 @@ component extends="testbox.system.compat.framework.TestCase" accessors="true" {
.each( function( name ){
mockedEvent.setValue( arguments.name, params[ arguments.name ] );
} );
arguments.headers
.keyArray()
.each( function( name ){
mockedEvent
.$( "getHTTPHeader" )
.$args( arguments.name )
.$results( headers[ arguments.name ] );
} );
mockedEvent
.$(
method="getHTTPHeader",
callback=function( name, defaultValue ){
if( headers.keyExists( arguments.name ) ){
return headers[ arguments.name ];
}
if( !isNull( arguments.defaultValue ) ){
return arguments.defaultValue;
}
}
);
return this.execute( argumentCollection = arguments );
}

Expand Down

0 comments on commit 47a1cd0

Please sign in to comment.