/wheels/tests/model/properties/accessibleproperties.cfc
ColdFusion CFScript | 37 lines | 33 code | 4 blank | 0 comment | 0 complexity | cba559664a4d47e45279f5999e21e40b MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
1<cfcomponent extends="wheelsMapping.Test"> 2 3 <cffunction name="test_all_properties_can_be_set_by_default"> 4 <cfset loc.model = model("author") /> 5 <cfset loc.model = duplicate(loc.model)> 6 <cfset loc.properties = { firstName = "James", lastName = "Gibson" } /> 7 <cfset loc.model = loc.model.new(properties=loc.properties) /> 8 <cfset assert('StructKeyExists(loc.model, "firstName") eq true') /> 9 <cfset assert('StructKeyExists(loc.model, "lastName") eq true') /> 10 </cffunction> 11 12 <cffunction name="test_all_other_properties_cannot_be_set_except_accessible_properties"> 13 <cfset loc.model = model("post") /> 14 <cfset loc.model = duplicate(loc.model)> 15 <cfset loc.model.accessibleProperties(properties="views") /> 16 <cfset loc.properties = { views = "2000", averageRating = 4.9, body = "This is the body", title = "this is the title" } /> 17 <cfset loc.model = loc.model.new(properties=loc.properties) /> 18 <cfset assert('StructKeyExists(loc.model, "averageRating") eq false') /> 19 <cfset assert('StructKeyExists(loc.model, "body") eq false') /> 20 <cfset assert('StructKeyExists(loc.model, "title") eq false') /> 21 <cfset assert('StructKeyExists(loc.model, "views") eq true') /> 22 </cffunction> 23 24 <cffunction name="test_all_other_properties_can_be_set_directly"> 25 <cfset loc.model = model("post") /> 26 <cfset loc.model = duplicate(loc.model)> 27 <cfset loc.model.accessibleProperties(propertyName="views") /> 28 <cfset loc.model = loc.model.new() /> 29 <cfset loc.model.averageRating = 4.9 /> 30 <cfset loc.model.body = "This is the body" /> 31 <cfset loc.model.title = "this is the title" /> 32 <cfset assert('StructKeyExists(loc.model, "averageRating") eq true') /> 33 <cfset assert('StructKeyExists(loc.model, "body") eq true') /> 34 <cfset assert('StructKeyExists(loc.model, "title") eq true') /> 35 </cffunction> 36 37</cfcomponent>