Browse files

first tests for drawStandardFormField()

  • Loading branch information...
1 parent c2a8801 commit 70a5d9ca4bcab19db22dbfd8c9458550a51310c9 @jaredbeck jaredbeck committed May 6, 2012
Showing with 70 additions and 8 deletions.
  1. +9 −7 test/Application.cfc
  2. +1 −1 test/index.cfm
  3. +9 −0 test/subphylum_set.cfc
  4. +51 −0 test/units/dbrow/drawStandardFormField_test.cfc
View
16 test/Application.cfc
@@ -1,18 +1,20 @@
-<cfcomponent>
+<cfcomponent>
-<cfset this.name = "TestApplication">
+<cfset this.name = "TestApplication">
<cfset this.sessionmanagement = false>
-<cfset this.applicationtimeout = "#CreateTimeSpan(0,0,0,5)#">
+<cfset this.applicationtimeout = "#CreateTimeSpan(0,0,0,5)#">
<cffunction name="onApplicationStart">
<cfset application.datasource = "dbrow_test">
<cfset application.objectMap = "dbrow.test">
</cffunction>
+
<cffunction name="onRequestStart">
- <cfif StructKeyExists(URL, "resetApplication")>
- <cfset onApplicationStart()>
- </cfif>
+<cfscript>
+ if (StructKeyExists(URL, "resetApplication")) { onApplicationStart(); }
+ request.timeNone = CreateTimeSpan(0, 0, 0, 0);
+</cfscript>
</cffunction>
-
+
</cfcomponent>
View
2 test/index.cfm
@@ -3,7 +3,7 @@
testSuite = createObject("component","mxunit.framework.TestSuite").TestSuite();
unitTestCFCs = ['instantiation_test', 'load_test', 'label_test',
- 'drawPropertyValue_test'];
+ 'drawPropertyValue_test', 'drawStandardFormField_test'];
for(i=1; i <= ArrayLen(unitTestCFCs); i++) {
testSuite.addAll("units.dbrow." & unitTestCFCs[i]);
View
9 test/subphylum_set.cfc
@@ -0,0 +1,9 @@
+<cfcomponent extends="dbrow.dbset3">
+<cfscript>
+
+theObject = "subphylum";
+theOrderField = "subphylum_name";
+this.init();
+
+</cfscript>
+</cfcomponent>
View
51 test/units/dbrow/drawStandardFormField_test.cfc
@@ -0,0 +1,51 @@
+<cfcomponent extends="dbrow.test.units.abstract_testcase">
+<cfscript>
+
+public void function beforeTests() {
+ arthropod_factory = CreateObject('support.factories.arthropod_factory');
+}
+
+
+public void function setUp() {
+ arthropod = arthropod_factory.create();
+}
+
+
+/* The following tests are very brittle because they hardcode the expected
+rendered output, including exact whitespace. Furthermore these tests do not
+come anywhere near to complete coverage of drawStandardFormField().
+-Jared 2012-05-06 */
+
+public void function drawStandardFormField_bit() {
+ var expected = '<input type="checkbox" name="venemous_checkbox" id="venemous_checkbox" value="1" tabindex="16383" desc="Venemous" onclick="document.getElementById(''venemous'').value=this.checked;" />
+ <input type="hidden" name="venemous" id="venemous" value="0" />
+ <span id="venemous_error" class="error hidden"></span>';
+ var actual = Trim(arthropod.drawStandardFormField('venemous'));
+ assertEquals(expected, actual);
+}
+
+
+public void function drawStandardFormField_foreignKey() {
+ var beginning = '<select name="subphylumid" id="subphylumid" tabindex="16383" desc="Subphylumid"><option value=""></option>';
+ var end = '</select><span id="subphylumid_error" class="error hidden"></span>';
+ var actual = arthropod.drawStandardFormField('subphylumID');
+ assert(actual contains beginning);
+ assert(actual contains end);
+}
+
+
+public void function drawStandardFormField_primaryKey() {
+ var expected = '<input type="hidden" name="arthropodid" id="arthropodid" value="' & arthropod.arthropodID & '" /><span id="arthropodid_error" class="error hidden"></span>';
+ var actual = arthropod.drawStandardFormField('arthropodID');
+ assertEquals(expected, actual);
+}
+
+
+public void function drawStandardFormField_varchar() {
+ var expected = '<input type="text" size="40" name="arthropod_name" id="arthropod_name" tabindex="16383" value="Honey Bee" desc="Creepy crawly" maxlength="50" /><span id="arthropod_name_error" class="error hidden"></span>';
+ var actual = arthropod.drawStandardFormField('arthropod_name');
+ assertEquals(expected, actual);
+}
+
+</cfscript>
+</cfcomponent>

0 comments on commit 70a5d9c

Please sign in to comment.