Skip to content

Commit ccee9bd

Browse files
authored
Use a callback to handle dynamic getHttpHeader calls in testing
1 parent 68f723a commit ccee9bd

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

system/testing/BaseTestCase.cfc

+12-8
Original file line numberDiff line numberDiff line change
@@ -604,14 +604,18 @@ component extends="testbox.system.compat.framework.TestCase" accessors="true" {
604604
.each( function( name ){
605605
mockedEvent.setValue( arguments.name, params[ arguments.name ] );
606606
} );
607-
arguments.headers
608-
.keyArray()
609-
.each( function( name ){
610-
mockedEvent
611-
.$( "getHTTPHeader" )
612-
.$args( arguments.name )
613-
.$results( headers[ arguments.name ] );
614-
} );
607+
mockedEvent
608+
.$(
609+
method="getHTTPHeader",
610+
callback=function( name, defaultValue ){
611+
if( headers.keyExists( arguments.name ) ){
612+
return headers[ arguments.name ];
613+
}
614+
if( !isNull( arguments.defaultValue ) ){
615+
return arguments.defaultValue;
616+
}
617+
}
618+
);
615619
return this.execute( argumentCollection = arguments );
616620
}
617621

0 commit comments

Comments
 (0)