PageRenderTime 404ms CodeModel.GetById 191ms app.highlight 1ms RepoModel.GetById 210ms app.codeStats 0ms

/wheels/tests/model/callbacks/afterSaveProperties.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 28 lines | 24 code | 4 blank | 0 comment | 0 complexity | ed15c1c07cb38559754c6db826165d4b MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="test_have_access_to_changed_property_values_in_aftersave">
 4		<cfset model("user").$registerCallback(type="afterSave", methods="saveHasChanged")>
 5		<cfset loc.obj = model("user").findOne(where="username = 'tonyp'")>
 6		<cfset loc.obj.saveHasChanged = saveHasChanged>
 7		<cfset loc.obj.getHasObjectChanged = getHasObjectChanged>
 8		<cfset assert('loc.obj.hasChanged() eq false')>
 9		<cfset loc.obj.password = "xxxxxxx">
10		<cfset assert('loc.obj.hasChanged() eq true')>
11		<cftransaction>
12			<cfset loc.obj.save(transaction="none")>
13			<cfset assert('loc.obj.getHasObjectChanged() eq true')>
14			<cfset assert('loc.obj.hasChanged() eq false')>
15			<cftransaction action="rollback"/>
16		</cftransaction>
17		<cfset model("user").$clearCallbacks(type="afterSave")>
18	</cffunction>
19
20	<cffunction name="saveHasChanged">
21		<cfset hasObjectChanged = hasChanged()>
22	</cffunction>
23
24	<cffunction name="getHasObjectChanged">
25		<cfreturn hasObjectChanged>
26	</cffunction>
27
28</cfcomponent>