PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/wheels/tests/model/errors/errors.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 171 lines | 160 code | 11 blank | 0 comment | 0 complexity | 9996c9e215d61f3ef5aca0eab42943dd MD5 | raw file
  1<cfcomponent extends="wheelsMapping.Test">
  2
  3	<cffunction name="setup">
  4		<cfset loc.user = model("user").findOne()>
  5		<cfset loc.user.addErrorToBase(message="base error1")>
  6		<cfset loc.user.addErrorToBase(message="base name error1", name="base_errors")>
  7		<cfset loc.user.addErrorToBase(message="base name error2", name="base_errors")>
  8		<cfset loc.user.addError(property="firstname", message="firstname error1")>
  9		<cfset loc.user.addError(property="firstname", message="firstname error2")>
 10		<cfset loc.user.addError(property="firstname", message="firstname name error1", name="firstname_errors")>
 11		<cfset loc.user.addError(property="firstname", message="firstname name error2", name="firstname_errors")>
 12		<cfset loc.user.addError(property="firstname", message="firstname name error3", name="firstname_errors")>
 13		<cfset loc.user.addError(property="lastname", message="lastname error1")>
 14		<cfset loc.user.addError(property="lastname", message="lastname error2")>
 15		<cfset loc.user.addError(property="lastname", message="lastname error3")>
 16		<cfset loc.user.addError(property="lastname", message="lastname name error1", name="lastname_errors")>
 17		<cfset loc.user.addError(property="lastname", message="lastname name error2", name="lastname_errors")>
 18	</cffunction>
 19
 20	<cffunction name="test_error_information_for_lastname_property_no_name_provided">
 21		<cfset loc.r = loc.user.hasErrors(property="lastname")>
 22		<cfset assert('loc.r eq true')>
 23		<cfset loc.r = loc.user.errorCount(property="lastname")>
 24		<cfset assert('loc.r eq 3')>
 25		<cfset loc.user.clearErrors(property="lastname")>
 26		<cfset loc.r = loc.user.errorCount(property="lastname")>
 27		<cfset assert('loc.r eq 0')>
 28		<cfset loc.r = loc.user.hasErrors()>
 29		<cfset assert('loc.r eq true')>
 30		<cfset loc.r = loc.user.hasErrors(property="lastname")>
 31		<cfset assert('loc.r eq false')>
 32		<cfset loc.r = loc.user.hasErrors(property="lastname", name="lastname_errors")>
 33		<cfset assert('loc.r eq true')>
 34	</cffunction>
 35
 36	<cffunction name="test_error_information_for_lastname_property_name_provided">
 37		<cfset loc.r = loc.user.hasErrors(property="lastname", name="lastname_errors")>
 38		<cfset assert('loc.r eq true')>
 39		<cfset loc.r = loc.user.errorCount(property="lastname", name="lastname_errors")>
 40		<cfset assert('loc.r eq 2')>
 41		<cfset loc.user.clearErrors(property="lastname", name="lastname_errors")>
 42		<cfset loc.r = loc.user.errorCount(property="lastname", name="lastname_errors")>
 43		<cfset assert('loc.r eq 0')>
 44		<cfset loc.r = loc.user.hasErrors()>
 45		<cfset assert('loc.r eq true')>
 46		<cfset loc.r = loc.user.hasErrors(property="lastname", name="lastname_errors")>
 47		<cfset assert('loc.r eq false')>
 48		<cfset loc.r = loc.user.hasErrors(property="lastname")>
 49		<cfset assert('loc.r eq true')>
 50	</cffunction>
 51
 52	<cffunction name="test_error_information_for_firstname_property_no_name_provided">
 53		<cfset loc.r = loc.user.hasErrors(property="firstname")>
 54		<cfset assert('loc.r eq true')>
 55		<cfset loc.r = loc.user.errorCount(property="firstname")>
 56		<cfset assert('loc.r eq 2')>
 57		<cfset loc.user.clearErrors(property="firstname")>
 58		<cfset loc.r = loc.user.errorCount(property="firstname")>
 59		<cfset assert('loc.r eq 0')>
 60		<cfset loc.r = loc.user.hasErrors()>
 61		<cfset assert('loc.r eq true')>
 62		<cfset loc.r = loc.user.hasErrors(property="firstname")>
 63		<cfset assert('loc.r eq false')>
 64		<cfset loc.r = loc.user.hasErrors(property="firstname", name="firstname_errors")>
 65		<cfset assert('loc.r eq true')>
 66	</cffunction>
 67
 68	<cffunction name="test_error_information_for_firstname_property_name_provided">
 69		<cfset loc.r = loc.user.hasErrors(property="firstname", name="firstname_errors")>
 70		<cfset assert('loc.r eq true')>
 71		<cfset loc.r = loc.user.errorCount(property="firstname", name="firstname_errors")>
 72		<cfset assert('loc.r eq 3')>
 73		<cfset loc.user.clearErrors(property="firstname", name="firstname_errors")>
 74		<cfset loc.r = loc.user.errorCount(property="firstname", name="firstname_errors")>
 75		<cfset assert('loc.r eq 0')>
 76		<cfset loc.r = loc.user.hasErrors()>
 77		<cfset assert('loc.r eq true')>
 78		<cfset loc.r = loc.user.hasErrors(property="firstname", name="firstname_errors")>
 79		<cfset assert('loc.r eq false')>
 80		<cfset loc.r = loc.user.hasErrors(property="firstname")>
 81		<cfset assert('loc.r eq true')>
 82	</cffunction>
 83
 84	<cffunction name="test_error_information_for_base_no_name_provided">
 85		<cfset loc.r = loc.user.hasErrors()>
 86		<cfset assert('loc.r eq true')>
 87		<cfset loc.r = loc.user.errorCount()>
 88		<cfset assert('loc.r eq 13')>
 89		<cfset loc.user.clearErrors()>
 90		<cfset loc.r = loc.user.errorCount()>
 91		<cfset assert('loc.r eq 0')>
 92		<cfset loc.r = loc.user.hasErrors()>
 93		<cfset assert('loc.r eq false')>
 94		<cfset loc.r = loc.user.hasErrors(property="lastname")>
 95		<cfset assert('loc.r eq false')>
 96		<cfset loc.r = loc.user.hasErrors(property="lastname", name="lastname_errors")>
 97		<cfset assert('loc.r eq false')>
 98		<cfset loc.r = loc.user.hasErrors(property="firstname")>
 99		<cfset assert('loc.r eq false')>
100		<cfset loc.r = loc.user.hasErrors(property="firstname", name="firstname_errors")>
101		<cfset assert('loc.r eq false')>
102	</cffunction>
103
104	<cffunction name="test_error_information_for_base_name_provided">
105		<cfset loc.r = loc.user.hasErrors(name="base_errors")>
106		<cfset assert('loc.r eq true')>
107		<cfset loc.r = loc.user.errorCount(name="base_errors")>
108		<cfset assert('loc.r eq 2')>
109		<cfset loc.user.clearErrors(name="base_errors")>
110		<cfset debug('loc.user.allErrors()', false)>
111		<cfset loc.r = loc.user.errorCount(name="base_errors")>
112		<cfset assert('loc.r eq 0')>
113		<cfset loc.r = loc.user.hasErrors(name="base_errors")>
114		<cfset assert('loc.r eq false')>
115		<cfset loc.r = loc.user.hasErrors(property="lastname")>
116		<cfset assert('loc.r eq true')>
117 		<cfset loc.r = loc.user.hasErrors(property="lastname", name="lastname_errors")>
118		<cfset assert('loc.r eq true')>
119		<cfset loc.r = loc.user.hasErrors(property="firstname")>
120		<cfset assert('loc.r eq true')>
121		<cfset loc.r = loc.user.hasErrors(property="firstname", name="firstname_errors")>
122		<cfset assert('loc.r eq true')>
123	</cffunction>
124
125	<cffunction name="test_error_information_for_incorrect_property">
126		<cfset loc.r = loc.user.hasErrors(property="firstnamex")>
127		<cfset assert('loc.r eq false')>
128		<cfset loc.r = loc.user.errorCount(property="firstnamex")>
129		<cfset assert('loc.r eq 0')>
130		<cfset loc.user.clearErrors(property="firstnamex")>
131		<cfset loc.r = loc.user.hasErrors()>
132		<cfset assert('loc.r eq true')>
133		<cfset loc.r = loc.user.hasErrors(property="firstname")>
134		<cfset assert('loc.r eq true')>
135		<cfset loc.r = loc.user.hasErrors(property="firstname", name="firstname_errors")>
136		<cfset assert('loc.r eq true')>
137	</cffunction>
138
139	<cffunction name="test_error_information_for_incorrect_name_on_property">
140		<cfset loc.r = loc.user.hasErrors(property="firstname", name="firstname_errorsx")>
141		<cfset assert('loc.r eq false')>
142		<cfset loc.r = loc.user.errorCount(property="firstname", name="firstname_errorsx")>
143		<cfset assert('loc.r eq 0')>
144		<cfset loc.user.clearErrors(property="firstname", name="firstname_errorsx")>
145		<cfset loc.r = loc.user.hasErrors()>
146		<cfset assert('loc.r eq true')>
147		<cfset loc.r = loc.user.hasErrors(property="firstname", name="firstname_errors")>
148		<cfset assert('loc.r eq true')>
149		<cfset loc.r = loc.user.hasErrors(property="firstname")>
150		<cfset assert('loc.r eq true')>
151	</cffunction>
152
153	<cffunction name="test_error_information_for_incorrect_name_on_base">
154		<cfset loc.r = loc.user.hasErrors(name="base_errorsx")>
155		<cfset assert('loc.r eq false')>
156		<cfset loc.r = loc.user.errorCount(name="base_errorsx")>
157		<cfset assert('loc.r eq 0')>
158		<cfset loc.user.clearErrors(name="base_errorsx")>
159		<cfset loc.r = loc.user.hasErrors(name="base_errors")>
160		<cfset assert('loc.r eq true')>
161		<cfset loc.r = loc.user.hasErrors(property="lastname")>
162		<cfset assert('loc.r eq true')>
163 		<cfset loc.r = loc.user.hasErrors(property="lastname", name="lastname_errors")>
164		<cfset assert('loc.r eq true')>
165		<cfset loc.r = loc.user.hasErrors(property="firstname")>
166		<cfset assert('loc.r eq true')>
167		<cfset loc.r = loc.user.hasErrors(property="firstname", name="firstname_errors")>
168		<cfset assert('loc.r eq true')>
169	</cffunction>
170
171</cfcomponent>