PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/wheels/tests/model/miscellaneous/primaryKeys.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 38 lines | 34 code | 4 blank | 0 comment | 0 complexity | 09ad7a1f23d3e3d44f4e966cf512546c MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="test_primarykey_returns_key">
 4		<cfset loc.author = model("author")>
 5		<cfset loc.e = loc.author.$classData().keys>
 6		<cfset loc.r = "id">
 7		<cfset assert("loc.e IS loc.r")>
 8		<cfset loc.r = loc.author.primaryKey()>
 9		<cfset assert("loc.e IS loc.r")>
10		<cfset loc.r = loc.author.primaryKeys()>
11		<cfset assert("loc.e IS loc.r")>
12	</cffunction>
13
14	<cffunction name="test_setprimarykey_appends_keys">
15		<cfset loc.author = model("author")>
16		<cfset loc.author = duplicate(loc.author)>
17		<cfset loc.e = loc.author.$classData().keys>
18		<cfset loc.r = "id">
19		<cfset assert("loc.e IS loc.r")>
20		<cfset loc.author.setprimaryKeys("id2,id3")>
21		<cfset loc.e = "id,id2,id3">
22		<cfset loc.r = loc.author.primaryKeys()>
23		<cfset assert("loc.e IS loc.r")>
24	</cffunction>
25	
26	<cffunction name="test_retrieve_primary_key_by_position">
27		<cfset loc.author = model("author")>
28		<cfset loc.author = duplicate(loc.author)>
29		<cfset loc.author.setprimaryKeys("id2,id3")>
30		<cfset loc.e = loc.author.primaryKeys(1)>
31		<cfset loc.r = "id">
32		<cfset assert("loc.e IS loc.r")>
33		<cfset loc.e = loc.author.primaryKeys(2)>
34		<cfset loc.r = "id2">
35		<cfset assert("loc.e IS loc.r")>
36	</cffunction>
37
38</cfcomponent>