Skip to content

Commit

Permalink
Use a callback to handle dynamic getHttpHeader calls in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
gpickin authored Dec 10, 2024
1 parent 68f723a commit ccee9bd
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 @@ -604,14 +604,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 ccee9bd

Please sign in to comment.