summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/validators
diff options
context:
space:
mode:
authorwei <>2007-03-27 08:34:28 +0000
committerwei <>2007-03-27 08:34:28 +0000
commitd5950ec0b553d46c4800adc0532d4464a4eb1883 (patch)
tree232a4f5ccbd36d6a114dff383adb383793422814 /tests/FunctionalTests/validators
parentcdf3ba1c190393d86460f8c13073dc9784436b3e (diff)
Fixed #278, conditional validation.
Diffstat (limited to 'tests/FunctionalTests/validators')
-rw-r--r--tests/FunctionalTests/validators/protected/pages/ConditionalValidation.page30
-rw-r--r--tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php20
-rw-r--r--tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php55
3 files changed, 105 insertions, 0 deletions
diff --git a/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.page b/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.page
new file mode 100644
index 00000000..ad43135b
--- /dev/null
+++ b/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.page
@@ -0,0 +1,30 @@
+<com:TContent ID="Content">
+<h1>Conditional Validation (clientside + server side)</h1>
+<div>
+ <div>
+ <com:TTextBox ID="text1" />
+ <com:TRequiredFieldValidator
+ ID="validator1"
+ ControlToValidate="text1"
+ ErrorMessage="*"
+ ControlCssClass="required"/>
+ <com:TTextBox ID="text2" />
+ <com:TRequiredFieldValidator
+ ID="validator2"
+ ControlToValidate="text2"
+ OnValidate="check_validate"
+ ErrorMessage="*"
+ ControlCssClass="required">
+ <prop:ClientSide.OnValidate>
+ sender.enabled = $('<%= $this->check1->ClientID %>').checked;
+ </prop:ClientSide.OnValidate>
+
+ </com:TRequiredFieldValidator>
+ <com:TCheckBox ID="check1" />
+ </div>
+ <com:TButton ID="submit1" Text="Submit" />
+</div>
+
+
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php b/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php
new file mode 100644
index 00000000..7756566c
--- /dev/null
+++ b/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php
@@ -0,0 +1,20 @@
+<?php
+/*
+ * Created on 27/03/2007
+ */
+
+class ConditionalValidation extends TPage
+{
+ function check_validate($sender, $params)
+ {
+ $sender->enabled = $this->check1->checked;
+ }
+
+ function onPreRender($param)
+ {
+ //always re-enable the validator2 so as to display the client-side validator
+ $this->validator2->enabled=true;
+ }
+}
+
+?>
diff --git a/tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php b/tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php
new file mode 100644
index 00000000..7191ff9f
--- /dev/null
+++ b/tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php
@@ -0,0 +1,55 @@
+<?php
+
+class ConditionalValidationTestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $base = "ctl0_Content_";
+ $this->open("validators/index.php?page=ConditionalValidation", "");
+ $this->verifyTextPresent("Conditional Validation (clientside + server side)", "");
+ $this->assertNotVisible("{$base}validator1", "");
+ $this->assertNotVisible("{$base}validator2", "");
+
+ $this->click("{$base}submit1");
+ $this->assertVisible("{$base}validator1", "");
+ $this->assertNotVisible("{$base}validator2", "");
+
+ $this->click("{$base}check1");
+ $this->click("{$base}submit1");
+ $this->assertVisible("{$base}validator1", "");
+ $this->assertVisible("{$base}validator2", "");
+
+ $this->click("{$base}check1");
+ $this->click("{$base}submit1");
+ $this->assertVisible("{$base}validator1", "");
+ $this->assertNotVisible("{$base}validator2", "");
+
+ $this->type("{$base}text1", "testing");
+ $this->clickAndWait("{$base}submit1");
+ $this->assertNotVisible("{$base}validator1", "");
+ $this->assertNotVisible("{$base}validator2", "");
+
+ $this->type("{$base}text1" ,"");
+ $this->click("{$base}check1");
+ $this->click("{$base}submit1");
+ $this->assertVisible("{$base}validator1", "");
+ $this->assertVisible("{$base}validator2", "");
+
+ $this->type("{$base}text1", "test");
+ $this->type("{$base}text2", "123");
+ $this->clickAndWait("{$base}submit1");
+ $this->assertNotVisible("{$base}validator1", "");
+ $this->assertNotVisible("{$base}validator2", "");
+
+ $this->click("{$base}check1");
+ $this->type("{$base}text1", "");
+ $this->type("{$base}text2", "");
+ $this->click("{$base}submit1");
+ $this->assertVisible("{$base}validator1", "");
+ $this->assertNotVisible("{$base}validator2", "");
+
+ }
+
+}
+
+?>