PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="setup">
  3. <cfset loc.dispatch = createobject("component", "wheelsMapping.Dispatch")>
  4. <cfset SavedRoutes = duplicate(application.wheels.routes)>
  5. <cfset application.wheels.routes = []>
  6. </cffunction>
  7. <cffunction name="teardown">
  8. <cfset application.wheels.routes = SavedRoutes>
  9. </cffunction>
  10. <cffunction name="test_empty_route">
  11. <cfset addRoute(pattern="", controller="pages", action="index")>
  12. <cfset loc.r = loc.dispatch.$findMatchingRoute(path="", format="")>
  13. <cfset assert('loc.r.controller eq "pages"')>
  14. <cfset assert('loc.r.action eq "index"')>
  15. </cffunction>
  16. <cffunction name="test_controller_only">
  17. <cfset addRoute(pattern="pages", controller="pages", action="index")>
  18. <cfset loc.r = loc.dispatch.$findMatchingRoute(path="/pages", format="")>
  19. <cfset assert('loc.r.controller eq "pages"')>
  20. <cfset assert('loc.r.action eq "index"')>
  21. </cffunction>
  22. <cffunction name="test_controller_and_action_required">
  23. <cfset addRoute(pattern="pages/blah", controller="pages", action="index")>
  24. <cfset loc.r = raised('loc.dispatch.$findMatchingRoute(path="/pages", format="")')>
  25. <cfset assert('loc.r eq "Wheels.RouteNotFound"')>
  26. <cfset loc.r = loc.dispatch.$findMatchingRoute(path="/pages/blah", format="")>
  27. <cfset assert('loc.r.controller eq "pages"')>
  28. <cfset assert('loc.r.action eq "index"')>
  29. </cffunction>
  30. <cffunction name="test_extra_variables_passed">
  31. <cfset addRoute(pattern="pages/blah/[firstname]/[lastname]", controller="pages", action="index")>
  32. <cfset loc.r = loc.dispatch.$findMatchingRoute(path="/pages/blah/tony/petruzzi", format="")>
  33. <cfset assert('loc.r.controller eq "pages"')>
  34. <cfset assert('loc.r.action eq "index"')>
  35. <cfset assert('loc.r.variables eq "firstname,lastname"')>
  36. </cffunction>
  37. <cffunction name="test_wildcard_route">
  38. <cfset addRoute(pattern="*", controller="pages", action="index")>
  39. <cfset loc.r = loc.dispatch.$findMatchingRoute(path="/thisismyroute/therearemanylikeit/butthisoneismine", format="")>
  40. <cfset assert('loc.r.controller eq "pages"')>
  41. <cfset assert('loc.r.action eq "index"')>
  42. </cffunction>
  43. </cfcomponent>