PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/wheels/tests/view/forms/selectTag.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 103 lines | 92 code | 11 blank | 0 comment | 0 complexity | 3f99d4668a0e65f48efc177cb17f0afe MD5 | raw file
  1<cfcomponent extends="wheelsMapping.Test">
  2
  3	<cffunction name="setup">
  4		<cfset loc.controller = controller(name="dummy")>
  5		<cfset loc.options.simplevalues = '<select id="testselect" name="testselect"><option value="first">first</option><option value="second">second</option><option value="third">third</option></select>'>
  6		<cfset loc.options.complexvalues = '<select id="testselect" name="testselect"><option value="1">first</option><option value="2">second</option><option value="3">third</option></select>'>
  7		<cfset loc.options.single_column_query = '<select id="testselect" name="testselect"><option value="first">first</option><option value="second">second</option><option value="third">third</option></select>'>
  8		<cfset loc.options.empty_query = '<select id="testselect" name="testselect"></select>'>
  9	</cffunction>
 10
 11	<cffunction name="test_list_for_option_values">
 12		<cfset loc.args.name = "testselect">
 13		<cfset loc.args.options = "first,second,third">
 14		<cfset debug("loc.controller.selectTag(argumentcollection=loc.args)", false)>
 15		<cfset loc.r = loc.controller.selectTag(argumentcollection=loc.args)>
 16		<cfset assert('loc.options.simplevalues eq loc.r')>
 17	</cffunction>
 18
 19	<cffunction name="test_struct_for_option_values">
 20		<cfset loc.args.name = "testselect">
 21		<cfset loc.args.options = {1="first", 2="second", 3="third"}>
 22		<cfset debug("loc.controller.selectTag(argumentcollection=loc.args)", false)>
 23		<cfset loc.r = loc.controller.selectTag(argumentcollection=loc.args)>
 24		<cfset assert('loc.options.complexvalues eq loc.r')>
 25	</cffunction>
 26
 27	<cffunction name="test_one_dimensional_array_for_option_values">
 28		<cfset loc.args.name = "testselect">
 29		<cfset loc.args.options = ["first", "second", "third"]>
 30		<cfset debug("loc.controller.selectTag(argumentcollection=loc.args)", false)>
 31		<cfset loc.r = loc.controller.selectTag(argumentcollection=loc.args)>
 32		<cfset assert('loc.options.simplevalues eq loc.r')>
 33	</cffunction>
 34
 35	<cffunction name="test_two_dimensional_array_for_option_values">
 36		<cfset loc.args.name = "testselect">
 37		<cfset loc.first = [1, "first"]>
 38		<cfset loc.second = [2, "second"]>
 39		<cfset loc.third = [3, "third"]>
 40		<cfset loc.args.options = [loc.first, loc.second, loc.third]>
 41		<cfset debug("loc.controller.selectTag(argumentcollection=loc.args)", false)>
 42		<cfset loc.r = loc.controller.selectTag(argumentcollection=loc.args)>
 43		<cfset assert('loc.options.complexvalues eq loc.r')>
 44	</cffunction>
 45
 46	<cffunction name="test_three_dimensional_array_for_option_values">
 47		<cfset loc.args.name = "testselect">
 48		<cfset loc.first = [1, "first", "a"]>
 49		<cfset loc.second = [2, "second", "b"]>
 50		<cfset loc.third = [3, "third", "c"]>
 51		<cfset loc.args.options = [loc.first, loc.second, loc.third]>
 52		<cfset debug("loc.controller.selectTag(argumentcollection=loc.args)", false)>
 53		<cfset loc.r = loc.controller.selectTag(argumentcollection=loc.args)>
 54		<cfset assert('loc.options.complexvalues eq loc.r')>
 55	</cffunction>
 56
 57	<cffunction name="test_query_for_option_values">
 58		<cfset loc.q = querynew("")>
 59		<cfset loc.id = [1,2,3]>
 60		<cfset loc.name = ["first", "second", "third"]>
 61		<cfset queryaddcolumn(loc.q, "id", loc.id)>
 62		<cfset queryaddcolumn(loc.q, "name", loc.name)>
 63		<cfset loc.args.name = "testselect">
 64		<cfset loc.args.options = loc.q>
 65		<cfset debug("loc.controller.selectTag(argumentcollection=loc.args)", false)>
 66		<cfset loc.r = loc.controller.selectTag(argumentcollection=loc.args)>
 67		<cfset assert('loc.options.complexvalues eq loc.r')>
 68	</cffunction>
 69
 70	<cffunction name="test_one_column_query_for_options">
 71		<cfset loc.q = querynew("")>
 72		<cfset loc.id = ["first", "second", "third"]>
 73		<cfset queryaddcolumn(loc.q, "id", loc.id)>
 74		<cfset loc.args.name = "testselect">
 75		<cfset loc.args.options = loc.q>
 76		<cfset debug("loc.controller.selectTag(argumentcollection=loc.args)", false)>
 77		<cfset loc.r = loc.controller.selectTag(argumentcollection=loc.args)>
 78		<cfset assert('loc.options.single_column_query eq loc.r')>
 79	</cffunction>
 80
 81	<cffunction name="test_query_with_no_records_for_option_values_">
 82		<cfset loc.q = querynew("")>
 83		<cfset loc.id = []>
 84		<cfset loc.name = []>
 85		<cfset queryaddcolumn(loc.q, "id", loc.id)>
 86		<cfset queryaddcolumn(loc.q, "name", loc.name)>
 87		<cfset loc.args.name = "testselect">
 88		<cfset loc.args.options = loc.q>
 89		<cfset debug("loc.controller.selectTag(argumentcollection=loc.args)", false)>
 90		<cfset loc.r = loc.controller.selectTag(argumentcollection=loc.args)>
 91		<cfset assert('loc.options.empty_query eq loc.r')>
 92	</cffunction>
 93
 94	<cffunction name="test_query_with_no_records_or_columns_for_option_values_">
 95		<cfset loc.q = querynew("")>
 96		<cfset loc.args.name = "testselect">
 97		<cfset loc.args.options = loc.q>
 98		<cfset debug("loc.controller.selectTag(argumentcollection=loc.args)", false)>
 99		<cfset loc.r = loc.controller.selectTag(argumentcollection=loc.args)>
100		<cfset assert('loc.options.empty_query eq loc.r')>
101	</cffunction>
102
103</cfcomponent>