PageRenderTime 305ms CodeModel.GetById 104ms app.highlight 0ms RepoModel.GetById 134ms app.codeStats 0ms

/wheels/tests/model/crud/create.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 31 lines | 26 code | 5 blank | 0 comment | 0 complexity | 7f73eaf37775d265a220c2bc21b40e74 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset results = {}>
 5	</cffunction>
 6
 7	<cffunction name="test_auto_incrementing_primary_key_should_be_set">
 8		<cftransaction>
 9			<cfset results.author = model("author").create(firstName="Test", lastName="Test")>
10			<cfset assert("IsObject(results.author) AND StructKeyExists(results.author, results.author.primaryKey()) AND IsNumeric(results.author[results.author.primaryKey()])")>
11			<cftransaction action="rollback" />
12		</cftransaction>
13	</cffunction>
14
15	<cffunction name="test_non_auto_incrementing_primary_key_should_not_be_changed">
16		<cftransaction>
17			<cfset results.shop = model("shop").create(ShopId=99, CityCode=99, Name="Test")>
18			<cfset assert("IsObject(results.shop) AND StructKeyExists(results.shop, results.shop.primaryKey()) AND results.shop[results.shop.primaryKey()] IS 99")>
19			<cftransaction action="rollback" />
20		</cftransaction>
21	</cffunction>
22
23	<cffunction name="test_composite_key_values_should_be_set_when_they_both_exist">
24		<cftransaction>
25			<cfset results.city = model("city").create(citycode=99, countyid="z", name="test")>
26			<cfset assert("results.city.citycode IS 99 AND results.city.countyid IS 'z'")>
27			<cftransaction action="rollback" />
28		</cftransaction>
29	</cffunction>
30
31</cfcomponent>