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

/wheels/tests/model/crud/binarydata.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 39 lines | 34 code | 5 blank | 0 comment | 0 complexity | fcaacdb7252190151fdb4976b2a35b61 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cffile action="readbinary" file="#expandpath('wheels/tests/_assets/files/cfwheels-logo.png')#" variable="loc.binaryData">
 5	</cffunction>
 6
 7 	<cffunction name="test_update">
 8		<cftransaction action="begin">
 9			<cfset loc.photo = model("photo").findOne()>
10			<cfset loc.photo.update(filename="somefilename", fileData=loc.binaryData)>
11			<cfset loc.photo = model("photo").findByKey(loc.photo.id)>
12			<cfset loc._binary = loc.photo.filedata>
13			<cftransaction action="rollback" />
14		</cftransaction>
15
16		<cfset assert('IsBinary(ToBinary(loc._binary))')>
17	</cffunction>
18
19 	<cffunction name="test_insert">
20		<cfset loc.gallery = model("gallery").findOne(
21			include="user"
22			,where="users.lastname = 'Petruzzi'"
23			,orderby="id"
24		)>
25		<cftransaction action="begin">
26			<cfset loc.photo = model("photo").create(
27				galleryid="#loc.gallery.id#"
28				,filename="somefilename"
29				,fileData=loc.binaryData
30				,description1="something something"
31			)>
32			<cfset loc.photo = model("photo").findByKey(loc.photo.id)>
33			<cfset loc._binary = loc.photo.filedata>
34			<cftransaction action="rollback" />
35		</cftransaction>
36		<cfset assert('IsBinary(ToBinary(loc._binary))')>
37	</cffunction>
38
39</cfcomponent>