From d5950ec0b553d46c4800adc0532d4464a4eb1883 Mon Sep 17 00:00:00 2001 From: wei <> Date: Tue, 27 Mar 2007 08:34:28 +0000 Subject: Fixed #278, conditional validation. --- .../protected/pages/ConditionalValidation.page | 30 ++++++++++++ .../protected/pages/ConditionalValidation.php | 20 ++++++++ .../tests/ConditionalValidationTestCase.php | 55 ++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 tests/FunctionalTests/validators/protected/pages/ConditionalValidation.page create mode 100644 tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php create mode 100644 tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php (limited to 'tests') 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 @@ + +

Conditional Validation (clientside + server side)

+
+
+ + + + + + sender.enabled = $('<%= $this->check1->ClientID %>').checked; + + + + +
+ +
+ + + +
\ 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 @@ +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 @@ +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", ""); + + } + +} + +?> -- cgit v1.2.3