From ccee9bd317ef8087fbddcf44598b3152ba661883 Mon Sep 17 00:00:00 2001 From: Gavin Pickin Date: Mon, 9 Dec 2024 16:51:11 -0800 Subject: [PATCH] Use a callback to handle dynamic getHttpHeader calls in testing --- system/testing/BaseTestCase.cfc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/system/testing/BaseTestCase.cfc b/system/testing/BaseTestCase.cfc index e0355211c..3e1c12deb 100755 --- a/system/testing/BaseTestCase.cfc +++ b/system/testing/BaseTestCase.cfc @@ -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 ); }