PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/wheels/tests/model/miscellaneous/properties.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 79 lines | 62 code | 17 blank | 0 comment | 0 complexity | 8f9da32fe98b032b497dd9a5065554e2 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="test_key">
 4		<cfset loc.author = model("author").findOne()>
 5		<cfset loc.result = loc.author.key()>
 6		<cfset assert("loc.result IS loc.author.id")>
 7	</cffunction>
 8
 9	<cffunction name="test_key_with_new">
10		<cfset loc.author = model("author").new(id=1, firstName="Per", lastName="Djurner")>
11		<cfset loc.result = loc.author.key()>
12		<cfset assert("loc.result IS 1")>
13	</cffunction>
14
15	<cffunction name="test_setting_and_getting_properties">
16
17		<cfset loc.user = model("user").new()>
18
19		<cfset loc.args = {}>
20		<cfset loc.args.Address = "1313 mockingbird lane">
21		<cfset loc.args.City = "deerfield beach">
22		<cfset loc.args.Fax = "9545551212">
23		<cfset loc.args.FirstName = "anthony">
24		<cfset loc.args.LastName = "Petruzzi">
25		<cfset loc.args.Password = "it's a secret">
26		<cfset loc.args.Phone = "9544826106">
27		<cfset loc.args.State = "fl">
28		<cfset loc.args.UserName = "tonypetruzzi">
29		<cfset loc.args.ZipCode = "33441">
30		<cfset loc.args.Id = "">
31		<cfset loc.args.birthday = "11/01/1975">
32		<cfset loc.args.birthdaymonth = "11">
33		<cfset loc.args.birthdayyear = "1975">
34
35		<cfset loc.user.setProperties(loc.args)>
36
37		<cfset loc.properties = loc.user.properties()>
38
39		<cfloop collection="#loc.properties#" item="loc.i">
40			<cfset assert("loc.properties[loc.i] eq loc.args[loc.i]")>
41		</cfloop>
42
43		<cfset loc.args.FirstName = "per">
44		<cfset loc.args.LastName = "djurner">
45
46		<cfset loc.user.setproperties(firstname="per", lastname="djurner")>
47		<cfset loc.properties = loc.user.properties()>
48
49		<cfloop collection="#loc.properties#" item="loc.i">
50			<cfset assert("loc.properties[loc.i] eq loc.args[loc.i]")>
51		</cfloop>
52
53		<cfset loc.args.FirstName = "chris">
54		<cfset loc.args.LastName = "peters">
55		<cfset loc.args.ZipCode = "33333">
56
57		<cfset loc.params = {}>
58		<cfset loc.params.lastname = "peters">
59		<cfset loc.params.zipcode = "33333">
60
61		<cfset loc.user.setproperties(firstname="chris", properties=loc.params)>
62		<cfset loc.properties = loc.user.properties()>
63
64		<cfloop collection="#loc.properties#" item="loc.i">
65			<cfset assert("loc.properties[loc.i] eq loc.args[loc.i]")>
66		</cfloop>
67	</cffunction>
68
69	<cffunction name="test_setting_and_getting_properties_with_named_arguments">
70		<cfset loc.author = model("author").findOne()>
71		<cfset loc.author.setProperties(firstName="a", lastName="b")>
72		<cfset loc.result = loc.author.properties()>
73		<cfset loc.compareWith.id = loc.author.key()>
74		<cfset loc.compareWith.firstName = "a">
75		<cfset loc.compareWith.lastName = "b">
76		<cfset assert("loc.result.toString() IS loc.compareWith.toString()")>
77	</cffunction>
78
79</cfcomponent>