PageRenderTime 41ms CodeModel.GetById 20ms app.highlight 1ms RepoModel.GetById 19ms app.codeStats 0ms

/wheels/tests/model/callbacks/afterFindNonLegacy.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 34 lines | 28 code | 6 blank | 0 comment | 0 complexity | eab4ad0bed7026ed7bcbfe3c2597255b MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset model("post").$registerCallback(type="afterFind", methods="afterFindCallback")>
 5	</cffunction>
 6	
 7	<cffunction name="teardown">
 8		<cfset model("post").$clearCallbacks(type="afterFind")>
 9	</cffunction>
10
11	<cffunction name="test_setting_property_on_one_object">
12		<cfset loc.post = model("post").findOne()>
13		<cfset assert("loc.post.title IS 'setTitle'")>
14	</cffunction>
15
16	<cffunction name="test_setting_properties_on_multiple_objects">
17		<cfset loc.postsOrg = model("post").findAll(returnAs="objects", callbacks="false", orderby="views DESC")>
18		<cfset loc.views1 = loc.postsOrg[1].views + 100>
19		<cfset loc.views2 = loc.postsOrg[2].views + 100>
20		<cfset loc.posts = model("post").findAll(returnAs="objects", orderby="views DESC")>
21		<cfset assert("loc.posts[1].title IS 'setTitle'")>
22		<cfset assert("loc.posts[2].title IS 'setTitle'")>
23		<cfset assert("loc.posts[1].views EQ loc.views1")>
24		<cfset assert("loc.posts[2].views EQ loc.views2")>
25	</cffunction>
26
27	<cffunction name="test_creation_of_new_column_and_property">
28		<cfset loc.posts = model("post").findAll(order="id DESC")>
29		<cfset assert("loc.posts.something[1] eq 'hello world'")>
30		<cfset loc.posts = model("post").findAll(returnAs="objects")>
31		<cfset assert("loc.posts[1].something eq 'hello world'")>
32	</cffunction>
33
34</cfcomponent>