PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms 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
  1<cfcomponent>
  2
  3	<cfinclude template="testhelper.cfm">
  4	
  5	<cffunction name="_setup">
  6		<cfset global.plugins.$unloadAllPlugins()>
  7		<cfset global.plugins.$uninstallPlugin("TestAssignMixins")>
  8		<cfset global.plugins.$uninstallPlugin("TestDefaultAssignMixins")>
  9		<cfset global.plugins.$uninstallPlugin("TestGlobalMixins")>
 10		<cfset global.plugins.$installPlugin("TestAssignMixins")>
 11		<cfset global.plugins.$installPlugin("TestDefaultAssignMixins")>
 12		<cfset global.plugins.$installPlugin("TestGlobalMixins")>
 13		<cfset global.plugins.$loadAllPlugins()>
 14		<cfset global.controller = createobject("component", "wheelsMapping.Controller")>
 15		<cfset global.model = createobject("component", "wheelsMapping.Model")>
 16		<cfset global.dispatch = createobject("component", "wheelsMapping.Dispatch")>
 17		<cfset global.test = createobject("component", "wheelsMapping.Test")>
 18		<cfset loc.wheelscontroller = [application.wheels.rootcomponentPath, "controllers", "wheels"]>
 19		<cfset global.wheelscontroller = createobject("component", listchangedelims(arraytolist(loc.wheelscontroller, "."), ".", "."))>
 20		<cfset global.wheelscontroller.$pluginInjection()>
 21	</cffunction>
 22	
 23	<cffunction name="_teardown">
 24		<cfset global.plugins.$uninstallPlugin("TestAssignMixins")>
 25		<cfset global.plugins.$uninstallPlugin("TestDefaultAssignMixins")>
 26		<cfset global.plugins.$uninstallPlugin("TestGlobalMixins")>
 27	</cffunction>
 28
 29	<cffunction name="test_controller_object_mixins">
 30		<cfset loc = {}>
 31		<cfset assert("structkeyexists(global.controller, '$GobalTestMixin')")>
 32		<cfset assert("structkeyexists(global.controller, '$DefaultMixin1')")>
 33		<cfset assert("structkeyexists(global.controller, '$DefaultMixin2')")>
 34		<cfset assert("structkeyexists(global.controller, '$MixinForControllers')")>
 35		<cfset assert("structkeyexists(global.controller, '$MixinForModelsAndContollers')")>
 36		<cfset assert("not structkeyexists(global.controller, '$MixinForModels')")>
 37		<cfset assert("not structkeyexists(global.controller, '$MixinForDispatch')")>
 38		<cfset assert("not structkeyexists(global.controller, '$MixinForTest')")>
 39	</cffunction>
 40
 41	<cffunction name="test_model_object_mixins">
 42		<cfset loc = {}>
 43		<cfset assert("structkeyexists(global.model, '$GobalTestMixin')")>
 44		<cfset assert("structkeyexists(global.model, '$DefaultMixin1')")>
 45		<cfset assert("structkeyexists(global.model, '$DefaultMixin2')")>
 46		<cfset assert("not structkeyexists(global.model, '$MixinForControllers')")>
 47		<cfset assert("structkeyexists(global.model, '$MixinForModelsAndContollers')")>
 48		<cfset assert("structkeyexists(global.model, '$MixinForModels')")>
 49		<cfset assert("not structkeyexists(global.model, '$MixinForDispatch')")>
 50		<cfset assert("not structkeyexists(global.model, '$MixinForTest')")>
 51	</cffunction>
 52
 53	<cffunction name="test_dispatch_object_mixins">
 54		<cfset loc = {}>
 55		<cfset assert("structkeyexists(global.dispatch, '$GobalTestMixin')")>
 56		<cfset assert("not structkeyexists(global.dispatch, '$DefaultMixin1')")>
 57		<cfset assert("not structkeyexists(global.dispatch, '$DefaultMixin2')")>
 58		<cfset assert("not structkeyexists(global.dispatch, '$MixinForControllers')")>
 59		<cfset assert("not structkeyexists(global.dispatch, '$MixinForModelsAndContollers')")>
 60		<cfset assert("not structkeyexists(global.dispatch, '$MixinForModels')")>
 61		<cfset assert("structkeyexists(global.dispatch, '$MixinForDispatch')")>
 62		<cfset assert("not structkeyexists(global.dispatch, '$MixinForTest')")>
 63	</cffunction>
 64
 65	<cffunction name="test_test_object_mixins">
 66		<cfset loc = {}>
 67		<cfset assert("structkeyexists(global.test, '$GobalTestMixin')")>
 68		<cfset assert("not structkeyexists(global.test, '$DefaultMixin1')")>
 69		<cfset assert("not structkeyexists(global.test, '$DefaultMixin2')")>
 70		<cfset assert("not structkeyexists(global.test, '$MixinForControllers')")>
 71		<cfset assert("not structkeyexists(global.test, '$MixinForModelsAndContollers')")>
 72		<cfset assert("not structkeyexists(global.test, '$MixinForModels')")>
 73		<cfset assert("not structkeyexists(global.test, '$MixinForDispatch')")>
 74		<cfset assert("structkeyexists(global.test, '$MixinForTest')")>
 75	</cffunction>
 76
 77	<cffunction name="test_wheels_controller_should_have_controller_mixins">
 78		<cfset loc = {}>
 79		<cfset assert("structkeyexists(global.wheelscontroller, '$GobalTestMixin')")>
 80		<cfset assert("structkeyexists(global.wheelscontroller, '$DefaultMixin1')")>
 81		<cfset assert("structkeyexists(global.wheelscontroller, '$DefaultMixin2')")>
 82		<cfset assert("structkeyexists(global.wheelscontroller, '$MixinForControllers')")>
 83		<cfset assert("structkeyexists(global.wheelscontroller, '$MixinForModelsAndContollers')")>
 84		<cfset assert("not structkeyexists(global.wheelscontroller, '$MixinForModels')")>
 85		<cfset assert("not structkeyexists(global.wheelscontroller, '$MixinForDispatch')")>
 86		<cfset assert("not structkeyexists(global.wheelscontroller, '$MixinForTest')")>
 87	</cffunction>
 88	
 89	<cffunction name="test_mixins_marked_as_app_should_be_mixed_into_wheels_controller_only">
 90		<cfset loc = {}>
 91		<cfset assert("structkeyexists(global.wheelscontroller, '$MixinForWheelsControllerOnly')")>
 92		<cfset assert("not structkeyexists(global.test, '$MixinForWheelsControllerOnly')")>
 93		<cfset assert("not structkeyexists(global.dispatch, '$MixinForWheelsControllerOnly')")>
 94		<cfset assert("not structkeyexists(global.model, '$MixinForWheelsControllerOnly')")>
 95	</cffunction>
 96	
 97	<cffunction name="test_overwritten_methods_move_to_core">
 98		<cfset assert("global.wheelscontroller.congratulations() eq true")>
 99	</cffunction>
100
101</cfcomponent>