From eb2a6e9431445b3cb24be4b75f02f07aef70aebc Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 28 Apr 2006 01:22:42 +0000 Subject: New abstract TCompositeControl + FT tests --- .gitattributes | 5 +++ HISTORY | 2 +- framework/Web/UI/WebControls/TCompositeControl.php | 49 ++++++++++++++++++++++ .../features/protected/application.xml | 3 ++ .../features/protected/controls/LabeledTextBox.tpl | 2 + .../features/protected/controls/LabeledTextbox.php | 19 +++++++++ .../features/protected/pages/CompositeControl.page | 12 ++++++ .../features/tests/CompositeControlTestCase.php | 23 ++++++++++ 8 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 framework/Web/UI/WebControls/TCompositeControl.php create mode 100644 tests/FunctionalTests/features/protected/controls/LabeledTextBox.tpl create mode 100644 tests/FunctionalTests/features/protected/controls/LabeledTextbox.php create mode 100644 tests/FunctionalTests/features/protected/pages/CompositeControl.page create mode 100644 tests/FunctionalTests/features/tests/CompositeControlTestCase.php diff --git a/.gitattributes b/.gitattributes index f70aa0e5..4cf64834 100644 --- a/.gitattributes +++ b/.gitattributes @@ -772,6 +772,7 @@ framework/Web/UI/WebControls/TCheckBoxList.php -text framework/Web/UI/WebControls/TClientScript.php -text framework/Web/UI/WebControls/TColorPicker.php -text framework/Web/UI/WebControls/TCompareValidator.php -text +framework/Web/UI/WebControls/TCompositeControl.php -text framework/Web/UI/WebControls/TContent.php -text framework/Web/UI/WebControls/TContentPlaceHolder.php -text framework/Web/UI/WebControls/TCustomValidator.php -text @@ -845,9 +846,12 @@ tests/FunctionalTests/config.php -text tests/FunctionalTests/features.php -text tests/FunctionalTests/features/index.php -text tests/FunctionalTests/features/protected/application.xml -text +tests/FunctionalTests/features/protected/controls/LabeledTextBox.tpl -text +tests/FunctionalTests/features/protected/controls/LabeledTextbox.php -text tests/FunctionalTests/features/protected/controls/Layout.php -text tests/FunctionalTests/features/protected/controls/Layout.tpl -text tests/FunctionalTests/features/protected/pages/ColorPicker.page -text +tests/FunctionalTests/features/protected/pages/CompositeControl.page -text tests/FunctionalTests/features/protected/pages/DatePicker.page -text tests/FunctionalTests/features/protected/pages/FeatureList.page -text tests/FunctionalTests/features/protected/pages/FeatureList.php -text @@ -859,6 +863,7 @@ tests/FunctionalTests/features/protected/pages/I18N/Home.zh_CN.page -text tests/FunctionalTests/features/protected/pages/I18N/config.xml -text tests/FunctionalTests/features/protected/pages/RatingList.page -text tests/FunctionalTests/features/protected/pages/ValidatorEffects.page -text +tests/FunctionalTests/features/tests/CompositeControlTestCase.php -text tests/FunctionalTests/index.php -text tests/FunctionalTests/quickstart.php -text tests/FunctionalTests/quickstart/Advanced/I18N.php -text diff --git a/HISTORY b/HISTORY index cd9c8482..2a3c7676 100644 --- a/HISTORY +++ b/HISTORY @@ -25,7 +25,7 @@ CHG: TDatePicker's date can be set using Date property, it value must be in same CHG: TSimpleDateFormatter::parse() now return an integer or null on parse error (Wei) NEW: TListControlValidator (Wei) NEW: TClientScript (Wei) - +NEW: TCompositeControl (Wei) Version 3.0RC2 April 16, 2006 diff --git a/framework/Web/UI/WebControls/TCompositeControl.php b/framework/Web/UI/WebControls/TCompositeControl.php new file mode 100644 index 00000000..80f2259c --- /dev/null +++ b/framework/Web/UI/WebControls/TCompositeControl.php @@ -0,0 +1,49 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Revision: $ $Date: $ + * @package System.Web.UI + */ + +/** + * The TCompositeControl class is an abstract class that provides naming + * container and control designer functionality for custom controls that + * encompass child controls in their entirety or use the functionality of other + * controls. You cannot use this class directly. + * + * To create a custom composite control, derive from the CompositeControl class. + * The functionality this class provides is built-in verification that child + * controls have been created prior to being accessed + * + * @author Wei Zhuo + * @version $Revision: $ $Date: $ + * @package System.Web.UI + * @since 3.0 + */ +abstract class TCompositeControl extends TTemplateControl +{ + /** + * The constructor ensures the child controls are created. + */ + public function __construct() + { + parent::__construct(); + $this->recreateChildControls(); + } + + /** + * Recreates the child controls in a control derived from TCompositeControl. + */ + protected function recreateChildControls() + { + $this->ensureChildControls(); + } + +} + +?> diff --git a/tests/FunctionalTests/features/protected/application.xml b/tests/FunctionalTests/features/protected/application.xml index 642152cc..9153f3f7 100644 --- a/tests/FunctionalTests/features/protected/application.xml +++ b/tests/FunctionalTests/features/protected/application.xml @@ -1,6 +1,9 @@ + + + diff --git a/tests/FunctionalTests/features/protected/controls/LabeledTextBox.tpl b/tests/FunctionalTests/features/protected/controls/LabeledTextBox.tpl new file mode 100644 index 00000000..276d03b2 --- /dev/null +++ b/tests/FunctionalTests/features/protected/controls/LabeledTextBox.tpl @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/controls/LabeledTextbox.php b/tests/FunctionalTests/features/protected/controls/LabeledTextbox.php new file mode 100644 index 00000000..33396734 --- /dev/null +++ b/tests/FunctionalTests/features/protected/controls/LabeledTextbox.php @@ -0,0 +1,19 @@ +textbox; + } + + public function getLabel() + { + return $this->label; + } +} + +?> diff --git a/tests/FunctionalTests/features/protected/pages/CompositeControl.page b/tests/FunctionalTests/features/protected/pages/CompositeControl.page new file mode 100644 index 00000000..b135445a --- /dev/null +++ b/tests/FunctionalTests/features/protected/pages/CompositeControl.page @@ -0,0 +1,12 @@ + +

Composite Control Test

+
+
+ + +user->TextBox->Text != "" %> > +

Result

+ User: <%= $this->user->TextBox->Text %> Pass: <%= $this->pass->TextBox->Text %> +
+ +
\ No newline at end of file diff --git a/tests/FunctionalTests/features/tests/CompositeControlTestCase.php b/tests/FunctionalTests/features/tests/CompositeControlTestCase.php new file mode 100644 index 00000000..dda3f63b --- /dev/null +++ b/tests/FunctionalTests/features/tests/CompositeControlTestCase.php @@ -0,0 +1,23 @@ +open("features/index.php?page=CompositeControl", ""); + $this->verifyTextPresent("Composite Control Test", ""); + $this->type("{$base}user_textbox", "Hello"); + $this->type("{$base}pass_textbox", "world"); + $this->clickAndWait("//input[@type='submit' and @value='Submit']", ""); + $this->verifyTextPresent("Result", ""); + $this->verifyTextPresent("User: Hello Pass: world", ""); + } + +} + +?> -- cgit v1.2.3