PageRenderTime 42ms CodeModel.GetById 20ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="setup">
  3. <cffile action="readbinary" file="#expandpath('wheels/tests/_assets/files/cfwheels-logo.png')#" variable="loc.binaryData">
  4. </cffunction>
  5. <cffunction name="test_update">
  6. <cftransaction action="begin">
  7. <cfset loc.photo = model("photo").findOne()>
  8. <cfset loc.photo.update(filename="somefilename", fileData=loc.binaryData)>
  9. <cfset loc.photo = model("photo").findByKey(loc.photo.id)>
  10. <cfset loc._binary = loc.photo.filedata>
  11. <cftransaction action="rollback" />
  12. </cftransaction>
  13. <cfset assert('IsBinary(ToBinary(loc._binary))')>
  14. </cffunction>
  15. <cffunction name="test_insert">
  16. <cfset loc.gallery = model("gallery").findOne(
  17. include="user"
  18. ,where="users.lastname = 'Petruzzi'"
  19. ,orderby="id"
  20. )>
  21. <cftransaction action="begin">
  22. <cfset loc.photo = model("photo").create(
  23. galleryid="#loc.gallery.id#"
  24. ,filename="somefilename"
  25. ,fileData=loc.binaryData
  26. ,description1="something something"
  27. )>
  28. <cfset loc.photo = model("photo").findByKey(loc.photo.id)>
  29. <cfset loc._binary = loc.photo.filedata>
  30. <cftransaction action="rollback" />
  31. </cftransaction>
  32. <cfset assert('IsBinary(ToBinary(loc._binary))')>
  33. </cffunction>
  34. </cfcomponent>