PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/wheels/tests/routing/$findMatchingRoute.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 51 lines | 43 code | 8 blank | 0 comment | 0 complexity | c775071a24f2e0d995831c11483f4455 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset loc.dispatch = createobject("component", "wheelsMapping.Dispatch")>
 5		<cfset SavedRoutes = duplicate(application.wheels.routes)>
 6		<cfset application.wheels.routes = []>
 7	</cffunction>
 8
 9	<cffunction name="teardown">
10		<cfset application.wheels.routes = SavedRoutes>
11	</cffunction>
12
13	<cffunction name="test_empty_route">
14		<cfset addRoute(pattern="", controller="pages", action="index")>
15		<cfset loc.r = loc.dispatch.$findMatchingRoute(path="", format="")>
16		<cfset assert('loc.r.controller eq "pages"')>
17		<cfset assert('loc.r.action eq "index"')>
18	</cffunction>
19
20	<cffunction name="test_controller_only">
21		<cfset addRoute(pattern="pages", controller="pages", action="index")>
22		<cfset loc.r = loc.dispatch.$findMatchingRoute(path="/pages", format="")>
23		<cfset assert('loc.r.controller eq "pages"')>
24		<cfset assert('loc.r.action eq "index"')>
25	</cffunction>
26
27	<cffunction name="test_controller_and_action_required">
28		<cfset addRoute(pattern="pages/blah", controller="pages", action="index")>
29 		<cfset loc.r = raised('loc.dispatch.$findMatchingRoute(path="/pages", format="")')>
30		<cfset assert('loc.r eq "Wheels.RouteNotFound"')>
31		<cfset loc.r = loc.dispatch.$findMatchingRoute(path="/pages/blah", format="")>
32		<cfset assert('loc.r.controller eq "pages"')>
33		<cfset assert('loc.r.action eq "index"')>
34	</cffunction>
35
36	<cffunction name="test_extra_variables_passed">
37		<cfset addRoute(pattern="pages/blah/[firstname]/[lastname]", controller="pages", action="index")>
38		<cfset loc.r = loc.dispatch.$findMatchingRoute(path="/pages/blah/tony/petruzzi", format="")>
39		<cfset assert('loc.r.controller eq "pages"')>
40		<cfset assert('loc.r.action eq "index"')>
41		<cfset assert('loc.r.variables eq "firstname,lastname"')>
42	</cffunction>
43	
44	<cffunction name="test_wildcard_route">
45		<cfset addRoute(pattern="*", controller="pages", action="index")>
46		<cfset loc.r = loc.dispatch.$findMatchingRoute(path="/thisismyroute/therearemanylikeit/butthisoneismine", format="")>
47		<cfset assert('loc.r.controller eq "pages"')>
48		<cfset assert('loc.r.action eq "index"')>
49	</cffunction>
50
51</cfcomponent>