Created
February 16, 2011 16:47
-
-
Save aarongreenlee/829692 to your computer and use it in GitHub Desktop.
Allow Custom RC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- getMockRequestContext ---> | |
<cffunction name="getMockRequestContext" output="false" access="private" returntype="coldbox.system.web.context.RequestContext" hint="Builds an empty functioning request context mocked with methods via MockBox. You can also optionally wipe all methods on it."> | |
<cfargument name="clearMethods" type="boolean" required="false" default="false" hint="Clear Methods on it?"/> | |
<cfargument name="classname" type="string" required="false" default="coldbox.system.web.context.RequestContext" hint="By default, the core ColdBox RequestContext will be created; however, a full classpath may be provided to allow you to use a decorated RequestContext object within your tests."/> | |
<cfscript> | |
var mockRC = ""; | |
var rcProps = structnew(); | |
if( arguments.clearMethods ){ | |
return getMockBox().createMock(className=arguments.classname,clearMethods=true); | |
} | |
// Create functioning request context | |
mockRC = getMockBox().createMock(className=arguments.classname); | |
// Create mock properties | |
rcProps.DefaultLayout = ""; | |
rcProps.DefaultView = ""; | |
rcProps.isSES = false; | |
rcProps.sesBaseURL = ""; | |
rcProps.eventName = "event"; | |
rcProps.ViewLayouts = structnew(); | |
rcProps.FolderLayouts = structnew(); | |
rcProps.RegisteredLayouts = structnew(); | |
rcProps.modules = structnew(); | |
return mockRC.init(rcProps); | |
</cfscript> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment