Created
October 18, 2012 08:25
-
-
Save marcins/3910445 to your computer and use it in GitHub Desktop.
Testing using a different HTTP method
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
component extends="mxunit.framework.TestCase" | |
{ | |
public void function setUp() { | |
variables.fw = new org.corfield.framework(); | |
makePublic(variables.fw, "processRouteMatch"); | |
} | |
public void function testRouteMatchMethod() | |
{ | |
debug("Testing for method #CGI.REQUEST_METHOD#"); | |
match = variables.fw.processRouteMatch("$GET/test/:id", "default.main?id=:id", "/test/5"); | |
if (CGI.REQUEST_METHOD == "GET") | |
{ | |
assertTrue(match.matched, "Expected GET to match $GET route"); | |
} | |
else | |
{ | |
assertFalse(match.matched, "Expected POST to NOT match $GET route"); | |
} | |
match = variables.fw.processRouteMatch("$POST/test/:id", "default.main?id=:id", "/test/5"); | |
if (CGI.REQUEST_METHOD == "POST") | |
{ | |
assertTrue(match.matched, "Expected POST to match $POST route"); | |
} | |
else | |
{ | |
assertFalse(match.matched, "Expected GET to NOT match $POST route"); | |
} | |
} | |
} |
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
<cfscript> | |
testSuite = createObject("component","mxunit.framework.TestSuite").TestSuite(); | |
testSuite.addAll("frameworkRouteMethodSpecificTest"); | |
results = testSuite.run(); | |
writeOutput(results.getResultsOutput('html')); | |
</cfscript> | |
<cfif CGI.REQUEST_METHOD EQ "GET"> | |
<cfhttp method="POST" url="http://#CGI.SERVER_NAME#/#CGI.SCRIPT_NAME#?debug=true"> | |
<cfhttpparam type="formfield" name="test" value="1" /> | |
</cfhttp> | |
<cfoutput>#cfhttp.fileContent#</cfoutput> | |
</cfif> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment