diff options
author | wei <> | 2006-04-25 01:00:08 +0000 |
---|---|---|
committer | wei <> | 2006-04-25 01:00:08 +0000 |
commit | c84f3e19b54cf54f525f4b2d158696ae32d1bf60 (patch) | |
tree | 60720fba29ef72175db47dd3cd4b74d8bbed605b /tests/FunctionalTests | |
parent | 09edc6590523e26fffbf32f7b0e7958c166f7537 (diff) |
Add TListControlValidator. Update client-side validators, datepicker.js, colorpicker.js.
Diffstat (limited to 'tests/FunctionalTests')
9 files changed, 315 insertions, 40 deletions
diff --git a/tests/FunctionalTests/features/protected/pages/DatePicker.page b/tests/FunctionalTests/features/protected/pages/DatePicker.page index 4347f748..261a6994 100644 --- a/tests/FunctionalTests/features/protected/pages/DatePicker.page +++ b/tests/FunctionalTests/features/protected/pages/DatePicker.page @@ -12,45 +12,47 @@ </tr>
<tr>
- <td class="samplenote">Button Mode</td>
+ <td class="samplenote">Button Mode, pre-selected date</td>
<td class="sampleaction">
- <com:TDatePicker Mode="Button" />
+ <com:TDatePicker Mode="Button" Date="20-10-2005"/>
</td>
</tr>
<tr>
<td class="samplenote">InputMode="DropDownList", custom DateFormat</td>
<td class="sampleaction">
- <com:TDatePicker DateFormat="yyyy/MMMM" InputMode="DropDownList"/>
+ <com:TDatePicker DateFormat="yyyy/MMM" InputMode="DropDownList"/>
</td>
</tr>
<tr>
<td class="samplenote">InputMode="DropDownList", custom DateFormat, Culture</td>
<td class="sampleaction">
- <com:TDatePicker DateFormat="MM/yyyy" Culture="fr" InputMode="DropDownList"/>
+ <com:TDatePicker DateFormat="MMM/yyyy" Culture="fr" InputMode="DropDownList"/>
</td>
</tr>
<tr>
- <td class="samplenote">Custom DateFormat, culture, ImageButton mode</td>
+ <td class="samplenote">Custom DateFormat, culture, ImageButton mode, pre-selected date</td>
<td class="sampleaction">
- <com:TDatePicker Mode="ImageButton" Culture="zh_CN" DateFormat="日期:yyyy年M月d日"/>
+ <com:TDatePicker Mode="ImageButton" Culture="zh_CN"
+ DateFormat="日期:yyyy年M月d日"
+ Timestamp=<%= @strtotime("-1 year") %>/>
</td>
</tr>
<tr>
<td class="samplenote">Custom DateFormat, DropDownList, pre-selected date set in as Text</td>
<td class="sampleaction">
- <com:TDatePicker DateFormat="yyyy/MMMM/dd" Text="2005/05/15" InputMode="DropDownList"/>
+ <com:TDatePicker DateFormat="yyyy/MMMM/dd" Date="2005/05/15" InputMode="DropDownList"/>
</td>
</tr>
<tr>
<td class="samplenote">DropDownList, pre-selected date as integer</td>
<td class="sampleaction">
- <com:TDatePicker InputMode="DropDownList" Date=<%= @strtotime("-1 month") %>/>
+ <com:TDatePicker InputMode="DropDownList" Timestamp=<%= @strtotime("-1 month") %>/>
</td>
</tr>
diff --git a/tests/FunctionalTests/validators/protected/pages/DataTypeValidator.page b/tests/FunctionalTests/validators/protected/pages/DataTypeValidator.page new file mode 100644 index 00000000..48821f83 --- /dev/null +++ b/tests/FunctionalTests/validators/protected/pages/DataTypeValidator.page @@ -0,0 +1,33 @@ +<com:TContent ID="Content">
+ <h1>Data Type Validator Tests</h1>
+ Integer test.
+ <com:TTextBox ID="textbox1" />
+ <com:TDataTypeValidator ID="validator1"
+ ControlToValidate="textbox1"
+ DataType="Integer"
+ ErrorMessage="Please enter an integer." />
+
+ <hr />
+
+ Float test.
+ <com:TTextBox ID="textbox2" />
+ <com:TDataTypeValidator ID="validator2"
+ ControlToValidate="textbox2"
+ DataType="Float"
+ ErrorMessage="Please enter float value." />
+
+ <hr />
+
+ Date Test
+ <com:TTextBox ID="textbox3" />
+ <com:TDataTypeValidator ID="validator3"
+ ControlToValidate="textbox3"
+ DataType="Date"
+ DateFormat="d/M/yyyy"
+ ErrorMessage="Please enter a date d/M/yyyy." />
+
+ <hr />
+
+ <com:TButton ID="button1" Text="submit!" />
+
+</com:TContent>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/protected/pages/DatePicker.page b/tests/FunctionalTests/validators/protected/pages/DatePicker.page new file mode 100644 index 00000000..fdbbbeb1 --- /dev/null +++ b/tests/FunctionalTests/validators/protected/pages/DatePicker.page @@ -0,0 +1,64 @@ +<com:TContent ID="Content">
+ <h1>Date Picker validation Test</h1>
+ <com:TDatePicker ID="picker1" DateFormat="d/M/yyyy"/>
+ <com:TRequiredFieldValidator
+ ID="validator1"
+ ControlToValidate="picker1"
+ ErrorMessage="Please enter a date (d/M/yyyy)" />
+ <com:TRangeValidator
+ ID="validator2"
+ ControlToValidate="picker1"
+ DataType="Date"
+ DateFormat="d/M/yyyy"
+ ErrorMessage="Please enter a date greater than 17/4/2007"
+ MinValue="17/4/2007" />
+
+ <hr />
+ <com:TDatePicker ID="picker2" DateFormat="d/M/yyyy" InputMode="DropDownList" />
+
+ <com:TRangeValidator
+ ID="validator4"
+ ControlToValidate="picker2"
+ DataType="Date"
+ DateFormat="d/M/yyyy"
+ ErrorMessage="Please enter a date between 9/9/2006 and 8/10/2006"
+ MinValue="9/9/2006"
+ MaxValue="8/10/2006" />
+
+ <hr />
+ Date 1:
+ <com:TDatePicker ID="picker3" DateFormat="d/M/yyyy" />
+ <com:TRequiredFieldValidator
+ ID="validator5"
+ ControlToValidate="picker3"
+ ErrorMessage="Please enter a date (d/M/yyyy)" />
+ <br />
+ Date 2:
+ <com:TDatePicker ID="picker4" DateFormat="d/M/yyyy" />
+ <com:TCompareValidator
+ ID="validator6"
+ ControlToValidate="picker4"
+ ControlToCompare="picker3"
+ Operator="GreaterThan"
+ DateFormat="d/M/yyyy"
+ DataType="Date"
+ ErrorMessage="Date 2 must be greater than Date 1" />
+
+ <hr />
+
+ Date 3:
+ <com:TDatePicker ID="picker5" DateFormat="d/M/yyyy" InputMode="DropDownList" />
+ <br />
+ Date 4:
+ <com:TDatePicker ID="picker6" DateFormat="d/M/yyyy" InputMode="DropDownList" />
+ <com:TCompareValidator
+ ID="validator8"
+ ControlToValidate="picker6"
+ ControlToCompare="picker5"
+ Operator="GreaterThan"
+ DateFormat="d/M/yyyy"
+ DataType="Date"
+ ErrorMessage="Date 2 must be greater than Date 1" />
+ <com:TButton ID="submit1" Text="Submit" />
+
+</com:TContent>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/protected/pages/Layout.tpl b/tests/FunctionalTests/validators/protected/pages/Layout.tpl index 224481e1..25dbea09 100644 --- a/tests/FunctionalTests/validators/protected/pages/Layout.tpl +++ b/tests/FunctionalTests/validators/protected/pages/Layout.tpl @@ -21,6 +21,11 @@ margin-top: 2em;
display: block;
}
+ .required
+ {
+ border: 1px solid red;
+ background-color: pink;
+ }
/*]]>*/
</style>
</com:THead>
diff --git a/tests/FunctionalTests/validators/protected/pages/ListControl.page b/tests/FunctionalTests/validators/protected/pages/ListControl.page new file mode 100644 index 00000000..1429e184 --- /dev/null +++ b/tests/FunctionalTests/validators/protected/pages/ListControl.page @@ -0,0 +1,58 @@ +<com:TContent ID="Content">
+ <h1>List Control Required Field Validation Test</h1>
+ <com:TCheckBoxList ID="list1">
+ <com:TListItem Text="Select a color below" Value="" />
+ <com:TListItem Text="Red" />
+ <com:TListItem Text="Blue" />
+ <com:TListItem Text="Green" />
+ </com:TCheckBoxList>
+
+ <com:TRequiredFieldValidator ID="validator1"
+ ControlToValidate="list1"
+ InitialValue="Select a color below"
+ ErrorMessage="*" />
+
+ <hr />
+
+ <com:TDropDownList ID="list2">
+ <com:TListItem Text="--- Select a color ---" />
+ <com:TListItem Text="Red" />
+ <com:TListItem Text="Blue" />
+ <com:TListItem Text="Green" />
+ </com:TDropDownList>
+
+ <com:TRequiredFieldValidator ID="validator2"
+ ControlToValidate="list2"
+ InitialValue="--- Select a color ---"
+ ErrorMessage="*" />
+
+ <hr />
+
+ <com:TListBox ID="list3">
+ <com:TListItem Text="Don't select this one" />
+ <com:TListItem Text="Red" />
+ <com:TListItem Text="Blue" />
+ <com:TListItem Text="Green" />
+ </com:TListBox>
+
+ <com:TRequiredFieldValidator ID="validator3"
+ ControlToValidate="list3"
+ InitialValue="Don't select this one"
+ ErrorMessage="*" />
+
+ <hr />
+
+ <com:TRadioButtonList ID="list4">
+ <com:TListItem Text="Select something else" />
+ <com:TListItem Text="Red" />
+ <com:TListItem Text="Blue" />
+ <com:TListItem Text="Green" />
+ </com:TRadioButtonList>
+
+ <com:TRequiredFieldValidator ID="validator4"
+ ControlToValidate="list4"
+ InitialValue="Select something else"
+ ErrorMessage="*" />
+
+ <com:TButton ID="submit1" Text="Submit!" />
+</com:TContent>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/protected/pages/RequiredListValidator.page b/tests/FunctionalTests/validators/protected/pages/RequiredListValidator.page index 9bbd9d5a..665d71b7 100644 --- a/tests/FunctionalTests/validators/protected/pages/RequiredListValidator.page +++ b/tests/FunctionalTests/validators/protected/pages/RequiredListValidator.page @@ -8,7 +8,7 @@ <com:TListItem Value="3" Text="Three" />
<com:TListItem Value="4" Text="Four" />
</com:TCheckBoxList>
- <com:TRequiredListValidator
+ <com:TListControlValidator
ID="validator1"
ControlToValidate="list1"
ErrorMessage="Must select at least 1 and no more than 3"
@@ -18,30 +18,31 @@ </div>
<div>
- <com:TListBox ID="list2" SelectionMode="Multiple" Rows="5" Style="width:10em">
+ <com:TListBox ID="list2" SelectionMode="Multiple" Rows="5" Style="width:10em;">
<com:TListItem Value="1" Text="One" />
<com:TListItem Value="2" Text="Two" />
<com:TListItem Value="3" Text="Three" />
<com:TListItem Value="4" Text="Four" />
<com:TListItem Value="5" Text="Five" />
</com:TListBox>
- <com:TRequiredListValidator
+ <com:TListControlValidator
ID="validator2"
ControlToValidate="list2"
ErrorMessage='Must select at least 2 and no more than 3 and value "two"'
MinSelection="2"
MaxSelection="3"
+ ControlCssClass="required"
RequiredSelections="2" />
</div>
<div class="lista">
- <com:TCheckBoxList ID="list3">
+ <com:TRadioButtonList ID="list3">
<com:TListItem Value="1" Text="One" />
<com:TListItem Value="2" Text="Two" />
<com:TListItem Value="3" Text="Three" />
<com:TListItem Value="4" Text="Four" />
- </com:TCheckBoxList>
- <com:TRequiredListValidator
+ </com:TRadioButtonList>
+ <com:TListControlValidator
ID="validator3"
ControlToValidate="list3"
ErrorMessage="Must select at least 1"
diff --git a/tests/FunctionalTests/validators/tests/DatePickerTestCase.php b/tests/FunctionalTests/validators/tests/DatePickerTestCase.php new file mode 100644 index 00000000..75894dc0 --- /dev/null +++ b/tests/FunctionalTests/validators/tests/DatePickerTestCase.php @@ -0,0 +1,63 @@ +<?php
+
+class DatePickerTestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $base = "ctl0_Content_";
+ $this->open("validators/index.php?page=DatePicker", "");
+ $this->verifyTextPresent("Date Picker validation Test", "");
+ $this->assertNotVisible("{$base}validator1", "");
+ $this->assertNotVisible("{$base}validator2", "");
+ $this->assertNotVisible("{$base}validator4", "");
+ $this->assertNotVisible("{$base}validator5", "");
+ $this->assertNotVisible("{$base}validator6", "");
+ $this->assertNotVisible("{$base}validator8", "");
+
+ $this->click("{$base}submit1");
+ $this->assertVisible("{$base}validator1", "");
+ $this->assertNotVisible("{$base}validator2", "");
+ $this->assertVisible("{$base}validator4", "");
+ $this->assertVisible("{$base}validator5", "");
+ $this->assertNotVisible("{$base}validator6", "");
+ $this->assertVisible("{$base}validator8", "");
+
+ $this->click("{$base}submit1");
+ $this->type("{$base}picker1", "13/4/2006");
+ $this->select("{$base}picker2_month", "label=9");
+ $this->select("{$base}picker2_day", "label=10");
+ $this->type("{$base}picker3", "14/4/2006");
+ $this->type("{$base}picker4", "7/4/2006");
+ $this->select("{$base}picker5_day", "label=6");
+ $this->select("{$base}picker5_month", "label=3");
+ $this->select("{$base}picker5_year", "label=2007");
+ $this->select("{$base}picker6_month", "label=3");
+ $this->select("{$base}picker6_year", "label=2007");
+ $this->select("{$base}picker6_day", "label=5");
+
+ $this->click("{$base}submit1");
+
+ $this->assertNotVisible("{$base}validator1", "");
+ $this->assertVisible("{$base}validator2", "");
+ $this->assertNotVisible("{$base}validator4", "");
+ $this->assertNotVisible("{$base}validator5", "");
+ $this->assertVisible("{$base}validator6", "");
+ $this->assertVisible("{$base}validator8", "");
+
+ $this->type("{$base}picker1", "20/4/2007");
+ $this->type("{$base}picker4", "29/4/2006");
+ $this->select("{$base}picker6_day", "label=10");
+
+ $this->clickAndWait("{$base}submit1");
+
+ $this->assertNotVisible("{$base}validator1", "");
+ $this->assertNotVisible("{$base}validator2", "");
+ $this->assertNotVisible("{$base}validator4", "");
+ $this->assertNotVisible("{$base}validator5", "");
+ $this->assertNotVisible("{$base}validator6", "");
+ $this->assertNotVisible("{$base}validator8", "");
+ }
+
+}
+
+?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/ListControlTestCase.php b/tests/FunctionalTests/validators/tests/ListControlTestCase.php new file mode 100644 index 00000000..6c0c73e7 --- /dev/null +++ b/tests/FunctionalTests/validators/tests/ListControlTestCase.php @@ -0,0 +1,48 @@ +<?php
+/*
+ * Created on 24/04/2006
+ */
+
+class ListControlTestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $base = "ctl0_Content_";
+ $this->open("validators/index.php?page=ListControl", "");
+ $this->verifyTextPresent("List Control Required Field Validation Test", "");
+ $this->click("//input[@type='submit' and @value='Submit!']", "");
+
+ $this->assertVisible("{$base}validator1");
+ $this->assertVisible("{$base}validator2");
+ $this->assertVisible("{$base}validator3");
+ $this->assertVisible("{$base}validator4");
+
+ $this->click("//input[@id='{$base}list1_1' and @value='Red']", "");
+ $this->select("{$base}list2", "label=Red");
+ $this->select("{$base}list3", "label=Blue");
+ $this->click("{$base}list4_3", "");
+ $this->clickAndWait("//input[@type='submit' and @value='Submit!']", "");
+
+ $this->assertNotVisible("{$base}validator1");
+ $this->assertNotVisible("{$base}validator2");
+ $this->assertNotVisible("{$base}validator3");
+ $this->assertNotVisible("{$base}validator4");
+
+ $this->select("{$base}list3", "label=Don't select this one");
+ $this->click("{$base}list4_0");
+ $this->select("{$base}list2", "label=--- Select a color ---");
+ $this->click("//input[@type='submit' and @value='Submit!']", "");
+ $this->click("//input[@id='{$base}list1_1' and @value='Red']", "");
+ $this->click("//input[@id='{$base}list1_0' and @value='Select a color below']", "");
+ $this->click("//input[@type='submit' and @value='Submit!']", "");
+
+ $this->assertVisible("{$base}validator1");
+ $this->assertVisible("{$base}validator2");
+ $this->assertVisible("{$base}validator3");
+ $this->assertVisible("{$base}validator4");
+
+ }
+
+}
+
+?>
diff --git a/tests/FunctionalTests/validators/tests/RequiredListTestCase.php b/tests/FunctionalTests/validators/tests/RequiredListTestCase.php index 1eab60d4..ad299dc5 100644 --- a/tests/FunctionalTests/validators/tests/RequiredListTestCase.php +++ b/tests/FunctionalTests/validators/tests/RequiredListTestCase.php @@ -5,35 +5,36 @@ class RequiredListTestCase extends SeleniumTestCase function test()
{
+ $base = "ctl0_Content_";
$this->open("validators/index.php?page=RequiredListValidator");
$this->assertLocation("index.php?page=RequiredListValidator");
- $this->click("submit1");
- $this->assertVisible("validator1");
- $this->assertVisible("validator2");
- $this->assertVisible("validator3");
- $this->click("list1:0");
- $this->select("list2", "label=One");
- $this->select("list2", "label=Two");
- $this->click("list3:3");
- $this->clickAndWait("submit1");
- $this->assertNotVisible("validator1");
- $this->assertNotVisible("validator2");
- $this->assertNotVisible("validator3");
- $this->click("list1:1");
- $this->click("list1:2");
- $this->click("list1:3");
- $this->select("list2", "label=Two");
- $this->click("list1:3");
- $this->click("submit1");
- $this->assertNotVisible("validator1");
- $this->assertNotVisible("validator2");
- $this->assertNotVisible("validator3");
- $this->click("list3:3");
- $this->click("submit1");
+ $this->click("{$base}submit1");
+ $this->assertVisible("{$base}validator1");
+ $this->assertVisible("{$base}validator2");
+ $this->assertVisible("{$base}validator3");
+ $this->click("{$base}list1_0");
+ $this->select("{$base}list2", "label=One");
+ $this->select("{$base}list2", "label=Two");
+ $this->click("{$base}list3_3");
+ $this->clickAndWait("{$base}submit1");
+ $this->assertNotVisible("{$base}validator1");
+ $this->assertNotVisible("{$base}validator2");
+ $this->assertNotVisible("{$base}validator3");
+ $this->click("{$base}list1_1");
+ $this->click("{$base}list1_2");
+ $this->click("{$base}list1_3");
+ $this->select("{$base}list2", "label=Two");
+ $this->click("{$base}list1_3");
+ $this->click("{$base}submit1");
+ $this->assertNotVisible("{$base}validator1");
+ $this->assertNotVisible("{$base}validator2");
+ $this->assertNotVisible("{$base}validator3");
+ $this->click("{$base}list3_3");
+ $this->click("{$base}submit1");
$this->pause(200);
- $this->assertNotVisible("validator1");
- $this->assertNotVisible("validator2");
- $this->assertVisible("validator3");
+ $this->assertNotVisible("{$base}validator1");
+ $this->assertNotVisible("{$base}validator2");
+ $this->assertNotVisible("{$base}validator3");
}
}
|