summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2006-04-28 01:22:42 +0000
committerwei <>2006-04-28 01:22:42 +0000
commiteb2a6e9431445b3cb24be4b75f02f07aef70aebc (patch)
treed634891aa58ed491398d8eef5d80fc7f467f1070
parent639a6b1c052f8b3ef1d1063843cae1c88ef4f346 (diff)
New abstract TCompositeControl + FT tests
-rw-r--r--.gitattributes5
-rw-r--r--HISTORY2
-rw-r--r--framework/Web/UI/WebControls/TCompositeControl.php49
-rw-r--r--tests/FunctionalTests/features/protected/application.xml3
-rw-r--r--tests/FunctionalTests/features/protected/controls/LabeledTextBox.tpl2
-rw-r--r--tests/FunctionalTests/features/protected/controls/LabeledTextbox.php19
-rw-r--r--tests/FunctionalTests/features/protected/pages/CompositeControl.page12
-rw-r--r--tests/FunctionalTests/features/tests/CompositeControlTestCase.php23
8 files changed, 114 insertions, 1 deletions
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 @@
+<?php
+/**
+ * TCompositeControl class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 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 <weizhuo[at]gmail[dot]com>
+ * @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 @@
<?xml version="1.0" encoding="utf-8"?>
<application id="FeatureTests" Mode="Debug">
+ <paths>
+ <using namespace="Application.controls.*" />
+ </paths>
<services>
<service id="page" class="TPageService" DefaultPage="FeatureList">
<pages MasterClass="Application.controls.Layout" />
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 @@
+<com:TLabel ID="label" ForControl="textbox" Text="label:" />
+<com:TTextBox ID="textbox" /> \ 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 @@
+<?php
+/*
+ * Created on 28/04/2006
+ */
+
+class LabeledTextBox extends TCompositeControl
+{
+ public function getTextBox()
+ {
+ return $this->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 @@
+<com:TContent ID="Content">
+<h1>Composite Control Test</h1>
+ <com:LabeledTextBox id="user" Label.Text="username:" /><br />
+ <com:LabeledTextBox id="pass" Label.Text="password:" /><br />
+ <com:TButton Text="Submit" />
+
+<com:TPanel Visible=<%= $this->user->TextBox->Text != "" %> >
+<h2>Result</h2>
+ User: <%= $this->user->TextBox->Text %> Pass: <%= $this->pass->TextBox->Text %>
+</com:TPanel>
+
+</com:TContent> \ 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 @@
+<?php
+/*
+ * Created on 28/04/2006
+ */
+
+class CompositeControlTestCase extends SeleniumTestCase
+{
+
+ function test()
+ {
+ $base = "ctl0_Content_";
+ $this->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", "");
+ }
+
+}
+
+?>