PageRenderTime 35ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/wheels/tests/_plugins/mixins.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 101 lines | 90 code | 11 blank | 0 comment | 0 complexity | fbe08bddd929dae1163be1a9930d6573 MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent>
  2. <cfinclude template="testhelper.cfm">
  3. <cffunction name="_setup">
  4. <cfset global.plugins.$unloadAllPlugins()>
  5. <cfset global.plugins.$uninstallPlugin("TestAssignMixins")>
  6. <cfset global.plugins.$uninstallPlugin("TestDefaultAssignMixins")>
  7. <cfset global.plugins.$uninstallPlugin("TestGlobalMixins")>
  8. <cfset global.plugins.$installPlugin("TestAssignMixins")>
  9. <cfset global.plugins.$installPlugin("TestDefaultAssignMixins")>
  10. <cfset global.plugins.$installPlugin("TestGlobalMixins")>
  11. <cfset global.plugins.$loadAllPlugins()>
  12. <cfset global.controller = createobject("component", "wheelsMapping.Controller")>
  13. <cfset global.model = createobject("component", "wheelsMapping.Model")>
  14. <cfset global.dispatch = createobject("component", "wheelsMapping.Dispatch")>
  15. <cfset global.test = createobject("component", "wheelsMapping.Test")>
  16. <cfset loc.wheelscontroller = [application.wheels.rootcomponentPath, "controllers", "wheels"]>
  17. <cfset global.wheelscontroller = createobject("component", listchangedelims(arraytolist(loc.wheelscontroller, "."), ".", "."))>
  18. <cfset global.wheelscontroller.$pluginInjection()>
  19. </cffunction>
  20. <cffunction name="_teardown">
  21. <cfset global.plugins.$uninstallPlugin("TestAssignMixins")>
  22. <cfset global.plugins.$uninstallPlugin("TestDefaultAssignMixins")>
  23. <cfset global.plugins.$uninstallPlugin("TestGlobalMixins")>
  24. </cffunction>
  25. <cffunction name="test_controller_object_mixins">
  26. <cfset loc = {}>
  27. <cfset assert("structkeyexists(global.controller, '$GobalTestMixin')")>
  28. <cfset assert("structkeyexists(global.controller, '$DefaultMixin1')")>
  29. <cfset assert("structkeyexists(global.controller, '$DefaultMixin2')")>
  30. <cfset assert("structkeyexists(global.controller, '$MixinForControllers')")>
  31. <cfset assert("structkeyexists(global.controller, '$MixinForModelsAndContollers')")>
  32. <cfset assert("not structkeyexists(global.controller, '$MixinForModels')")>
  33. <cfset assert("not structkeyexists(global.controller, '$MixinForDispatch')")>
  34. <cfset assert("not structkeyexists(global.controller, '$MixinForTest')")>
  35. </cffunction>
  36. <cffunction name="test_model_object_mixins">
  37. <cfset loc = {}>
  38. <cfset assert("structkeyexists(global.model, '$GobalTestMixin')")>
  39. <cfset assert("structkeyexists(global.model, '$DefaultMixin1')")>
  40. <cfset assert("structkeyexists(global.model, '$DefaultMixin2')")>
  41. <cfset assert("not structkeyexists(global.model, '$MixinForControllers')")>
  42. <cfset assert("structkeyexists(global.model, '$MixinForModelsAndContollers')")>
  43. <cfset assert("structkeyexists(global.model, '$MixinForModels')")>
  44. <cfset assert("not structkeyexists(global.model, '$MixinForDispatch')")>
  45. <cfset assert("not structkeyexists(global.model, '$MixinForTest')")>
  46. </cffunction>
  47. <cffunction name="test_dispatch_object_mixins">
  48. <cfset loc = {}>
  49. <cfset assert("structkeyexists(global.dispatch, '$GobalTestMixin')")>
  50. <cfset assert("not structkeyexists(global.dispatch, '$DefaultMixin1')")>
  51. <cfset assert("not structkeyexists(global.dispatch, '$DefaultMixin2')")>
  52. <cfset assert("not structkeyexists(global.dispatch, '$MixinForControllers')")>
  53. <cfset assert("not structkeyexists(global.dispatch, '$MixinForModelsAndContollers')")>
  54. <cfset assert("not structkeyexists(global.dispatch, '$MixinForModels')")>
  55. <cfset assert("structkeyexists(global.dispatch, '$MixinForDispatch')")>
  56. <cfset assert("not structkeyexists(global.dispatch, '$MixinForTest')")>
  57. </cffunction>
  58. <cffunction name="test_test_object_mixins">
  59. <cfset loc = {}>
  60. <cfset assert("structkeyexists(global.test, '$GobalTestMixin')")>
  61. <cfset assert("not structkeyexists(global.test, '$DefaultMixin1')")>
  62. <cfset assert("not structkeyexists(global.test, '$DefaultMixin2')")>
  63. <cfset assert("not structkeyexists(global.test, '$MixinForControllers')")>
  64. <cfset assert("not structkeyexists(global.test, '$MixinForModelsAndContollers')")>
  65. <cfset assert("not structkeyexists(global.test, '$MixinForModels')")>
  66. <cfset assert("not structkeyexists(global.test, '$MixinForDispatch')")>
  67. <cfset assert("structkeyexists(global.test, '$MixinForTest')")>
  68. </cffunction>
  69. <cffunction name="test_wheels_controller_should_have_controller_mixins">
  70. <cfset loc = {}>
  71. <cfset assert("structkeyexists(global.wheelscontroller, '$GobalTestMixin')")>
  72. <cfset assert("structkeyexists(global.wheelscontroller, '$DefaultMixin1')")>
  73. <cfset assert("structkeyexists(global.wheelscontroller, '$DefaultMixin2')")>
  74. <cfset assert("structkeyexists(global.wheelscontroller, '$MixinForControllers')")>
  75. <cfset assert("structkeyexists(global.wheelscontroller, '$MixinForModelsAndContollers')")>
  76. <cfset assert("not structkeyexists(global.wheelscontroller, '$MixinForModels')")>
  77. <cfset assert("not structkeyexists(global.wheelscontroller, '$MixinForDispatch')")>
  78. <cfset assert("not structkeyexists(global.wheelscontroller, '$MixinForTest')")>
  79. </cffunction>
  80. <cffunction name="test_mixins_marked_as_app_should_be_mixed_into_wheels_controller_only">
  81. <cfset loc = {}>
  82. <cfset assert("structkeyexists(global.wheelscontroller, '$MixinForWheelsControllerOnly')")>
  83. <cfset assert("not structkeyexists(global.test, '$MixinForWheelsControllerOnly')")>
  84. <cfset assert("not structkeyexists(global.dispatch, '$MixinForWheelsControllerOnly')")>
  85. <cfset assert("not structkeyexists(global.model, '$MixinForWheelsControllerOnly')")>
  86. </cffunction>
  87. <cffunction name="test_overwritten_methods_move_to_core">
  88. <cfset assert("global.wheelscontroller.congratulations() eq true")>
  89. </cffunction>
  90. </cfcomponent>