Title: RE: Using getPlugin() in cfcUnit creates error with coldbox controller (coldspring)
Thread: Using getPlugin() in cfcUnit creates error with coldbox controller (coldspring)
Forum: Need Help?
Conference: ColdBox
User: prentice Hi Luis,
I played around with it, but could not get it to work. So instead,
I've attached a sample app to show you what I mean.
For the sample app, I
generated a new app using the ant build in the coldbox dist called TestApp.
Then I added a TestModel.cfc in the /model/ directory as a test. I created a
method as a test, then a getter/setter for coldspring to pass in references to
the coldbox controller.
After this, I created the coldspring.xml.cfm to
have three declarations needed to pass in the coldbox controller to my
TestModel.cfc:
[code]
<beans>
<bean id="TestModel"
class="TestApp.model.TestModel" singleton="false">
<property
name="ColdBoxController">
<ref bean="ColdBoxController" />
</property>
</bean>
<bean id="ColdBoxFactory"
class="coldbox.system.extras.ColdboxFactory" />
<!-- coldbox controller -->
<bean id="ColdBoxController" factory-bean="ColdBoxFactory"
factory-method="getColdBox" />
</beans>
[code]
I then modified the
general.dspHome event to get TestModel from the ioc plugin to make sure
everything's working properly:
[code]
<cffunction name="dspHome"
access="public" returntype="void" output="false">
<cfargument name="Event"
type="coldbox.system.beans.requestContext">
<!--- Do Your Logic Here to
prepare a view --->
<cfset Event.setValue("welcomeMessage","Welcome to
ColdBox!")>
<cfset Event.setValue("testModel",
getPlugin("ioc").getBean("TestModel")) />
<!--- Set the View To Display,
after Logic --->
<cfset Event.setView("home")>
</cffunction>
[/code]
When all this is done, I ran the unit test in the unittests/ directory (which is
the same as what coldbox generates for me, except I moved it out of /handlers/),
and that's when I get the same error as before.
I am very confused as to what
causes this error. If I remove all references to the coldbox controller in the
coldspring config, or if I don't use it at all (as in no reference to it in the
coldspring config), I don't get any errors. The moment I do, the error popups
during the unit test.
http://forums.coldboxframework.com/index.cfm?event=ehMessages.dspMessages&threadid=8A6EC886-FF65-CEF6-65606CFA2E50F4BA