diff options
author | ctrlaltca <> | 2012-07-12 11:21:01 +0000 |
---|---|---|
committer | ctrlaltca <> | 2012-07-12 11:21:01 +0000 |
commit | 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch) | |
tree | e08bf04f0823650a231227ac3499121270172a23 /tests | |
parent | 3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff) |
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'tests')
369 files changed, 19158 insertions, 19158 deletions
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.php index e873ae9d..d0b8650e 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveControlExpressionTag.php @@ -1,26 +1,26 @@ -<?php
-
-class ActiveControlExpressionTag extends TPage
-{
- public function button1_clicked($sender, $param)
- {
- $this->subpanel1->Visible = true;
- $data = array('1', 'two');
- $this->repeater1->DataSource = $data;
- $this->repeater1->dataBind();
- }
-
- public function button1_callback($sender, $param)
- {
- $this->panel1->renderControl($param->NewWriter);
- $this->button2->Enabled=true;
- }
-
- public function button2_callback($sender, $param)
- {
- $this->panel2->Visible=true;
- $this->Page->CallbackClient->insertContentAfter('contents', $this->panel2);
- }
-}
-
+<?php + +class ActiveControlExpressionTag extends TPage +{ + public function button1_clicked($sender, $param) + { + $this->subpanel1->Visible = true; + $data = array('1', 'two'); + $this->repeater1->DataSource = $data; + $this->repeater1->dataBind(); + } + + public function button1_callback($sender, $param) + { + $this->panel1->renderControl($param->NewWriter); + $this->button2->Enabled=true; + } + + public function button2_callback($sender, $param) + { + $this->panel2->Visible=true; + $this->Page->CallbackClient->insertContentAfter('contents', $this->panel2); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveControlWithTinyMce.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveControlWithTinyMce.php index a154e0dd..ec9040a1 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveControlWithTinyMce.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveControlWithTinyMce.php @@ -1,11 +1,11 @@ -<?php
-
-class ActiveControlWithTinyMce extends TPage
-{
- function button1_callback($sender, $param)
- {
- $this->label1->Text = $this->text1->SafeText;
- }
-}
-
+<?php + +class ActiveControlWithTinyMce extends TPage +{ + function button1_callback($sender, $param) + { + $this->label1->Text = $this->text1->SafeText; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.php index eced2457..44c20ef6 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveImageButtonTest.php @@ -1,31 +1,31 @@ -<?php
-
-class ActiveImageButtonTest extends TPage
-{
- function change_text($sender, $param)
- {
- $this->image1->AlternateText = "Muahahahah";
- }
-
- function change_image($sender, $param)
- {
- $this->image1->ImageUrl = $sender->CustomData;
- }
-
- function change_align($sender, $param)
- {
- $this->image1->ImageAlign="absbottom";
- }
-
- function change_description($sender, $param)
- {
- $this->image1->DescriptionUrl = "maahahhaa";
- }
-
- function image1_clicked($sender, $param)
- {
- $this->label1->Text = "Image clicked at x={$param->x}, y={$param->y}";
- }
-}
-
+<?php + +class ActiveImageButtonTest extends TPage +{ + function change_text($sender, $param) + { + $this->image1->AlternateText = "Muahahahah"; + } + + function change_image($sender, $param) + { + $this->image1->ImageUrl = $sender->CustomData; + } + + function change_align($sender, $param) + { + $this->image1->ImageAlign="absbottom"; + } + + function change_description($sender, $param) + { + $this->image1->DescriptionUrl = "maahahhaa"; + } + + function image1_clicked($sender, $param) + { + $this->label1->Text = "Image clicked at x={$param->x}, y={$param->y}"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.php index 4fc3a23e..74ce985c 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveLinkButtonTest.php @@ -1,16 +1,16 @@ -<?php
-
-class ActiveLinkButtonTest extends TPage
-{
- function button2_onclick($sender, $param)
- {
- $this->label1->Text = "Button 1 was clicked ";
- }
-
- function button2_oncallback($sender, $param)
- {
- $this->label1->Text .= "using callback!";
- }
-}
-
+<?php + +class ActiveLinkButtonTest extends TPage +{ + function button2_onclick($sender, $param) + { + $this->label1->Text = "Button 1 was clicked "; + } + + function button2_oncallback($sender, $param) + { + $this->label1->Text .= "using callback!"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.php index d2991653..eaa61fd6 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxMasterTest.php @@ -1,47 +1,47 @@ -<?php
-
-class ActiveListBoxMasterTest extends TPage
-{
- function list1_callback($sender, $param)
- {
- $values = $sender->getSelectedValues();
- $this->label1->setText("Selection: ".implode(', ', $values));
- }
-
- function select_index_123()
- {
- $this->list1->setSelectedIndices(array(1,2,3));
- }
-
- function select_index_4()
- {
- $this->list1->setSelectedIndex(4);
- }
-
- function clear_selections()
- {
- $this->list1->clearSelection();
- }
-
- function select_value_1()
- {
- $this->list1->setSelectedValue("value 1");
- }
-
- function select_values_25()
- {
- $this->list1->setSelectedValues(array('value 2', 'value 5'));
- }
-
- function change_to_multiple()
- {
- $this->list1->SelectionMode="Multiple";
- }
-
- function change_to_single()
- {
- $this->list1->SelectionMode="Single";
- }
-}
-
+<?php + +class ActiveListBoxMasterTest extends TPage +{ + function list1_callback($sender, $param) + { + $values = $sender->getSelectedValues(); + $this->label1->setText("Selection: ".implode(', ', $values)); + } + + function select_index_123() + { + $this->list1->setSelectedIndices(array(1,2,3)); + } + + function select_index_4() + { + $this->list1->setSelectedIndex(4); + } + + function clear_selections() + { + $this->list1->clearSelection(); + } + + function select_value_1() + { + $this->list1->setSelectedValue("value 1"); + } + + function select_values_25() + { + $this->list1->setSelectedValues(array('value 2', 'value 5')); + } + + function change_to_multiple() + { + $this->list1->SelectionMode="Multiple"; + } + + function change_to_single() + { + $this->list1->SelectionMode="Single"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.php index 942bb1a0..a80dbc1c 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveListBoxTest.php @@ -1,47 +1,47 @@ -<?php
-
-class ActiveListBoxTest extends TPage
-{
- function list1_callback($sender, $param)
- {
- $values = $sender->getSelectedValues();
- $this->label1->setText("Selection: ".implode(', ', $values));
- }
-
- function select_index_123()
- {
- $this->list1->setSelectedIndices(array(1,2,3));
- }
-
- function select_index_4()
- {
- $this->list1->setSelectedIndex(4);
- }
-
- function clear_selections()
- {
- $this->list1->clearSelection();
- }
-
- function select_value_1()
- {
- $this->list1->setSelectedValue("value 1");
- }
-
- function select_values_25()
- {
- $this->list1->setSelectedValues(array('value 2', 'value 5'));
- }
-
- function change_to_multiple()
- {
- $this->list1->SelectionMode="Multiple";
- }
-
- function change_to_single()
- {
- $this->list1->SelectionMode="Single";
- }
-}
-
+<?php + +class ActiveListBoxTest extends TPage +{ + function list1_callback($sender, $param) + { + $values = $sender->getSelectedValues(); + $this->label1->setText("Selection: ".implode(', ', $values)); + } + + function select_index_123() + { + $this->list1->setSelectedIndices(array(1,2,3)); + } + + function select_index_4() + { + $this->list1->setSelectedIndex(4); + } + + function clear_selections() + { + $this->list1->clearSelection(); + } + + function select_value_1() + { + $this->list1->setSelectedValue("value 1"); + } + + function select_values_25() + { + $this->list1->setSelectedValues(array('value 2', 'value 5')); + } + + function change_to_multiple() + { + $this->list1->SelectionMode="Multiple"; + } + + function change_to_single() + { + $this->list1->SelectionMode="Single"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActivePanelVisibleTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActivePanelVisibleTest.php index e922319e..aaf43abc 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActivePanelVisibleTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActivePanelVisibleTest.php @@ -1,18 +1,18 @@ -<?php
-
-class ActivePanelVisibleTest extends TPage
-{
- public function showA()
- {
- $this->pnlB->Visible = false;
- $this->pnlA->Visible = true;
- }
-
- public function showB()
- {
- $this->pnlB->Visible = true;
- $this->pnlA->Visible = false;
- }
-}
-
+<?php + +class ActivePanelVisibleTest extends TPage +{ + public function showA() + { + $this->pnlB->Visible = false; + $this->pnlA->Visible = true; + } + + public function showB() + { + $this->pnlB->Visible = true; + $this->pnlA->Visible = false; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.php index ee805e11..22d2c79c 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.php @@ -1,28 +1,28 @@ -<?php
-
-class ActiveRadioButtonListTest extends TPage
-{
- function list1_callback($sender, $param)
- {
- $values = $sender->getSelectedValues();
- var_dump($values);
- $this->label1->setText("Selection: ".implode(', ', $values));
- }
-
- function select_index_4()
- {
- $this->list1->setSelectedIndex(4);
- }
-
- function clear_selections()
- {
- $this->list1->clearSelection();
- }
-
- function select_value_1()
- {
- $this->list1->setSelectedValue("value 1");
- }
-}
-
+<?php + +class ActiveRadioButtonListTest extends TPage +{ + function list1_callback($sender, $param) + { + $values = $sender->getSelectedValues(); + var_dump($values); + $this->label1->setText("Selection: ".implode(', ', $values)); + } + + function select_index_4() + { + $this->list1->setSelectedIndex(4); + } + + function clear_selections() + { + $this->list1->clearSelection(); + } + + function select_value_1() + { + $this->list1->setSelectedValue("value 1"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.php index 64e7d92e..fce204d1 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.php @@ -1,34 +1,34 @@ -<?php
-
-class ActiveRadioButtonTest extends TPage
-{
- function change_radio1_text()
- {
- $this->radio1->Text = "Hello Radio Button 1";
- }
-
- function change_radio1_checked()
- {
- $this->radio1->Checked = !$this->radio1->Checked;
- }
-
- function change_radio2_text()
- {
- $this->radio2->Text = "Radio Button 2 World";
- }
-
- function change_radio2_checked()
- {
- $this->radio2->Checked = !$this->radio2->Checked;
- }
-
- function radiobutton_requested($sender, $param)
- {
- $this->label1->Text = "Label 1:".$sender->Text.
- ($sender->checked ? ' Checked ' : ' Not Checked');
- }
-
-
-}
-
+<?php + +class ActiveRadioButtonTest extends TPage +{ + function change_radio1_text() + { + $this->radio1->Text = "Hello Radio Button 1"; + } + + function change_radio1_checked() + { + $this->radio1->Checked = !$this->radio1->Checked; + } + + function change_radio2_text() + { + $this->radio2->Text = "Radio Button 2 World"; + } + + function change_radio2_checked() + { + $this->radio2->Checked = !$this->radio2->Checked; + } + + function radiobutton_requested($sender, $param) + { + $this->label1->Text = "Label 1:".$sender->Text. + ($sender->checked ? ' Checked ' : ' Not Checked'); + } + + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListAllowInputTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListAllowInputTest.php index c825f3f8..50b9817d 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListAllowInputTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListAllowInputTest.php @@ -1,27 +1,27 @@ -<?php
-/**
- * TRatingListTest.php
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Creation Date: Oct 13, 2008
- */
-
-/**
- * TRatingListTest.php class
- *
- *
- *
- * Properties
- * -
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Modified Date: Oct 13, 2008
- *
- * Modifications:
- */
-class ActiveRatingListAllowInputTest extends TPage{
- public function ratingChanged($sender, $param){
- $this->Status->setText($sender->getRating().' : '.$sender->getSelectedValue());
- }
-}
+<?php +/** + * TRatingListTest.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Creation Date: Oct 13, 2008 + */ + +/** + * TRatingListTest.php class + * + * + * + * Properties + * - + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Modified Date: Oct 13, 2008 + * + * Modifications: + */ +class ActiveRatingListAllowInputTest extends TPage{ + public function ratingChanged($sender, $param){ + $this->Status->setText($sender->getRating().' : '.$sender->getSelectedValue()); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListAutoPostBackTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListAutoPostBackTest.php index 4b087b76..c094a34b 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListAutoPostBackTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListAutoPostBackTest.php @@ -1,27 +1,27 @@ -<?php
-/**
- * TRatingListTest.php
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Creation Date: Oct 13, 2008
- */
-
-/**
- * TRatingListTest.php class
- *
- *
- *
- * Properties
- * -
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Modified Date: Oct 13, 2008
- *
- * Modifications:
- */
-class ActiveRatingListAutoPostBackTest extends TPage{
- public function ratingChanged($sender, $param){
- $this->Status->setText($sender->getRating().' : '.$sender->getSelectedValue());
- }
-}
+<?php +/** + * TRatingListTest.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Creation Date: Oct 13, 2008 + */ + +/** + * TRatingListTest.php class + * + * + * + * Properties + * - + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Modified Date: Oct 13, 2008 + * + * Modifications: + */ +class ActiveRatingListAutoPostBackTest extends TPage{ + public function ratingChanged($sender, $param){ + $this->Status->setText($sender->getRating().' : '.$sender->getSelectedValue()); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListCheckBoxesTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListCheckBoxesTest.php index 5c6dfa70..0ba260d4 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListCheckBoxesTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListCheckBoxesTest.php @@ -1,23 +1,23 @@ -<?php
-/**
- * TRatingListTest.php
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Creation Date: Oct 13, 2008
- */
-
-/**
- * TRatingListTest.php class
- *
- *
- *
- * Properties
- * -
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Modified Date: Oct 13, 2008
- *
- * Modifications:
- */
-class ActiveRatingListCheckBoxesTest extends TPage{ }
+<?php +/** + * TRatingListTest.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Creation Date: Oct 13, 2008 + */ + +/** + * TRatingListTest.php class + * + * + * + * Properties + * - + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Modified Date: Oct 13, 2008 + * + * Modifications: + */ +class ActiveRatingListCheckBoxesTest extends TPage{ } ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListEnabledTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListEnabledTest.php index 0cac7418..fde87812 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListEnabledTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListEnabledTest.php @@ -1,37 +1,37 @@ -<?php
-/**
- * TRatingListTest.php
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Creation Date: Oct 13, 2008
- */
-
-/**
- * TRatingListTest.php class
- *
- *
- *
- * Properties
- * -
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Modified Date: Oct 13, 2008
- *
- * Modifications:
- */
-class ActiveRatingListEnabledTest extends TPage{
- public function ratingChanged($sender, $param){
- $this->Status->setText($sender->getRating().' : '.$sender->getSelectedValue());
- }
-
- public function enable($sender, $param){
- $this->RatingList->setEnabled(true);
- $this->Status->setText('Enabled=true');
- }
-
- public function disable($sender, $param){
- $this->RatingList->setEnabled(false);
- $this->Status->setText('Enabled=false');
- }
-}
+<?php +/** + * TRatingListTest.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Creation Date: Oct 13, 2008 + */ + +/** + * TRatingListTest.php class + * + * + * + * Properties + * - + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Modified Date: Oct 13, 2008 + * + * Modifications: + */ +class ActiveRatingListEnabledTest extends TPage{ + public function ratingChanged($sender, $param){ + $this->Status->setText($sender->getRating().' : '.$sender->getSelectedValue()); + } + + public function enable($sender, $param){ + $this->RatingList->setEnabled(true); + $this->Status->setText('Enabled=true'); + } + + public function disable($sender, $param){ + $this->RatingList->setEnabled(false); + $this->Status->setText('Enabled=false'); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListHoverCaptionTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListHoverCaptionTest.php index 06d82d39..c8281256 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListHoverCaptionTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListHoverCaptionTest.php @@ -1,27 +1,27 @@ -<?php
-/**
- * TRatingListTest.php
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Creation Date: Oct 13, 2008
- */
-
-/**
- * TRatingListTest.php class
- *
- *
- *
- * Properties
- * -
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Modified Date: Oct 13, 2008
- *
- * Modifications:
- */
-class ActiveRatingListHoverCaptionTest extends TPage{
- public function ratingChanged($sender, $param){
- $sender->setCaption($sender->getRating().' : '.$sender->getSelectedValue());
- }
-}
+<?php +/** + * TRatingListTest.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Creation Date: Oct 13, 2008 + */ + +/** + * TRatingListTest.php class + * + * + * + * Properties + * - + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Modified Date: Oct 13, 2008 + * + * Modifications: + */ +class ActiveRatingListHoverCaptionTest extends TPage{ + public function ratingChanged($sender, $param){ + $sender->setCaption($sender->getRating().' : '.$sender->getSelectedValue()); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListRatingTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListRatingTest.php index fe5c8404..97369a8d 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListRatingTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListRatingTest.php @@ -1,32 +1,32 @@ -<?php
-/**
- * TRatingListTest.php
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Creation Date: Oct 13, 2008
- */
-
-/**
- * TRatingListTest.php class
- *
- *
- *
- * Properties
- * -
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Modified Date: Oct 13, 2008
- *
- * Modifications:
- */
-class ActiveRatingListRatingTest extends TPage{
- public function ratingChanged($sender, $param){
- $this->Status->setText('Rating: '.$sender->getRating());
- }
-
- public function setRating($sender, $param){
- $this->RatingList->setRating(3);
- $this->ratingChanged($this->RatingList, null);
- }
-}
+<?php +/** + * TRatingListTest.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Creation Date: Oct 13, 2008 + */ + +/** + * TRatingListTest.php class + * + * + * + * Properties + * - + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Modified Date: Oct 13, 2008 + * + * Modifications: + */ +class ActiveRatingListRatingTest extends TPage{ + public function ratingChanged($sender, $param){ + $this->Status->setText('Rating: '.$sender->getRating()); + } + + public function setRating($sender, $param){ + $this->RatingList->setRating(3); + $this->ratingChanged($this->RatingList, null); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListReadOnlyTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListReadOnlyTest.php index 070fd13f..722f60ea 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListReadOnlyTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListReadOnlyTest.php @@ -1,38 +1,38 @@ -<?php
-/**
- * TRatingListTest.php
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Creation Date: Oct 13, 2008
- */
-
-/**
- * TRatingListTest.php class
- *
- *
- *
- * Properties
- * -
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Modified Date: Oct 13, 2008
- *
- * Modifications:
- */
-class ActiveRatingListReadOnlyTest extends TPage{
- public function ratingChanged($sender, $param){
- $this->Status->setText($sender->getRating().' : '.$sender->getSelectedValue());
- }
-
- public function readOnly($sender, $param){
- $this->RatingList->setReadOnly(true);
- $this->Status->setText('ReadOnly=true');
- }
-
- public function writable($sender, $param){
- $this->RatingList->setReadOnly(false);
- $this->Status->setText('ReadOnly=false');
- }
-
-}
+<?php +/** + * TRatingListTest.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Creation Date: Oct 13, 2008 + */ + +/** + * TRatingListTest.php class + * + * + * + * Properties + * - + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Modified Date: Oct 13, 2008 + * + * Modifications: + */ +class ActiveRatingListReadOnlyTest extends TPage{ + public function ratingChanged($sender, $param){ + $this->Status->setText($sender->getRating().' : '.$sender->getSelectedValue()); + } + + public function readOnly($sender, $param){ + $this->RatingList->setReadOnly(true); + $this->Status->setText('ReadOnly=true'); + } + + public function writable($sender, $param){ + $this->RatingList->setReadOnly(false); + $this->Status->setText('ReadOnly=false'); + } + +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListSelectedIndexTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListSelectedIndexTest.php index 4dbc6949..f0d8d2ef 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListSelectedIndexTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRatingListSelectedIndexTest.php @@ -1,32 +1,32 @@ -<?php
-/**
- * TRatingListTest.php
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Creation Date: Oct 13, 2008
- */
-
-/**
- * TRatingListTest.php class
- *
- *
- *
- * Properties
- * -
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Modified Date: Oct 13, 2008
- *
- * Modifications:
- */
-class ActiveRatingListSelectedIndexTest extends TPage{
- public function ratingChanged($sender, $param){
- $this->Status->setText('SelectedIndex: '.$sender->getSelectedIndex());
- }
-
- public function setSelectedIndex($sender, $param){
- $this->RatingList->setSelectedIndex(5);
- $this->ratingChanged($this->RatingList, null);
- }
-}
+<?php +/** + * TRatingListTest.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Creation Date: Oct 13, 2008 + */ + +/** + * TRatingListTest.php class + * + * + * + * Properties + * - + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Modified Date: Oct 13, 2008 + * + * Modifications: + */ +class ActiveRatingListSelectedIndexTest extends TPage{ + public function ratingChanged($sender, $param){ + $this->Status->setText('SelectedIndex: '.$sender->getSelectedIndex()); + } + + public function setSelectedIndex($sender, $param){ + $this->RatingList->setSelectedIndex(5); + $this->ratingChanged($this->RatingList, null); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.php index 65958eeb..a3c714fe 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.php @@ -1,12 +1,12 @@ -<?php
-
-class ActiveRedirectionTest extends TPage
-{
- function button_clicked($sender, $param)
- {
- $default=$this->Service->constructUrl($this->Service->DefaultPage);
- $this->Response->redirect($default);
- }
-}
-
+<?php + +class ActiveRedirectionTest extends TPage +{ + function button_clicked($sender, $param) + { + $default=$this->Service->constructUrl($this->Service->DefaultPage); + $this->Response->redirect($default); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/Callback.php b/tests/FunctionalTests/active-controls/protected/pages/Callback.php index d19d92aa..00357f1e 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/Callback.php +++ b/tests/FunctionalTests/active-controls/protected/pages/Callback.php @@ -1,13 +1,13 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Callback extends TPage
-{
- function callback1_Requested()
- {
- var_dump("ok!");
- }
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); + +class Callback extends TPage +{ + function callback1_Requested() + { + var_dump("ok!"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/CallbackCustomValidatorTest.php b/tests/FunctionalTests/active-controls/protected/pages/CallbackCustomValidatorTest.php index bf8d730b..319cc354 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/CallbackCustomValidatorTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/CallbackCustomValidatorTest.php @@ -1,11 +1,11 @@ -<?php
-
-class CallbackCustomValidatorTest extends TPage
-{
- function validate_text1($sender, $param)
- {
- $param->IsValid = $param->Value == 'Prado';
- }
-}
-
+<?php + +class CallbackCustomValidatorTest extends TPage +{ + function validate_text1($sender, $param) + { + $param->IsValid = $param->Value == 'Prado'; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ClientSideDispatch.php b/tests/FunctionalTests/active-controls/protected/pages/ClientSideDispatch.php index 84099114..e747bb63 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ClientSideDispatch.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ClientSideDispatch.php @@ -1,17 +1,17 @@ -<?php
-
-class ClientSideDispatch extends TPage
-{
-
- function method1($sender, $param)
- {
- $this->status1->Text = "Method 1 callback with parameter: {$param->CallbackParameter}";
- }
-
- function method2($sender, $param)
- {
- $this->status2->Text = "Method 2 callback";
- }
-}
-
+<?php + +class ClientSideDispatch extends TPage +{ + + function method1($sender, $param) + { + $this->status1->Text = "Method 1 callback with parameter: {$param->CallbackParameter}"; + } + + function method2($sender, $param) + { + $this->status2->Text = "Method 2 callback"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateComponent.php b/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateComponent.php index 7da2834e..8a3e6c9f 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateComponent.php +++ b/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateComponent.php @@ -1,11 +1,11 @@ -<?php
-
-class CustomTemplateComponent extends TTemplateControl
-{
- public function suboncallback ($sender, $param)
- {
- $sender->setText("Foo");
- }
-}
-
+<?php + +class CustomTemplateComponent extends TTemplateControl +{ + public function suboncallback ($sender, $param) + { + $sender->setText("Foo"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.php b/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.php index 18005a2b..a1d55adc 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/CustomTemplateControlTest.php @@ -1,27 +1,27 @@ -<?php
-
-class CustomTemplateControlTest extends TPage
-{
- function button2_onclick($sender, $param)
- {
-
- $this->label1->Text = "Button 1 was clicked ";
- $this->label1->Text .= $this->foo->Text;
-
- $x=Prado::createComponent('Application.pages.CustomTemplateComponent');
-
- $this->placeholder->getControls()->add($x);
- $this->placeholder->dataBind();
- }
-
- function button2_callback($sender, $param)
- {
- $this->placeholder->render($param->NewWriter);
-
- $this->label1->Text .= " using callback!";
- $this->label1->Text .= "... and this is the textbox text: ". $this->foo->Text;
- }
-
-}
-
+<?php + +class CustomTemplateControlTest extends TPage +{ + function button2_onclick($sender, $param) + { + + $this->label1->Text = "Button 1 was clicked "; + $this->label1->Text .= $this->foo->Text; + + $x=Prado::createComponent('Application.pages.CustomTemplateComponent'); + + $this->placeholder->getControls()->add($x); + $this->placeholder->dataBind(); + } + + function button2_callback($sender, $param) + { + $this->placeholder->render($param->NewWriter); + + $this->label1->Text .= " using callback!"; + $this->label1->Text .= "... and this is the textbox text: ". $this->foo->Text; + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.php b/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.php index 54c99c64..edc68ae4 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.php +++ b/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.php @@ -1,37 +1,37 @@ -<?php
-
-class CustomValidatorByPass extends TPage
-{
- public function onLoad($param)
- {
-
- parent::onLoad($param);
-
- $Client = $this->validator2->getActiveControl()->getClientSide();
-
- $Client->setOnLoading('$(\'loginLoader\').show();');
- $Client->setOnComplete('$(\'loginLoader\').hide();');
-
- //$Client->setOnValidationError('alert(\'Authentication Failed\');');
- //$Client->setOnValidationSuccess('new Effect.Fade(\'loginBox\')');
-
- }
-
- public function validateUser($sender,$param)
- {
- $param->IsValid = $this->Password->Text=='test';
- }
-
- public function doLogin($sender,$param)
- {
-
- /* This isnt even getting called */
- if($this->Page->IsValid)
- {
- // Re-Render the active panel
- }
-
- }
-}
-
+<?php + +class CustomValidatorByPass extends TPage +{ + public function onLoad($param) + { + + parent::onLoad($param); + + $Client = $this->validator2->getActiveControl()->getClientSide(); + + $Client->setOnLoading('$(\'loginLoader\').show();'); + $Client->setOnComplete('$(\'loginLoader\').hide();'); + + //$Client->setOnValidationError('alert(\'Authentication Failed\');'); + //$Client->setOnValidationSuccess('new Effect.Fade(\'loginBox\')'); + + } + + public function validateUser($sender,$param) + { + $param->IsValid = $this->Password->Text=='test'; + } + + public function doLogin($sender,$param) + { + + /* This isnt even getting called */ + if($this->Page->IsValid) + { + // Re-Render the active panel + } + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/DMessagesPanel.php b/tests/FunctionalTests/active-controls/protected/pages/DMessagesPanel.php index d318660d..ce3d1bc0 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/DMessagesPanel.php +++ b/tests/FunctionalTests/active-controls/protected/pages/DMessagesPanel.php @@ -1,63 +1,63 @@ -<?php
-
-class DMessagesPanel extends TTemplateControl
-{
- private $_panelCssClass = '';
-
- public function onInit($param)
- {
- parent::onInit($param);
- $this->MessagesPanelEffect->Text = "";
- }
-
- public function setMessage($value)
- {
- $this->Message->Text = $value;
- if ($value != '')
- $this->setVisible(true);
- else
- $this->setVisible(false);
- }
-
- public function setVisible($value)
- {
- $this->ensureChildControls();
- if ($value === true) {
- echo "set visible";
- $this->MessagesPanel->Visible = true;
- $this->Message->Visible = true;
- $this->setEffect(null);
- } else {
- $this->MessagesPanel->Visible = false;
- }
- }
-
- public function setEffect($effect = null)
- {
- if ($effect !== null) {
- $text = "<script type=\"text/javascript\" language=\"javascript\">\r\n";
- $text .= "// <![CDATA[\r\n";
- //$text .= "new Effect.$effect(\"" . $this->Page->DMessagesPanel->MessagesPanel->ClientID . "\");\r\n";
- $text .= "new Effect.$effect(\"" . $this->ClientID . "\");\r\n";
- $text .= "// ]]>\r\n";
- $text .= "</script>";
- $this->MessagesPanelEffect->Text = $text;
- } else {
- $this->MessagesPanelEffect->Text = '';
- }
- }
-
- public function setPanelCssClass($value)
- {
- $this->ensureChildControls();
- $this->MessagesPanel->CssClass = $value;
- }
-
- public function setMessageCssClass($value)
- {
- $this->ensureChildControls();
- $this->Message->CssClass = $value;
- }
-}
-
+<?php + +class DMessagesPanel extends TTemplateControl +{ + private $_panelCssClass = ''; + + public function onInit($param) + { + parent::onInit($param); + $this->MessagesPanelEffect->Text = ""; + } + + public function setMessage($value) + { + $this->Message->Text = $value; + if ($value != '') + $this->setVisible(true); + else + $this->setVisible(false); + } + + public function setVisible($value) + { + $this->ensureChildControls(); + if ($value === true) { + echo "set visible"; + $this->MessagesPanel->Visible = true; + $this->Message->Visible = true; + $this->setEffect(null); + } else { + $this->MessagesPanel->Visible = false; + } + } + + public function setEffect($effect = null) + { + if ($effect !== null) { + $text = "<script type=\"text/javascript\" language=\"javascript\">\r\n"; + $text .= "// <![CDATA[\r\n"; + //$text .= "new Effect.$effect(\"" . $this->Page->DMessagesPanel->MessagesPanel->ClientID . "\");\r\n"; + $text .= "new Effect.$effect(\"" . $this->ClientID . "\");\r\n"; + $text .= "// ]]>\r\n"; + $text .= "</script>"; + $this->MessagesPanelEffect->Text = $text; + } else { + $this->MessagesPanelEffect->Text = ''; + } + } + + public function setPanelCssClass($value) + { + $this->ensureChildControls(); + $this->MessagesPanel->CssClass = $value; + } + + public function setMessageCssClass($value) + { + $this->ensureChildControls(); + $this->Message->CssClass = $value; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/DatePickerInCallback.php b/tests/FunctionalTests/active-controls/protected/pages/DatePickerInCallback.php index 94a4ec25..05fd323e 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/DatePickerInCallback.php +++ b/tests/FunctionalTests/active-controls/protected/pages/DatePickerInCallback.php @@ -1,17 +1,17 @@ -<?php
-
-class DatePickerInCallback extends TPage {
-
- public function onLoad($param){
- parent::onLoad($param);
- if(!$this->IsPostBack)
- $this->datepicker->setTimeStamp(time());
- }
-
- public function testDatePicker($sender, $param){
- $this->status->Text = $this->datepicker->getTimestamp()." ".$this->datepicker->getText();
- }
-
- }
-
+<?php + +class DatePickerInCallback extends TPage { + + public function onLoad($param){ + parent::onLoad($param); + if(!$this->IsPostBack) + $this->datepicker->setTimeStamp(time()); + } + + public function testDatePicker($sender, $param){ + $this->status->Text = $this->datepicker->getTimestamp()." ".$this->datepicker->getText(); + } + + } + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/DelayedCallback.php b/tests/FunctionalTests/active-controls/protected/pages/DelayedCallback.php index 7e9195dc..1785bd34 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/DelayedCallback.php +++ b/tests/FunctionalTests/active-controls/protected/pages/DelayedCallback.php @@ -1,21 +1,21 @@ -<?php
-
-class DelayedCallback extends TPage
-{
- function callback1($sender, $param)
- {
- $ms = 4;
- sleep($ms);
- $this->status->Text="Callback 1 returned after {$ms}s";
- }
-
- function callback2($sender, $param)
- {
- $ms = 2;
- sleep($ms);
- $this->status->Text="Callback 2 delayed {$ms}s";
- }
-
-}
-
+<?php + +class DelayedCallback extends TPage +{ + function callback1($sender, $param) + { + $ms = 4; + sleep($ms); + $this->status->Text="Callback 1 returned after {$ms}s"; + } + + function callback2($sender, $param) + { + $ms = 2; + sleep($ms); + $this->status->Text="Callback 2 delayed {$ms}s"; + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/DisplayStyleTest.php b/tests/FunctionalTests/active-controls/protected/pages/DisplayStyleTest.php index a49a8bfa..7c791564 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/DisplayStyleTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/DisplayStyleTest.php @@ -1,26 +1,26 @@ -<?php
-
-class DisplayStyleTest extends TPage
-{
- function display_button1()
- {
- $this->button1->Display="Dynamic";
- }
-
- function hide_button1()
- {
- $this->button1->Display="None";
- }
-
- function show_button2()
- {
- $this->button2->Display="Fixed";
- }
-
- function hide_button2()
- {
- $this->button2->Display="Hidden";
- }
-}
-
+<?php + +class DisplayStyleTest extends TPage +{ + function display_button1() + { + $this->button1->Display="Dynamic"; + } + + function hide_button1() + { + $this->button1->Display="None"; + } + + function show_button2() + { + $this->button2->Display="Fixed"; + } + + function hide_button2() + { + $this->button2->Display="Hidden"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/DynamicRepeaterDataTest.php b/tests/FunctionalTests/active-controls/protected/pages/DynamicRepeaterDataTest.php index 729a87dc..0df32f6a 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/DynamicRepeaterDataTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/DynamicRepeaterDataTest.php @@ -1,23 +1,23 @@ -<?php
-
-class DynamicRepeaterDataTest extends TPage
-{
- function button_clicked($sender, $param)
- {
- $this->_repeater->dataSource = array(1,2,3);
- $this->_repeater->dataBind();
- }
-
- function button_callback($sender, $param)
- {
- $this->panel1->render($param->NewWriter);
- }
-
- function rpt_button_clicked($sender, $param)
- {
- $item = $sender->NamingContainer;
- $item->label1->Text = $sender->Text;
- }
-}
-
+<?php + +class DynamicRepeaterDataTest extends TPage +{ + function button_clicked($sender, $param) + { + $this->_repeater->dataSource = array(1,2,3); + $this->_repeater->dataBind(); + } + + function button_callback($sender, $param) + { + $this->panel1->render($param->NewWriter); + } + + function rpt_button_clicked($sender, $param) + { + $item = $sender->NamingContainer; + $item->label1->Text = $sender->Text; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/EventTriggeredCallback.php b/tests/FunctionalTests/active-controls/protected/pages/EventTriggeredCallback.php index dc47d867..bcc53389 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/EventTriggeredCallback.php +++ b/tests/FunctionalTests/active-controls/protected/pages/EventTriggeredCallback.php @@ -1,21 +1,21 @@ -<?php
-
-class EventTriggeredCallback extends TPage
-{
- function text1_focused($sender, $param)
- {
- $this->label1->Text = 'text 1 focused';
- }
-
- function panel1_onmouseover($sender, $param)
- {
- $this->label1->Text = 'panel 1 on mouse over '.time();
- }
-
- function button1_clicked($sender, $param)
- {
- $this->label1->Text = 'button 1 clicked';
- }
-}
-
+<?php + +class EventTriggeredCallback extends TPage +{ + function text1_focused($sender, $param) + { + $this->label1->Text = 'text 1 focused'; + } + + function panel1_onmouseover($sender, $param) + { + $this->label1->Text = 'panel 1 on mouse over '.time(); + } + + function button1_clicked($sender, $param) + { + $this->label1->Text = 'button 1 clicked'; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/GerTurno2.php b/tests/FunctionalTests/active-controls/protected/pages/GerTurno2.php index d31c10f6..e2ffbf07 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/GerTurno2.php +++ b/tests/FunctionalTests/active-controls/protected/pages/GerTurno2.php @@ -1,53 +1,53 @@ -<?php
-
-class GerTurno2 extends TPage {
-
- private $_turnos = null;
-
-
- public function onLoad($param) {
- parent::onLoad($param);
-
- $this->loadTurnoOptions();
-
- if (!$this->IsPostBack) {
- $this->ativaModoEdicao();
- }
- }
-
-
- protected function loadTurnoOptions()
- {
- $this->DDropTurno->DataTextField="descricao";
- $this->DDropTurno->DataValueField="id";
- $this->_turnos = array(
- array('id' => 1, 'codigo'=>'test 1', 'descricao' => 'hello 1'),
- array('id' => 2, 'codigo'=>'test 2', 'descricao' => 'hello 2')
- );
- $this->DDropTurno->setDataSource($this->_turnos);
- $this->DDropTurno->dataBind();
- }
-
-
- protected function ativaModoEdicao() {
- $this->loadDadosTurno($this->DDropTurno->getSelectedValue());
- }
-
-
- protected function loadDadosTurno($id) {
- foreach ($this->_turnos as $key => $tur) {
- if ($tur['id'] == $id) {
- $this->Codigo->setText($tur['codigo']);
- $this->Descricao->setText($tur['descricao']);
- }
- }
- }
-
-
- public function trocaTurno($sender,$param) {
- $this->loadDadosTurno($sender->getSelectedValue());
- }
-
-}
-
+<?php + +class GerTurno2 extends TPage { + + private $_turnos = null; + + + public function onLoad($param) { + parent::onLoad($param); + + $this->loadTurnoOptions(); + + if (!$this->IsPostBack) { + $this->ativaModoEdicao(); + } + } + + + protected function loadTurnoOptions() + { + $this->DDropTurno->DataTextField="descricao"; + $this->DDropTurno->DataValueField="id"; + $this->_turnos = array( + array('id' => 1, 'codigo'=>'test 1', 'descricao' => 'hello 1'), + array('id' => 2, 'codigo'=>'test 2', 'descricao' => 'hello 2') + ); + $this->DDropTurno->setDataSource($this->_turnos); + $this->DDropTurno->dataBind(); + } + + + protected function ativaModoEdicao() { + $this->loadDadosTurno($this->DDropTurno->getSelectedValue()); + } + + + protected function loadDadosTurno($id) { + foreach ($this->_turnos as $key => $tur) { + if ($tur['id'] == $id) { + $this->Codigo->setText($tur['codigo']); + $this->Descricao->setText($tur['descricao']); + } + } + } + + + public function trocaTurno($sender,$param) { + $this->loadDadosTurno($sender->getSelectedValue()); + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/Home.php b/tests/FunctionalTests/active-controls/protected/pages/Home.php index 22b6528a..3dfb4bb0 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/Home.php +++ b/tests/FunctionalTests/active-controls/protected/pages/Home.php @@ -1,11 +1,11 @@ -<?php
-
-class Home extends TPage
-{
- public function btnTest_OnCallback($sender,$param)
- {
- $this->lblTest->Text = "Testing";
- }
-}
-
+<?php + +class Home extends TPage +{ + public function btnTest_OnCallback($sender,$param) + { + $this->lblTest->Text = "Testing"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/InPlaceWithValidator.php b/tests/FunctionalTests/active-controls/protected/pages/InPlaceWithValidator.php index e69ffdf2..c58a006a 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/InPlaceWithValidator.php +++ b/tests/FunctionalTests/active-controls/protected/pages/InPlaceWithValidator.php @@ -1,13 +1,13 @@ -<?php
-
-class InPlaceWithValidator extends TPage
-{
- function button_valid($sender, $param){
-
- $this->status->Text = "Status: ". $this->Firstname->Text.".".$this->Lastname->Text;
-
- }
-
-}
-
+<?php + +class InPlaceWithValidator extends TPage +{ + function button_valid($sender, $param){ + + $this->status->Text = "Status: ". $this->Firstname->Text.".".$this->Lastname->Text; + + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.php b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.php index 1102ffb2..51e56d48 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.php @@ -1,22 +1,22 @@ -<?php
-
-class LargePageStateTest extends TPage
-{
- function onLoad($param)
- {
- parent::onLoad($param);
- for($i=0;$i<100;$i++) //may try 10000, but may crash PHP.
- {
- $label = new TLabel();
- $label->Text=" this is a very long label with some text $i:";
- $this->Panel1->Controls[] = $label;
- }
- }
-
- function button_clicked($sender, $param)
- {
- $this->status->Text .= ' Callback Clicked... ';
- }
-}
-
+<?php + +class LargePageStateTest extends TPage +{ + function onLoad($param) + { + parent::onLoad($param); + for($i=0;$i<100;$i++) //may try 10000, but may crash PHP. + { + $label = new TLabel(); + $label->Text=" this is a very long label with some text $i:"; + $this->Panel1->Controls[] = $label; + } + } + + function button_clicked($sender, $param) + { + $this->status->Text .= ' Callback Clicked... '; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.php b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.php index 3c3038c2..56f9c68f 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.php +++ b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.php @@ -1,22 +1,22 @@ -<?php
-
-class LargePageStateTest2 extends TPage
-{
- function onLoad($param)
- {
- parent::onLoad($param);
- for($i=0;$i<100;$i++) //may try 10000, but may crash PHP.
- {
- $label = new TLabel();
- $label->Text=" this is a very long label with some text $i:";
- $this->Panel1->Controls[] = $label;
- }
- }
-
- function button_clicked($sender, $param)
- {
- $this->status->Text .= ' Callback Clicked... ';
- }
-}
-
+<?php + +class LargePageStateTest2 extends TPage +{ + function onLoad($param) + { + parent::onLoad($param); + for($i=0;$i<100;$i++) //may try 10000, but may crash PHP. + { + $label = new TLabel(); + $label->Text=" this is a very long label with some text $i:"; + $this->Panel1->Controls[] = $label; + } + } + + function button_clicked($sender, $param) + { + $this->status->Text .= ' Callback Clicked... '; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/Master1.php b/tests/FunctionalTests/active-controls/protected/pages/Master1.php index 173a59f0..1bbcb9c4 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/Master1.php +++ b/tests/FunctionalTests/active-controls/protected/pages/Master1.php @@ -1,7 +1,7 @@ -<?php
-
-class Master1 extends TTemplateControl
-{
-}
-
+<?php + +class Master1 extends TTemplateControl +{ +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/MessagesPanelTest.php b/tests/FunctionalTests/active-controls/protected/pages/MessagesPanelTest.php index 9a59713d..d3713308 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/MessagesPanelTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/MessagesPanelTest.php @@ -1,16 +1,16 @@ -<?php
-
-class MessagesPanelTest extends TPage
-{
- function show_clicked($sender, $param)
- {
- $this->panel1->setMessage("hello world");
- }
-
- function hide_clicked($sender, $param)
- {
- $this->panel1->setMessage("");
- }
-}
-
+<?php + +class MessagesPanelTest extends TPage +{ + function show_clicked($sender, $param) + { + $this->panel1->setMessage("hello world"); + } + + function hide_clicked($sender, $param) + { + $this->panel1->setMessage(""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/MyControl.php b/tests/FunctionalTests/active-controls/protected/pages/MyControl.php index 2c6b7f5b..5ced5d3a 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/MyControl.php +++ b/tests/FunctionalTests/active-controls/protected/pages/MyControl.php @@ -1,8 +1,8 @@ -<?php
-
-class MyControl extends TTemplateControl
-{
-
-}
-
+<?php + +class MyControl extends TTemplateControl +{ + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/MyTabPanelTest.php b/tests/FunctionalTests/active-controls/protected/pages/MyTabPanelTest.php index 723af42d..6736138d 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/MyTabPanelTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/MyTabPanelTest.php @@ -1,42 +1,42 @@ -<?php
-
-class MyTabPanelTest extends TPage
-{
- private $panels = array('pnlContentsA', 'pnlContentsB', 'pnlContentsC', );
-
- private function showPanel($id, $param)
- {
- foreach($this->panels as $panel)
- {
- if($id == $panel)
- {
- $this->$panel->setAttribute('style', 'display: block;');
- $this->$panel->setVisible(true);
- $this->$panel->render($param->NewWriter);
- }
- else
- {
- $this->$panel->setVisible(false);
- }
- }
- }
-
- public function onShowPanelA($sender, $param)
- {
- $this->showPanel('pnlContentsA', $param);
- }
-
- public function onShowPanelB($sender, $param)
- {
- $this->showPanel('pnlContentsB', $param);
- }
-
- public function onShowPanelC($sender, $param)
- {
- $this->showPanel('pnlContentsC', $param);
- }
-}
-
-
-
+<?php + +class MyTabPanelTest extends TPage +{ + private $panels = array('pnlContentsA', 'pnlContentsB', 'pnlContentsC', ); + + private function showPanel($id, $param) + { + foreach($this->panels as $panel) + { + if($id == $panel) + { + $this->$panel->setAttribute('style', 'display: block;'); + $this->$panel->setVisible(true); + $this->$panel->render($param->NewWriter); + } + else + { + $this->$panel->setVisible(false); + } + } + } + + public function onShowPanelA($sender, $param) + { + $this->showPanel('pnlContentsA', $param); + } + + public function onShowPanelB($sender, $param) + { + $this->showPanel('pnlContentsB', $param); + } + + public function onShowPanelC($sender, $param) + { + $this->showPanel('pnlContentsC', $param); + } +} + + + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/NullStateTest.php b/tests/FunctionalTests/active-controls/protected/pages/NullStateTest.php index 0abd8eb5..f6e5071d 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/NullStateTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/NullStateTest.php @@ -1,11 +1,11 @@ <?php -
-class NullStateTest extends TPage
-{
- public function btnTest_OnCallback($sender,$param)
- {
- $this->lblTest->Text = "Testing";
- }
-}
+ +class NullStateTest extends TPage +{ + public function btnTest_OnCallback($sender,$param) + { + $this->lblTest->Text = "Testing"; + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.php b/tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.php index 022f6dad..8a1ba198 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.php +++ b/tests/FunctionalTests/active-controls/protected/pages/PopulateActiveList.php @@ -1,34 +1,34 @@ -<?php
-
-class PopulateActiveList extends TPage
-{
- public function populate_list1($sender, $param)
- {
- $data = array('Hello', 'World', 'Prado');
- $this->list1->Items->clear();
- for($i = 0,$k=count($data); $i<$k; $i++)
- {
- $item = new TListItem($data[$i], $i);
- $this->list1->Items[] = $item;
- }
- }
-
- public function populate_list2($sender, $param)
- {
- $data = array('Hello', 'World', 'Prado');
- $this->list2->Items->clear();
- for($i = 0,$k=count($data); $i<$k; $i++)
- {
- $item = new TListItem($data[$i], $i);
- $this->list2->Items[] = $item;
- }
- }
-
- public function list_changed($sender, $param)
- {
- $text = $sender->SelectedItem ? $sender->SelectedItem->Text : 'Not selected';
- $this->label1->Text = $sender->ID . ': '.$text;
- }
-}
-
+<?php + +class PopulateActiveList extends TPage +{ + public function populate_list1($sender, $param) + { + $data = array('Hello', 'World', 'Prado'); + $this->list1->Items->clear(); + for($i = 0,$k=count($data); $i<$k; $i++) + { + $item = new TListItem($data[$i], $i); + $this->list1->Items[] = $item; + } + } + + public function populate_list2($sender, $param) + { + $data = array('Hello', 'World', 'Prado'); + $this->list2->Items->clear(); + for($i = 0,$k=count($data); $i<$k; $i++) + { + $item = new TListItem($data[$i], $i); + $this->list2->Items[] = $item; + } + } + + public function list_changed($sender, $param) + { + $text = $sender->SelectedItem ? $sender->SelectedItem->Text : 'Not selected'; + $this->label1->Text = $sender->ID . ': '.$text; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/PostLoadingTest.php b/tests/FunctionalTests/active-controls/protected/pages/PostLoadingTest.php index 1257b45b..d22f2922 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/PostLoadingTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/PostLoadingTest.php @@ -1,45 +1,45 @@ -<?php
-
-class PostLoadingTest extends TPage
-{
- public function onInit($param)
- {
- parent::onInit($param);
-
- // Text Box
- $textBox=new TTextBox();
- $textBox->setVisible(false);
- $textBox->setID("MyTextBox");
- $this->panel1->getControls()->add($textBox);
- $this->registerObject("MyTextBox", $textBox);
-
-
- // Submit button
- $button=new TActiveButton();
- $button->setVisible(false);
- $button->setID("MyButton");
- $button->setText("Submit");
- $button->attachEventHandler("OnCallback", array($this, "clickedButton"));
- $this->panel1->getControls()->add($button);
- $this->registerObject("MyButton", $button);
-
- }
-
-
- function callback1_requested($sender, $param)
- {
- $this->MyTextBox->visible = true;
- $this->MyButton->ActiveControl->EnableUpdate=false;
- $this->MyButton->visible = true;
- $this->panel1->render($param->NewWriter);
- }
-
- function clickedButton($sender, $param)
- {
- $this->panel1->getControls()->add('Result is '.$this->MyTextBox->getText());
- $this->panel1->render($param->NewWriter);
- $this->Page->CallbackClient->Highlight('heading');
- }
-}
-
+<?php + +class PostLoadingTest extends TPage +{ + public function onInit($param) + { + parent::onInit($param); + + // Text Box + $textBox=new TTextBox(); + $textBox->setVisible(false); + $textBox->setID("MyTextBox"); + $this->panel1->getControls()->add($textBox); + $this->registerObject("MyTextBox", $textBox); + + + // Submit button + $button=new TActiveButton(); + $button->setVisible(false); + $button->setID("MyButton"); + $button->setText("Submit"); + $button->attachEventHandler("OnCallback", array($this, "clickedButton")); + $this->panel1->getControls()->add($button); + $this->registerObject("MyButton", $button); + + } + + + function callback1_requested($sender, $param) + { + $this->MyTextBox->visible = true; + $this->MyButton->ActiveControl->EnableUpdate=false; + $this->MyButton->visible = true; + $this->panel1->render($param->NewWriter); + } + + function clickedButton($sender, $param) + { + $this->panel1->getControls()->add('Result is '.$this->MyTextBox->getText()); + $this->panel1->render($param->NewWriter); + $this->Page->CallbackClient->Highlight('heading'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/RadioButtonListTest.php b/tests/FunctionalTests/active-controls/protected/pages/RadioButtonListTest.php index 10c45aa3..eb77073b 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/RadioButtonListTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/RadioButtonListTest.php @@ -1,28 +1,28 @@ -<?php
-
-class RadioButtonListTest extends TPage
-{
- public function radChange($sender,$param){
- $choice = 'Choice : ';
- switch($this->rad_button_list->SelectedValue){
- case 'yes':
- $choice.='Yes :-)';
- break;
- case 'no':
- $choice.='No :-(';
- break;
- case 'whynot':
- $choice.='Why not ???';
- break;
- }
- $this->label->Text = $choice;
- }
-
- public function action($sender,$param){
- $this->label->Text = 'Action...';
- }
-
-}
-
-
+<?php + +class RadioButtonListTest extends TPage +{ + public function radChange($sender,$param){ + $choice = 'Choice : '; + switch($this->rad_button_list->SelectedValue){ + case 'yes': + $choice.='Yes :-)'; + break; + case 'no': + $choice.='No :-('; + break; + case 'whynot': + $choice.='Why not ???'; + break; + } + $this->label->Text = $choice; + } + + public function action($sender,$param){ + $this->label->Text = 'Action...'; + } + +} + + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/RatingList.php b/tests/FunctionalTests/active-controls/protected/pages/RatingList.php index 98b62e04..8fd879bc 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/RatingList.php +++ b/tests/FunctionalTests/active-controls/protected/pages/RatingList.php @@ -1,34 +1,34 @@ -<?php
-
-class RatingList extends TPage
-{
- function list1_oncallback($sender, $param)
- {
- $newRating = ($sender->Rating + $sender->SelectedIndex+1)/2;
- $sender->Rating = $newRating;
- $sender->Caption = "Rating : ".$newRating;
- $sender->Enabled=false;
- }
-
-
- function list2_oncallback($sender, $param)
- {
- }
-
- function button1_clicked($sender, $param)
- {
- $this->list1->Enabled = true;
- }
-
- function button2_clicked($sender, $param)
- {
- $this->list1->Enabled=false;
- }
-
- function button5_clicked($sender, $param)
- {
- $this->list1->SelectedIndex=3;
- }
-}
-
+<?php + +class RatingList extends TPage +{ + function list1_oncallback($sender, $param) + { + $newRating = ($sender->Rating + $sender->SelectedIndex+1)/2; + $sender->Rating = $newRating; + $sender->Caption = "Rating : ".$newRating; + $sender->Enabled=false; + } + + + function list2_oncallback($sender, $param) + { + } + + function button1_clicked($sender, $param) + { + $this->list1->Enabled = true; + } + + function button2_clicked($sender, $param) + { + $this->list1->Enabled=false; + } + + function button5_clicked($sender, $param) + { + $this->list1->SelectedIndex=3; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/RepeaterWithActiveControls.php b/tests/FunctionalTests/active-controls/protected/pages/RepeaterWithActiveControls.php index c5235dc6..013ffe61 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/RepeaterWithActiveControls.php +++ b/tests/FunctionalTests/active-controls/protected/pages/RepeaterWithActiveControls.php @@ -1,61 +1,61 @@ -<?php
-
-class RepeaterWithActiveControls extends TPage
-{
- private $_data=array('Hello', 'World', 'Prado');
-
- private $_status='';
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsCallback)
- {
- $this->repeater1->DataSource = $this->_data;
- $this->repeater1->dataBind();
- }
- }
-
- public function label_changed($sender, $param)
- {
- $index = $sender->getParent()->ItemIndex + 1;
- $this->_status .= " Update textbox {$index}: ".$sender->Text;
- }
-
- public function onPreRender($param)
- {
- parent::onPreRender($param);
- if(trim($this->_status))
- $this->label1->Text = $this->_status;
- }
-
- public function enable_edit($sender, $param)
- {
- if($this->update_button->Enabled==false)
- {
- for($i = 0; $i<count($this->repeater1->Items); $i++)
- {
- $textbox = $this->repeater1->Items[$i]->edit_box;
- $textbox->DisplayTextBox = true;
- }
- $this->update_button->Enabled = true;
- $sender->Enabled=false;
- }
- }
-
- public function disable_edit($sender, $param)
- {
- if($this->update_button->Enabled==true)
- {
- for($i = 0; $i<count($this->repeater1->Items); $i++)
- {
- $textbox = $this->repeater1->Items[$i]->edit_box;
- $textbox->DisplayTextBox = false;
- }
- $this->edit_button->Enabled = true;
- $sender->Enabled=false;
- }
- }
-}
-
+<?php + +class RepeaterWithActiveControls extends TPage +{ + private $_data=array('Hello', 'World', 'Prado'); + + private $_status=''; + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsCallback) + { + $this->repeater1->DataSource = $this->_data; + $this->repeater1->dataBind(); + } + } + + public function label_changed($sender, $param) + { + $index = $sender->getParent()->ItemIndex + 1; + $this->_status .= " Update textbox {$index}: ".$sender->Text; + } + + public function onPreRender($param) + { + parent::onPreRender($param); + if(trim($this->_status)) + $this->label1->Text = $this->_status; + } + + public function enable_edit($sender, $param) + { + if($this->update_button->Enabled==false) + { + for($i = 0; $i<count($this->repeater1->Items); $i++) + { + $textbox = $this->repeater1->Items[$i]->edit_box; + $textbox->DisplayTextBox = true; + } + $this->update_button->Enabled = true; + $sender->Enabled=false; + } + } + + public function disable_edit($sender, $param) + { + if($this->update_button->Enabled==true) + { + for($i = 0; $i<count($this->repeater1->Items); $i++) + { + $textbox = $this->repeater1->Items[$i]->edit_box; + $textbox->DisplayTextBox = false; + } + $this->edit_button->Enabled = true; + $sender->Enabled=false; + } + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php b/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php index a5358d98..a6df2abd 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ReplaceContentTest.php @@ -1,42 +1,42 @@ -<?php
-
-class ReplaceContentTest extends TPage
-{
- function appendContent($sender, $param)
- {
- $this->CallbackClient->appendContent($this->subpanel, $this->replacementContent());
- }
-
- function prependContent($sender, $param)
- {
- $this->CallbackClient->prependContent($this->subpanel, $this->replacementContent());
- }
-
- function insertContentBefore($sender, $param)
- {
- $this->CallbackClient->insertContentBefore($this->subpanel, $this->replacementContent());
- }
-
- function insertContentAfter($sender, $param)
- {
- $this->CallbackClient->insertContentAfter($this->subpanel, $this->replacementContent());
- }
-
- function replaceContent($sender, $param)
- {
- $this->CallbackClient->replaceContent($this->subpanel, $this->replacementContent());
- }
-
- function replacementContent()
- {
- if($this->check1->Checked)
- {
- $this->newPanel->Visible=true;
- return $this->newPanel;
- }
- else
- return $this->content->Text;
- }
-}
-
+<?php + +class ReplaceContentTest extends TPage +{ + function appendContent($sender, $param) + { + $this->CallbackClient->appendContent($this->subpanel, $this->replacementContent()); + } + + function prependContent($sender, $param) + { + $this->CallbackClient->prependContent($this->subpanel, $this->replacementContent()); + } + + function insertContentBefore($sender, $param) + { + $this->CallbackClient->insertContentBefore($this->subpanel, $this->replacementContent()); + } + + function insertContentAfter($sender, $param) + { + $this->CallbackClient->insertContentAfter($this->subpanel, $this->replacementContent()); + } + + function replaceContent($sender, $param) + { + $this->CallbackClient->replaceContent($this->subpanel, $this->replacementContent()); + } + + function replacementContent() + { + if($this->check1->Checked) + { + $this->newPanel->Visible=true; + return $this->newPanel; + } + else + return $this->content->Text; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/Sessioned/PageStateTest.php b/tests/FunctionalTests/active-controls/protected/pages/Sessioned/PageStateTest.php index 4a488107..9d4a7695 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/Sessioned/PageStateTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/Sessioned/PageStateTest.php @@ -1,13 +1,13 @@ -<?php
-
-class PageStateTest extends TPage
-{
- function button1_oncallback($sender, $param)
- {
- //sleep(rand(0,5));
- $sender->CustomData = $sender->CustomData + 1;
- $this->label1->Text = " button1 clicked ".$sender->CustomData." times";
- }
-}
-
+<?php + +class PageStateTest extends TPage +{ + function button1_oncallback($sender, $param) + { + //sleep(rand(0,5)); + $sender->CustomData = $sender->CustomData + 1; + $this->label1->Text = " button1 clicked ".$sender->CustomData." times"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.php b/tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.php index 9b5a05f7..6cc5a500 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.php @@ -1,26 +1,26 @@ -<?php
-
-class TInPlaceTextBoxTest extends TPage
-{
- function load_text($sender, $param)
- {
- $sender->Text = "muahaha";
- }
-
- function label1_changed($sender, $param)
- {
- $this->status->Text = "Status: ". $sender->Text;
- }
-
- function button_clicked($sender, $param)
- {
- $this->label1->Text = "hahahaha";
- }
-
- function NewPackageSubject($sender, $param)
- {
- throw new TException('Exist');
- }
-}
-
+<?php + +class TInPlaceTextBoxTest extends TPage +{ + function load_text($sender, $param) + { + $sender->Text = "muahaha"; + } + + function label1_changed($sender, $param) + { + $this->status->Text = "Status: ". $sender->Text; + } + + function button_clicked($sender, $param) + { + $this->label1->Text = "hahahaha"; + } + + function NewPackageSubject($sender, $param) + { + throw new TException('Exist'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.php b/tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.php index dc643e52..170e618b 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.php +++ b/tests/FunctionalTests/active-controls/protected/pages/TestMasterPage.php @@ -1,7 +1,7 @@ -<?php
-
-class TestMasterPage extends TTemplateControl
-{
-}
-
+<?php + +class TestMasterPage extends TTemplateControl +{ +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/TextBoxValidationCallback.php b/tests/FunctionalTests/active-controls/protected/pages/TextBoxValidationCallback.php index cf43bccd..1d2cc92f 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/TextBoxValidationCallback.php +++ b/tests/FunctionalTests/active-controls/protected/pages/TextBoxValidationCallback.php @@ -1,11 +1,11 @@ -<?php
-
-class TextBoxValidationCallback extends TPage
-{
-
- function lookupZipCode()
- {
- $this->City->Text = "City: ".$this->Address->Text . ' Zip: '.$this->ZipCode->Text;
- }
-}
+<?php + +class TextBoxValidationCallback extends TPage +{ + + function lookupZipCode() + { + $this->City->Text = "City: ".$this->Address->Text . ' Zip: '.$this->ZipCode->Text; + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.php b/tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.php index a8f83187..69985541 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.php +++ b/tests/FunctionalTests/active-controls/protected/pages/ValueTriggerCallbackTest.php @@ -1,12 +1,12 @@ -<?php
-
-class ValueTriggerCallbackTest extends TPage
-{
- function text1_changed($sender, $param)
- {
- $values = $param->getCallbackParameter();
- $this->label1->Text = "Old = ".$values->OldValue." : New Value = ".$values->NewValue;
- }
-}
-
+<?php + +class ValueTriggerCallbackTest extends TPage +{ + function text1_changed($sender, $param) + { + $values = $param->getCallbackParameter(); + $this->label1->Text = "Old = ".$values->OldValue." : New Value = ".$values->NewValue; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActiveControlExpressTagTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveControlExpressTagTestCase.php index 7da7315c..0cf7d927 100644 --- a/tests/FunctionalTests/active-controls/tests/ActiveControlExpressTagTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ActiveControlExpressTagTestCase.php @@ -1,20 +1,20 @@ -<?php
-
-class ActiveControlExpressionTagTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('active-controls/index.php?page=ActiveControlExpressionTag');
- $this->assertTextPresent('Active Control With Expression Tag Test');
- $this->assertTextNotPresent('Text box content:');
-
- $this->type('textbox1', 'Hello world');
- $this->click('button1');
- $this->pause(800);
-
- $this->assertText('repeats', 'result - 1 result - two');
- $this->assertText('contents', 'Text box content: Hello world');
- }
-}
-
+<?php + +class ActiveControlExpressionTagTestCase extends SeleniumTestCase +{ + function test() + { + $this->open('active-controls/index.php?page=ActiveControlExpressionTag'); + $this->assertTextPresent('Active Control With Expression Tag Test'); + $this->assertTextNotPresent('Text box content:'); + + $this->type('textbox1', 'Hello world'); + $this->click('button1'); + $this->pause(800); + + $this->assertText('repeats', 'result - 1 result - two'); + $this->assertText('contents', 'Text box content: Hello world'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActiveImageButtonTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveImageButtonTestCase.php index d497e915..477f7fea 100644 --- a/tests/FunctionalTests/active-controls/tests/ActiveImageButtonTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ActiveImageButtonTestCase.php @@ -1,17 +1,17 @@ -<?php
-
-class ActiveImageButtonTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("active-controls/index.php?page=ActiveImageButtonTest");
- $this->assertTextPresent("TActiveImageButton Functional Test");
- $this->assertText("label1", "Label 1");
- $this->click("image1");
- $this->pause(800);
- //unable to determine mouse position
- $this->assertTextPresent("regexp:Image clicked at x=\d+, y=\d+");
- }
-}
-
+<?php + +class ActiveImageButtonTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=ActiveImageButtonTest"); + $this->assertTextPresent("TActiveImageButton Functional Test"); + $this->assertText("label1", "Label 1"); + $this->click("image1"); + $this->pause(800); + //unable to determine mouse position + $this->assertTextPresent("regexp:Image clicked at x=\d+, y=\d+"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActiveLinkButtonTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveLinkButtonTestCase.php index 305a5c93..7024acd2 100644 --- a/tests/FunctionalTests/active-controls/tests/ActiveLinkButtonTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ActiveLinkButtonTestCase.php @@ -1,16 +1,16 @@ -<?php
-
-class ActiveLinkButtonTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("active-controls/index.php?page=ActiveLinkButtonTest");
- $this->verifyTextPresent("TActiveLinkButton Functional Test");
- $this->assertText("label1", "Label 1");
- $this->click("button2");
- $this->pause(800);
- $this->assertText("label1", "Button 1 was clicked using callback!");
- }
-}
-
+<?php + +class ActiveLinkButtonTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=ActiveLinkButtonTest"); + $this->verifyTextPresent("TActiveLinkButton Functional Test"); + $this->assertText("label1", "Label 1"); + $this->click("button2"); + $this->pause(800); + $this->assertText("label1", "Button 1 was clicked using callback!"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActiveListBoxMasterTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveListBoxMasterTestCase.php index 7f006d9e..116dd4ad 100644 --- a/tests/FunctionalTests/active-controls/tests/ActiveListBoxMasterTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ActiveListBoxMasterTestCase.php @@ -1,49 +1,49 @@ -<?php
-
-class ActiveListBoxMasterTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("active-controls/index.php?page=ActiveListBoxMasterTest");
- $this->assertTextPresent('Active List Box Functional Test');
-
- $base = 'ctl0_body_';
-
- $this->assertText($base."label1", "Label 1");
-
- $this->click($base."button1");
- $this->pause(800);
- $this->assertSelectedIndexes($base.'list1', '1,2,3');
-
- $this->click($base.'button3');
- $this->pause(800);
- $this->assertSelectedIndexes($base.'list1', '0');
-
- $this->click($base.'button4');
- $this->pause(800);
- $this->assertSelectedIndexes($base.'list1', '4');
-
- $this->click($base.'button5');
- $this->pause(800);
- $this->assertSelectedIndexes($base.'list1', '1,4');
-
- $this->click($base.'button2');
- $this->pause(800);
- $this->assertEmptySelection($base."list1");
-
- $this->click($base.'button6');
- $this->pause(800);
- $this->click($base."button1");
- $this->pause(800);
- $this->assertSelectedIndexes($base.'list1', '1,2,3');
-
- $this->select($base."list1", "item 1");
- $this->pause(800);
- $this->assertText($base.'label1', 'Selection: value 1');
-
- $this->addSelection($base."list1", "item 4");
- $this->pause(800);
- $this->assertText($base.'label1', 'Selection: value 1, value 4');
- }
-}
+<?php + +class ActiveListBoxMasterTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=ActiveListBoxMasterTest"); + $this->assertTextPresent('Active List Box Functional Test'); + + $base = 'ctl0_body_'; + + $this->assertText($base."label1", "Label 1"); + + $this->click($base."button1"); + $this->pause(800); + $this->assertSelectedIndexes($base.'list1', '1,2,3'); + + $this->click($base.'button3'); + $this->pause(800); + $this->assertSelectedIndexes($base.'list1', '0'); + + $this->click($base.'button4'); + $this->pause(800); + $this->assertSelectedIndexes($base.'list1', '4'); + + $this->click($base.'button5'); + $this->pause(800); + $this->assertSelectedIndexes($base.'list1', '1,4'); + + $this->click($base.'button2'); + $this->pause(800); + $this->assertEmptySelection($base."list1"); + + $this->click($base.'button6'); + $this->pause(800); + $this->click($base."button1"); + $this->pause(800); + $this->assertSelectedIndexes($base.'list1', '1,2,3'); + + $this->select($base."list1", "item 1"); + $this->pause(800); + $this->assertText($base.'label1', 'Selection: value 1'); + + $this->addSelection($base."list1", "item 4"); + $this->pause(800); + $this->assertText($base.'label1', 'Selection: value 1, value 4'); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActiveListBoxTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveListBoxTestCase.php index 96f56b30..78dbd77e 100644 --- a/tests/FunctionalTests/active-controls/tests/ActiveListBoxTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ActiveListBoxTestCase.php @@ -1,47 +1,47 @@ -<?php
-
-class ActiveListBoxTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("active-controls/index.php?page=ActiveListBoxTest");
- $this->assertTextPresent('Active List Box Functional Test');
-
- $this->assertText("label1", "Label 1");
-
- $this->click("button1");
- $this->pause(800);
- $this->assertSelectedIndexes('list1', '1,2,3');
-
- $this->click('button3');
- $this->pause(800);
- $this->assertSelectedIndexes('list1', '0');
-
- $this->click('button4');
- $this->pause(800);
- $this->assertSelectedIndexes('list1', '4');
-
- $this->click('button5');
- $this->pause(800);
- $this->assertSelectedIndexes('list1', '1,4');
-
- $this->click('button2');
- $this->pause(800);
- $this->assertEmptySelection("list1");
-
- $this->click('button6');
- $this->pause(800);
- $this->click("button1");
- $this->pause(800);
- $this->assertSelectedIndexes('list1', '1,2,3');
-
- $this->select("list1", "item 1");
- $this->pause(800);
- $this->assertText('label1', 'Selection: value 1');
-
- $this->addSelection("list1", "item 4");
- $this->pause(800);
- $this->assertText('label1', 'Selection: value 1, value 4');
- }
-}
+<?php + +class ActiveListBoxTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=ActiveListBoxTest"); + $this->assertTextPresent('Active List Box Functional Test'); + + $this->assertText("label1", "Label 1"); + + $this->click("button1"); + $this->pause(800); + $this->assertSelectedIndexes('list1', '1,2,3'); + + $this->click('button3'); + $this->pause(800); + $this->assertSelectedIndexes('list1', '0'); + + $this->click('button4'); + $this->pause(800); + $this->assertSelectedIndexes('list1', '4'); + + $this->click('button5'); + $this->pause(800); + $this->assertSelectedIndexes('list1', '1,4'); + + $this->click('button2'); + $this->pause(800); + $this->assertEmptySelection("list1"); + + $this->click('button6'); + $this->pause(800); + $this->click("button1"); + $this->pause(800); + $this->assertSelectedIndexes('list1', '1,2,3'); + + $this->select("list1", "item 1"); + $this->pause(800); + $this->assertText('label1', 'Selection: value 1'); + + $this->addSelection("list1", "item 4"); + $this->pause(800); + $this->assertText('label1', 'Selection: value 1, value 4'); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php index ce269cd1..45078830 100644 --- a/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonListTestCase.php @@ -1,50 +1,50 @@ -<?php
-
-class ActiveRadioButtonListTestCase extends SeleniumTestCase
-{
- function test()
- {
- //problem with test runner clicking on radio buttons
- $this->skipBrowsers(self::OPERA);
-
- $this->open("active-controls/index.php?page=ActiveRadioButtonListTest");
- $this->verifyTextPresent("TActiveRadioButtonList Test Case");
-
- $this->assertText("label1", "Label 1");
-
-
- $this->click("button3");
- $this->pause(800);
- $this->assertCheckBoxes(array(0));
-
- $this->click("button2");
- $this->pause(800);
- $this->assertCheckBoxes(array());
-
- $this->click("button4");
- $this->pause(800);
- $this->assertCheckBoxes(array(4));
-
- $this->click("list1_c2");
- $this->pause(800);
- $this->assertText("label1", "Selection: value 3");
-
- $this->click("list1_c3");
- $this->pause(800);
- $this->assertText("label1", "Selection: value 4");
-
- }
-
- function assertCheckBoxes($checks, $total = 5)
- {
- for($i = 0; $i < $total; $i++)
- {
- if(in_array($i, $checks))
- $this->assertChecked("list1_c{$i}");
- else
- $this->assertNotChecked("list1_c{$i}");
- }
- }
-}
-
+<?php + +class ActiveRadioButtonListTestCase extends SeleniumTestCase +{ + function test() + { + //problem with test runner clicking on radio buttons + $this->skipBrowsers(self::OPERA); + + $this->open("active-controls/index.php?page=ActiveRadioButtonListTest"); + $this->verifyTextPresent("TActiveRadioButtonList Test Case"); + + $this->assertText("label1", "Label 1"); + + + $this->click("button3"); + $this->pause(800); + $this->assertCheckBoxes(array(0)); + + $this->click("button2"); + $this->pause(800); + $this->assertCheckBoxes(array()); + + $this->click("button4"); + $this->pause(800); + $this->assertCheckBoxes(array(4)); + + $this->click("list1_c2"); + $this->pause(800); + $this->assertText("label1", "Selection: value 3"); + + $this->click("list1_c3"); + $this->pause(800); + $this->assertText("label1", "Selection: value 4"); + + } + + function assertCheckBoxes($checks, $total = 5) + { + for($i = 0; $i < $total; $i++) + { + if(in_array($i, $checks)) + $this->assertChecked("list1_c{$i}"); + else + $this->assertNotChecked("list1_c{$i}"); + } + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php index 46925960..2991da9b 100644 --- a/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ActiveRadioButtonTestCase.php @@ -1,57 +1,57 @@ -<?php
-
-class ActiveRadioButtonTestCase extends SeleniumTestCase
-{
- function test()
- {
- //problem with test runner clicking on radio buttons
- $this->skipBrowsers(self::OPERA);
-
- $this->open("active-controls/index.php?page=ActiveRadioButtonTest");
- $this->verifyTextPresent("Active Radio Button Test");
- $this->assertText('label1', 'Label 1');
-
- $this->assertNotChecked('radio1');
- $this->assertNotChecked('radio2');
- $this->assertNotChecked('radio3');
-
- $this->assertText('radio1_label', 'Radio Button 1');
- $this->assertText('radio2_label', 'Radio Button 2');
- $this->assertText('radio3_label', 'Radio Button 3');
-
- $this->click('change_text1');
- $this->pause(800);
- $this->assertText('radio1_label', 'Hello Radio Button 1');
- $this->assertText('radio2_label', 'Radio Button 2');
- $this->assertText('radio3_label', 'Radio Button 3');
-
- $this->click('change_text2');
- $this->pause(800);
- $this->assertText('radio1_label', 'Hello Radio Button 1');
- $this->assertText('radio2_label', 'Radio Button 2 World');
- $this->assertText('radio3_label', 'Radio Button 3');
-
- $this->click('change_radio1');
- $this->pause(800);
- $this->assertChecked('radio1');
- $this->assertNotChecked('radio2');
- $this->assertNotChecked('radio3');
-
- $this->click('change_radio2');
- $this->pause(800);
- $this->assertNotChecked('radio1');
- $this->assertChecked('radio2');
- $this->assertNotChecked('radio3');
-
-
- $this->click('radio3');
- $this->pause(800);
- $this->assertNotChecked('radio1');
- $this->assertChecked('radio2');
- $this->assertChecked('radio3');
- $this->assertText('label1', 'Label 1:Radio Button 3 Checked');
-
-
- }
-}
+<?php + +class ActiveRadioButtonTestCase extends SeleniumTestCase +{ + function test() + { + //problem with test runner clicking on radio buttons + $this->skipBrowsers(self::OPERA); + + $this->open("active-controls/index.php?page=ActiveRadioButtonTest"); + $this->verifyTextPresent("Active Radio Button Test"); + $this->assertText('label1', 'Label 1'); + + $this->assertNotChecked('radio1'); + $this->assertNotChecked('radio2'); + $this->assertNotChecked('radio3'); + + $this->assertText('radio1_label', 'Radio Button 1'); + $this->assertText('radio2_label', 'Radio Button 2'); + $this->assertText('radio3_label', 'Radio Button 3'); + + $this->click('change_text1'); + $this->pause(800); + $this->assertText('radio1_label', 'Hello Radio Button 1'); + $this->assertText('radio2_label', 'Radio Button 2'); + $this->assertText('radio3_label', 'Radio Button 3'); + + $this->click('change_text2'); + $this->pause(800); + $this->assertText('radio1_label', 'Hello Radio Button 1'); + $this->assertText('radio2_label', 'Radio Button 2 World'); + $this->assertText('radio3_label', 'Radio Button 3'); + + $this->click('change_radio1'); + $this->pause(800); + $this->assertChecked('radio1'); + $this->assertNotChecked('radio2'); + $this->assertNotChecked('radio3'); + + $this->click('change_radio2'); + $this->pause(800); + $this->assertNotChecked('radio1'); + $this->assertChecked('radio2'); + $this->assertNotChecked('radio3'); + + + $this->click('radio3'); + $this->pause(800); + $this->assertNotChecked('radio1'); + $this->assertChecked('radio2'); + $this->assertChecked('radio3'); + $this->assertText('label1', 'Label 1:Radio Button 3 Checked'); + + + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php b/tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php index 9cde186a..59bc2e93 100644 --- a/tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/CustomTemplateTestCase.php @@ -1,22 +1,22 @@ -<?php
-
-class CustomTemplateTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('active-controls/index.php?page=CustomTemplateControlTest');
- $this->assertTextPresent('Add Dynamic Custom TTemplateControl Test');
- $this->assertText('label1', 'Label 1');
-
- $this->type('foo', 'Foo Bar!');
- $this->click('button2');
- $this->pause(800);
-
- $this->assertVisible('ctl1_ThePanel');
- $this->assertTextPresent('Client ID: ctl1_ThePanel');
-
- $this->assertText('label1', 'Button 1 was clicked Foo Bar! using callback!... and this is the textbox text: Foo Bar!');
- }
-}
-
+<?php + +class CustomTemplateTestCase extends SeleniumTestCase +{ + function test() + { + $this->open('active-controls/index.php?page=CustomTemplateControlTest'); + $this->assertTextPresent('Add Dynamic Custom TTemplateControl Test'); + $this->assertText('label1', 'Label 1'); + + $this->type('foo', 'Foo Bar!'); + $this->click('button2'); + $this->pause(800); + + $this->assertVisible('ctl1_ThePanel'); + $this->assertTextPresent('Client ID: ctl1_ThePanel'); + + $this->assertText('label1', 'Button 1 was clicked Foo Bar! using callback!... and this is the textbox text: Foo Bar!'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/DelayedCallbackTestCase.php b/tests/FunctionalTests/active-controls/tests/DelayedCallbackTestCase.php index 3653dae1..c5367612 100644 --- a/tests/FunctionalTests/active-controls/tests/DelayedCallbackTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/DelayedCallbackTestCase.php @@ -1,22 +1,22 @@ -<?php
-
-class DelayedCallbackTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("active-controls/index.php?page=DelayedCallback");
- $this->verifyTextPresent("Delayed Callback Test");
-
- $this->assertText("status", "");
- $this->click("button1");
- $this->click("button2");
-
- $this->pause("5000");
- $this->assertText("status", "Callback 1 returned after 4s");
- $this->pause("3000");
- $this->assertText("status", "Callback 2 delayed 2s");
-
- }
-}
-
+<?php + +class DelayedCallbackTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=DelayedCallback"); + $this->verifyTextPresent("Delayed Callback Test"); + + $this->assertText("status", ""); + $this->click("button1"); + $this->click("button2"); + + $this->pause("5000"); + $this->assertText("status", "Callback 1 returned after 4s"); + $this->pause("3000"); + $this->assertText("status", "Callback 2 delayed 2s"); + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/EventTriggerTestCase.php b/tests/FunctionalTests/active-controls/tests/EventTriggerTestCase.php index 8e400b5b..dc10bd28 100644 --- a/tests/FunctionalTests/active-controls/tests/EventTriggerTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/EventTriggerTestCase.php @@ -1,22 +1,22 @@ -<?php
-
-class EventTriggerTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("active-controls/index.php?page=EventTriggeredCallback");
- $this->verifyTextPresent("Event Triggered Callback Test");
-
- $this->assertText('label1', 'Label 1');
-
- $this->click('button1');
- $this->pause(800);
- $this->assertText('label1', 'button 1 clicked');
-
- $this->type('text1', 'test');
- $this->pause(800);
- $this->assertText('label1', 'text 1 focused');
- }
-}
-
+<?php + +class EventTriggerTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=EventTriggeredCallback"); + $this->verifyTextPresent("Event Triggered Callback Test"); + + $this->assertText('label1', 'Label 1'); + + $this->click('button1'); + $this->pause(800); + $this->assertText('label1', 'button 1 clicked'); + + $this->type('text1', 'test'); + $this->pause(800); + $this->assertText('label1', 'text 1 focused'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/PopulateListTestCase.php b/tests/FunctionalTests/active-controls/tests/PopulateListTestCase.php index 4929b879..25a6fde5 100644 --- a/tests/FunctionalTests/active-controls/tests/PopulateListTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/PopulateListTestCase.php @@ -1,25 +1,25 @@ -<?php
-
-class PopulateListTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("active-controls/index.php?page=PopulateActiveList");
- $this->verifyTextPresent("Populate active list controls");
- $this->assertText("label1", "");
-
- $this->click("button1");
- $this->pause(800);
- $this->select("list1", "World");
- $this->pause(800);
- $this->assertText("label1", "list1: World");
-
- $this->click("button2");
- $this->pause(800);
- $this->select("list2", "Prado");
- $this->pause(800);
- $this->assertText("label1", "list2: Prado");
- }
-}
-
+<?php + +class PopulateListTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=PopulateActiveList"); + $this->verifyTextPresent("Populate active list controls"); + $this->assertText("label1", ""); + + $this->click("button1"); + $this->pause(800); + $this->select("list1", "World"); + $this->pause(800); + $this->assertText("label1", "list1: World"); + + $this->click("button2"); + $this->pause(800); + $this->select("list2", "Prado"); + $this->pause(800); + $this->assertText("label1", "list2: Prado"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/PostLoadingTestCase.php b/tests/FunctionalTests/active-controls/tests/PostLoadingTestCase.php index 3b4d0ce9..0fa95b4d 100644 --- a/tests/FunctionalTests/active-controls/tests/PostLoadingTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/PostLoadingTestCase.php @@ -1,22 +1,22 @@ -<?php
-
-class PostLoadingTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('active-controls/index.php?page=PostLoadingTest');
- $this->assertTextPresent('PostLoading Test');
-
- $this->assertTextNotPresent('Hello World');
-
- $this->click('div1');
- $this->pause(800);
- $this->type('MyTextBox', 'Hello World');
- $this->click('MyButton');
-
- $this->pause(800);
- $this->assertTextPresent('Result is Hello World');
- }
-}
-
+<?php + +class PostLoadingTestCase extends SeleniumTestCase +{ + function test() + { + $this->open('active-controls/index.php?page=PostLoadingTest'); + $this->assertTextPresent('PostLoading Test'); + + $this->assertTextNotPresent('Hello World'); + + $this->click('div1'); + $this->pause(800); + $this->type('MyTextBox', 'Hello World'); + $this->click('MyButton'); + + $this->pause(800); + $this->assertTextPresent('Result is Hello World'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php b/tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php index b90607e6..910b1063 100644 --- a/tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ReplaceContentTestCase.php @@ -1,95 +1,95 @@ -<?php
-
-class ReplaceContentTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->skipBrowsers(self::INTERNET_EXPLORER);
-
- $this->open('active-controls/index.php?page=ReplaceContentTest');
- $this->assertTextPresent('Callback Replace Content Test');
-
- $this->assertText('subpanel', 'Sub Panel');
- $this->assertText('panel1', 'Main Panel Sub Panel');
-
- $this->type('content', 'something');
-
- $this->click('btn_append');
- $this->pause(800);
-
- $this->assertText('subpanel', 'Sub Panel something');
- $this->assertText('panel1', 'Main Panel Sub Panel something');
-
- $this->type('content', 'more');
- $this->click('btn_prepend');
- $this->pause(800);
-
- $this->assertText('subpanel', 'more Sub Panel something');
- $this->assertText('panel1', 'Main Panel more Sub Panel something');
-
-
- $this->type('content', 'prado');
- $this->click('btn_before');
- $this->pause(800);
-
- $this->assertText('subpanel', 'more Sub Panel something');
- $this->assertText('panel1', 'Main Panel pradomore Sub Panel something');
-
- $this->type('content', ' php ');
- $this->click('btn_after');
- $this->pause(800);
-
- $this->type('content', 'mauahahaha');
- $this->click('btn_replace');
- $this->pause(1000);
-
- $this->assertText('panel1', 'Main Panel pradomauahahahaphp');
- }
-
- function testIE()
- {
- $this->targetBrowsers(self::INTERNET_EXPLORER);
-
- $this->open('active-controls/index.php?page=ReplaceContentTest');
- $this->assertTextPresent('Callback Replace Content Test');
-
- $this->assertText('subpanel', 'Sub Panel');
- $this->assertText('panel1', 'regexp:Main Panel\s*Sub Panel');
-
- $this->type('content', 'something');
-
- $this->click('btn_append');
- $this->pause(800);
-
- $this->assertText('subpanel', 'Sub Panel something');
- $this->assertText('panel1', 'regexp:Main Panel\s*Sub Panel\s*something');
-
- $this->type('content', 'more');
- $this->click('btn_prepend');
- $this->pause(800);
-
- $this->assertText('subpanel', 'regexp:more\s*Sub Panel\s*something');
- $this->assertText('panel1', 'regexp:Main Panel\s*moreSub Panel\s*something');
-
-
- $this->type('content', 'prado');
- $this->click('btn_before');
- $this->pause(800);
-
- $this->assertText('subpanel', 'regexp:more\s*Sub Panel\s*something');
- $this->assertText('panel1', 'regexp:Main Panel\s*prado\s*more\s*Sub Panel\s*something');
-
- $this->type('content', ' php ');
- $this->click('btn_after');
- $this->pause(800);
-
- $this->type('content', 'mauahahaha');
- $this->click('btn_replace');
- $this->pause(1000);
-
- $this->assertText('panel1', 'Main Panel pradomauahahahaphp');
- }
-
-}
-
+<?php + +class ReplaceContentTestCase extends SeleniumTestCase +{ + function test() + { + $this->skipBrowsers(self::INTERNET_EXPLORER); + + $this->open('active-controls/index.php?page=ReplaceContentTest'); + $this->assertTextPresent('Callback Replace Content Test'); + + $this->assertText('subpanel', 'Sub Panel'); + $this->assertText('panel1', 'Main Panel Sub Panel'); + + $this->type('content', 'something'); + + $this->click('btn_append'); + $this->pause(800); + + $this->assertText('subpanel', 'Sub Panel something'); + $this->assertText('panel1', 'Main Panel Sub Panel something'); + + $this->type('content', 'more'); + $this->click('btn_prepend'); + $this->pause(800); + + $this->assertText('subpanel', 'more Sub Panel something'); + $this->assertText('panel1', 'Main Panel more Sub Panel something'); + + + $this->type('content', 'prado'); + $this->click('btn_before'); + $this->pause(800); + + $this->assertText('subpanel', 'more Sub Panel something'); + $this->assertText('panel1', 'Main Panel pradomore Sub Panel something'); + + $this->type('content', ' php '); + $this->click('btn_after'); + $this->pause(800); + + $this->type('content', 'mauahahaha'); + $this->click('btn_replace'); + $this->pause(1000); + + $this->assertText('panel1', 'Main Panel pradomauahahahaphp'); + } + + function testIE() + { + $this->targetBrowsers(self::INTERNET_EXPLORER); + + $this->open('active-controls/index.php?page=ReplaceContentTest'); + $this->assertTextPresent('Callback Replace Content Test'); + + $this->assertText('subpanel', 'Sub Panel'); + $this->assertText('panel1', 'regexp:Main Panel\s*Sub Panel'); + + $this->type('content', 'something'); + + $this->click('btn_append'); + $this->pause(800); + + $this->assertText('subpanel', 'Sub Panel something'); + $this->assertText('panel1', 'regexp:Main Panel\s*Sub Panel\s*something'); + + $this->type('content', 'more'); + $this->click('btn_prepend'); + $this->pause(800); + + $this->assertText('subpanel', 'regexp:more\s*Sub Panel\s*something'); + $this->assertText('panel1', 'regexp:Main Panel\s*moreSub Panel\s*something'); + + + $this->type('content', 'prado'); + $this->click('btn_before'); + $this->pause(800); + + $this->assertText('subpanel', 'regexp:more\s*Sub Panel\s*something'); + $this->assertText('panel1', 'regexp:Main Panel\s*prado\s*more\s*Sub Panel\s*something'); + + $this->type('content', ' php '); + $this->click('btn_after'); + $this->pause(800); + + $this->type('content', 'mauahahaha'); + $this->click('btn_replace'); + $this->pause(1000); + + $this->assertText('panel1', 'Main Panel pradomauahahahaphp'); + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php b/tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php index aff9a1b2..0fa0c982 100644 --- a/tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/TextBoxGroupValidationTestCase.php @@ -1,24 +1,24 @@ -<?php
-
-class TextBoxGroupValidationTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("active-controls/index.php?page=TextBoxValidationCallback");
- $this->assertTextPresent('TextBox AutoPostBack With Group Validation');
- $this->assertNotVisible('validator1');
-
- $this->type('ZipCode', 'test');
- $this->assertVisible('validator1');
-
- $this->type('Address', 'Sydney');
- $this->type('ZipCode', '2000');
-
- $this->assertNotVisible('validator1');
-
- $this->pause(800);
- $this->assertValue('City', 'City: Sydney Zip: 2000');
- }
-}
-
+<?php + +class TextBoxGroupValidationTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=TextBoxValidationCallback"); + $this->assertTextPresent('TextBox AutoPostBack With Group Validation'); + $this->assertNotVisible('validator1'); + + $this->type('ZipCode', 'test'); + $this->assertVisible('validator1'); + + $this->type('Address', 'Sydney'); + $this->type('ZipCode', '2000'); + + $this->assertNotVisible('validator1'); + + $this->pause(800); + $this->assertValue('City', 'City: Sydney Zip: 2000'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/tests/ValueTriggerCallbackTestCase.php b/tests/FunctionalTests/active-controls/tests/ValueTriggerCallbackTestCase.php index f98fc4a8..5d2e954c 100644 --- a/tests/FunctionalTests/active-controls/tests/ValueTriggerCallbackTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ValueTriggerCallbackTestCase.php @@ -1,22 +1,22 @@ -<?php
-
-class ValueTriggerTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("active-controls/index.php?page=ValueTriggerCallbackTest");
- $this->verifyTextPresent("Value Trigger Callback Test");
-
- $this->assertText('label1', 'Label 1');
-
- $this->type('text1', 'test');
- $this->pause(2000);
- $this->assertText('label1', 'Old = : New Value = test');
-
- $this->type('text1', 'more');
- $this->pause(3000);
- $this->assertText('label1', 'Old = test : New Value = more');
- }
-}
-
+<?php + +class ValueTriggerTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("active-controls/index.php?page=ValueTriggerCallbackTest"); + $this->verifyTextPresent("Value Trigger Callback Test"); + + $this->assertText('label1', 'Label 1'); + + $this->type('text1', 'test'); + $this->pause(2000); + $this->assertText('label1', 'Old = : New Value = test'); + + $this->type('text1', 'more'); + $this->pause(3000); + $this->assertText('label1', 'Old = test : New Value = more'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controlstests/ActiveRatingListTestCase.php b/tests/FunctionalTests/active-controlstests/ActiveRatingListTestCase.php index c6dc50c2..921543cd 100644 --- a/tests/FunctionalTests/active-controlstests/ActiveRatingListTestCase.php +++ b/tests/FunctionalTests/active-controlstests/ActiveRatingListTestCase.php @@ -1,253 +1,253 @@ -<?php
-/**
- * ActiveRatingListTestCase.php
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Creation Date: Oct 22, 2008
- */
-
-/**
- * ActiveRatingListTestCase.php class
- *
- *
- *
- * Properties
- * -
- *
- * @author Bradley Booms <Bradley.Booms@nsighttel.com>
- * @version Modified Date: Oct 22, 2008
- *
- * Modifications:
- */
-class ActiveRatingListTestCase extends SeleniumTestCase
-{
- function testCheckBoxes()
- {
- // Verify we're on the right page.
- $this->open("active-controls/index.php?page=ActiveRatingListCheckBoxesTest");
- $this->verifyTextPresent("TActiveRatingList Check Boxes Test Case");
- $this->assertCheckBoxes("RatingList", array(2), 6);
-
- // Change the list and make sure the radio buttons get updated properly.
- $this->clickTD("RatingList_c4");
- $this->pause(800);
- $this->assertCheckBoxes("RatingList", array(4), 6);
-
- $this->clickTD("RatingList_c2");
- $this->pause(800);
- $this->assertCheckBoxes("RatingList", array(2), 6);
- }
-
- function testRating()
- {
- // Verify we're on the right page.
- $this->open("active-controls/index.php?page=ActiveRatingListRatingTest");
- $this->verifyTextPresent("TActiveRatingList Rating Test Case");
-
- // Check the list, make sure it starts out with 5 stars.
- $this->assertText("Status", "Rating: 5");
-
- // Click on 1 star and make sure the Rating property updates.
- $this->clickTD("RatingList_c0");
- $this->pause(800);
- $this->assertText("Status", "Rating: 1");
-
- // Then set Rating to three on the server side and make sure it's correct.
- $this->click("SetRating");
- $this->pause(800);
- $this->assertText("Status", "Rating: 3");
- }
-
- function testSelectedIndex()
- {
- // Verify we're on the right page.
- $this->open("active-controls/index.php?page=ActiveRatingListSelectedIndexTest");
- $this->verifyTextPresent("TActiveRatingList SelectedIndex Test Case");
- $this->assertText("Status", " SelectedIndex: 1");
-
- // Click on 5 stars and make sure the SelectedIndex property updates.
- $this->clickTD("RatingList_c4");
- $this->pause(800);
- $this->assertText("Status", " SelectedIndex: 4");
-
- // Then set SelectedIndex to 5 on the server side and make sure it's correct.
- $this->click("SetSelectedIndex");
- $this->pause(800);
- $this->assertText("Status", " SelectedIndex: 5");
- }
-
- function testAutoPostBack()
- {
- // Verify we're on the right page.
- $this->open("active-controls/index.php?page=ActiveRatingListAutoPostBackTest");
- $this->verifyTextPresent("TActiveRatingList AutoPostBack Test Case");
- $this->assertText("Status", "AutoPostback=false");
-
- // Make sure that it doesn't auto post when clicked.
- $this->clickTD("RatingList_c3");
- $this->pause(800);
- $this->assertText("Status", "AutoPostback=false");
-
- // Then submit with an active button and make sure it updates.
- $this->click("Submit");
- $this->pause(800);
- $this->assertText("Status", "4 : Good");
- }
-
- function testAllowInput()
- {
- // Verify we're on the right page.
- $this->open("active-controls/index.php?page=ActiveRatingListAllowInputTest");
- $this->verifyTextPresent("TActiveRatingList AllowInput Test Case");
- $this->assertText("Status", "AllowInput=false");
- $this->assertCheckBoxes("RatingList", array(3), 6);
-
- // Make sure that clicking doesn't change anything.
- $this->clickTD("RatingList_c5");
- $this->pause(800);
- $this->assertText("Status", "AllowInput=false");
- $this->assertCheckBoxes("RatingList", array(3), 6);
- }
-
- function testReadOnly()
- {
- // Verify we're on the right page.
- $this->open("active-controls/index.php?page=ActiveRatingListReadOnlyTest");
- $this->verifyTextPresent("TActiveRatingList ReadOnly Test Case");
- $this->assertText("Status", "ReadOnly=true");
- $this->assertCheckBoxes("RatingList", array(0), 6);
-
- $this->clickTD("RatingList_c4");
- $this->pause(800);
- $this->assertText("Status", "ReadOnly=true");
- $this->assertCheckBoxes("RatingList", array(0), 6);
-
- // Then set ReadOnly to false, and make sure it works.
- $this->click("Writable");
- $this->pause(800);
- $this->assertText("Status", "ReadOnly=false");
- $this->assertCheckBoxes("RatingList", array(0), 6);
-
-
- $this->clickTD("RatingList_c1");
- $this->pause(800);
- $this->assertText("Status", "2 : Fair");
- $this->assertCheckBoxes("RatingList", array(1), 6);
-
- // Then set ReadOnly to true, and make sure it doesn't work anymore.
- $this->click("ReadOnly");
- $this->pause(800);
- $this->assertText("Status", "ReadOnly=true");
- $this->assertCheckBoxes("RatingList", array(1), 6);
-
-
- $this->clickTD("RatingList_c2");
- $this->pause(800);
- $this->assertText("Status", "ReadOnly=true");
- $this->assertCheckBoxes("RatingList", array(1), 6);
- }
-
- function testEnabled()
- {
- // Verify we're on the right page.
- $this->open("active-controls/index.php?page=ActiveRatingListEnabledTest");
- $this->verifyTextPresent("TActiveRatingList Enabled Test Case");
- $this->assertText("Status", "Enabled=false");
- $this->assertCheckBoxes("RatingList", array(5), 6);
-
- $this->clickTD("RatingList_c4");
- $this->pause(800);
- $this->assertText("Status", "Enabled=false");
- $this->assertCheckBoxes("RatingList", array(5), 6);
-
- // Then set Enable to true, and make sure it works.
- $this->click("Enable");
- $this->pause(800);
- $this->assertText("Status", "Enabled=true");
- $this->assertCheckBoxes("RatingList", array(5), 6);
-
-
- $this->clickTD("RatingList_c3");
- $this->pause(800);
- $this->assertText("Status", "4 : Good");
- $this->assertCheckBoxes("RatingList", array(3), 6);
-
- // Then set Enable to false, and make sure it doesn't work anymore.
- $this->click("Disable");
- $this->pause(800);
- $this->assertText("Status", "Enabled=false");
- $this->assertCheckBoxes("RatingList", array(3), 6);
-
-
- $this->clickTD("RatingList_c5");
- $this->pause(800);
- $this->assertText("Status", "Enabled=false");
- $this->assertCheckBoxes("RatingList", array(3), 6);
- }
-
- function testHoverCaption()
- {
- // Verify we're on the right page.
- $this->open("active-controls/index.php?page=ActiveRatingListHoverCaptionTest");
- $this->verifyTextPresent("TActiveRatingList Hover Caption Test Case");
- $this->assertText("Status", "CaptionID='Status'");
- $this->assertElementPresent("//input[@id='RatingList_c0']/../..[contains(@class, 'rating_selected')]");
- $this->assertElementPresent("//input[@id='RatingList_c1']/../..[contains(@class, 'rating_selected')]");
- $this->assertElementPresent("//input[@id='RatingList_c2']/../..[contains(@class, 'rating_selected')]");
- $this->assertElementPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating_half')]");
- $this->assertElementPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating')]");
- $this->assertElementPresent("//input[@id='RatingList_c4']/../..[contains(@class, 'rating')]");
- $this->assertElementPresent("//input[@id='RatingList_c5']/../..[contains(@class, 'rating')]");
-
- $this->mouseOver("//input[@id='RatingList_c4']/../../");
- $this->assertText("Status", "Excellent");
- $this->assertElementPresent("//input[@id='RatingList_c0']/../..[contains(@class, 'rating_hover')]");
- $this->assertElementPresent("//input[@id='RatingList_c1']/../..[contains(@class, 'rating_hover')]");
- $this->assertElementPresent("//input[@id='RatingList_c2']/../..[contains(@class, 'rating_hover')]");
- $this->assertElementPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating_hover')]");
- $this->assertElementPresent("//input[@id='RatingList_c4']/../..[contains(@class, 'rating_hover')]");
- $this->assertElementNotPresent("//input[@id='RatingList_c5']/../..[contains(@class, 'rating_hover')]");
- $this->assertElementPresent("//input[@id='RatingList_c5']/../..[contains(@class, 'rating')]");
-
- $this->mouseOut("//input[@id='RatingList_c4']/../../");
- $this->assertText("Status", "CaptionID='Status'");
- $this->assertElementPresent("//input[@id='RatingList_c0']/../..[contains(@class, 'rating_selected')]");
- $this->assertElementPresent("//input[@id='RatingList_c1']/../..[contains(@class, 'rating_selected')]");
- $this->assertElementPresent("//input[@id='RatingList_c2']/../..[contains(@class, 'rating_selected')]");
- $this->assertElementNotPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating_selected')]");
- $this->assertElementPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating')]");
- $this->assertElementPresent("//input[@id='RatingList_c4']/../..[contains(@class, 'rating')]");
- $this->assertElementPresent("//input[@id='RatingList_c5']/../..[contains(@class, 'rating')]");
-
-
- $this->mouseOver("//input[@id='RatingList_c1']/../../");
- $this->assertText("Status", "Fair");
-
- $this->click("//input[@id='RatingList_c1']/../../");
- $this->pause(800);
- $this->assertText("Status", "2 : Fair");
- $this->assertElementPresent("//input[@id='RatingList_c0']/../..[contains(@class, 'rating_selected')]");
- $this->assertElementPresent("//input[@id='RatingList_c1']/../..[contains(@class, 'rating_selected')]");
- $this->assertElementNotPresent("//input[@id='RatingList_c2']/../..[contains(@class, 'rating_selected')]");
- $this->assertElementPresent("//input[@id='RatingList_c2']/../..[contains(@class, 'rating')]");
- $this->assertElementPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating')]");
- $this->assertElementPresent("//input[@id='RatingList_c4']/../..[contains(@class, 'rating')]");
- $this->assertElementPresent("//input[@id='RatingList_c5']/../..[contains(@class, 'rating')]");
- }
-
- function clickTD($clientID){
- $this->click("//input[@id='{$clientID}']/../..");
- }
-
- function assertCheckBoxes($clientID, $checks, $total = 5)
- {
- for($i = 0; $i < $total; $i++)
- {
- if(in_array($i, $checks))
- $this->assertChecked("{$clientID}_c{$i}");
- else
- $this->assertNotChecked("{$clientID}_c{$i}");
- }
- }
-}
+<?php +/** + * ActiveRatingListTestCase.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Creation Date: Oct 22, 2008 + */ + +/** + * ActiveRatingListTestCase.php class + * + * + * + * Properties + * - + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @version Modified Date: Oct 22, 2008 + * + * Modifications: + */ +class ActiveRatingListTestCase extends SeleniumTestCase +{ + function testCheckBoxes() + { + // Verify we're on the right page. + $this->open("active-controls/index.php?page=ActiveRatingListCheckBoxesTest"); + $this->verifyTextPresent("TActiveRatingList Check Boxes Test Case"); + $this->assertCheckBoxes("RatingList", array(2), 6); + + // Change the list and make sure the radio buttons get updated properly. + $this->clickTD("RatingList_c4"); + $this->pause(800); + $this->assertCheckBoxes("RatingList", array(4), 6); + + $this->clickTD("RatingList_c2"); + $this->pause(800); + $this->assertCheckBoxes("RatingList", array(2), 6); + } + + function testRating() + { + // Verify we're on the right page. + $this->open("active-controls/index.php?page=ActiveRatingListRatingTest"); + $this->verifyTextPresent("TActiveRatingList Rating Test Case"); + + // Check the list, make sure it starts out with 5 stars. + $this->assertText("Status", "Rating: 5"); + + // Click on 1 star and make sure the Rating property updates. + $this->clickTD("RatingList_c0"); + $this->pause(800); + $this->assertText("Status", "Rating: 1"); + + // Then set Rating to three on the server side and make sure it's correct. + $this->click("SetRating"); + $this->pause(800); + $this->assertText("Status", "Rating: 3"); + } + + function testSelectedIndex() + { + // Verify we're on the right page. + $this->open("active-controls/index.php?page=ActiveRatingListSelectedIndexTest"); + $this->verifyTextPresent("TActiveRatingList SelectedIndex Test Case"); + $this->assertText("Status", " SelectedIndex: 1"); + + // Click on 5 stars and make sure the SelectedIndex property updates. + $this->clickTD("RatingList_c4"); + $this->pause(800); + $this->assertText("Status", " SelectedIndex: 4"); + + // Then set SelectedIndex to 5 on the server side and make sure it's correct. + $this->click("SetSelectedIndex"); + $this->pause(800); + $this->assertText("Status", " SelectedIndex: 5"); + } + + function testAutoPostBack() + { + // Verify we're on the right page. + $this->open("active-controls/index.php?page=ActiveRatingListAutoPostBackTest"); + $this->verifyTextPresent("TActiveRatingList AutoPostBack Test Case"); + $this->assertText("Status", "AutoPostback=false"); + + // Make sure that it doesn't auto post when clicked. + $this->clickTD("RatingList_c3"); + $this->pause(800); + $this->assertText("Status", "AutoPostback=false"); + + // Then submit with an active button and make sure it updates. + $this->click("Submit"); + $this->pause(800); + $this->assertText("Status", "4 : Good"); + } + + function testAllowInput() + { + // Verify we're on the right page. + $this->open("active-controls/index.php?page=ActiveRatingListAllowInputTest"); + $this->verifyTextPresent("TActiveRatingList AllowInput Test Case"); + $this->assertText("Status", "AllowInput=false"); + $this->assertCheckBoxes("RatingList", array(3), 6); + + // Make sure that clicking doesn't change anything. + $this->clickTD("RatingList_c5"); + $this->pause(800); + $this->assertText("Status", "AllowInput=false"); + $this->assertCheckBoxes("RatingList", array(3), 6); + } + + function testReadOnly() + { + // Verify we're on the right page. + $this->open("active-controls/index.php?page=ActiveRatingListReadOnlyTest"); + $this->verifyTextPresent("TActiveRatingList ReadOnly Test Case"); + $this->assertText("Status", "ReadOnly=true"); + $this->assertCheckBoxes("RatingList", array(0), 6); + + $this->clickTD("RatingList_c4"); + $this->pause(800); + $this->assertText("Status", "ReadOnly=true"); + $this->assertCheckBoxes("RatingList", array(0), 6); + + // Then set ReadOnly to false, and make sure it works. + $this->click("Writable"); + $this->pause(800); + $this->assertText("Status", "ReadOnly=false"); + $this->assertCheckBoxes("RatingList", array(0), 6); + + + $this->clickTD("RatingList_c1"); + $this->pause(800); + $this->assertText("Status", "2 : Fair"); + $this->assertCheckBoxes("RatingList", array(1), 6); + + // Then set ReadOnly to true, and make sure it doesn't work anymore. + $this->click("ReadOnly"); + $this->pause(800); + $this->assertText("Status", "ReadOnly=true"); + $this->assertCheckBoxes("RatingList", array(1), 6); + + + $this->clickTD("RatingList_c2"); + $this->pause(800); + $this->assertText("Status", "ReadOnly=true"); + $this->assertCheckBoxes("RatingList", array(1), 6); + } + + function testEnabled() + { + // Verify we're on the right page. + $this->open("active-controls/index.php?page=ActiveRatingListEnabledTest"); + $this->verifyTextPresent("TActiveRatingList Enabled Test Case"); + $this->assertText("Status", "Enabled=false"); + $this->assertCheckBoxes("RatingList", array(5), 6); + + $this->clickTD("RatingList_c4"); + $this->pause(800); + $this->assertText("Status", "Enabled=false"); + $this->assertCheckBoxes("RatingList", array(5), 6); + + // Then set Enable to true, and make sure it works. + $this->click("Enable"); + $this->pause(800); + $this->assertText("Status", "Enabled=true"); + $this->assertCheckBoxes("RatingList", array(5), 6); + + + $this->clickTD("RatingList_c3"); + $this->pause(800); + $this->assertText("Status", "4 : Good"); + $this->assertCheckBoxes("RatingList", array(3), 6); + + // Then set Enable to false, and make sure it doesn't work anymore. + $this->click("Disable"); + $this->pause(800); + $this->assertText("Status", "Enabled=false"); + $this->assertCheckBoxes("RatingList", array(3), 6); + + + $this->clickTD("RatingList_c5"); + $this->pause(800); + $this->assertText("Status", "Enabled=false"); + $this->assertCheckBoxes("RatingList", array(3), 6); + } + + function testHoverCaption() + { + // Verify we're on the right page. + $this->open("active-controls/index.php?page=ActiveRatingListHoverCaptionTest"); + $this->verifyTextPresent("TActiveRatingList Hover Caption Test Case"); + $this->assertText("Status", "CaptionID='Status'"); + $this->assertElementPresent("//input[@id='RatingList_c0']/../..[contains(@class, 'rating_selected')]"); + $this->assertElementPresent("//input[@id='RatingList_c1']/../..[contains(@class, 'rating_selected')]"); + $this->assertElementPresent("//input[@id='RatingList_c2']/../..[contains(@class, 'rating_selected')]"); + $this->assertElementPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating_half')]"); + $this->assertElementPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating')]"); + $this->assertElementPresent("//input[@id='RatingList_c4']/../..[contains(@class, 'rating')]"); + $this->assertElementPresent("//input[@id='RatingList_c5']/../..[contains(@class, 'rating')]"); + + $this->mouseOver("//input[@id='RatingList_c4']/../../"); + $this->assertText("Status", "Excellent"); + $this->assertElementPresent("//input[@id='RatingList_c0']/../..[contains(@class, 'rating_hover')]"); + $this->assertElementPresent("//input[@id='RatingList_c1']/../..[contains(@class, 'rating_hover')]"); + $this->assertElementPresent("//input[@id='RatingList_c2']/../..[contains(@class, 'rating_hover')]"); + $this->assertElementPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating_hover')]"); + $this->assertElementPresent("//input[@id='RatingList_c4']/../..[contains(@class, 'rating_hover')]"); + $this->assertElementNotPresent("//input[@id='RatingList_c5']/../..[contains(@class, 'rating_hover')]"); + $this->assertElementPresent("//input[@id='RatingList_c5']/../..[contains(@class, 'rating')]"); + + $this->mouseOut("//input[@id='RatingList_c4']/../../"); + $this->assertText("Status", "CaptionID='Status'"); + $this->assertElementPresent("//input[@id='RatingList_c0']/../..[contains(@class, 'rating_selected')]"); + $this->assertElementPresent("//input[@id='RatingList_c1']/../..[contains(@class, 'rating_selected')]"); + $this->assertElementPresent("//input[@id='RatingList_c2']/../..[contains(@class, 'rating_selected')]"); + $this->assertElementNotPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating_selected')]"); + $this->assertElementPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating')]"); + $this->assertElementPresent("//input[@id='RatingList_c4']/../..[contains(@class, 'rating')]"); + $this->assertElementPresent("//input[@id='RatingList_c5']/../..[contains(@class, 'rating')]"); + + + $this->mouseOver("//input[@id='RatingList_c1']/../../"); + $this->assertText("Status", "Fair"); + + $this->click("//input[@id='RatingList_c1']/../../"); + $this->pause(800); + $this->assertText("Status", "2 : Fair"); + $this->assertElementPresent("//input[@id='RatingList_c0']/../..[contains(@class, 'rating_selected')]"); + $this->assertElementPresent("//input[@id='RatingList_c1']/../..[contains(@class, 'rating_selected')]"); + $this->assertElementNotPresent("//input[@id='RatingList_c2']/../..[contains(@class, 'rating_selected')]"); + $this->assertElementPresent("//input[@id='RatingList_c2']/../..[contains(@class, 'rating')]"); + $this->assertElementPresent("//input[@id='RatingList_c3']/../..[contains(@class, 'rating')]"); + $this->assertElementPresent("//input[@id='RatingList_c4']/../..[contains(@class, 'rating')]"); + $this->assertElementPresent("//input[@id='RatingList_c5']/../..[contains(@class, 'rating')]"); + } + + function clickTD($clientID){ + $this->click("//input[@id='{$clientID}']/../.."); + } + + function assertCheckBoxes($clientID, $checks, $total = 5) + { + for($i = 0; $i < $total; $i++) + { + if(in_array($i, $checks)) + $this->assertChecked("{$clientID}_c{$i}"); + else + $this->assertNotChecked("{$clientID}_c{$i}"); + } + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/controls/LabeledTextbox.php b/tests/FunctionalTests/features/protected/controls/LabeledTextbox.php index 9a50d095..ef36863b 100644 --- a/tests/FunctionalTests/features/protected/controls/LabeledTextbox.php +++ b/tests/FunctionalTests/features/protected/controls/LabeledTextbox.php @@ -1,25 +1,25 @@ -<?php
-/*
- * Created on 28/04/2006
- */
-
-class LabeledTextBox extends TTemplateControl
-{
- public function __construct()
- {
- parent::__construct();
- $this->ensureChildControls();
- }
-
- public function getTextBox()
- {
- return $this->getRegisteredObject('textbox');
- }
-
- public function getLabel()
- {
- return $this->getRegisteredObject('label');
- }
-}
-
-?>
+<?php +/* + * Created on 28/04/2006 + */ + +class LabeledTextBox extends TTemplateControl +{ + public function __construct() + { + parent::__construct(); + $this->ensureChildControls(); + } + + public function getTextBox() + { + return $this->getRegisteredObject('textbox'); + } + + public function getLabel() + { + return $this->getRegisteredObject('label'); + } +} + +?> diff --git a/tests/FunctionalTests/features/protected/controls/Layout.php b/tests/FunctionalTests/features/protected/controls/Layout.php index 2c6e02d6..f60a9a18 100644 --- a/tests/FunctionalTests/features/protected/controls/Layout.php +++ b/tests/FunctionalTests/features/protected/controls/Layout.php @@ -1,8 +1,8 @@ -<?php
-
-class Layout extends TTemplateControl
-{
-
-}
-
+<?php + +class Layout extends TTemplateControl +{ + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.php b/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.php index b2dd2233..322f4db7 100644 --- a/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.php +++ b/tests/FunctionalTests/features/protected/pages/ActiveControls/ActiveControl.php @@ -1,43 +1,43 @@ -<?php
-/*
- * Created on 2/05/2006
- */
-
-class ActiveControl extends TPage
-{
- static private $_colors = array('red', 'green', 'blue', 'purple','black','orange');
-
- public function slowResponse($sender, $param)
- {
- //sleep(1);
- $this->label1->setText("The time is ".time()." from ".$sender->ID);
- $this->label1->setForeColor($this->getColor());
- $this->label1->renderControl($param->getOutput());
-
- $this->button2->setEnabled(true);
-
- $this->panel2->setVisible(true);
- $this->panel1->setBackColor($this->getColor());
- $this->panel1->renderControl($param->getOutput());
- $this->getCallbackClient()->shake($this->panel1);
- }
-
- public function onButtonClicked($sender, $param)
- {
- $this->label2->setText("Muahaha !!! the time is ".time()." from ".$sender->ID);
- }
-
- public function fastResponse($sender, $param)
- {
- $this->button2->setEnabled(false);
- $style['color'] = $this->getColor();
- $this->getCallbackClient()->setStyle($this->label2, $style);
- $this->getCallbackClient()->shake($this->label2);
- }
-
- private function getColor()
- {
- return self::$_colors[rand(0,count(self::$_colors)-1)];
- }
-}
-?>
+<?php +/* + * Created on 2/05/2006 + */ + +class ActiveControl extends TPage +{ + static private $_colors = array('red', 'green', 'blue', 'purple','black','orange'); + + public function slowResponse($sender, $param) + { + //sleep(1); + $this->label1->setText("The time is ".time()." from ".$sender->ID); + $this->label1->setForeColor($this->getColor()); + $this->label1->renderControl($param->getOutput()); + + $this->button2->setEnabled(true); + + $this->panel2->setVisible(true); + $this->panel1->setBackColor($this->getColor()); + $this->panel1->renderControl($param->getOutput()); + $this->getCallbackClient()->shake($this->panel1); + } + + public function onButtonClicked($sender, $param) + { + $this->label2->setText("Muahaha !!! the time is ".time()." from ".$sender->ID); + } + + public function fastResponse($sender, $param) + { + $this->button2->setEnabled(false); + $style['color'] = $this->getColor(); + $this->getCallbackClient()->setStyle($this->label2, $style); + $this->getCallbackClient()->shake($this->label2); + } + + private function getColor() + { + return self::$_colors[rand(0,count(self::$_colors)-1)]; + } +} +?> diff --git a/tests/FunctionalTests/features/protected/pages/ActiveControls/AutoComplete.php b/tests/FunctionalTests/features/protected/pages/ActiveControls/AutoComplete.php index 3474234e..ac08e4ed 100644 --- a/tests/FunctionalTests/features/protected/pages/ActiveControls/AutoComplete.php +++ b/tests/FunctionalTests/features/protected/pages/ActiveControls/AutoComplete.php @@ -1,34 +1,34 @@ -<?php
-/*
- * Created on 7/05/2006
- */
-
-class AutoComplete extends TPage
-{
- public function suggestCountries($sender, $param)
- {
- $sender->setDataSource($this->matchCountries($param->getParameter()));
- $sender->dataBind();
- $sender->render($param->getOutput());
- }
-
- protected function matchCountries($token)
- {
- $info = Prado::createComponent('System.I18N.core.CultureInfo', 'en');
- $list = array();
- $count = 0;
- $token = strtolower($token);
- foreach($info->getCountries() as $country)
- {
- if(strpos(strtolower($country), $token) === 0)
- {
- $list[] = $country;
- $count++;
- if($count > 10) break;
- }
- }
- return $list;
- }
-}
-
+<?php +/* + * Created on 7/05/2006 + */ + +class AutoComplete extends TPage +{ + public function suggestCountries($sender, $param) + { + $sender->setDataSource($this->matchCountries($param->getParameter())); + $sender->dataBind(); + $sender->render($param->getOutput()); + } + + protected function matchCountries($token) + { + $info = Prado::createComponent('System.I18N.core.CultureInfo', 'en'); + $list = array(); + $count = 0; + $token = strtolower($token); + foreach($info->getCountries() as $country) + { + if(strpos(strtolower($country), $token) === 0) + { + $list[] = $country; + $count++; + if($count > 10) break; + } + } + return $list; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.php b/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.php index 9821d8c9..7afd1d59 100644 --- a/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.php +++ b/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator.php @@ -1,15 +1,15 @@ -<?php
-/*
- * Created on 6/05/2006
- */
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Calculator extends TPage
-{
- public function do_sum($sender, $param)
- {
- $this->c->Text = floatval($this->a->Text) + floatval($this->b->Text);
- }
-}
-
+<?php +/* + * Created on 6/05/2006 + */ +Prado::using('System.Web.UI.ActiveControls.*'); + +class Calculator extends TPage +{ + public function do_sum($sender, $param) + { + $this->c->Text = floatval($this->a->Text) + floatval($this->b->Text); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator2.php b/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator2.php index df07440f..3789a3f9 100644 --- a/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator2.php +++ b/tests/FunctionalTests/features/protected/pages/ActiveControls/Calculator2.php @@ -1,20 +1,20 @@ -<?php
-/*
- * Created on 13/05/2006
- */
-
-class Calculator2 extends TPage
-{
- public function do_sum($sender, $param)
- {
- $this->c->Text = floatval($this->a->Text) + floatval($this->b->Text);
- }
-
- public function update_callback($sender, $param)
- {
- $this->do_sum($this->sum, null);
- $this->panel1->renderControl($param->Output);
- }
-}
-
+<?php +/* + * Created on 13/05/2006 + */ + +class Calculator2 extends TPage +{ + public function do_sum($sender, $param) + { + $this->c->Text = floatval($this->a->Text) + floatval($this->b->Text); + } + + public function update_callback($sender, $param) + { + $this->do_sum($this->sum, null); + $this->panel1->renderControl($param->Output); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/ActiveControls/VisibleUpdate.php b/tests/FunctionalTests/features/protected/pages/ActiveControls/VisibleUpdate.php index 0c9b16d5..1b1d0cbc 100644 --- a/tests/FunctionalTests/features/protected/pages/ActiveControls/VisibleUpdate.php +++ b/tests/FunctionalTests/features/protected/pages/ActiveControls/VisibleUpdate.php @@ -1,36 +1,36 @@ -<?php
-/*
- * Created on 13/05/2006
- */
-
-class VisibleUpdate extends TPage
-{
- function click1($sender)
- {
- $this->label1->setText($this->getButtonState($sender));
-
- //$this->button1->setEnabled(false);
- $this->button1->setVisible(false);
- // $this->button2->setEnabled(true);
- $this->button2->setVisible(true);
- }
-
- function click2($sender)
- {
- $this->label1->setText($this->getButtonState($sender));
-
- // $this->button1->setEnabled(true);
- $this->button1->setVisible(true);
- /// $this->button2->setEnabled(false);
- $this->button2->setVisible(false);
- }
-
- protected function getButtonState($button)
- {
- return "Before you clicked on ".$button->Text.
- ", Button 1 was ".($this->button1->Enabled ? 'enabled' : 'disabled').
- " and Button 2 was ".($this->button2->Enabled ? 'enabled' : 'disabled');
- }
-}
-
+<?php +/* + * Created on 13/05/2006 + */ + +class VisibleUpdate extends TPage +{ + function click1($sender) + { + $this->label1->setText($this->getButtonState($sender)); + + //$this->button1->setEnabled(false); + $this->button1->setVisible(false); + // $this->button2->setEnabled(true); + $this->button2->setVisible(true); + } + + function click2($sender) + { + $this->label1->setText($this->getButtonState($sender)); + + // $this->button1->setEnabled(true); + $this->button1->setVisible(true); + /// $this->button2->setEnabled(false); + $this->button2->setVisible(false); + } + + protected function getButtonState($button) + { + return "Before you clicked on ".$button->Text. + ", Button 1 was ".($this->button1->Enabled ? 'enabled' : 'disabled'). + " and Button 2 was ".($this->button2->Enabled ? 'enabled' : 'disabled'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/FeatureList.php b/tests/FunctionalTests/features/protected/pages/FeatureList.php index 7f82d34e..8f28f6de 100644 --- a/tests/FunctionalTests/features/protected/pages/FeatureList.php +++ b/tests/FunctionalTests/features/protected/pages/FeatureList.php @@ -1,34 +1,34 @@ -<?php
-
-class FeatureList extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $list=$this->getPageList(dirname(__FILE__),'');
- $this->List->DataSource=$list;
- $this->List->dataBind();
- }
-
- protected function getPageList($directory,$basePath)
- {
- $list=array();
- $folder=@opendir($directory);
- while($entry=@readdir($folder))
- {
- if($entry[0]==='.')
- continue;
- else if(is_file($directory.'/'.$entry))
- {
- if(($page=basename($entry,'.page'))!==$entry && strpos($page,'.')===false)
- $list['?page='.$basePath.$page]=$basePath.$page;
- }
- else
- $list=array_merge($list,$this->getPageList($directory.'/'.$entry,$basePath.$entry.'.'));
- }
- closedir($folder);
- return $list;
- }
-}
-
+<?php + +class FeatureList extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + $list=$this->getPageList(dirname(__FILE__),''); + $this->List->DataSource=$list; + $this->List->dataBind(); + } + + protected function getPageList($directory,$basePath) + { + $list=array(); + $folder=@opendir($directory); + while($entry=@readdir($folder)) + { + if($entry[0]==='.') + continue; + else if(is_file($directory.'/'.$entry)) + { + if(($page=basename($entry,'.page'))!==$entry && strpos($page,'.')===false) + $list['?page='.$basePath.$page]=$basePath.$page; + } + else + $list=array_merge($list,$this->getPageList($directory.'/'.$entry,$basePath.$entry.'.')); + } + closedir($folder); + return $list; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/FocusControl.php b/tests/FunctionalTests/features/protected/pages/FocusControl.php index d78f28c4..e534a92a 100644 --- a/tests/FunctionalTests/features/protected/pages/FocusControl.php +++ b/tests/FunctionalTests/features/protected/pages/FocusControl.php @@ -1,17 +1,17 @@ -<?php
-
-class FocusControl extends TPage
-{
- function doFocus($sender, $param)
- {
- $selected = $this->list->SelectedIndex;
- if($selected >= 0)
- {
- $id = "button".($selected+1);
- $controlID = $this->{$id}->ClientID;
- $this->ClientScript->registerFocusControl($controlID);
- }
- }
-}
-
+<?php + +class FocusControl extends TPage +{ + function doFocus($sender, $param) + { + $selected = $this->list->SelectedIndex; + if($selected >= 0) + { + $id = "button".($selected+1); + $controlID = $this->{$id}->ClientID; + $this->ClientScript->registerFocusControl($controlID); + } + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/I18N/BasicI18N.php b/tests/FunctionalTests/features/protected/pages/I18N/BasicI18N.php index cac0a04e..929e2f17 100644 --- a/tests/FunctionalTests/features/protected/pages/I18N/BasicI18N.php +++ b/tests/FunctionalTests/features/protected/pages/I18N/BasicI18N.php @@ -1,45 +1,45 @@ -<?php
-
-/**
- * ${classname}
- *
- * ${description}
- *
- * @author Wei Zhuo<weizhuo[at]gmail[dot]com>
- * @version $Revision: 1.66 $ $Date: ${DATE} ${TIME} $
- * @package ${package}
- */
-class BasicI18N extends TPage
-{
-}
-
-/**
- * ${classname}
- *
- * ${description}
- *
- * @author Wei Zhuo<weizhuo[at]gmail[dot]com>
- * @version $Revision: 1.66 $ $Date: ${DATE} ${TIME} $
- * @package ${package}
- *//*
-class BasicI18NTestCase extends SeleniumTestCase
-{
- function setup()
- {
- $page = Prado::getApplication()->getTestPage(__FILE__);
- $this->open($page);
- }
-
- function testI18N()
- {
- $this->verifyTitle("Basic I18N Test", "");
- $this->verifyTextPresent("Hello", "");
- $this->verifyTextPresent("US$10,000.00", "");
- $this->verifyTextPresent("2006年1月15日 上午12时00分00秒", "");
- $this->verifyTextPresent("None", "");
- $this->verifyTextPresent("One thing.", "");
- $this->verifyTextPresent("Many things.", "");
- }
-}
-*/
+<?php + +/** + * ${classname} + * + * ${description} + * + * @author Wei Zhuo<weizhuo[at]gmail[dot]com> + * @version $Revision: 1.66 $ $Date: ${DATE} ${TIME} $ + * @package ${package} + */ +class BasicI18N extends TPage +{ +} + +/** + * ${classname} + * + * ${description} + * + * @author Wei Zhuo<weizhuo[at]gmail[dot]com> + * @version $Revision: 1.66 $ $Date: ${DATE} ${TIME} $ + * @package ${package} + *//* +class BasicI18NTestCase extends SeleniumTestCase +{ + function setup() + { + $page = Prado::getApplication()->getTestPage(__FILE__); + $this->open($page); + } + + function testI18N() + { + $this->verifyTitle("Basic I18N Test", ""); + $this->verifyTextPresent("Hello", ""); + $this->verifyTextPresent("US$10,000.00", ""); + $this->verifyTextPresent("2006年1月15日 上午12时00分00秒", ""); + $this->verifyTextPresent("None", ""); + $this->verifyTextPresent("One thing.", ""); + $this->verifyTextPresent("Many things.", ""); + } +} +*/ ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/MyJavascriptLib.php b/tests/FunctionalTests/features/protected/pages/MyJavascriptLib.php index 964b48a5..72e6061e 100644 --- a/tests/FunctionalTests/features/protected/pages/MyJavascriptLib.php +++ b/tests/FunctionalTests/features/protected/pages/MyJavascriptLib.php @@ -1,32 +1,32 @@ -<?php
-
-class MyJavascriptLib extends TComponent
-{
- private $_packages=array(); //keep track of all registrations
-
- private $_manager;
-
- protected function __construct(TPage $owner)
- {
- $this->_manager = $owner->getClientScript();
- $owner->onPreRenderComplete = array($this, 'registerScriptLoader');
- }
-
- public static function registerPackage(TControl $control, $name)
- {
- static $instance;
- if($instance===null)
- $instance=new self($control->getPage());
- $instance->_packages[$name]=true;
- }
-
- protected function registerScriptLoader()
- {
- $dir = dirname(__FILE__).'/myscripts'; //contains my javascript files
- $scripts = array_keys($this->_packages);
- $url = $this->_manager->registerJavascriptPackages($dir, $scripts);
- $this->_manager->registerScriptFile($url,$url);
- }
-}
-
+<?php + +class MyJavascriptLib extends TComponent +{ + private $_packages=array(); //keep track of all registrations + + private $_manager; + + protected function __construct(TPage $owner) + { + $this->_manager = $owner->getClientScript(); + $owner->onPreRenderComplete = array($this, 'registerScriptLoader'); + } + + public static function registerPackage(TControl $control, $name) + { + static $instance; + if($instance===null) + $instance=new self($control->getPage()); + $instance->_packages[$name]=true; + } + + protected function registerScriptLoader() + { + $dir = dirname(__FILE__).'/myscripts'; //contains my javascript files + $scripts = array_keys($this->_packages); + $url = $this->_manager->registerJavascriptPackages($dir, $scripts); + $this->_manager->registerScriptFile($url,$url); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/TestComp.php b/tests/FunctionalTests/features/protected/pages/TestComp.php index f9d02c77..0358357a 100644 --- a/tests/FunctionalTests/features/protected/pages/TestComp.php +++ b/tests/FunctionalTests/features/protected/pages/TestComp.php @@ -1,20 +1,20 @@ -<?php
-
-Prado::using('Application.pages.MyJavascriptLib');
-
-class TestComp extends TControl
-{
- private $_class;
- public function setClass($value)
- {
- $this->_class=$value;
- }
-
- public function onPreRender($param)
- {
- parent::onPreRender($param);
- MyJavascriptLib::registerPackage($this,$this->_class);
- }
-}
-
+<?php + +Prado::using('Application.pages.MyJavascriptLib'); + +class TestComp extends TControl +{ + private $_class; + public function setClass($value) + { + $this->_class=$value; + } + + public function onPreRender($param) + { + parent::onPreRender($param); + MyJavascriptLib::registerPackage($this,$this->_class); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/protected/pages/myscripts/packages.php b/tests/FunctionalTests/features/protected/pages/myscripts/packages.php index 41561a71..e39199f9 100644 --- a/tests/FunctionalTests/features/protected/pages/myscripts/packages.php +++ b/tests/FunctionalTests/features/protected/pages/myscripts/packages.php @@ -1,10 +1,10 @@ -<?php
-
-$packages['test'] = array('test.js');
-
-$deps['test'] = array('test');
-$deps['test2'] = array('test');
-
-return array($packages,$deps);
-
+<?php + +$packages['test'] = array('test.js'); + +$deps['test'] = array('test'); +$deps['test2'] = array('test'); + +return array($packages,$deps); + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/features/tests/MyTestCase.php b/tests/FunctionalTests/features/tests/MyTestCase.php index cb26d709..43a4762d 100644 --- a/tests/FunctionalTests/features/tests/MyTestCase.php +++ b/tests/FunctionalTests/features/tests/MyTestCase.php @@ -1,19 +1,19 @@ -<?php
-
-class MyTestCase extends SeleniumTestCase
-{
- function test1()
- {
- $this->open('http://127.0.0.1');
- $this->assertTextNotPresent('asd');
- }
-
- function test2()
- {
- $this->skipBrowsers(self::FIREFOX);
- $this->open('http://127.0.0.1');
- $this->assertTextNotPresent('asd');
- }
-}
-
+<?php + +class MyTestCase extends SeleniumTestCase +{ + function test1() + { + $this->open('http://127.0.0.1'); + $this->assertTextNotPresent('asd'); + } + + function test2() + { + $this->skipBrowsers(self::FIREFOX); + $this->open('http://127.0.0.1'); + $this->assertTextNotPresent('asd'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/ActiveControls/ActiveButtonTestCase.php b/tests/FunctionalTests/quickstart/ActiveControls/ActiveButtonTestCase.php index c0d6af63..fd12cc4f 100644 --- a/tests/FunctionalTests/quickstart/ActiveControls/ActiveButtonTestCase.php +++ b/tests/FunctionalTests/quickstart/ActiveControls/ActiveButtonTestCase.php @@ -1,38 +1,38 @@ -<?php
-//$Id$
-class ActiveButtonTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=ActiveControls.Samples.TActiveButton.Home&notheme=true&lang=en");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- $this->assertTextPresent('TActiveButton Samples (AJAX)');
-
- // a click button
- $this->verifyElementNotPresent("//input[@type='submit' and @value=\"I'm clicked\"]");
- $this->click("//input[@type='submit' and @value='click me']", "");
- $this->pause(800);
- $this->verifyElementPresent("//input[@type='submit' and @value=\"I'm clicked\"]");
-
- // a command button
- $this->verifyElementNotPresent("//input[@type='submit' and @value=\"Name: test, Param: value using callback\"]");
- $this->click("//input[@type='submit' and @value='click me']", "");
- $this->pause(800);
- $this->verifyElementPresent("//input[@type='submit' and @value=\"Name: test, Param: value using callback\"]");
-
- // a button causing validation
- $this->verifyNotVisible('ctl0_body_ctl2');
- $this->click("//input[@type='submit' and @value='submit']", "");
- $this->pause(800);
- $this->verifyVisible('ctl0_body_ctl2');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->click("//input[@type='submit' and @value='submit']", "");
- $this->pause(800);
- $this->verifyNotVisible('ctl0_body_ctl2');
- $this->verifyElementPresent("//input[@type='submit' and @value=\"I'm clicked using callback\"]", "");
- }
-}
-
+<?php +//$Id$ +class ActiveButtonTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=ActiveControls.Samples.TActiveButton.Home&notheme=true&lang=en"); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + $this->assertTextPresent('TActiveButton Samples (AJAX)'); + + // a click button + $this->verifyElementNotPresent("//input[@type='submit' and @value=\"I'm clicked\"]"); + $this->click("//input[@type='submit' and @value='click me']", ""); + $this->pause(800); + $this->verifyElementPresent("//input[@type='submit' and @value=\"I'm clicked\"]"); + + // a command button + $this->verifyElementNotPresent("//input[@type='submit' and @value=\"Name: test, Param: value using callback\"]"); + $this->click("//input[@type='submit' and @value='click me']", ""); + $this->pause(800); + $this->verifyElementPresent("//input[@type='submit' and @value=\"Name: test, Param: value using callback\"]"); + + // a button causing validation + $this->verifyNotVisible('ctl0_body_ctl2'); + $this->click("//input[@type='submit' and @value='submit']", ""); + $this->pause(800); + $this->verifyVisible('ctl0_body_ctl2'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->click("//input[@type='submit' and @value='submit']", ""); + $this->pause(800); + $this->verifyNotVisible('ctl0_body_ctl2'); + $this->verifyElementPresent("//input[@type='submit' and @value=\"I'm clicked using callback\"]", ""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/ActiveControls/ActiveCheckBoxTestCase.php b/tests/FunctionalTests/quickstart/ActiveControls/ActiveCheckBoxTestCase.php index 80784086..ca17a5dc 100644 --- a/tests/FunctionalTests/quickstart/ActiveControls/ActiveCheckBoxTestCase.php +++ b/tests/FunctionalTests/quickstart/ActiveControls/ActiveCheckBoxTestCase.php @@ -1,58 +1,58 @@ -<?php
-
-//$Id$
-class ActiveCheckBoxTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=ActiveControls.Samples.TActiveCheckBox.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- $this->assertTextPresent('TActiveCheckBox Samples (AJAX)');
-
-
- // an auto postback checkbox
- $this->verifyTextNotPresent("ctl0_body_ctl0 clicked using callback");
- $this->click("//input[@name='ctl0\$body\$ctl0']");
- $this->pause(800);
- $this->assertChecked("//input[@name='ctl0\$body\$ctl0']");
- $this->verifyTextPresent("ctl0_body_ctl0 clicked using callback");
- $this->click("//input[@name='ctl0\$body\$ctl0']");
- $this->pause(800);
- $this->verifyTextPresent("ctl0_body_ctl0 clicked using callback");
- $this->assertNotChecked("//input[@name='ctl0\$body\$ctl0']");
-
- // a checkbox causing validation on a textbox
- $this->verifyNotVisible('ctl0_body_ctl1');
- $this->click("//input[@name='ctl0\$body\$ctl2']");
- $this->verifyVisible('ctl0_body_ctl1');
- $this->click("//input[@name='ctl0\$body\$ctl2']", "");
- $this->verifyVisible('ctl0_body_ctl3');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->click("//input[@name='ctl0\$body\$ctl2']", "");
- $this->pause(800);
- $this->verifyNotVisible('ctl0_body_ctl1');
- $this->assertTextPresent("ctl0_body_ctl2 clicked using callback");
-
- // a checkbox validated by a required field validator
- $this->assertNotChecked("//input[@name='ctl0\$body\$CheckBox']");
- $this->verifyNotVisible('ctl0_body_ctl4');
- $this->click("//input[@type='submit' and @value='Submit']", "");
- $this->verifyVisible('ctl0_body_ctl4');
- $this->click("//input[@name='ctl0\$body\$CheckBox']", "");
- $this->assertChecked("//input[@name='ctl0\$body\$CheckBox']");
- $this->click("//input[@type='submit' and @value='Submit']", "");
- $this->verifyNotVisible('ctl0_body_ctl4');
- $this->assertTextPresent("ctl0_body_CheckBox clicked");
-
- // a checkbox validated by a required field validator using AutoPostBack
- $this->assertChecked("//input[@name='ctl0\$body\$CheckBox2']");
- $this->verifyNotVisible('ctl0_body_ctl5');
- $this->click("//input[@name='ctl0\$body\$CheckBox2']", "");
- $this->verifyVisible('ctl0_body_ctl5');
- $this->assertChecked("//input[@name='ctl0\$body\$CheckBox2']");
- }
-}
-
+<?php + +//$Id$ +class ActiveCheckBoxTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=ActiveControls.Samples.TActiveCheckBox.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + $this->assertTextPresent('TActiveCheckBox Samples (AJAX)'); + + + // an auto postback checkbox + $this->verifyTextNotPresent("ctl0_body_ctl0 clicked using callback"); + $this->click("//input[@name='ctl0\$body\$ctl0']"); + $this->pause(800); + $this->assertChecked("//input[@name='ctl0\$body\$ctl0']"); + $this->verifyTextPresent("ctl0_body_ctl0 clicked using callback"); + $this->click("//input[@name='ctl0\$body\$ctl0']"); + $this->pause(800); + $this->verifyTextPresent("ctl0_body_ctl0 clicked using callback"); + $this->assertNotChecked("//input[@name='ctl0\$body\$ctl0']"); + + // a checkbox causing validation on a textbox + $this->verifyNotVisible('ctl0_body_ctl1'); + $this->click("//input[@name='ctl0\$body\$ctl2']"); + $this->verifyVisible('ctl0_body_ctl1'); + $this->click("//input[@name='ctl0\$body\$ctl2']", ""); + $this->verifyVisible('ctl0_body_ctl3'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->click("//input[@name='ctl0\$body\$ctl2']", ""); + $this->pause(800); + $this->verifyNotVisible('ctl0_body_ctl1'); + $this->assertTextPresent("ctl0_body_ctl2 clicked using callback"); + + // a checkbox validated by a required field validator + $this->assertNotChecked("//input[@name='ctl0\$body\$CheckBox']"); + $this->verifyNotVisible('ctl0_body_ctl4'); + $this->click("//input[@type='submit' and @value='Submit']", ""); + $this->verifyVisible('ctl0_body_ctl4'); + $this->click("//input[@name='ctl0\$body\$CheckBox']", ""); + $this->assertChecked("//input[@name='ctl0\$body\$CheckBox']"); + $this->click("//input[@type='submit' and @value='Submit']", ""); + $this->verifyNotVisible('ctl0_body_ctl4'); + $this->assertTextPresent("ctl0_body_CheckBox clicked"); + + // a checkbox validated by a required field validator using AutoPostBack + $this->assertChecked("//input[@name='ctl0\$body\$CheckBox2']"); + $this->verifyNotVisible('ctl0_body_ctl5'); + $this->click("//input[@name='ctl0\$body\$CheckBox2']", ""); + $this->verifyVisible('ctl0_body_ctl5'); + $this->assertChecked("//input[@name='ctl0\$body\$CheckBox2']"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/ActiveControls/ActiveCustomValidatorTestCase.php b/tests/FunctionalTests/quickstart/ActiveControls/ActiveCustomValidatorTestCase.php index 3346f2b1..4b81e872 100644 --- a/tests/FunctionalTests/quickstart/ActiveControls/ActiveCustomValidatorTestCase.php +++ b/tests/FunctionalTests/quickstart/ActiveControls/ActiveCustomValidatorTestCase.php @@ -1,34 +1,34 @@ -<?php
-//$Id: ActiveButtonTestCase.php 1405 2006-09-10 01:03:56Z wei $
-class ActiveCustomValidatorTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=ActiveControls.Samples.TActiveCustomValidator.Home&notheme=true&lang=en");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- $this->assertTextPresent('TActiveCustomValidator Samples (AJAX)');
-
- $base = 'ctl0_body_';
-
- $this->assertNotVisible($base.'validator1');
- $this->click($base.'button1');
- $this->pause(800);
- $this->assertVisible($base.'validator1');
-
- $this->type($base.'textbox1', 'hello');
- $this->pause(800);
- $this->assertVisible($base.'validator1');
-
- $this->type($base.'textbox1', 'Prado');
- $this->pause(800);
- $this->assertVisible($base.'validator1');
-
- $this->click($base.'button1');
- $this->pause(800);
- $this->assertNotVisible($base.'validator1');
- }
-}
-
+<?php +//$Id: ActiveButtonTestCase.php 1405 2006-09-10 01:03:56Z wei $ +class ActiveCustomValidatorTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=ActiveControls.Samples.TActiveCustomValidator.Home&notheme=true&lang=en"); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + $this->assertTextPresent('TActiveCustomValidator Samples (AJAX)'); + + $base = 'ctl0_body_'; + + $this->assertNotVisible($base.'validator1'); + $this->click($base.'button1'); + $this->pause(800); + $this->assertVisible($base.'validator1'); + + $this->type($base.'textbox1', 'hello'); + $this->pause(800); + $this->assertVisible($base.'validator1'); + + $this->type($base.'textbox1', 'Prado'); + $this->pause(800); + $this->assertVisible($base.'validator1'); + + $this->click($base.'button1'); + $this->pause(800); + $this->assertNotVisible($base.'validator1'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Advanced/I18N.php b/tests/FunctionalTests/quickstart/Advanced/I18N.php index 010b7da5..fb8aa710 100644 --- a/tests/FunctionalTests/quickstart/Advanced/I18N.php +++ b/tests/FunctionalTests/quickstart/Advanced/I18N.php @@ -1,54 +1,54 @@ -<?php
-
-//New Test
-class I18NTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?notheme=true&page=Advanced.Samples.I18N.Home&lang=en&notheme=true", "");
- $this->verifyTextPresent("Internationlization in PRADO", "");
- $this->verifyTextPresent("46.412,42 €", "");
- $this->verifyTextPresent("$12.40", "");
- $this->verifyTextPresent("€100.00", "");
- $this->verifyTextPresent("December 6, 2004", "");
- $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=zh&notheme=true", "");
- $this->verifyTextPresent("PRADO 国际化", "");
- $this->verifyTextPresent("2004 十二月", "");
- $this->verifyTextPresent("US$ 12.40", "");
- $this->verifyTextPresent("46.412,42 €", "");
- $this->verifyTextPresent("€100.00 ", "");
- $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=zh_TW&notheme=true", "");
- $this->verifyTextPresent("PRADO 國際化", "");
- $this->verifyTextPresent("2004年12月6日", "");
- $this->verifyTextPresent("US$12.40", "");
- $this->verifyTextPresent("46.412,42 €", "");
- $this->verifyTextPresent("€100.00", "");
- $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=de&notheme=true", "");
- $this->verifyTextPresent("Internationalisierung in PRADO", "");
- $this->verifyTextPresent("6. Dezember 2004 ", "");
- $this->verifyTextPresent("$ 12,40", "");
- $this->verifyTextPresent("46.412,42 €", "");
- $this->verifyTextPresent("€100.00", "");
- $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=es&notheme=true", "");
- $this->verifyTextPresent("Internationlization en PRADO", "");
- $this->verifyTextPresent("6 de diciembre de 2004", "");
- $this->verifyTextPresent("US$12.40", "");
- $this->verifyTextPresent("46.412,42 €", "");
- $this->verifyTextPresent("€100.00", "");
- $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=fr&notheme=true", "");
- $this->verifyTextPresent("Internationalisation avec PRADO", "");
- $this->verifyTextPresent("6 décembre 2004", "");
- $this->verifyTextPresent("12,40 $", "");
- $this->verifyTextPresent("46.412,42 €", "");
- $this->verifyTextPresent("€100.00", "");
- $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=pl&notheme=true", "");
- $this->verifyTextPresent("Internacjonalizacja w PRADO", "");
- $this->verifyTextPresent("6 grudnia 2004", "");
- $this->verifyTextPresent("US$ 12,40", "");
- $this->verifyTextPresent("46.412,42 €", "");
- $this->verifyTextPresent("€100.00", "");
-
- }
-}
-
+<?php + +//New Test +class I18NTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?notheme=true&page=Advanced.Samples.I18N.Home&lang=en&notheme=true", ""); + $this->verifyTextPresent("Internationlization in PRADO", ""); + $this->verifyTextPresent("46.412,42 €", ""); + $this->verifyTextPresent("$12.40", ""); + $this->verifyTextPresent("€100.00", ""); + $this->verifyTextPresent("December 6, 2004", ""); + $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=zh&notheme=true", ""); + $this->verifyTextPresent("PRADO 国际化", ""); + $this->verifyTextPresent("2004 十二月", ""); + $this->verifyTextPresent("US$ 12.40", ""); + $this->verifyTextPresent("46.412,42 €", ""); + $this->verifyTextPresent("€100.00 ", ""); + $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=zh_TW&notheme=true", ""); + $this->verifyTextPresent("PRADO 國際化", ""); + $this->verifyTextPresent("2004年12月6日", ""); + $this->verifyTextPresent("US$12.40", ""); + $this->verifyTextPresent("46.412,42 €", ""); + $this->verifyTextPresent("€100.00", ""); + $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=de&notheme=true", ""); + $this->verifyTextPresent("Internationalisierung in PRADO", ""); + $this->verifyTextPresent("6. Dezember 2004 ", ""); + $this->verifyTextPresent("$ 12,40", ""); + $this->verifyTextPresent("46.412,42 €", ""); + $this->verifyTextPresent("€100.00", ""); + $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=es&notheme=true", ""); + $this->verifyTextPresent("Internationlization en PRADO", ""); + $this->verifyTextPresent("6 de diciembre de 2004", ""); + $this->verifyTextPresent("US$12.40", ""); + $this->verifyTextPresent("46.412,42 €", ""); + $this->verifyTextPresent("€100.00", ""); + $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=fr&notheme=true", ""); + $this->verifyTextPresent("Internationalisation avec PRADO", ""); + $this->verifyTextPresent("6 décembre 2004", ""); + $this->verifyTextPresent("12,40 $", ""); + $this->verifyTextPresent("46.412,42 €", ""); + $this->verifyTextPresent("€100.00", ""); + $this->open("../../demos/quickstart/index.php?page=Advanced.Samples.I18N.Home&lang=pl&notheme=true", ""); + $this->verifyTextPresent("Internacjonalizacja w PRADO", ""); + $this->verifyTextPresent("6 grudnia 2004", ""); + $this->verifyTextPresent("US$ 12,40", ""); + $this->verifyTextPresent("46.412,42 €", ""); + $this->verifyTextPresent("€100.00", ""); + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/BulletedListTestCase.php b/tests/FunctionalTests/quickstart/Controls/BulletedListTestCase.php index 23107824..e1987e38 100644 --- a/tests/FunctionalTests/quickstart/Controls/BulletedListTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/BulletedListTestCase.php @@ -1,38 +1,38 @@ -<?php
-
-class BulletedListTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TBulletedList.Home&notheme=true&lang=en", "");
-
- // verify if all required texts are present
- $this->verifyTextPresent('item 1','');
- $this->verifyTextPresent('item 2','');
- $this->verifyTextPresent('item 3','');
- $this->verifyTextPresent('item 4','');
- $this->verifyTextPresent('google','');
- $this->verifyTextPresent('yahoo','');
- $this->verifyTextPresent('amazon','');
-
- // verify order list starting from 5
- $this->verifyElementPresent("//ol[@start='5']");
-
- // unable to verify styles
-
- // verify hyperlink list
- $this->verifyElementPresent("//a[@href='http://www.google.com/']");
- $this->verifyElementPresent("//a[@href='http://www.yahoo.com/']");
- $this->verifyElementPresent("//a[@href='http://www.amazon.com/']");
-
- // verify linkbutton list
- $this->clickAndWait("id=ctl0_body_ctl40", "");
- $this->verifyTextPresent("You clicked google : http://www.google.com/.", "");
- $this->clickAndWait("id=ctl0_body_ctl41", "");
- $this->verifyTextPresent("You clicked yahoo : http://www.yahoo.com/.", "");
- $this->clickAndWait("id=ctl0_body_ctl42", "");
- $this->verifyTextPresent("You clicked amazon : http://www.amazon.com/.", "");
- }
-}
-
+<?php + +class BulletedListTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TBulletedList.Home&notheme=true&lang=en", ""); + + // verify if all required texts are present + $this->verifyTextPresent('item 1',''); + $this->verifyTextPresent('item 2',''); + $this->verifyTextPresent('item 3',''); + $this->verifyTextPresent('item 4',''); + $this->verifyTextPresent('google',''); + $this->verifyTextPresent('yahoo',''); + $this->verifyTextPresent('amazon',''); + + // verify order list starting from 5 + $this->verifyElementPresent("//ol[@start='5']"); + + // unable to verify styles + + // verify hyperlink list + $this->verifyElementPresent("//a[@href='http://www.google.com/']"); + $this->verifyElementPresent("//a[@href='http://www.yahoo.com/']"); + $this->verifyElementPresent("//a[@href='http://www.amazon.com/']"); + + // verify linkbutton list + $this->clickAndWait("id=ctl0_body_ctl40", ""); + $this->verifyTextPresent("You clicked google : http://www.google.com/.", ""); + $this->clickAndWait("id=ctl0_body_ctl41", ""); + $this->verifyTextPresent("You clicked yahoo : http://www.yahoo.com/.", ""); + $this->clickAndWait("id=ctl0_body_ctl42", ""); + $this->verifyTextPresent("You clicked amazon : http://www.amazon.com/.", ""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/ButtonTestCase.php b/tests/FunctionalTests/quickstart/Controls/ButtonTestCase.php index 50458663..ca079c14 100644 --- a/tests/FunctionalTests/quickstart/Controls/ButtonTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/ButtonTestCase.php @@ -1,35 +1,35 @@ -<?php
-
-class ButtonTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TButton.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // a regular button
- $this->clickAndWait("//input[@type='submit' and @value='text']", "");
-
- // a click button
- $this->verifyElementNotPresent("//input[@type='submit' and @value=\"I'm clicked\"]");
- $this->clickAndWait("//input[@type='submit' and @value='click me']", "");
- $this->verifyElementPresent("//input[@type='submit' and @value=\"I'm clicked\"]");
-
- // a command button
- $this->verifyElementNotPresent("//input[@type='submit' and @value=\"Name: test, Param: value\"]");
- $this->clickAndWait("//input[@type='submit' and @value='click me']", "");
- $this->verifyElementPresent("//input[@type='submit' and @value=\"Name: test, Param: value\"]");
-
- // a button causing validation
- $this->verifyNotVisible('ctl0_body_ctl3');
- $this->click("//input[@type='submit' and @value='submit']", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl3');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->clickAndWait("//input[@type='submit' and @value='submit']", "");
- $this->verifyNotVisible('ctl0_body_ctl3');
- }
-}
-
+<?php + +class ButtonTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TButton.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // a regular button + $this->clickAndWait("//input[@type='submit' and @value='text']", ""); + + // a click button + $this->verifyElementNotPresent("//input[@type='submit' and @value=\"I'm clicked\"]"); + $this->clickAndWait("//input[@type='submit' and @value='click me']", ""); + $this->verifyElementPresent("//input[@type='submit' and @value=\"I'm clicked\"]"); + + // a command button + $this->verifyElementNotPresent("//input[@type='submit' and @value=\"Name: test, Param: value\"]"); + $this->clickAndWait("//input[@type='submit' and @value='click me']", ""); + $this->verifyElementPresent("//input[@type='submit' and @value=\"Name: test, Param: value\"]"); + + // a button causing validation + $this->verifyNotVisible('ctl0_body_ctl3'); + $this->click("//input[@type='submit' and @value='submit']", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl3'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->clickAndWait("//input[@type='submit' and @value='submit']", ""); + $this->verifyNotVisible('ctl0_body_ctl3'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/CheckBoxListTestCase.php b/tests/FunctionalTests/quickstart/Controls/CheckBoxListTestCase.php index a28efd75..01db9da7 100644 --- a/tests/FunctionalTests/quickstart/Controls/CheckBoxListTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/CheckBoxListTestCase.php @@ -1,54 +1,54 @@ -<?php
-
-//New Test
-class CheckBoxListTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TCheckBoxList.Home&notheme=true&lang=en", "");
-
- // Check box list with default settings:
- $this->click("//input[@name='ctl0\$body\$ctl0\$c0' and @value='value 1']", "");
-
- // Check box list with customized cellpadding, cellspacing, color and text alignment:
- $this->click("//input[@name='ctl0\$body\$ctl1\$c1' and @value='value 2']", "");
-
- // *** Currently unable to test the following cases:
- // Check box list with vertical (default) repeat direction
- // Check box list with horizontal repeat direction
- // Check box list with flow layout and vertical (default) repeat direction
- // Check box list with flow layout and horizontal repeat direction:
-
- // Check box list's behavior upon postback
- $this->click("//input[@name='ctl0\$body\$CheckBoxList\$c2' and @value='value 3']", "");
- $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
- $this->verifyTextPresent("Your selection is: (Index: 1, Value: value 2, Text: item 2)(Index: 2, Value: value 3, Text: item 3)(Index: 4, Value: value 5, Text: item 5)", "");
-
- // Auto postback check box list
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl7\$c1' and @value='value 2']", "");
- $this->verifyTextPresent("Your selection is: (Index: 4, Value: value 5, Text: item 5)", "");
-
- // Databind to an integer-indexed array
- $this->clickAndWait("//input[@name='ctl0\$body\$DBCheckBoxList1\$c1' and @value='1']", "");
- $this->verifyTextPresent("Your selection is: (Index: 1, Value: 1, Text: item 2)", "");
-
- // Databind to an associative array:
- $this->clickAndWait("//input[@name='ctl0\$body\$DBCheckBoxList2\$c1' and @value='key 2']", "");
- $this->verifyTextPresent("Your selection is: (Index: 1, Value: key 2, Text: item 2)", "");
-
- // Databind with DataTextField and DataValueField specified
- $this->clickAndWait("//input[@name='ctl0\$body\$DBCheckBoxList3\$c2' and @value='003']", "");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: 003, Text: Cary)", "");
-
- // CheckBox list causing validation
- $this->verifyNotVisible('ctl0_body_ctl8');
- $this->click("//input[@name='ctl0\$body\$ctl9\$c0' and @value='Agree']", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl8');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl9\$c0' and @value='Agree']", "");
- $this->verifyNotVisible('ctl0_body_ctl8');
- }
-}
-
+<?php + +//New Test +class CheckBoxListTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TCheckBoxList.Home&notheme=true&lang=en", ""); + + // Check box list with default settings: + $this->click("//input[@name='ctl0\$body\$ctl0\$c0' and @value='value 1']", ""); + + // Check box list with customized cellpadding, cellspacing, color and text alignment: + $this->click("//input[@name='ctl0\$body\$ctl1\$c1' and @value='value 2']", ""); + + // *** Currently unable to test the following cases: + // Check box list with vertical (default) repeat direction + // Check box list with horizontal repeat direction + // Check box list with flow layout and vertical (default) repeat direction + // Check box list with flow layout and horizontal repeat direction: + + // Check box list's behavior upon postback + $this->click("//input[@name='ctl0\$body\$CheckBoxList\$c2' and @value='value 3']", ""); + $this->clickAndWait("//input[@type='submit' and @value='Submit']", ""); + $this->verifyTextPresent("Your selection is: (Index: 1, Value: value 2, Text: item 2)(Index: 2, Value: value 3, Text: item 3)(Index: 4, Value: value 5, Text: item 5)", ""); + + // Auto postback check box list + $this->clickAndWait("//input[@name='ctl0\$body\$ctl7\$c1' and @value='value 2']", ""); + $this->verifyTextPresent("Your selection is: (Index: 4, Value: value 5, Text: item 5)", ""); + + // Databind to an integer-indexed array + $this->clickAndWait("//input[@name='ctl0\$body\$DBCheckBoxList1\$c1' and @value='1']", ""); + $this->verifyTextPresent("Your selection is: (Index: 1, Value: 1, Text: item 2)", ""); + + // Databind to an associative array: + $this->clickAndWait("//input[@name='ctl0\$body\$DBCheckBoxList2\$c1' and @value='key 2']", ""); + $this->verifyTextPresent("Your selection is: (Index: 1, Value: key 2, Text: item 2)", ""); + + // Databind with DataTextField and DataValueField specified + $this->clickAndWait("//input[@name='ctl0\$body\$DBCheckBoxList3\$c2' and @value='003']", ""); + $this->verifyTextPresent("Your selection is: (Index: 2, Value: 003, Text: Cary)", ""); + + // CheckBox list causing validation + $this->verifyNotVisible('ctl0_body_ctl8'); + $this->click("//input[@name='ctl0\$body\$ctl9\$c0' and @value='Agree']", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl8'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->clickAndWait("//input[@name='ctl0\$body\$ctl9\$c0' and @value='Agree']", ""); + $this->verifyNotVisible('ctl0_body_ctl8'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/CheckBoxTestCase.php b/tests/FunctionalTests/quickstart/Controls/CheckBoxTestCase.php index 464769d7..4cd71bd4 100644 --- a/tests/FunctionalTests/quickstart/Controls/CheckBoxTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/CheckBoxTestCase.php @@ -1,55 +1,55 @@ -<?php
-
-class CheckBoxTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TCheckBox.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // a regular checkbox
- $this->click("//input[@name='ctl0\$body\$ctl0']", "");
-
- // a checkbox with customized value
- $this->click("//input[@name='ctl0\$body\$ctl1' and @value='value']", "");
-
- // an auto postback checkbox
- $this->verifyTextNotPresent("I'm clicked");
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl2']", "");
- $this->verifyTextPresent("I'm clicked");
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl2']", "");
- $this->verifyTextPresent("I'm clicked");
-
- // a checkbox causing validation on a textbox
- $this->verifyNotVisible('ctl0_body_ctl3');
- $this->click("//input[@name='ctl0\$body\$ctl4']", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl3');
- $this->click("//input[@name='ctl0\$body\$ctl4']", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl3');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl4']", "");
- $this->verifyNotVisible('ctl0_body_ctl3');
-
- // a checkbox validated by a required field validator
- $this->verifyNotVisible('ctl0_body_ctl6');
- $this->click("//input[@type='submit' and @value='Submit']", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl6');
- $this->click("//input[@name='ctl0\$body\$CheckBox']", "");
- $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
- $this->verifyNotVisible('ctl0_body_ctl6');
-
- // a checkbox validated by a required field validator using AutoPostBack
- $this->verifyNotVisible('ctl0_body_ctl7');
- $this->click("//input[@name='ctl0\$body\$CheckBox2']", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl7');
-// $this->clickAndWait("//input[@name='ctl0\$body\$CheckBox2' and @value='ctl0\$body\$CheckBox2']", "");
-// $this->verifyNotVisible('ctl0_body_ctl7');
- }
-}
-
+<?php + +class CheckBoxTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TCheckBox.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // a regular checkbox + $this->click("//input[@name='ctl0\$body\$ctl0']", ""); + + // a checkbox with customized value + $this->click("//input[@name='ctl0\$body\$ctl1' and @value='value']", ""); + + // an auto postback checkbox + $this->verifyTextNotPresent("I'm clicked"); + $this->clickAndWait("//input[@name='ctl0\$body\$ctl2']", ""); + $this->verifyTextPresent("I'm clicked"); + $this->clickAndWait("//input[@name='ctl0\$body\$ctl2']", ""); + $this->verifyTextPresent("I'm clicked"); + + // a checkbox causing validation on a textbox + $this->verifyNotVisible('ctl0_body_ctl3'); + $this->click("//input[@name='ctl0\$body\$ctl4']", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl3'); + $this->click("//input[@name='ctl0\$body\$ctl4']", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl3'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->clickAndWait("//input[@name='ctl0\$body\$ctl4']", ""); + $this->verifyNotVisible('ctl0_body_ctl3'); + + // a checkbox validated by a required field validator + $this->verifyNotVisible('ctl0_body_ctl6'); + $this->click("//input[@type='submit' and @value='Submit']", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl6'); + $this->click("//input[@name='ctl0\$body\$CheckBox']", ""); + $this->clickAndWait("//input[@type='submit' and @value='Submit']", ""); + $this->verifyNotVisible('ctl0_body_ctl6'); + + // a checkbox validated by a required field validator using AutoPostBack + $this->verifyNotVisible('ctl0_body_ctl7'); + $this->click("//input[@name='ctl0\$body\$CheckBox2']", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl7'); +// $this->clickAndWait("//input[@name='ctl0\$body\$CheckBox2' and @value='ctl0\$body\$CheckBox2']", ""); +// $this->verifyNotVisible('ctl0_body_ctl7'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/DataGrid1TestCase.php b/tests/FunctionalTests/quickstart/Controls/DataGrid1TestCase.php index 41bb754b..9eea13b8 100644 --- a/tests/FunctionalTests/quickstart/Controls/DataGrid1TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/DataGrid1TestCase.php @@ -1,31 +1,31 @@ -<?php
-
-class DataGrid1TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample1&notheme=true&lang=en", "");
-
- // verify if all required texts are present
- $this->verifyTextPresent('id','');
- $this->verifyTextPresent('name','');
- $this->verifyTextPresent('quantity','');
- $this->verifyTextPresent('price','');
- $this->verifyTextPresent('imported','');
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextPresent('Motherboard','');
- $this->verifyTextPresent('100','');
- $this->verifyTextPresent('true','');
- $this->verifyTextPresent('ITN019','');
- $this->verifyTextPresent('Speaker','');
- $this->verifyTextPresent('35','');
- $this->verifyTextPresent('65','');
- $this->verifyTextPresent('false','');
-
- // verify specific table tags
- $this->verifyElementPresent("ctl0_body_DataGrid");
- $this->verifyAttribute("ctl0_body_DataGrid@cellpadding","2");
- }
-}
-
+<?php + +class DataGrid1TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample1&notheme=true&lang=en", ""); + + // verify if all required texts are present + $this->verifyTextPresent('id',''); + $this->verifyTextPresent('name',''); + $this->verifyTextPresent('quantity',''); + $this->verifyTextPresent('price',''); + $this->verifyTextPresent('imported',''); + $this->verifyTextPresent('ITN001',''); + $this->verifyTextPresent('Motherboard',''); + $this->verifyTextPresent('100',''); + $this->verifyTextPresent('true',''); + $this->verifyTextPresent('ITN019',''); + $this->verifyTextPresent('Speaker',''); + $this->verifyTextPresent('35',''); + $this->verifyTextPresent('65',''); + $this->verifyTextPresent('false',''); + + // verify specific table tags + $this->verifyElementPresent("ctl0_body_DataGrid"); + $this->verifyAttribute("ctl0_body_DataGrid@cellpadding","2"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/DataGrid2TestCase.php b/tests/FunctionalTests/quickstart/Controls/DataGrid2TestCase.php index 3c01c29a..6573125a 100644 --- a/tests/FunctionalTests/quickstart/Controls/DataGrid2TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/DataGrid2TestCase.php @@ -1,51 +1,51 @@ -<?php
-
-class DataGrid2TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample2&notheme=true&lang=en", "");
-
- // verify if all required texts are present
- $this->verifyTextPresent('Book Title','');
- $this->verifyTextPresent('Publisher','');
- $this->verifyTextPresent('Price','');
- $this->verifyTextPresent('In-stock','');
- $this->verifyTextPresent('Rating','');
-
- // verify book titles
- $this->verifyElementPresent("//a[@href='http://www.amazon.com/gp/product/0596007124' and text()='Head First Design Patterns']",'');
- $this->verifyElementPresent("//a[@href='http://www.amazon.com/gp/product/0321278658' and text()='Extreme Programming Explained : Embrace Change']",'');
-
- // verify publishers
- $this->verifyTextPresent("O'Reilly Media, Inc.",'');
- $this->verifyTextPresent("Addison-Wesley Professional",'');
-
- // verify prices
- $this->verifyTextPresent("\$37.49",'');
- $this->verifyTextPresent("\$38.49",'');
-
- // verify in-stock
- $this->verifyAttribute('ctl0_body_DataGrid_ctl1_ctl5@checked','regexp:true|checked');
- $this->verifyAttribute('ctl0_body_DataGrid_ctl1_ctl5@disabled','regexp:true|disabled');
- $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl5@checked','regexp:true|checked');
- $this->verifyAttribute('ctl0_body_DataGrid_ctl6_ctl5@checked','regexp:false|null');
- $this->verifyAttribute('ctl0_body_DataGrid_ctl6_ctl5@disabled','regexp:true|disabled');
-
- // verify ratings
- //$this->verifyElementPresent("//img[@src='images/star5.gif']",'');
- //$this->verifyElementPresent("//img[@src='images/star2.gif']",'');
-
- // verify toggle column visibility
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c0' and @value='Book Title']", "");
- $this->verifyTextNotPresent('Head First Design Patterns','');
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c3' and @value='In-stock']", "");
- $this->verifyElementNotPresent('ctl0_body_DataGrid_ctl1_ctl5','');
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c3' and @value='In-stock']", "");
- $this->verifyElementPresent('ctl0_body_DataGrid_ctl1_ctl5','');
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c0' and @value='Book Title']", "");
- $this->verifyTextPresent('Head First Design Patterns','');
- }
-}
-
+<?php + +class DataGrid2TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample2&notheme=true&lang=en", ""); + + // verify if all required texts are present + $this->verifyTextPresent('Book Title',''); + $this->verifyTextPresent('Publisher',''); + $this->verifyTextPresent('Price',''); + $this->verifyTextPresent('In-stock',''); + $this->verifyTextPresent('Rating',''); + + // verify book titles + $this->verifyElementPresent("//a[@href='http://www.amazon.com/gp/product/0596007124' and text()='Head First Design Patterns']",''); + $this->verifyElementPresent("//a[@href='http://www.amazon.com/gp/product/0321278658' and text()='Extreme Programming Explained : Embrace Change']",''); + + // verify publishers + $this->verifyTextPresent("O'Reilly Media, Inc.",''); + $this->verifyTextPresent("Addison-Wesley Professional",''); + + // verify prices + $this->verifyTextPresent("\$37.49",''); + $this->verifyTextPresent("\$38.49",''); + + // verify in-stock + $this->verifyAttribute('ctl0_body_DataGrid_ctl1_ctl5@checked','regexp:true|checked'); + $this->verifyAttribute('ctl0_body_DataGrid_ctl1_ctl5@disabled','regexp:true|disabled'); + $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl5@checked','regexp:true|checked'); + $this->verifyAttribute('ctl0_body_DataGrid_ctl6_ctl5@checked','regexp:false|null'); + $this->verifyAttribute('ctl0_body_DataGrid_ctl6_ctl5@disabled','regexp:true|disabled'); + + // verify ratings + //$this->verifyElementPresent("//img[@src='images/star5.gif']",''); + //$this->verifyElementPresent("//img[@src='images/star2.gif']",''); + + // verify toggle column visibility + $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c0' and @value='Book Title']", ""); + $this->verifyTextNotPresent('Head First Design Patterns',''); + $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c3' and @value='In-stock']", ""); + $this->verifyElementNotPresent('ctl0_body_DataGrid_ctl1_ctl5',''); + $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c3' and @value='In-stock']", ""); + $this->verifyElementPresent('ctl0_body_DataGrid_ctl1_ctl5',''); + $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c0' and @value='Book Title']", ""); + $this->verifyTextPresent('Head First Design Patterns',''); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/DataGrid3TestCase.php b/tests/FunctionalTests/quickstart/Controls/DataGrid3TestCase.php index f084ff40..d342c791 100644 --- a/tests/FunctionalTests/quickstart/Controls/DataGrid3TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/DataGrid3TestCase.php @@ -1,52 +1,52 @@ -<?php
-
-class DataGrid3TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample3&notheme=true&lang=en", "");
-
- // verify the 2nd row of data
- $this->verifyTextPresent("Design Patterns: Elements of Reusable Object-Oriented Software", "");
- $this->verifyTextPresent("Addison-Wesley Professional", "");
- $this->verifyTextPresent("$47.04", "");
- $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl4@checked','regexp:true|checked');
- $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl4@disabled','regexp:true|disabled');
- //$this->verifyElementPresent("//img[@src='images/star5.gif']",'');
-
- // edit the 2nd row
- $this->clickAndWait("id=ctl0_body_DataGrid_ctl2_ctl7", "");
- $this->type("ctl0\$body\$DataGrid\$ctl2\$ctl1", "Design Pattern: Elements of Reusable Object-Oriented Software");
- $this->type("ctl0\$body\$DataGrid\$ctl2\$ctl3", "Addison Wesley Professional");
- $this->type("ctl0\$body\$DataGrid\$ctl2\$ctl5", "\$57.04");
- $this->click("//input[@name='ctl0\$body\$DataGrid\$ctl2\$ctl7']", "");
- $this->select("ctl0\$body\$DataGrid\$ctl2\$ctl9", "label=1");
- $this->clickAndWait("link=Save", "");
-
- // verify the 2nd row is saved
- $this->verifyTextPresent("Design Pattern: Elements of Reusable Object-Oriented Software", "");
- $this->verifyTextPresent("Addison Wesley Professional", "");
- $this->verifyTextPresent("$57.04", "");
- $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl4@checked','regexp:false|null');
- $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl4@disabled','regexp:true|disabled');
- //$this->verifyElementPresent("//img[@src='images/star1.gif']",'');
-
- // verify cancel editting the 3rd row
- $this->clickAndWait("id=ctl0_body_DataGrid_ctl3_ctl7", "");
- $this->clickAndWait("link=Cancel", "");
- $this->verifyTextPresent("Design Patterns Explained : A New Perspective on Object-Oriented Design", "");
-
- // verify deleting
- $this->clickAndWait("id=ctl0_body_DataGrid_ctl3_ctl9", "");
- $this->verifyConfirmation("Are you sure?");
- $this->verifyTextNotPresent("Design Patterns Explained : A New Perspective on Object-Oriented Design", "");
-
- $this->verifyTextPresent("Extreme Programming Explained : Embrace Change",'');
- $this->chooseCancelOnNextConfirmation();
- $this->click("id=ctl0_body_DataGrid_ctl6_ctl9", "");
- $this->verifyConfirmation("Are you sure?");
- $this->verifyTextPresent("Extreme Programming Explained : Embrace Change",'');
- }
-}
-
+<?php + +class DataGrid3TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample3&notheme=true&lang=en", ""); + + // verify the 2nd row of data + $this->verifyTextPresent("Design Patterns: Elements of Reusable Object-Oriented Software", ""); + $this->verifyTextPresent("Addison-Wesley Professional", ""); + $this->verifyTextPresent("$47.04", ""); + $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl4@checked','regexp:true|checked'); + $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl4@disabled','regexp:true|disabled'); + //$this->verifyElementPresent("//img[@src='images/star5.gif']",''); + + // edit the 2nd row + $this->clickAndWait("id=ctl0_body_DataGrid_ctl2_ctl7", ""); + $this->type("ctl0\$body\$DataGrid\$ctl2\$ctl1", "Design Pattern: Elements of Reusable Object-Oriented Software"); + $this->type("ctl0\$body\$DataGrid\$ctl2\$ctl3", "Addison Wesley Professional"); + $this->type("ctl0\$body\$DataGrid\$ctl2\$ctl5", "\$57.04"); + $this->click("//input[@name='ctl0\$body\$DataGrid\$ctl2\$ctl7']", ""); + $this->select("ctl0\$body\$DataGrid\$ctl2\$ctl9", "label=1"); + $this->clickAndWait("link=Save", ""); + + // verify the 2nd row is saved + $this->verifyTextPresent("Design Pattern: Elements of Reusable Object-Oriented Software", ""); + $this->verifyTextPresent("Addison Wesley Professional", ""); + $this->verifyTextPresent("$57.04", ""); + $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl4@checked','regexp:false|null'); + $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl4@disabled','regexp:true|disabled'); + //$this->verifyElementPresent("//img[@src='images/star1.gif']",''); + + // verify cancel editting the 3rd row + $this->clickAndWait("id=ctl0_body_DataGrid_ctl3_ctl7", ""); + $this->clickAndWait("link=Cancel", ""); + $this->verifyTextPresent("Design Patterns Explained : A New Perspective on Object-Oriented Design", ""); + + // verify deleting + $this->clickAndWait("id=ctl0_body_DataGrid_ctl3_ctl9", ""); + $this->verifyConfirmation("Are you sure?"); + $this->verifyTextNotPresent("Design Patterns Explained : A New Perspective on Object-Oriented Design", ""); + + $this->verifyTextPresent("Extreme Programming Explained : Embrace Change",''); + $this->chooseCancelOnNextConfirmation(); + $this->click("id=ctl0_body_DataGrid_ctl6_ctl9", ""); + $this->verifyConfirmation("Are you sure?"); + $this->verifyTextPresent("Extreme Programming Explained : Embrace Change",''); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/DataGrid4TestCase.php b/tests/FunctionalTests/quickstart/Controls/DataGrid4TestCase.php index 0d36480c..0e554dea 100644 --- a/tests/FunctionalTests/quickstart/Controls/DataGrid4TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/DataGrid4TestCase.php @@ -1,30 +1,30 @@ -<?php
-
-class DataGrid4TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample4&notheme=true&lang=en", "");
-
- // verify the 2nd row of data
- $this->verifyTextPresent("Design Patterns: Elements of Reusable Object-Oriented Software", "");
- $this->verifyTextPresent("Addison-Wesley Professional", "");
- $this->verifyTextPresent("$47.04", "");
- $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl5@checked','regexp:true|checked');
- $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl5@disabled','regexp:true|disabled');
-
- // verify sorting
- $this->clickAndWait("link=Book Title", "");
- $this->verifyAttribute('ctl0_body_DataGrid_ctl1_ctl5@checked','regexp:false|null');
- $this->clickAndWait("link=Publisher", "");
- $this->verifyAttribute('ctl0_body_DataGrid_ctl6_ctl5@checked','regexp:false|null');
- $this->clickAndWait("link=Price", "");
- $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl5@checked','regexp:false|null');
- $this->clickAndWait("link=In-stock", "");
- $this->verifyAttribute('ctl0_body_DataGrid_ctl1_ctl5@checked','regexp:false|null');
- $this->clickAndWait("link=Rating", "");
- $this->verifyAttribute('ctl0_body_DataGrid_ctl4_ctl5@checked','regexp:false|null');
- }
-}
-
+<?php + +class DataGrid4TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample4&notheme=true&lang=en", ""); + + // verify the 2nd row of data + $this->verifyTextPresent("Design Patterns: Elements of Reusable Object-Oriented Software", ""); + $this->verifyTextPresent("Addison-Wesley Professional", ""); + $this->verifyTextPresent("$47.04", ""); + $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl5@checked','regexp:true|checked'); + $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl5@disabled','regexp:true|disabled'); + + // verify sorting + $this->clickAndWait("link=Book Title", ""); + $this->verifyAttribute('ctl0_body_DataGrid_ctl1_ctl5@checked','regexp:false|null'); + $this->clickAndWait("link=Publisher", ""); + $this->verifyAttribute('ctl0_body_DataGrid_ctl6_ctl5@checked','regexp:false|null'); + $this->clickAndWait("link=Price", ""); + $this->verifyAttribute('ctl0_body_DataGrid_ctl2_ctl5@checked','regexp:false|null'); + $this->clickAndWait("link=In-stock", ""); + $this->verifyAttribute('ctl0_body_DataGrid_ctl1_ctl5@checked','regexp:false|null'); + $this->clickAndWait("link=Rating", ""); + $this->verifyAttribute('ctl0_body_DataGrid_ctl4_ctl5@checked','regexp:false|null'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/DataGrid5TestCase.php b/tests/FunctionalTests/quickstart/Controls/DataGrid5TestCase.php index 065986ec..c602ddf1 100644 --- a/tests/FunctionalTests/quickstart/Controls/DataGrid5TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/DataGrid5TestCase.php @@ -1,115 +1,115 @@ -<?php
-
-class DataGrid5TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample5&notheme=true&lang=en", "");
-
- // verify if all required texts are present
- // verify column headers
- $this->verifyTextPresent('id','');
- $this->verifyTextPresent('name','');
- $this->verifyTextPresent('quantity','');
- $this->verifyTextPresent('price','');
- $this->verifyTextPresent('imported','');
-
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextPresent('ITN002','');
- $this->verifyTextPresent('ITN003','');
- $this->verifyTextPresent('ITN004','');
- $this->verifyTextPresent('ITN005','');
- $this->verifyTextNotPresent('ITN006','');
-
- // verify paging
- $this->clickAndWait("link=2", "");
- $this->verifyTextPresent('ITN006','');
- $this->verifyTextPresent('ITN007','');
- $this->verifyTextPresent('ITN008','');
- $this->verifyTextPresent('ITN009','');
- $this->verifyTextPresent('ITN010','');
- $this->verifyTextNotPresent('ITN011','');
- $this->verifyTextNotPresent('ITN005','');
-
- $this->clickAndWait("link=4", "");
- $this->verifyTextPresent('ITN016','');
- $this->verifyTextPresent('ITN017','');
- $this->verifyTextPresent('ITN018','');
- $this->verifyTextPresent('ITN019','');
- $this->verifyTextNotPresent('ITN015','');
-
- $this->clickAndWait("link=1", "");
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextPresent('ITN002','');
- $this->verifyTextPresent('ITN003','');
- $this->verifyTextPresent('ITN004','');
- $this->verifyTextPresent('ITN005','');
- $this->verifyTextNotPresent('ITN006','');
-
- // show top pager
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c0' and @value='Top']", "");
- $this->clickAndWait("id=ctl0_body_DataGrid_ctl8_ctl3", "");
- $this->clickAndWait("link=1", "");
- // hide top pager
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c0' and @value='Top']", "");
-
- // change next prev caption
- $this->type("ctl0\$body\$NextPageText", "Next Page");
- $this->type("ctl0\$body\$PrevPageText", "Prev Page");
- $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
-
- // verify next prev paging
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextNotPresent('ITN006','');
- $this->clickAndWait("link=Next Page", "");
- $this->verifyTextNotPresent('ITN005','');
- $this->verifyTextPresent('ITN006','');
- $this->verifyTextNotPresent('ITN011','');
- $this->clickAndWait("link=Next Page", "");
- $this->verifyTextNotPresent('ITN010','');
- $this->verifyTextPresent('ITN011','');
- $this->verifyTextNotPresent('ITN016','');
- $this->clickAndWait("link=Next Page", "");
- $this->verifyTextNotPresent('ITN015','');
- $this->verifyTextPresent('ITN016','');
- $this->clickAndWait("link=Prev Page", "");
- $this->verifyTextNotPresent('ITN010','');
- $this->verifyTextPresent('ITN011','');
- $this->verifyTextNotPresent('ITN016','');
- $this->clickAndWait("link=Prev Page", "");
- $this->verifyTextNotPresent('ITN005','');
- $this->verifyTextPresent('ITN006','');
- $this->verifyTextNotPresent('ITN011','');
- $this->clickAndWait("link=Prev Page", "");
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextNotPresent('ITN006','');
-
- // change button count
- $this->type("ctl0\$body\$PageButtonCount", "2");
- $this->clickAndWait("name=ctl0\$body\$ctl6", "");
- $this->clickAndWait("link=Next Page", "");
- $this->verifyTextNotPresent('ITN010','');
- $this->verifyTextPresent('ITN011','');
- $this->verifyTextNotPresent('ITN016','');
- $this->clickAndWait("link=4", "");
- $this->verifyTextNotPresent('ITN015','');
- $this->verifyTextPresent('ITN016','');
- $this->clickAndWait("link=Prev Page", "");
- $this->verifyTextNotPresent('ITN005','');
- $this->verifyTextPresent('ITN006','');
- $this->verifyTextNotPresent('ITN011','');
-
- $this->type("ctl0\$body\$PageButtonCount", "10");
- $this->clickAndWait("name=ctl0\$body\$ctl6", "");
- $this->type("ctl0\$body\$PageSize", "2");
- $this->clickAndWait("name=ctl0\$body\$ctl8", "");
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextPresent('ITN002','');
- $this->verifyTextNotPresent('ITN003','');
- $this->clickAndWait("link=10", "");
- $this->verifyTextPresent('ITN019','');
- $this->verifyTextNotPresent('ITN018','');
- }
-}
-
+<?php + +class DataGrid5TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample5&notheme=true&lang=en", ""); + + // verify if all required texts are present + // verify column headers + $this->verifyTextPresent('id',''); + $this->verifyTextPresent('name',''); + $this->verifyTextPresent('quantity',''); + $this->verifyTextPresent('price',''); + $this->verifyTextPresent('imported',''); + + $this->verifyTextPresent('ITN001',''); + $this->verifyTextPresent('ITN002',''); + $this->verifyTextPresent('ITN003',''); + $this->verifyTextPresent('ITN004',''); + $this->verifyTextPresent('ITN005',''); + $this->verifyTextNotPresent('ITN006',''); + + // verify paging + $this->clickAndWait("link=2", ""); + $this->verifyTextPresent('ITN006',''); + $this->verifyTextPresent('ITN007',''); + $this->verifyTextPresent('ITN008',''); + $this->verifyTextPresent('ITN009',''); + $this->verifyTextPresent('ITN010',''); + $this->verifyTextNotPresent('ITN011',''); + $this->verifyTextNotPresent('ITN005',''); + + $this->clickAndWait("link=4", ""); + $this->verifyTextPresent('ITN016',''); + $this->verifyTextPresent('ITN017',''); + $this->verifyTextPresent('ITN018',''); + $this->verifyTextPresent('ITN019',''); + $this->verifyTextNotPresent('ITN015',''); + + $this->clickAndWait("link=1", ""); + $this->verifyTextPresent('ITN001',''); + $this->verifyTextPresent('ITN002',''); + $this->verifyTextPresent('ITN003',''); + $this->verifyTextPresent('ITN004',''); + $this->verifyTextPresent('ITN005',''); + $this->verifyTextNotPresent('ITN006',''); + + // show top pager + $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c0' and @value='Top']", ""); + $this->clickAndWait("id=ctl0_body_DataGrid_ctl8_ctl3", ""); + $this->clickAndWait("link=1", ""); + // hide top pager + $this->clickAndWait("//input[@name='ctl0\$body\$ctl1\$c0' and @value='Top']", ""); + + // change next prev caption + $this->type("ctl0\$body\$NextPageText", "Next Page"); + $this->type("ctl0\$body\$PrevPageText", "Prev Page"); + $this->clickAndWait("//input[@type='submit' and @value='Submit']", ""); + + // verify next prev paging + $this->verifyTextPresent('ITN001',''); + $this->verifyTextNotPresent('ITN006',''); + $this->clickAndWait("link=Next Page", ""); + $this->verifyTextNotPresent('ITN005',''); + $this->verifyTextPresent('ITN006',''); + $this->verifyTextNotPresent('ITN011',''); + $this->clickAndWait("link=Next Page", ""); + $this->verifyTextNotPresent('ITN010',''); + $this->verifyTextPresent('ITN011',''); + $this->verifyTextNotPresent('ITN016',''); + $this->clickAndWait("link=Next Page", ""); + $this->verifyTextNotPresent('ITN015',''); + $this->verifyTextPresent('ITN016',''); + $this->clickAndWait("link=Prev Page", ""); + $this->verifyTextNotPresent('ITN010',''); + $this->verifyTextPresent('ITN011',''); + $this->verifyTextNotPresent('ITN016',''); + $this->clickAndWait("link=Prev Page", ""); + $this->verifyTextNotPresent('ITN005',''); + $this->verifyTextPresent('ITN006',''); + $this->verifyTextNotPresent('ITN011',''); + $this->clickAndWait("link=Prev Page", ""); + $this->verifyTextPresent('ITN001',''); + $this->verifyTextNotPresent('ITN006',''); + + // change button count + $this->type("ctl0\$body\$PageButtonCount", "2"); + $this->clickAndWait("name=ctl0\$body\$ctl6", ""); + $this->clickAndWait("link=Next Page", ""); + $this->verifyTextNotPresent('ITN010',''); + $this->verifyTextPresent('ITN011',''); + $this->verifyTextNotPresent('ITN016',''); + $this->clickAndWait("link=4", ""); + $this->verifyTextNotPresent('ITN015',''); + $this->verifyTextPresent('ITN016',''); + $this->clickAndWait("link=Prev Page", ""); + $this->verifyTextNotPresent('ITN005',''); + $this->verifyTextPresent('ITN006',''); + $this->verifyTextNotPresent('ITN011',''); + + $this->type("ctl0\$body\$PageButtonCount", "10"); + $this->clickAndWait("name=ctl0\$body\$ctl6", ""); + $this->type("ctl0\$body\$PageSize", "2"); + $this->clickAndWait("name=ctl0\$body\$ctl8", ""); + $this->verifyTextPresent('ITN001',''); + $this->verifyTextPresent('ITN002',''); + $this->verifyTextNotPresent('ITN003',''); + $this->clickAndWait("link=10", ""); + $this->verifyTextPresent('ITN019',''); + $this->verifyTextNotPresent('ITN018',''); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/DataGrid6TestCase.php b/tests/FunctionalTests/quickstart/Controls/DataGrid6TestCase.php index 05368157..1bf00aff 100644 --- a/tests/FunctionalTests/quickstart/Controls/DataGrid6TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/DataGrid6TestCase.php @@ -1,50 +1,50 @@ -<?php
-
-class DataGrid6TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample6&notheme=true&lang=en", "");
-
- // verify column headers
- $this->verifyTextPresent('id','');
- $this->verifyTextPresent('name','');
- $this->verifyTextPresent('quantity','');
- $this->verifyTextPresent('price','');
- $this->verifyTextPresent('imported','');
-
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextPresent('ITN002','');
- $this->verifyTextPresent('ITN003','');
- $this->verifyTextPresent('ITN004','');
- $this->verifyTextPresent('ITN005','');
- $this->verifyTextNotPresent('ITN006','');
-
- // verify paging
- $this->clickAndWait("link=2", "");
- $this->verifyTextPresent('ITN006','');
- $this->verifyTextPresent('ITN007','');
- $this->verifyTextPresent('ITN008','');
- $this->verifyTextPresent('ITN009','');
- $this->verifyTextPresent('ITN010','');
- $this->verifyTextNotPresent('ITN011','');
- $this->verifyTextNotPresent('ITN005','');
-
- $this->clickAndWait("link=4", "");
- $this->verifyTextPresent('ITN016','');
- $this->verifyTextPresent('ITN017','');
- $this->verifyTextPresent('ITN018','');
- $this->verifyTextPresent('ITN019','');
- $this->verifyTextNotPresent('ITN015','');
-
- $this->clickAndWait("link=1", "");
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextPresent('ITN002','');
- $this->verifyTextPresent('ITN003','');
- $this->verifyTextPresent('ITN004','');
- $this->verifyTextPresent('ITN005','');
- $this->verifyTextNotPresent('ITN006','');
- }
-}
-
+<?php + +class DataGrid6TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataGrid.Sample6&notheme=true&lang=en", ""); + + // verify column headers + $this->verifyTextPresent('id',''); + $this->verifyTextPresent('name',''); + $this->verifyTextPresent('quantity',''); + $this->verifyTextPresent('price',''); + $this->verifyTextPresent('imported',''); + + $this->verifyTextPresent('ITN001',''); + $this->verifyTextPresent('ITN002',''); + $this->verifyTextPresent('ITN003',''); + $this->verifyTextPresent('ITN004',''); + $this->verifyTextPresent('ITN005',''); + $this->verifyTextNotPresent('ITN006',''); + + // verify paging + $this->clickAndWait("link=2", ""); + $this->verifyTextPresent('ITN006',''); + $this->verifyTextPresent('ITN007',''); + $this->verifyTextPresent('ITN008',''); + $this->verifyTextPresent('ITN009',''); + $this->verifyTextPresent('ITN010',''); + $this->verifyTextNotPresent('ITN011',''); + $this->verifyTextNotPresent('ITN005',''); + + $this->clickAndWait("link=4", ""); + $this->verifyTextPresent('ITN016',''); + $this->verifyTextPresent('ITN017',''); + $this->verifyTextPresent('ITN018',''); + $this->verifyTextPresent('ITN019',''); + $this->verifyTextNotPresent('ITN015',''); + + $this->clickAndWait("link=1", ""); + $this->verifyTextPresent('ITN001',''); + $this->verifyTextPresent('ITN002',''); + $this->verifyTextPresent('ITN003',''); + $this->verifyTextPresent('ITN004',''); + $this->verifyTextPresent('ITN005',''); + $this->verifyTextNotPresent('ITN006',''); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/DataList1TestCase.php b/tests/FunctionalTests/quickstart/Controls/DataList1TestCase.php index 75f0ff30..4a42bf7b 100644 --- a/tests/FunctionalTests/quickstart/Controls/DataList1TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/DataList1TestCase.php @@ -1,26 +1,26 @@ -<?php
-
-class DataList1TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataList.Sample1&notheme=true&lang=en", "");
-
- // verify if all required texts are present
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextPresent('$100','');
- $this->verifyTextPresent('Motherboard','');
- $this->verifyTextPresent('ITN018','');
- $this->verifyTextPresent('Surge protector','');
- $this->verifyTextPresent('45','');
- $this->verifyTextPresent('$15','');
- $this->verifyTextPresent('Total 19 products.','');
- $this->verifyTextPresent('Computer Parts','');
-
- // verify specific table tags
- $this->verifyElementPresent("ctl0_body_DataList");
- $this->verifyElementPresent("//td[@align='right']");
- }
-}
-
+<?php + +class DataList1TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataList.Sample1&notheme=true&lang=en", ""); + + // verify if all required texts are present + $this->verifyTextPresent('ITN001',''); + $this->verifyTextPresent('$100',''); + $this->verifyTextPresent('Motherboard',''); + $this->verifyTextPresent('ITN018',''); + $this->verifyTextPresent('Surge protector',''); + $this->verifyTextPresent('45',''); + $this->verifyTextPresent('$15',''); + $this->verifyTextPresent('Total 19 products.',''); + $this->verifyTextPresent('Computer Parts',''); + + // verify specific table tags + $this->verifyElementPresent("ctl0_body_DataList"); + $this->verifyElementPresent("//td[@align='right']"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/DataList2TestCase.php b/tests/FunctionalTests/quickstart/Controls/DataList2TestCase.php index 47e9bb94..4d91e409 100644 --- a/tests/FunctionalTests/quickstart/Controls/DataList2TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/DataList2TestCase.php @@ -1,61 +1,61 @@ -<?php
-
-class DataList2TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataList.Sample2&notheme=true&lang=en", "");
-
- // verify initial presentation
- $this->verifyTextPresent("Motherboard ", "");
- $this->verifyTextPresent("Monitor ", "");
-
- // verify selecting an item
- $this->clickAndWait("link=ITN003", "");
- $this->verifyTextPresent("Quantity", "");
- $this->verifyTextPresent("Price", "");
- $this->verifyTextPresent("\$80", "");
- $this->clickAndWait("link=ITN005", "");
- $this->verifyTextPresent("\$150", "");
-
- // verify editting an item
- $this->clickAndWait("id=ctl0_body_DataList_ctl5_ctl0", "");
- $this->type("ctl0\$body\$DataList\$ctl5\$ProductQuantity", "11");
- $this->type("ctl0\$body\$DataList\$ctl5\$ProductPrice", "140.99");
- $this->click("//input[@name='ctl0\$body\$DataList\$ctl5\$ProductImported']", "");
- $this->clickAndWait("link=Save", "");
-
- // verify item is saved
- $this->clickAndWait("link=ITN005", "");
- $this->verifyTextPresent("\$140.99", "");
- $this->verifyTextPresent("11", "");
-
- // verify editting another item
- $this->clickAndWait("id=ctl0_body_DataList_ctl3_ctl1", "");
- $this->type("ctl0\$body\$DataList\$ctl3\$ProductName", "Hard Drive");
- $this->type("ctl0\$body\$DataList\$ctl3\$ProductQuantity", "23");
- $this->click("//input[@name='ctl0\$body\$DataList\$ctl3\$ProductImported']", "");
- $this->clickAndWait("link=Cancel", "");
-
- // verify item is canceled
- $this->clickAndWait("link=ITN003", "");
- $this->verifyTextPresent("2", "");
- $this->verifyTextPresent("Harddrive ", "");
-
- // verify item deletion
- $this->clickAndWait("id=ctl0_body_DataList_ctl3_ctl1", "");
- $this->verifyConfirmation("Are you sure?");
- $this->chooseCancelOnNextConfirmation();
- $this->click("id=ctl0_body_DataList_ctl5_ctl2", "");
- $this->verifyConfirmation("Are you sure?");
- $this->verifyTextPresent("Motherboard ", "");
- $this->verifyTextPresent("CPU ", "");
- $this->verifyTextNotPresent("Harddrive","");
- $this->verifyTextPresent("Sound card", "");
- $this->verifyTextPresent("Video card", "");
- $this->verifyTextPresent("Keyboard","");
- $this->verifyTextPresent("Monitor ", "");
- }
-}
-
+<?php + +class DataList2TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDataList.Sample2&notheme=true&lang=en", ""); + + // verify initial presentation + $this->verifyTextPresent("Motherboard ", ""); + $this->verifyTextPresent("Monitor ", ""); + + // verify selecting an item + $this->clickAndWait("link=ITN003", ""); + $this->verifyTextPresent("Quantity", ""); + $this->verifyTextPresent("Price", ""); + $this->verifyTextPresent("\$80", ""); + $this->clickAndWait("link=ITN005", ""); + $this->verifyTextPresent("\$150", ""); + + // verify editting an item + $this->clickAndWait("id=ctl0_body_DataList_ctl5_ctl0", ""); + $this->type("ctl0\$body\$DataList\$ctl5\$ProductQuantity", "11"); + $this->type("ctl0\$body\$DataList\$ctl5\$ProductPrice", "140.99"); + $this->click("//input[@name='ctl0\$body\$DataList\$ctl5\$ProductImported']", ""); + $this->clickAndWait("link=Save", ""); + + // verify item is saved + $this->clickAndWait("link=ITN005", ""); + $this->verifyTextPresent("\$140.99", ""); + $this->verifyTextPresent("11", ""); + + // verify editting another item + $this->clickAndWait("id=ctl0_body_DataList_ctl3_ctl1", ""); + $this->type("ctl0\$body\$DataList\$ctl3\$ProductName", "Hard Drive"); + $this->type("ctl0\$body\$DataList\$ctl3\$ProductQuantity", "23"); + $this->click("//input[@name='ctl0\$body\$DataList\$ctl3\$ProductImported']", ""); + $this->clickAndWait("link=Cancel", ""); + + // verify item is canceled + $this->clickAndWait("link=ITN003", ""); + $this->verifyTextPresent("2", ""); + $this->verifyTextPresent("Harddrive ", ""); + + // verify item deletion + $this->clickAndWait("id=ctl0_body_DataList_ctl3_ctl1", ""); + $this->verifyConfirmation("Are you sure?"); + $this->chooseCancelOnNextConfirmation(); + $this->click("id=ctl0_body_DataList_ctl5_ctl2", ""); + $this->verifyConfirmation("Are you sure?"); + $this->verifyTextPresent("Motherboard ", ""); + $this->verifyTextPresent("CPU ", ""); + $this->verifyTextNotPresent("Harddrive",""); + $this->verifyTextPresent("Sound card", ""); + $this->verifyTextPresent("Video card", ""); + $this->verifyTextPresent("Keyboard",""); + $this->verifyTextPresent("Monitor ", ""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/DropDownListTestCase.php b/tests/FunctionalTests/quickstart/Controls/DropDownListTestCase.php index 86ef3f00..ebd0b5e7 100644 --- a/tests/FunctionalTests/quickstart/Controls/DropDownListTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/DropDownListTestCase.php @@ -1,67 +1,67 @@ -<?php
-
-class DropDownListTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDropDownList.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // dropdown list with default settings
- $this->verifyElementPresent("ctl0\$body\$ctl0");
-
- // dropdown list with initial options
- $this->verifySelectOptions("ctl0\$body\$ctl1","item 1,item 2,item 3,item 4");
- $this->verifySelected("ctl0\$body\$ctl1","value=value 2");
-
- // dropdown list with customized styles
- $this->verifySelectOptions("ctl0\$body\$ctl2","item 1,item 2,item 3,item 4");
- $this->verifySelected("ctl0\$body\$ctl2","value=value 2");
-
- // a disabled dropdown list
- $this->verifyAttribute("ctl0\$body\$ctl3@disabled","regexp:true|disabled");
-
- // an auto postback dropdown list
- $this->verifyTextNotPresent("Your selection is: (Index: 2, Value: value 3, Text: item 3)", "");
- $this->selectAndWait("ctl0\$body\$ctl4", "label=item 3");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: value 3, Text: item 3)", "");
-
- // a single selection list box upon postback
- $this->select("ctl0\$body\$DropDownList1", "label=item 4");
- $this->verifyTextNotPresent("Your selection is: (Index: 3, Value: value 4, Text: item 4)", "");
- $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
- $this->verifyTextPresent("Your selection is: (Index: 3, Value: value 4, Text: item 4)", "");
-
- // Databind to an integer-indexed array
- $this->selectAndWait("ctl0\$body\$DBDropDownList1", "label=item 3");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: 2, Text: item 3)", "");
-
- // Databind to an associative array
- $this->selectAndWait("ctl0\$body\$DBDropDownList2", "label=item 2");
- $this->verifyTextPresent("Your selection is: (Index: 1, Value: key 2, Text: item 2)", "");
-
- // Databind with DataTextField and DataValueField specified
- $this->selectAndWait("ctl0\$body\$DBDropDownList3", "label=Cary");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: 003, Text: Cary)", "");
-
- // dropdown list is being validated
- $this->verifyNotVisible('ctl0_body_ctl6');
- $this->click("id=ctl0_body_ctl7", "");
- $this->verifyVisible('ctl0_body_ctl6');
- $this->select("ctl0\$body\$VDropDownList1", "label=item 2");
- $this->clickAndWait("id=ctl0_body_ctl7", "");
- $this->verifyNotVisible('ctl0_body_ctl6');
-
- // dropdown list causing validation
- $this->verifyNotVisible('ctl0_body_ctl8');
- $this->select("ctl0\$body\$VDropDownList2", "label=Disagree");
- $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl8');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->selectAndWait("ctl0\$body\$VDropDownList2", "label=Agree");
- $this->verifyNotVisible('ctl0_body_ctl8');
- }
-}
-
+<?php + +class DropDownListTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TDropDownList.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // dropdown list with default settings + $this->verifyElementPresent("ctl0\$body\$ctl0"); + + // dropdown list with initial options + $this->verifySelectOptions("ctl0\$body\$ctl1","item 1,item 2,item 3,item 4"); + $this->verifySelected("ctl0\$body\$ctl1","value=value 2"); + + // dropdown list with customized styles + $this->verifySelectOptions("ctl0\$body\$ctl2","item 1,item 2,item 3,item 4"); + $this->verifySelected("ctl0\$body\$ctl2","value=value 2"); + + // a disabled dropdown list + $this->verifyAttribute("ctl0\$body\$ctl3@disabled","regexp:true|disabled"); + + // an auto postback dropdown list + $this->verifyTextNotPresent("Your selection is: (Index: 2, Value: value 3, Text: item 3)", ""); + $this->selectAndWait("ctl0\$body\$ctl4", "label=item 3"); + $this->verifyTextPresent("Your selection is: (Index: 2, Value: value 3, Text: item 3)", ""); + + // a single selection list box upon postback + $this->select("ctl0\$body\$DropDownList1", "label=item 4"); + $this->verifyTextNotPresent("Your selection is: (Index: 3, Value: value 4, Text: item 4)", ""); + $this->clickAndWait("//input[@type='submit' and @value='Submit']", ""); + $this->verifyTextPresent("Your selection is: (Index: 3, Value: value 4, Text: item 4)", ""); + + // Databind to an integer-indexed array + $this->selectAndWait("ctl0\$body\$DBDropDownList1", "label=item 3"); + $this->verifyTextPresent("Your selection is: (Index: 2, Value: 2, Text: item 3)", ""); + + // Databind to an associative array + $this->selectAndWait("ctl0\$body\$DBDropDownList2", "label=item 2"); + $this->verifyTextPresent("Your selection is: (Index: 1, Value: key 2, Text: item 2)", ""); + + // Databind with DataTextField and DataValueField specified + $this->selectAndWait("ctl0\$body\$DBDropDownList3", "label=Cary"); + $this->verifyTextPresent("Your selection is: (Index: 2, Value: 003, Text: Cary)", ""); + + // dropdown list is being validated + $this->verifyNotVisible('ctl0_body_ctl6'); + $this->click("id=ctl0_body_ctl7", ""); + $this->verifyVisible('ctl0_body_ctl6'); + $this->select("ctl0\$body\$VDropDownList1", "label=item 2"); + $this->clickAndWait("id=ctl0_body_ctl7", ""); + $this->verifyNotVisible('ctl0_body_ctl6'); + + // dropdown list causing validation + $this->verifyNotVisible('ctl0_body_ctl8'); + $this->select("ctl0\$body\$VDropDownList2", "label=Disagree"); + $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl8'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->selectAndWait("ctl0\$body\$VDropDownList2", "label=Agree"); + $this->verifyNotVisible('ctl0_body_ctl8'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/ExpressionTestCase.php b/tests/FunctionalTests/quickstart/Controls/ExpressionTestCase.php index 793a1df0..b474518d 100644 --- a/tests/FunctionalTests/quickstart/Controls/ExpressionTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/ExpressionTestCase.php @@ -1,15 +1,15 @@ -<?php
-
-class ExpressionTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TExpression.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- $this->verifyTextPresent('PRADO QuickStart Sample');
- }
-}
-
+<?php + +class ExpressionTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TExpression.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + $this->verifyTextPresent('PRADO QuickStart Sample'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/HtmlAreaTestCase.php b/tests/FunctionalTests/quickstart/Controls/HtmlAreaTestCase.php index 00055da6..82d3ad24 100644 --- a/tests/FunctionalTests/quickstart/Controls/HtmlAreaTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/HtmlAreaTestCase.php @@ -1,15 +1,15 @@ -<?php
-
-class HtmlAreaTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.THtmlArea.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // can't perform any test
- }
-}
-
+<?php + +class HtmlAreaTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.THtmlArea.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // can't perform any test + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/HyperLinkTestCase.php b/tests/FunctionalTests/quickstart/Controls/HyperLinkTestCase.php index b564c85a..3b48e961 100644 --- a/tests/FunctionalTests/quickstart/Controls/HyperLinkTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/HyperLinkTestCase.php @@ -1,17 +1,17 @@ -<?php
-
-class HyperLinkTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.THyperLink.Home&notheme=true&lang=en", "");
- $this->verifyTitle("PRADO QuickStart Sample", "");
- $this->verifyElementPresent("//a[@href=\"http://www.pradosoft.com/\" and @target=\"_blank\"]");
- $this->verifyTextPresent("Welcome to", "");
- $this->verifyTextPresent("Body contents", "");
- $this->verifyElementPresent("//a[img/@alt='Hello World']");
- $this->verifyElementPresent("//a[contains(text(),'Body contents')]");
- }
-}
-
+<?php + +class HyperLinkTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.THyperLink.Home&notheme=true&lang=en", ""); + $this->verifyTitle("PRADO QuickStart Sample", ""); + $this->verifyElementPresent("//a[@href=\"http://www.pradosoft.com/\" and @target=\"_blank\"]"); + $this->verifyTextPresent("Welcome to", ""); + $this->verifyTextPresent("Body contents", ""); + $this->verifyElementPresent("//a[img/@alt='Hello World']"); + $this->verifyElementPresent("//a[contains(text(),'Body contents')]"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/ImageButtonTestCase.php b/tests/FunctionalTests/quickstart/Controls/ImageButtonTestCase.php index fb40fbea..32568e59 100644 --- a/tests/FunctionalTests/quickstart/Controls/ImageButtonTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/ImageButtonTestCase.php @@ -1,30 +1,30 @@ -<?php
-
-class ImageButtonTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TImageButton.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // a click button
- $this->clickAndWait("//input[@type='image' and @alt='hello world']", "");
- $this->verifyTextPresent("You clicked at ","");
-
- // a command button
- $this->clickAndWait("ctl0\$body\$ctl1", "");
- $this->verifyTextPresent("Command name: test, Command parameter: value","");
-
- // a button causing validation
- $this->verifyNotVisible('ctl0_body_ctl2');
- $this->click("id=ctl0_body_ctl3", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl2');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->clickAndWait("id=ctl0_body_ctl3", "");
- $this->verifyNotVisible('ctl0_body_ctl2');
- }
-}
-
+<?php + +class ImageButtonTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TImageButton.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // a click button + $this->clickAndWait("//input[@type='image' and @alt='hello world']", ""); + $this->verifyTextPresent("You clicked at ",""); + + // a command button + $this->clickAndWait("ctl0\$body\$ctl1", ""); + $this->verifyTextPresent("Command name: test, Command parameter: value",""); + + // a button causing validation + $this->verifyNotVisible('ctl0_body_ctl2'); + $this->click("id=ctl0_body_ctl3", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl2'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->clickAndWait("id=ctl0_body_ctl3", ""); + $this->verifyNotVisible('ctl0_body_ctl2'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/ImageTestCase.php b/tests/FunctionalTests/quickstart/Controls/ImageTestCase.php index c95b94d7..f203f6aa 100644 --- a/tests/FunctionalTests/quickstart/Controls/ImageTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/ImageTestCase.php @@ -1,20 +1,20 @@ -<?php
-
-//New Test
-class ImageTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TImage.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- //$this->verifyElementPresent("//img[contains(@src,'/hello_world.gif') and @alt='']");
- $this->verifyElementPresent("//img[contains(@src,'/hello_world.gif') and @alt='Hello World!']");
- $this->verifyTextPresent("Hello World! Hello World! Hello World!", "");
- //$this->verifyElementPresent("//img[contains(@src,'/hello_world.gif') and @align='baseline']");
- //$this->verifyElementPresent("//img[contains(@src,'/hello_world.gif') and contains(@longdesc,'HelloWorld.html')]");
- }
-}
-
+<?php + +//New Test +class ImageTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TImage.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + //$this->verifyElementPresent("//img[contains(@src,'/hello_world.gif') and @alt='']"); + $this->verifyElementPresent("//img[contains(@src,'/hello_world.gif') and @alt='Hello World!']"); + $this->verifyTextPresent("Hello World! Hello World! Hello World!", ""); + //$this->verifyElementPresent("//img[contains(@src,'/hello_world.gif') and @align='baseline']"); + //$this->verifyElementPresent("//img[contains(@src,'/hello_world.gif') and contains(@longdesc,'HelloWorld.html')]"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/LabelTestCase.php b/tests/FunctionalTests/quickstart/Controls/LabelTestCase.php index 4dc4d5f4..a2a02ff5 100644 --- a/tests/FunctionalTests/quickstart/Controls/LabelTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/LabelTestCase.php @@ -1,23 +1,23 @@ -<?php
-
-//New Test
-class LabelTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TLabel.Home&notheme=true&lang=en", "");
- $this->verifyTitle("PRADO QuickStart Sample", "");
- $this->verifyTextPresent("This is a label with customized color and font.", "");
- $this->verifyTextPresent("This is a form label associated with the TTextBox control below", "");
- $this->verifyTextPresent("This is a label with empty Text property and nonempty body", "");
- $this->verifyTextPresent("This is a disabled label", "");
-
- $this->verifyAttribute("ctl0_body_Label2@disabled","regexp:true|disabled");
-
- //$this->verifyAttribute("ctl0_body_Label1@for","ctl0_body_test");
-
- $this->type("ctl0\$body\$test", "test");
- }
-}
-
+<?php + +//New Test +class LabelTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TLabel.Home&notheme=true&lang=en", ""); + $this->verifyTitle("PRADO QuickStart Sample", ""); + $this->verifyTextPresent("This is a label with customized color and font.", ""); + $this->verifyTextPresent("This is a form label associated with the TTextBox control below", ""); + $this->verifyTextPresent("This is a label with empty Text property and nonempty body", ""); + $this->verifyTextPresent("This is a disabled label", ""); + + $this->verifyAttribute("ctl0_body_Label2@disabled","regexp:true|disabled"); + + //$this->verifyAttribute("ctl0_body_Label1@for","ctl0_body_test"); + + $this->type("ctl0\$body\$test", "test"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/LinkButtonTestCase.php b/tests/FunctionalTests/quickstart/Controls/LinkButtonTestCase.php index 49fd1f9b..1f33ba07 100644 --- a/tests/FunctionalTests/quickstart/Controls/LinkButtonTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/LinkButtonTestCase.php @@ -1,34 +1,34 @@ -<?php
-
-class LinkButtonTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TLinkButton.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // regular buttons
- $this->clickAndWait("link=link button", "");
- $this->clickAndWait("//a[contains(text(),'body content')]", "");
-
- // a click button
- $this->clickAndWait("link=click me", "");
- $this->clickAndWait("link=I'm clicked", "");
-
- // a command button
- $this->clickAndWait("link=click me", "");
- $this->clickAndWait("//a[contains(text(),'Name: test, Param: value')]", "");
-
- // a button causing validation
- $this->verifyNotVisible('ctl0_body_ctl4');
- $this->click("link=submit", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl4');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->clickAndWait("link=submit", "");
- $this->verifyNotVisible('ctl0_body_ctl4');
- }
-}
-
+<?php + +class LinkButtonTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TLinkButton.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // regular buttons + $this->clickAndWait("link=link button", ""); + $this->clickAndWait("//a[contains(text(),'body content')]", ""); + + // a click button + $this->clickAndWait("link=click me", ""); + $this->clickAndWait("link=I'm clicked", ""); + + // a command button + $this->clickAndWait("link=click me", ""); + $this->clickAndWait("//a[contains(text(),'Name: test, Param: value')]", ""); + + // a button causing validation + $this->verifyNotVisible('ctl0_body_ctl4'); + $this->click("link=submit", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl4'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->clickAndWait("link=submit", ""); + $this->verifyNotVisible('ctl0_body_ctl4'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/ListBoxTestCase.php b/tests/FunctionalTests/quickstart/Controls/ListBoxTestCase.php index 182bbd25..dcd048b5 100644 --- a/tests/FunctionalTests/quickstart/Controls/ListBoxTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/ListBoxTestCase.php @@ -1,84 +1,84 @@ -<?php
-
-//New Test
-class ListBoxTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TListBox.Home&notheme=true&lang=en", "");
-
- // a default single selection listbox
- $this->verifyAttribute("ctl0\$body\$ctl0@size","4");
-
- // single selection list box with initial options
- $this->verifySelectOptions("ctl0\$body\$ctl1","item 1,item 2,item 3,item 4");
- $this->verifySelected("ctl0\$body\$ctl1","value=value 2");
-
- // a single selection list box with customized style
- $this->verifyAttribute("ctl0\$body\$ctl2@size","3");
- $this->verifySelectOptions("ctl0\$body\$ctl2","item 1,item 2,item 3,item 4");
- $this->verifySelected("ctl0\$body\$ctl2","value=value 2");
-
- // a disabled list box
- $this->verifyAttribute("ctl0\$body\$ctl3@disabled","regexp:true|disabled");
-
- // an auto postback single selection list box
- $this->verifyTextNotPresent("Your selection is: (Index: 2, Value: value 3, Text: item 3)", "");
- $this->selectAndWait("ctl0\$body\$ctl4", "label=item 3");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: value 3, Text: item 3)", "");
-
- // a single selection list box upon postback
- $this->select("ctl0\$body\$ListBox1", "label=item 4");
- $this->verifyTextNotPresent("Your selection is: (Index: 3, Value: value 4, Text: item 4)", "");
- $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
- $this->verifyTextPresent("Your selection is: (Index: 3, Value: value 4, Text: item 4)", "");
-
- // a multiple selection list box
- $this->verifyAttribute("ctl0\$body\$ctl6[]@size","4");
- $this->verifyAttribute("ctl0\$body\$ctl6[]@multiple","regexp:true|multiple");
-
- // a multiple selection list box with initial options
- $this->verifyAttribute("ctl0\$body\$ctl7[]@multiple","regexp:true|multiple");
- $this->verifySelectOptions("ctl0\$body\$ctl7[]","item 1,item 2,item 3,item 4");
-
- // multiselection list box's behavior upon postback
- $this->addSelection("ctl0\$body\$ListBox2[]", "label=item 3");
- $this->clickAndWait("name=ctl0\$body\$ctl8", "");
- $this->verifyText("ctl0_body_MultiSelectionResult2","Your selection is: (Index: 1, Value: value 2, Text: item 2)(Index: 2, Value: value 3, Text: item 3)(Index: 3, Value: value 4, Text: item 4)");
-
- // Auto postback multiselection list box
- $this->addSelection("ctl0\$body\$ctl9[]", "label=item 1");
- $this->waitForPageToLoad(1000);
- $this->verifyText("ctl0_body_MultiSelectionResult","Your selection is: (Index: 0, Value: value 1, Text: item 1)(Index: 1, Value: value 2, Text: item 2)(Index: 3, Value: value 4, Text: item 4)");
-
- // Databind to an integer-indexed array
- $this->selectAndWait("ctl0\$body\$DBListBox1[]", "label=item 3");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: 2, Text: item 3)", "");
-
- // Databind to an associative array
- $this->selectAndWait("ctl0\$body\$DBListBox2[]", "label=item 2");
- $this->verifyTextPresent("Your selection is: (Index: 1, Value: key 2, Text: item 2)", "");
-
- // Databind with DataTextField and DataValueField specified
- $this->selectAndWait("ctl0\$body\$DBListBox3[]", "label=Cary");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: 003, Text: Cary)", "");
-
- // List box is being validated
- $this->verifyNotVisible('ctl0_body_ctl10');
- $this->click("id=ctl0_body_ctl11", "");
- $this->verifyVisible('ctl0_body_ctl10');
- $this->select("ctl0\$body\$VListBox1", "label=item 2");
- $this->clickAndWait("id=ctl0_body_ctl11", "");
- $this->verifyNotVisible('ctl0_body_ctl10');
-
- // List box causing validation
- $this->verifyNotVisible('ctl0_body_ctl12');
- $this->select("ctl0\$body\$VListBox2", "label=Agree");
- $this->verifyVisible('ctl0_body_ctl12');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->selectAndWait("ctl0\$body\$VListBox2", "label=Disagree");
- $this->verifyNotVisible('ctl0_body_ctl12');
- }
-}
-
+<?php + +//New Test +class ListBoxTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TListBox.Home&notheme=true&lang=en", ""); + + // a default single selection listbox + $this->verifyAttribute("ctl0\$body\$ctl0@size","4"); + + // single selection list box with initial options + $this->verifySelectOptions("ctl0\$body\$ctl1","item 1,item 2,item 3,item 4"); + $this->verifySelected("ctl0\$body\$ctl1","value=value 2"); + + // a single selection list box with customized style + $this->verifyAttribute("ctl0\$body\$ctl2@size","3"); + $this->verifySelectOptions("ctl0\$body\$ctl2","item 1,item 2,item 3,item 4"); + $this->verifySelected("ctl0\$body\$ctl2","value=value 2"); + + // a disabled list box + $this->verifyAttribute("ctl0\$body\$ctl3@disabled","regexp:true|disabled"); + + // an auto postback single selection list box + $this->verifyTextNotPresent("Your selection is: (Index: 2, Value: value 3, Text: item 3)", ""); + $this->selectAndWait("ctl0\$body\$ctl4", "label=item 3"); + $this->verifyTextPresent("Your selection is: (Index: 2, Value: value 3, Text: item 3)", ""); + + // a single selection list box upon postback + $this->select("ctl0\$body\$ListBox1", "label=item 4"); + $this->verifyTextNotPresent("Your selection is: (Index: 3, Value: value 4, Text: item 4)", ""); + $this->clickAndWait("//input[@type='submit' and @value='Submit']", ""); + $this->verifyTextPresent("Your selection is: (Index: 3, Value: value 4, Text: item 4)", ""); + + // a multiple selection list box + $this->verifyAttribute("ctl0\$body\$ctl6[]@size","4"); + $this->verifyAttribute("ctl0\$body\$ctl6[]@multiple","regexp:true|multiple"); + + // a multiple selection list box with initial options + $this->verifyAttribute("ctl0\$body\$ctl7[]@multiple","regexp:true|multiple"); + $this->verifySelectOptions("ctl0\$body\$ctl7[]","item 1,item 2,item 3,item 4"); + + // multiselection list box's behavior upon postback + $this->addSelection("ctl0\$body\$ListBox2[]", "label=item 3"); + $this->clickAndWait("name=ctl0\$body\$ctl8", ""); + $this->verifyText("ctl0_body_MultiSelectionResult2","Your selection is: (Index: 1, Value: value 2, Text: item 2)(Index: 2, Value: value 3, Text: item 3)(Index: 3, Value: value 4, Text: item 4)"); + + // Auto postback multiselection list box + $this->addSelection("ctl0\$body\$ctl9[]", "label=item 1"); + $this->waitForPageToLoad(1000); + $this->verifyText("ctl0_body_MultiSelectionResult","Your selection is: (Index: 0, Value: value 1, Text: item 1)(Index: 1, Value: value 2, Text: item 2)(Index: 3, Value: value 4, Text: item 4)"); + + // Databind to an integer-indexed array + $this->selectAndWait("ctl0\$body\$DBListBox1[]", "label=item 3"); + $this->verifyTextPresent("Your selection is: (Index: 2, Value: 2, Text: item 3)", ""); + + // Databind to an associative array + $this->selectAndWait("ctl0\$body\$DBListBox2[]", "label=item 2"); + $this->verifyTextPresent("Your selection is: (Index: 1, Value: key 2, Text: item 2)", ""); + + // Databind with DataTextField and DataValueField specified + $this->selectAndWait("ctl0\$body\$DBListBox3[]", "label=Cary"); + $this->verifyTextPresent("Your selection is: (Index: 2, Value: 003, Text: Cary)", ""); + + // List box is being validated + $this->verifyNotVisible('ctl0_body_ctl10'); + $this->click("id=ctl0_body_ctl11", ""); + $this->verifyVisible('ctl0_body_ctl10'); + $this->select("ctl0\$body\$VListBox1", "label=item 2"); + $this->clickAndWait("id=ctl0_body_ctl11", ""); + $this->verifyNotVisible('ctl0_body_ctl10'); + + // List box causing validation + $this->verifyNotVisible('ctl0_body_ctl12'); + $this->select("ctl0\$body\$VListBox2", "label=Agree"); + $this->verifyVisible('ctl0_body_ctl12'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->selectAndWait("ctl0\$body\$VListBox2", "label=Disagree"); + $this->verifyNotVisible('ctl0_body_ctl12'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/MultiViewTestCase.php b/tests/FunctionalTests/quickstart/Controls/MultiViewTestCase.php index c6b22e00..080af26d 100644 --- a/tests/FunctionalTests/quickstart/Controls/MultiViewTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/MultiViewTestCase.php @@ -1,39 +1,39 @@ -<?php
-
-class MultiViewTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TMultiView.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // view 1 : type in a string
- $this->verifyElementNotPresent('ctl0_body_Result1');
- $this->verifyElementNotPresent('ctl0_body_Result2');
- $this->type('ctl0_body_Memo','test');
- $this->clickAndWait('ctl0$body$ctl0'); // view 2 to select the dropdown
- $this->clickAndWait('ctl0$body$ctl4');
-
- // view 3 : check if the output is updated
- $this->verifyTextPresent('Your text input is: test');
- $this->verifyTextPresent('Your color choice is: Red');
- $this->clickAndWait('ctl0$body$ctl7');
-
- // view 2 : update dropdownlist
- $this->verifyElementNotPresent('ctl0_body_Result1');
- $this->verifyElementNotPresent('ctl0_body_Result2');
- $this->select('ctl0$body$DropDownList', "label=Blue");
- $this->clickAndWait('ctl0$body$ctl4');
-
- // view 3 : check if the output is updated
- $this->verifyTextPresent('Your text input is: test');
- $this->verifyTextPresent('Your color choice is: Blue');
- $this->clickAndWait('ctl0$body$ctl7');
-
- // view 2 : check if dropdownlist maintains state
- $this->verifySelected('ctl0$body$DropDownList', "label=Blue");
- }
-}
-
+<?php + +class MultiViewTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TMultiView.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // view 1 : type in a string + $this->verifyElementNotPresent('ctl0_body_Result1'); + $this->verifyElementNotPresent('ctl0_body_Result2'); + $this->type('ctl0_body_Memo','test'); + $this->clickAndWait('ctl0$body$ctl0'); // view 2 to select the dropdown + $this->clickAndWait('ctl0$body$ctl4'); + + // view 3 : check if the output is updated + $this->verifyTextPresent('Your text input is: test'); + $this->verifyTextPresent('Your color choice is: Red'); + $this->clickAndWait('ctl0$body$ctl7'); + + // view 2 : update dropdownlist + $this->verifyElementNotPresent('ctl0_body_Result1'); + $this->verifyElementNotPresent('ctl0_body_Result2'); + $this->select('ctl0$body$DropDownList', "label=Blue"); + $this->clickAndWait('ctl0$body$ctl4'); + + // view 3 : check if the output is updated + $this->verifyTextPresent('Your text input is: test'); + $this->verifyTextPresent('Your color choice is: Blue'); + $this->clickAndWait('ctl0$body$ctl7'); + + // view 2 : check if dropdownlist maintains state + $this->verifySelected('ctl0$body$DropDownList', "label=Blue"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/PagerTestCase.php b/tests/FunctionalTests/quickstart/Controls/PagerTestCase.php index c1ff9209..fac4160f 100644 --- a/tests/FunctionalTests/quickstart/Controls/PagerTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/PagerTestCase.php @@ -1,58 +1,58 @@ -<?php
-
-class PagerTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TPager.Sample1&notheme=true&lang=en", "");
-
- // verify datalist content
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextPresent('ITN002','');
- $this->verifyTextNotPresent('ITN003','');
-
- // verify numeric paging
- $this->clickAndWait("ctl0_body_Pager_ctl1", ""); // 2nd page
- $this->verifyTextPresent('ITN003','');
- $this->verifyTextPresent('ITN004','');
- $this->verifyTextNotPresent('ITN002','');
- $this->verifyTextNotPresent('ITN005','');
- $this->clickAndWait("ctl0_body_Pager_ctl3", ""); // 4rd page
- $this->verifyTextPresent('ITN007','');
- $this->verifyTextPresent('ITN008','');
- $this->verifyTextNotPresent('ITN006','');
- $this->verifyTextNotPresent('ITN009','');
- $this->clickAndWait("ctl0_body_Pager_ctl6", ""); // last page
- $this->verifyTextPresent('ITN019','');
- $this->verifyTextNotPresent('ITN018','');
- $this->verifyTextNotPresent('ITN001','');
-
- // verify next-prev paging
- $this->clickAndWait("ctl0_body_Pager2_ctl1", ""); // prev page
- $this->verifyTextPresent('ITN017','');
- $this->verifyTextPresent('ITN018','');
- $this->verifyTextNotPresent('ITN019','');
- $this->verifyTextNotPresent('ITN016','');
- $this->clickAndWait("ctl0_body_Pager2_ctl0", ""); // first page
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextPresent('ITN002','');
- $this->verifyTextNotPresent('ITN003','');
- $this->clickAndWait("ctl0_body_Pager2_ctl2", ""); // next page
- $this->verifyTextPresent('ITN003','');
- $this->verifyTextPresent('ITN004','');
- $this->verifyTextNotPresent('ITN002','');
- $this->verifyTextNotPresent('ITN005','');
-
- $this->verifySelected("ctl0_body_Pager3_ctl0","label=2");
- $this->selectAndWait("ctl0_body_Pager3_ctl0", "label=5");
- $this->verifyTextPresent('ITN009','');
- $this->verifyTextPresent('ITN010','');
- $this->verifyTextNotPresent('ITN008','');
- $this->verifyTextNotPresent('ITN011','');
- $this->selectAndWait("ctl0_body_Pager3_ctl0", "label=10");
- $this->verifyTextPresent('ITN019','');
- $this->verifyTextNotPresent('ITN018','');
- }
-}
-
+<?php + +class PagerTestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TPager.Sample1&notheme=true&lang=en", ""); + + // verify datalist content + $this->verifyTextPresent('ITN001',''); + $this->verifyTextPresent('ITN002',''); + $this->verifyTextNotPresent('ITN003',''); + + // verify numeric paging + $this->clickAndWait("ctl0_body_Pager_ctl1", ""); // 2nd page + $this->verifyTextPresent('ITN003',''); + $this->verifyTextPresent('ITN004',''); + $this->verifyTextNotPresent('ITN002',''); + $this->verifyTextNotPresent('ITN005',''); + $this->clickAndWait("ctl0_body_Pager_ctl3", ""); // 4rd page + $this->verifyTextPresent('ITN007',''); + $this->verifyTextPresent('ITN008',''); + $this->verifyTextNotPresent('ITN006',''); + $this->verifyTextNotPresent('ITN009',''); + $this->clickAndWait("ctl0_body_Pager_ctl6", ""); // last page + $this->verifyTextPresent('ITN019',''); + $this->verifyTextNotPresent('ITN018',''); + $this->verifyTextNotPresent('ITN001',''); + + // verify next-prev paging + $this->clickAndWait("ctl0_body_Pager2_ctl1", ""); // prev page + $this->verifyTextPresent('ITN017',''); + $this->verifyTextPresent('ITN018',''); + $this->verifyTextNotPresent('ITN019',''); + $this->verifyTextNotPresent('ITN016',''); + $this->clickAndWait("ctl0_body_Pager2_ctl0", ""); // first page + $this->verifyTextPresent('ITN001',''); + $this->verifyTextPresent('ITN002',''); + $this->verifyTextNotPresent('ITN003',''); + $this->clickAndWait("ctl0_body_Pager2_ctl2", ""); // next page + $this->verifyTextPresent('ITN003',''); + $this->verifyTextPresent('ITN004',''); + $this->verifyTextNotPresent('ITN002',''); + $this->verifyTextNotPresent('ITN005',''); + + $this->verifySelected("ctl0_body_Pager3_ctl0","label=2"); + $this->selectAndWait("ctl0_body_Pager3_ctl0", "label=5"); + $this->verifyTextPresent('ITN009',''); + $this->verifyTextPresent('ITN010',''); + $this->verifyTextNotPresent('ITN008',''); + $this->verifyTextNotPresent('ITN011',''); + $this->selectAndWait("ctl0_body_Pager3_ctl0", "label=10"); + $this->verifyTextPresent('ITN019',''); + $this->verifyTextNotPresent('ITN018',''); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/PanelTestCase.php b/tests/FunctionalTests/quickstart/Controls/PanelTestCase.php index 086fb4c1..8d1e28fb 100644 --- a/tests/FunctionalTests/quickstart/Controls/PanelTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/PanelTestCase.php @@ -1,18 +1,18 @@ -<?php
-
-class PanelTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TPanel.Home&notheme=true&lang=en", "");
- $this->verifyTextPresent("This is panel content with", "");
- $this->verifyElementPresent("//span[text()='label']");
- $this->verifyTextPresent("grouping text", "");
- $this->click("//input[@name='ctl0\$body\$ctl17']", "");
- $this->verifyTextNotPresent("You have clicked on 'button2'.");
- $this->clickAndWait("//input[@type='submit' and @value='button2']", "");
- $this->verifyTextPresent("You have clicked on 'button2'.");
- }
-}
-
+<?php + +class PanelTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TPanel.Home&notheme=true&lang=en", ""); + $this->verifyTextPresent("This is panel content with", ""); + $this->verifyElementPresent("//span[text()='label']"); + $this->verifyTextPresent("grouping text", ""); + $this->click("//input[@name='ctl0\$body\$ctl17']", ""); + $this->verifyTextNotPresent("You have clicked on 'button2'."); + $this->clickAndWait("//input[@type='submit' and @value='button2']", ""); + $this->verifyTextPresent("You have clicked on 'button2'."); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/RadioButtonListTestCase.php b/tests/FunctionalTests/quickstart/Controls/RadioButtonListTestCase.php index 8e64cc3e..6c179a24 100644 --- a/tests/FunctionalTests/quickstart/Controls/RadioButtonListTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/RadioButtonListTestCase.php @@ -1,54 +1,54 @@ -<?php
-
-//New Test
-class RadioButtonListTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRadioButtonList.Home&notheme=true&lang=en", "");
-
- // RadioButton list with default settings:
- $this->click("//input[@name='ctl0\$body\$ctl0' and @value='value 3']", "");
-
- // RadioButton list with customized cellpadding, cellspacing, color and text alignment:
- $this->click("//input[@name='ctl0\$body\$ctl1' and @value='value 1']", "");
-
- // *** Currently unable to test the following cases:
- // RadioButton list with vertical (default) repeat direction
- // RadioButton list with horizontal repeat direction
- // RadioButton list with flow layout and vertical (default) repeat direction
- // RadioButton list with flow layout and horizontal repeat direction:
-
- // RadioButton list's behavior upon postback
- $this->click("//input[@name='ctl0\$body\$RadioButtonList' and @value='value 3']", "");
- $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: value 3, Text: item 3)", "");
-
- // Auto postback check box list
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl7' and @value='value 5']", "");
- $this->verifyTextPresent("Your selection is: (Index: 4, Value: value 5, Text: item 5)", "");
-
- // Databind to an integer-indexed array
- $this->clickAndWait("//input[@name='ctl0\$body\$DBRadioButtonList1' and @value='0']", "");
- $this->verifyTextPresent("Your selection is: (Index: 0, Value: 0, Text: item 1)", "");
-
- // Databind to an associative array:
- $this->clickAndWait("//input[@name='ctl0\$body\$DBRadioButtonList2' and @value='key 2']", "");
- $this->verifyTextPresent("Your selection is: (Index: 1, Value: key 2, Text: item 2)", "");
-
- // Databind with DataTextField and DataValueField specified
- $this->clickAndWait("//input[@name='ctl0\$body\$DBRadioButtonList3' and @value='003']", "");
- $this->verifyTextPresent("Your selection is: (Index: 2, Value: 003, Text: Cary)", "");
-
- // RadioButton list causing validation
- $this->verifyNotVisible('ctl0_body_ctl8');
- $this->click("//input[@name='ctl0\$body\$ctl9' and @value='Agree']", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl8');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl9' and @value='Disagree']", "");
- $this->verifyNotVisible('ctl0_body_ctl8');
- }
-}
-
+<?php + +//New Test +class RadioButtonListTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRadioButtonList.Home&notheme=true&lang=en", ""); + + // RadioButton list with default settings: + $this->click("//input[@name='ctl0\$body\$ctl0' and @value='value 3']", ""); + + // RadioButton list with customized cellpadding, cellspacing, color and text alignment: + $this->click("//input[@name='ctl0\$body\$ctl1' and @value='value 1']", ""); + + // *** Currently unable to test the following cases: + // RadioButton list with vertical (default) repeat direction + // RadioButton list with horizontal repeat direction + // RadioButton list with flow layout and vertical (default) repeat direction + // RadioButton list with flow layout and horizontal repeat direction: + + // RadioButton list's behavior upon postback + $this->click("//input[@name='ctl0\$body\$RadioButtonList' and @value='value 3']", ""); + $this->clickAndWait("//input[@type='submit' and @value='Submit']", ""); + $this->verifyTextPresent("Your selection is: (Index: 2, Value: value 3, Text: item 3)", ""); + + // Auto postback check box list + $this->clickAndWait("//input[@name='ctl0\$body\$ctl7' and @value='value 5']", ""); + $this->verifyTextPresent("Your selection is: (Index: 4, Value: value 5, Text: item 5)", ""); + + // Databind to an integer-indexed array + $this->clickAndWait("//input[@name='ctl0\$body\$DBRadioButtonList1' and @value='0']", ""); + $this->verifyTextPresent("Your selection is: (Index: 0, Value: 0, Text: item 1)", ""); + + // Databind to an associative array: + $this->clickAndWait("//input[@name='ctl0\$body\$DBRadioButtonList2' and @value='key 2']", ""); + $this->verifyTextPresent("Your selection is: (Index: 1, Value: key 2, Text: item 2)", ""); + + // Databind with DataTextField and DataValueField specified + $this->clickAndWait("//input[@name='ctl0\$body\$DBRadioButtonList3' and @value='003']", ""); + $this->verifyTextPresent("Your selection is: (Index: 2, Value: 003, Text: Cary)", ""); + + // RadioButton list causing validation + $this->verifyNotVisible('ctl0_body_ctl8'); + $this->click("//input[@name='ctl0\$body\$ctl9' and @value='Agree']", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl8'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->clickAndWait("//input[@name='ctl0\$body\$ctl9' and @value='Disagree']", ""); + $this->verifyNotVisible('ctl0_body_ctl8'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/RadioButtonTestCase.php b/tests/FunctionalTests/quickstart/Controls/RadioButtonTestCase.php index 09f0238d..644d1c29 100644 --- a/tests/FunctionalTests/quickstart/Controls/RadioButtonTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/RadioButtonTestCase.php @@ -1,58 +1,58 @@ -<?php
-
-class RadioButtonTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRadioButton.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // a regular radiobutton
- $this->click("//input[@name='ctl0\$body\$ctl0' and @value='ctl0\$body\$ctl0']", "");
-
- // a radiobutton with customized value
- $this->click("//input[@name='ctl0\$body\$ctl1' and @value='value']", "");
-
- // an auto postback radiobutton
- $this->verifyTextNotPresent("I'm clicked");
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl2' and @value='ctl0\$body\$ctl2']", "");
- $this->verifyTextPresent("I'm clicked");
- $this->click("//input[@name='ctl0\$body\$ctl2' and @value='ctl0\$body\$ctl2']", "");
- $this->verifyTextPresent("I'm clicked");
-
- // a radiobutton causing validation on a textbox
- $this->verifyNotVisible('ctl0_body_ctl3');
- $this->click("//input[@name='ctl0\$body\$ctl4' and @value='ctl0\$body\$ctl4']", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl3');
- $this->click("//input[@name='ctl0\$body\$ctl4' and @value='ctl0\$body\$ctl4']", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl3');
- $this->type("ctl0\$body\$TextBox", "test");
- $this->clickAndWait("//input[@name='ctl0\$body\$ctl4' and @value='ctl0\$body\$ctl4']", "");
- $this->verifyNotVisible('ctl0_body_ctl3');
-
- // a radiobutton validated by a required field validator
- $this->verifyNotVisible('ctl0_body_ctl6');
- $this->click("//input[@type='submit' and @value='Submit']", "");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl6');
- $this->click("//input[@name='ctl0\$body\$RadioButton' and @value='ctl0\$body\$RadioButton']", "");
- $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
- $this->verifyNotVisible('ctl0_body_ctl6');
-
- // a radiobutton group
- $this->clickAndWait("name=ctl0\$body\$ctl7", "");
- $this->verifyTextPresent("Your selection is empty");
- $this->click("//input[@name='ctl0\$body\$RadioGroup' and @value='ctl0\$body\$Radio2']", "");
- $this->clickAndWait("name=ctl0\$body\$ctl7", "");
- $this->verifyTextPresent("Your selection is 2");
- $this->click("//input[@name='ctl0\$body\$RadioGroup' and @value='ctl0\$body\$Radio3']", "");
- $this->click("//input[@name='ctl0\$body\$Radio4' and @value='ctl0\$body\$Radio4']", "");
- $this->clickAndWait("name=ctl0\$body\$ctl7", "");
- $this->verifyTextPresent("Your selection is 34");
- }
-}
-
+<?php + +class RadioButtonTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRadioButton.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // a regular radiobutton + $this->click("//input[@name='ctl0\$body\$ctl0' and @value='ctl0\$body\$ctl0']", ""); + + // a radiobutton with customized value + $this->click("//input[@name='ctl0\$body\$ctl1' and @value='value']", ""); + + // an auto postback radiobutton + $this->verifyTextNotPresent("I'm clicked"); + $this->clickAndWait("//input[@name='ctl0\$body\$ctl2' and @value='ctl0\$body\$ctl2']", ""); + $this->verifyTextPresent("I'm clicked"); + $this->click("//input[@name='ctl0\$body\$ctl2' and @value='ctl0\$body\$ctl2']", ""); + $this->verifyTextPresent("I'm clicked"); + + // a radiobutton causing validation on a textbox + $this->verifyNotVisible('ctl0_body_ctl3'); + $this->click("//input[@name='ctl0\$body\$ctl4' and @value='ctl0\$body\$ctl4']", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl3'); + $this->click("//input[@name='ctl0\$body\$ctl4' and @value='ctl0\$body\$ctl4']", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl3'); + $this->type("ctl0\$body\$TextBox", "test"); + $this->clickAndWait("//input[@name='ctl0\$body\$ctl4' and @value='ctl0\$body\$ctl4']", ""); + $this->verifyNotVisible('ctl0_body_ctl3'); + + // a radiobutton validated by a required field validator + $this->verifyNotVisible('ctl0_body_ctl6'); + $this->click("//input[@type='submit' and @value='Submit']", ""); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl6'); + $this->click("//input[@name='ctl0\$body\$RadioButton' and @value='ctl0\$body\$RadioButton']", ""); + $this->clickAndWait("//input[@type='submit' and @value='Submit']", ""); + $this->verifyNotVisible('ctl0_body_ctl6'); + + // a radiobutton group + $this->clickAndWait("name=ctl0\$body\$ctl7", ""); + $this->verifyTextPresent("Your selection is empty"); + $this->click("//input[@name='ctl0\$body\$RadioGroup' and @value='ctl0\$body\$Radio2']", ""); + $this->clickAndWait("name=ctl0\$body\$ctl7", ""); + $this->verifyTextPresent("Your selection is 2"); + $this->click("//input[@name='ctl0\$body\$RadioGroup' and @value='ctl0\$body\$Radio3']", ""); + $this->click("//input[@name='ctl0\$body\$Radio4' and @value='ctl0\$body\$Radio4']", ""); + $this->clickAndWait("name=ctl0\$body\$ctl7", ""); + $this->verifyTextPresent("Your selection is 34"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/Repeater1TestCase.php b/tests/FunctionalTests/quickstart/Controls/Repeater1TestCase.php index e0c8cede..b2d51118 100644 --- a/tests/FunctionalTests/quickstart/Controls/Repeater1TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/Repeater1TestCase.php @@ -1,29 +1,29 @@ -<?php
-
-class Repeater1TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRepeater.Sample1&notheme=true&lang=en", "");
-
- // verify if all required texts are present
- $this->verifyTextPresent('ID','');
- $this->verifyTextPresent('Name','');
- $this->verifyTextPresent('Quantity','');
- $this->verifyTextPresent('Price','');
- $this->verifyTextPresent('Imported','');
- $this->verifyTextPresent('ITN001','');
- $this->verifyTextPresent('Motherboard','');
- $this->verifyTextPresent('Yes','');
- $this->verifyTextPresent('ITN019','');
- $this->verifyTextPresent('Speaker','');
- $this->verifyTextPresent('No','');
- $this->verifyTextPresent('Computer Parts Inventory','');
-
- // verify specific table tags
- $this->verifyElementPresent("//td[@colspan='5']");
- $this->verifyElementPresent("//table[@cellpadding='2']");
- }
-}
-
+<?php + +class Repeater1TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRepeater.Sample1&notheme=true&lang=en", ""); + + // verify if all required texts are present + $this->verifyTextPresent('ID',''); + $this->verifyTextPresent('Name',''); + $this->verifyTextPresent('Quantity',''); + $this->verifyTextPresent('Price',''); + $this->verifyTextPresent('Imported',''); + $this->verifyTextPresent('ITN001',''); + $this->verifyTextPresent('Motherboard',''); + $this->verifyTextPresent('Yes',''); + $this->verifyTextPresent('ITN019',''); + $this->verifyTextPresent('Speaker',''); + $this->verifyTextPresent('No',''); + $this->verifyTextPresent('Computer Parts Inventory',''); + + // verify specific table tags + $this->verifyElementPresent("//td[@colspan='5']"); + $this->verifyElementPresent("//table[@cellpadding='2']"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/Repeater2TestCase.php b/tests/FunctionalTests/quickstart/Controls/Repeater2TestCase.php index 59cff7a0..b592a135 100644 --- a/tests/FunctionalTests/quickstart/Controls/Repeater2TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/Repeater2TestCase.php @@ -1,37 +1,37 @@ -<?php
-
-class Repeater2TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRepeater.Sample2&notheme=true&lang=en", "");
-
- // verify if all required texts are present
- $this->verifyTextPresent('North','');
- $this->verifyTextPresent('John','');
- $this->verifyTextPresent('Developer','');
- $this->verifyTextPresent('South','');
- $this->verifyTextPresent('Carter','');
- $this->verifyTextPresent('Program Manager','');
-
- // verify specific table tags
- $this->verifyElementPresent("//table[@cellspacing='1']");
- $this->verifyElementPresent("//td[@id='ctl0_body_Repeater_ctl1_Cell' and contains(text(),'North')]","");
- $this->verifyElementPresent("//td[@id='ctl0_body_Repeater_ctl1_Cell']","");
- $this->verifyElementPresent("//td[@id='ctl0_body_Repeater_ctl2_Cell']","");
- $this->verifyElementPresent("//td[@id='ctl0_body_Repeater_ctl3_Cell']","");
- $this->verifyElementPresent("//td[@id='ctl0_body_Repeater_ctl4_Cell']","");
- $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl1_Repeater2_ctl1_Row']","");
- $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl1_Repeater2_ctl2_Row']","");
- $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl1_Repeater2_ctl3_Row']","");
- $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl2_Repeater2_ctl1_Row']","");
- $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl2_Repeater2_ctl2_Row']","");
- $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl2_Repeater2_ctl3_Row']","");
- $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl3_Repeater2_ctl1_Row']","");
- $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl3_Repeater2_ctl2_Row']","");
- $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl4_Repeater2_ctl1_Row']","");
- $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl4_Repeater2_ctl2_Row']","");
- }
-}
-
+<?php + +class Repeater2TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRepeater.Sample2&notheme=true&lang=en", ""); + + // verify if all required texts are present + $this->verifyTextPresent('North',''); + $this->verifyTextPresent('John',''); + $this->verifyTextPresent('Developer',''); + $this->verifyTextPresent('South',''); + $this->verifyTextPresent('Carter',''); + $this->verifyTextPresent('Program Manager',''); + + // verify specific table tags + $this->verifyElementPresent("//table[@cellspacing='1']"); + $this->verifyElementPresent("//td[@id='ctl0_body_Repeater_ctl1_Cell' and contains(text(),'North')]",""); + $this->verifyElementPresent("//td[@id='ctl0_body_Repeater_ctl1_Cell']",""); + $this->verifyElementPresent("//td[@id='ctl0_body_Repeater_ctl2_Cell']",""); + $this->verifyElementPresent("//td[@id='ctl0_body_Repeater_ctl3_Cell']",""); + $this->verifyElementPresent("//td[@id='ctl0_body_Repeater_ctl4_Cell']",""); + $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl1_Repeater2_ctl1_Row']",""); + $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl1_Repeater2_ctl2_Row']",""); + $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl1_Repeater2_ctl3_Row']",""); + $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl2_Repeater2_ctl1_Row']",""); + $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl2_Repeater2_ctl2_Row']",""); + $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl2_Repeater2_ctl3_Row']",""); + $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl3_Repeater2_ctl1_Row']",""); + $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl3_Repeater2_ctl2_Row']",""); + $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl4_Repeater2_ctl1_Row']",""); + $this->verifyElementPresent("//tr[@id='ctl0_body_Repeater_ctl4_Repeater2_ctl2_Row']",""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/Repeater3TestCase.php b/tests/FunctionalTests/quickstart/Controls/Repeater3TestCase.php index 60d68d33..e1922ffd 100644 --- a/tests/FunctionalTests/quickstart/Controls/Repeater3TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/Repeater3TestCase.php @@ -1,37 +1,37 @@ -<?php
-
-class Repeater3TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRepeater.Sample3&notheme=true&lang=en", "");
-
- // verify product name is required
- $this->verifyNotVisible('ctl0_body_Repeater_ctl0_ctl0');
- $this->type("ctl0_body_Repeater_ctl0_ProductName", "");
- $this->click("//input[@type='submit' and @value='Save']", "");
- $this->verifyVisible('ctl0_body_Repeater_ctl0_ctl0');
-
- // verify product price is of proper format
- $this->verifyNotVisible('ctl0_body_Repeater_ctl0_ctl1');
- $this->type("ctl0_body_Repeater_ctl0_ProductPrice", "abc");
- $this->click("//input[@type='submit' and @value='Save']", "");
- $this->verifyVisible('ctl0_body_Repeater_ctl0_ctl1');
-
- // perform postback
- $this->click("ctl0_body_Repeater_ctl0_ProductImported",'');
- $this->type("ctl0_body_Repeater_ctl0_ProductName", "Mother Board");
- $this->type("ctl0_body_Repeater_ctl0_ProductPrice", "99.01");
- $this->select("ctl0_body_Repeater_ctl3_ProductCategory", "label=Accessories");
- $this->clickAndWait("//input[@type='submit' and @value='Save']", "");
- $this->verifyNotVisible('ctl0_body_Repeater_ctl0_ctl0');
- $this->verifyNotVisible('ctl0_body_Repeater_ctl0_ctl1');
-
- // verify postback results
- $this->verifyElementPresent("//td[text()='Mother Board']",'');
- $this->verifyElementNotPresent("//td[text()='Input Devices']",'');
- $this->verifyElementPresent("//td[text()='99.01']",'');
- }
-}
-
+<?php + +class Repeater3TestCase extends SeleniumTestCase +{ + function test() + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TRepeater.Sample3&notheme=true&lang=en", ""); + + // verify product name is required + $this->verifyNotVisible('ctl0_body_Repeater_ctl0_ctl0'); + $this->type("ctl0_body_Repeater_ctl0_ProductName", ""); + $this->click("//input[@type='submit' and @value='Save']", ""); + $this->verifyVisible('ctl0_body_Repeater_ctl0_ctl0'); + + // verify product price is of proper format + $this->verifyNotVisible('ctl0_body_Repeater_ctl0_ctl1'); + $this->type("ctl0_body_Repeater_ctl0_ProductPrice", "abc"); + $this->click("//input[@type='submit' and @value='Save']", ""); + $this->verifyVisible('ctl0_body_Repeater_ctl0_ctl1'); + + // perform postback + $this->click("ctl0_body_Repeater_ctl0_ProductImported",''); + $this->type("ctl0_body_Repeater_ctl0_ProductName", "Mother Board"); + $this->type("ctl0_body_Repeater_ctl0_ProductPrice", "99.01"); + $this->select("ctl0_body_Repeater_ctl3_ProductCategory", "label=Accessories"); + $this->clickAndWait("//input[@type='submit' and @value='Save']", ""); + $this->verifyNotVisible('ctl0_body_Repeater_ctl0_ctl0'); + $this->verifyNotVisible('ctl0_body_Repeater_ctl0_ctl1'); + + // verify postback results + $this->verifyElementPresent("//td[text()='Mother Board']",''); + $this->verifyElementNotPresent("//td[text()='Input Devices']",''); + $this->verifyElementPresent("//td[text()='99.01']",''); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/StatementsTestCase.php b/tests/FunctionalTests/quickstart/Controls/StatementsTestCase.php index 783b0b6c..b8f322d7 100644 --- a/tests/FunctionalTests/quickstart/Controls/StatementsTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/StatementsTestCase.php @@ -1,15 +1,15 @@ -<?php
-
-class StatementsTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TStatements.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- $this->verifyTextPresent('UniqueID is \'ctl0$body$ctl0\'');
- }
-}
-
+<?php + +class StatementsTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TStatements.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + $this->verifyTextPresent('UniqueID is \'ctl0$body$ctl0\''); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/TabPanelTestCase.php b/tests/FunctionalTests/quickstart/Controls/TabPanelTestCase.php index b60a8047..66417eda 100644 --- a/tests/FunctionalTests/quickstart/Controls/TabPanelTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/TabPanelTestCase.php @@ -1,49 +1,49 @@ -<?php
-
-class TabPanelTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TTabPanel.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // verify initial visibility
- $this->verifyNotVisible('ctl0_body_View1'); // view 1
- $this->verifyVisible('ctl0_body_View2'); // view 2
- $this->verifyNotVisible('ctl0_body_ctl2'); // view 3
-
- // switching to the first view
- $this->click('ctl0_body_View1_0');
- $this->pause(500);
- $this->verifyVisible('ctl0_body_View1'); // view 1
- $this->verifyNotVisible('ctl0_body_View2'); // view 2
- $this->verifyNotVisible('ctl0_body_ctl2'); // view 3
- $this->verifyNotVisible('ctl0_body_View11'); // view 11
- $this->verifyVisible('ctl0_body_View21'); // view 21
-
- // switching to View11
- $this->click('ctl0_body_View11_0');
- $this->pause(500);
- $this->verifyVisible('ctl0_body_View1'); // view 1
- $this->verifyNotVisible('ctl0_body_View2'); // view 2
- $this->verifyNotVisible('ctl0_body_ctl2'); // view 3
- $this->verifyVisible('ctl0_body_View11'); // view 11
- $this->verifyNotVisible('ctl0_body_View21'); // view 21
-
- // switching to the third view
- $this->click('ctl0_body_ctl2_0');
- $this->pause(500);
- $this->verifyNotVisible('ctl0_body_View1'); // view 1
- $this->verifyNotVisible('ctl0_body_View2'); // view 2
- $this->verifyVisible('ctl0_body_ctl2'); // view 3
-
- // submit: check if the visibility is kept
- $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
- $this->verifyNotVisible('ctl0_body_View1'); // view 1
- $this->verifyNotVisible('ctl0_body_View2'); // view 2
- $this->verifyVisible('ctl0_body_ctl2'); // view 3
- }
-}
-
+<?php + +class TabPanelTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TTabPanel.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // verify initial visibility + $this->verifyNotVisible('ctl0_body_View1'); // view 1 + $this->verifyVisible('ctl0_body_View2'); // view 2 + $this->verifyNotVisible('ctl0_body_ctl2'); // view 3 + + // switching to the first view + $this->click('ctl0_body_View1_0'); + $this->pause(500); + $this->verifyVisible('ctl0_body_View1'); // view 1 + $this->verifyNotVisible('ctl0_body_View2'); // view 2 + $this->verifyNotVisible('ctl0_body_ctl2'); // view 3 + $this->verifyNotVisible('ctl0_body_View11'); // view 11 + $this->verifyVisible('ctl0_body_View21'); // view 21 + + // switching to View11 + $this->click('ctl0_body_View11_0'); + $this->pause(500); + $this->verifyVisible('ctl0_body_View1'); // view 1 + $this->verifyNotVisible('ctl0_body_View2'); // view 2 + $this->verifyNotVisible('ctl0_body_ctl2'); // view 3 + $this->verifyVisible('ctl0_body_View11'); // view 11 + $this->verifyNotVisible('ctl0_body_View21'); // view 21 + + // switching to the third view + $this->click('ctl0_body_ctl2_0'); + $this->pause(500); + $this->verifyNotVisible('ctl0_body_View1'); // view 1 + $this->verifyNotVisible('ctl0_body_View2'); // view 2 + $this->verifyVisible('ctl0_body_ctl2'); // view 3 + + // submit: check if the visibility is kept + $this->clickAndWait("//input[@type='submit' and @value='Submit']", ""); + $this->verifyNotVisible('ctl0_body_View1'); // view 1 + $this->verifyNotVisible('ctl0_body_View2'); // view 2 + $this->verifyVisible('ctl0_body_ctl2'); // view 3 + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/TableTestCase.php b/tests/FunctionalTests/quickstart/Controls/TableTestCase.php index 2dbc695c..7ea6fc39 100644 --- a/tests/FunctionalTests/quickstart/Controls/TableTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/TableTestCase.php @@ -1,20 +1,20 @@ -<?php
-
-class TableTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TTable.Home&notheme=true&lang=en", "");
-
- $this->verifyElementPresent("//table[@rules='all' and @border='1']");
- $this->verifyElementPresent("//table/caption[@align='bottom' and text()='This is table caption']");
- $this->verifyElementPresent("//th[text()='header cell 2']");
- $this->verifyElementPresent("//tr[@align='right']/td[text()='text']");
- $this->verifyElementPresent("//td[@align='center' and contains(text(),'cell 5')]");
-
- $this->verifyElementPresent("//th[text()='Header 1']");
- $this->verifyElementPresent("//td[text()='Cell 1']");
- }
-}
-
+<?php + +class TableTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TTable.Home&notheme=true&lang=en", ""); + + $this->verifyElementPresent("//table[@rules='all' and @border='1']"); + $this->verifyElementPresent("//table/caption[@align='bottom' and text()='This is table caption']"); + $this->verifyElementPresent("//th[text()='header cell 2']"); + $this->verifyElementPresent("//tr[@align='right']/td[text()='text']"); + $this->verifyElementPresent("//td[@align='center' and contains(text(),'cell 5')]"); + + $this->verifyElementPresent("//th[text()='Header 1']"); + $this->verifyElementPresent("//td[text()='Cell 1']"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/TextBoxTestCase.php b/tests/FunctionalTests/quickstart/Controls/TextBoxTestCase.php index c20bf871..7bf46351 100644 --- a/tests/FunctionalTests/quickstart/Controls/TextBoxTestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/TextBoxTestCase.php @@ -1,93 +1,93 @@ -<?php
-
-class TextBoxTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TTextBox.Home&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // a normal textbox
- $this->type("ctl0\$body\$ctl0", "test");
-
- // textbox with maxlength set
- $this->verifyAttribute("ctl0\$body\$ctl1@size","4");
- $this->verifyAttribute("ctl0\$body\$ctl1@maxlength","6");
- $this->type("ctl0\$body\$ctl1", "textte");
-
- // vCard textboxes
- $this->verifyAttribute("ctl0\$body\$ctl2@vcard_name","vCard.FirstName");
- $this->type("ctl0\$body\$ctl2", "first");
- $this->verifyAttribute("ctl0\$body\$ctl3@vcard_name","vCard.LastName");
- $this->type("ctl0\$body\$ctl3", "last");
-
- // a disabled textbox
- $this->verifyAttribute("ctl0\$body\$ctl4@disabled","regexp:true|disabled");
-
- // a read-only textbox
- $this->verifyAttribute("ctl0\$body\$ctl5@readonly","regexp:true|readonly");
-
- // auto postback textbox, CausesValidation=false
- $this->verifyValue("ctl0\$body\$ctl6", "change me");
- $this->typeAndWait("ctl0\$body\$ctl6", "change mes");
- $this->verifyValue("ctl0\$body\$ctl6", "text changed");
-
- // auto postback textbox, CausesValidation=true
- $this->verifyNotVisible('ctl0_body_ctl7');
- $this->type("ctl0\$body\$TextBox3", "test");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl7');
- $this->typeAndWait("ctl0\$body\$TextBox3", "non test");
- $this->verifyNotVisible('ctl0_body_ctl7');
-
- // submitting textbox with a button
- $this->type("ctl0\$body\$TextBox1", "texttext");
- $this->clickAndWait("//input[@type='submit' and @value='Submit']", "");
- $this->verifyValue("ctl0\$body\$TextBox1", "You just entered 'texttext'.");
-
- // SafeText
- $this->verifyText("ctl0_body_Output","test");
- $this->typeAndWait("ctl0\$body\$TextBox2","<a href=javascript:xxx>malicious code</a>");
- $this->verifyText("ctl0_body_Output","malicious code");
-
- // password
- $this->verifyAttribute("ctl0\$body\$ctl9@type","password");
-
- // ------------------multiline textbox----------------------
-
- // regular textbox
- $this->type("ctl0\$body\$ctl10", "This is a\nmultiline\ntextbox.");
- $this->type("ctl0\$body\$ctl11", "This is a multiline text box.
-In HTML, it is displayed as a textarea.
-End of message
-");
-
- // a disabled multiline textbox
- $this->verifyAttribute("ctl0\$body\$ctl12@disabled","regexp:true|disabled");
-
- // a read-only multiline textbox
- $this->verifyAttribute("ctl0\$body\$ctl13@readonly","regexp:true|readonly");
- $this->verifyAttribute("ctl0\$body\$ctl13@wrap","off");
-
- // auto postback textbox
- $this->verifyValue("ctl0\$body\$ctl14", "change me");
- $this->typeAndWait("ctl0\$body\$ctl14", "change mes");
- $this->verifyValue("ctl0\$body\$ctl14", "text changed");
- $this->verifyValue("ctl0\$body\$ctl10", "This is a\nmultiline\ntextbox.");
- $this->verifyValue("ctl0\$body\$ctl11", "This is a multiline text box.
-In HTML, it is displayed as a textarea.
-End of message
-");
-
- // textbox associated with a validator
- $this->verifyNotVisible('ctl0_body_ctl15');
- $this->type("ctl0\$body\$MultiTextBox3", "demo");
-// $this->pause(1000);
- $this->verifyVisible('ctl0_body_ctl15');
- $this->typeAndWait("ctl0\$body\$MultiTextBox3", "non demo");
- $this->verifyNotVisible('ctl0_body_ctl15');
- }
-}
-
+<?php + +class TextBoxTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TTextBox.Home&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // a normal textbox + $this->type("ctl0\$body\$ctl0", "test"); + + // textbox with maxlength set + $this->verifyAttribute("ctl0\$body\$ctl1@size","4"); + $this->verifyAttribute("ctl0\$body\$ctl1@maxlength","6"); + $this->type("ctl0\$body\$ctl1", "textte"); + + // vCard textboxes + $this->verifyAttribute("ctl0\$body\$ctl2@vcard_name","vCard.FirstName"); + $this->type("ctl0\$body\$ctl2", "first"); + $this->verifyAttribute("ctl0\$body\$ctl3@vcard_name","vCard.LastName"); + $this->type("ctl0\$body\$ctl3", "last"); + + // a disabled textbox + $this->verifyAttribute("ctl0\$body\$ctl4@disabled","regexp:true|disabled"); + + // a read-only textbox + $this->verifyAttribute("ctl0\$body\$ctl5@readonly","regexp:true|readonly"); + + // auto postback textbox, CausesValidation=false + $this->verifyValue("ctl0\$body\$ctl6", "change me"); + $this->typeAndWait("ctl0\$body\$ctl6", "change mes"); + $this->verifyValue("ctl0\$body\$ctl6", "text changed"); + + // auto postback textbox, CausesValidation=true + $this->verifyNotVisible('ctl0_body_ctl7'); + $this->type("ctl0\$body\$TextBox3", "test"); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl7'); + $this->typeAndWait("ctl0\$body\$TextBox3", "non test"); + $this->verifyNotVisible('ctl0_body_ctl7'); + + // submitting textbox with a button + $this->type("ctl0\$body\$TextBox1", "texttext"); + $this->clickAndWait("//input[@type='submit' and @value='Submit']", ""); + $this->verifyValue("ctl0\$body\$TextBox1", "You just entered 'texttext'."); + + // SafeText + $this->verifyText("ctl0_body_Output","test"); + $this->typeAndWait("ctl0\$body\$TextBox2","<a href=javascript:xxx>malicious code</a>"); + $this->verifyText("ctl0_body_Output","malicious code"); + + // password + $this->verifyAttribute("ctl0\$body\$ctl9@type","password"); + + // ------------------multiline textbox---------------------- + + // regular textbox + $this->type("ctl0\$body\$ctl10", "This is a\nmultiline\ntextbox."); + $this->type("ctl0\$body\$ctl11", "This is a multiline text box. +In HTML, it is displayed as a textarea. +End of message +"); + + // a disabled multiline textbox + $this->verifyAttribute("ctl0\$body\$ctl12@disabled","regexp:true|disabled"); + + // a read-only multiline textbox + $this->verifyAttribute("ctl0\$body\$ctl13@readonly","regexp:true|readonly"); + $this->verifyAttribute("ctl0\$body\$ctl13@wrap","off"); + + // auto postback textbox + $this->verifyValue("ctl0\$body\$ctl14", "change me"); + $this->typeAndWait("ctl0\$body\$ctl14", "change mes"); + $this->verifyValue("ctl0\$body\$ctl14", "text changed"); + $this->verifyValue("ctl0\$body\$ctl10", "This is a\nmultiline\ntextbox."); + $this->verifyValue("ctl0\$body\$ctl11", "This is a multiline text box. +In HTML, it is displayed as a textarea. +End of message +"); + + // textbox associated with a validator + $this->verifyNotVisible('ctl0_body_ctl15'); + $this->type("ctl0\$body\$MultiTextBox3", "demo"); +// $this->pause(1000); + $this->verifyVisible('ctl0_body_ctl15'); + $this->typeAndWait("ctl0\$body\$MultiTextBox3", "non demo"); + $this->verifyNotVisible('ctl0_body_ctl15'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/Wizard1TestCase.php b/tests/FunctionalTests/quickstart/Controls/Wizard1TestCase.php index 80e8bbe9..474529a6 100644 --- a/tests/FunctionalTests/quickstart/Controls/Wizard1TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/Wizard1TestCase.php @@ -1,26 +1,26 @@ -<?php
-
-class Wizard1TestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample1&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // step 1
- $this->verifyTextPresent('Wizard Step 1');
- $this->verifyTextNotPresent('Wizard Step 2');
- $this->verifyVisible('ctl0_body_Wizard1_SideBarList_ctl0_SideBarButton');
- $this->verifyAttribute('ctl0_body_Wizard1_SideBarList_ctl1_SideBarButton@disabled','regexp:true|disabled');
- $this->select('ctl0$body$Wizard1$DropDownList1', "label=Purple");
- $this->clickAndWait('ctl0$body$Wizard1$ctl6$ctl1');
-
- // step 2
- $this->verifyTextPresent('Your favorite color is: Purple');
- $this->verifyTextNotPresent('Wizard Step 1');
- $this->verifyTextPresent('Wizard Step 2');
- }
-}
-
+<?php + +class Wizard1TestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample1&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // step 1 + $this->verifyTextPresent('Wizard Step 1'); + $this->verifyTextNotPresent('Wizard Step 2'); + $this->verifyVisible('ctl0_body_Wizard1_SideBarList_ctl0_SideBarButton'); + $this->verifyAttribute('ctl0_body_Wizard1_SideBarList_ctl1_SideBarButton@disabled','regexp:true|disabled'); + $this->select('ctl0$body$Wizard1$DropDownList1', "label=Purple"); + $this->clickAndWait('ctl0$body$Wizard1$ctl6$ctl1'); + + // step 2 + $this->verifyTextPresent('Your favorite color is: Purple'); + $this->verifyTextNotPresent('Wizard Step 1'); + $this->verifyTextPresent('Wizard Step 2'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/Wizard2TestCase.php b/tests/FunctionalTests/quickstart/Controls/Wizard2TestCase.php index ba5f66c3..3c49bfd8 100644 --- a/tests/FunctionalTests/quickstart/Controls/Wizard2TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/Wizard2TestCase.php @@ -1,26 +1,26 @@ -<?php
-
-class Wizard2TestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample2&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // step 1
- $this->verifyTextPresent('Please let us know your preference');
- $this->verifyTextNotPresent('Thank you for your answer');
- $this->verifyVisible('ctl0_body_Wizard1_SideBarList_ctl0_SideBarButton');
- $this->verifyAttribute('ctl0_body_Wizard1_SideBarList_ctl1_SideBarButton@disabled','regexp:true|disabled');
- $this->select('ctl0$body$Wizard1$DropDownList1', "label=Blue");
- $this->clickAndWait('ctl0$body$Wizard1$ctl6$ctl1');
-
- // step 2
- $this->verifyTextPresent('Your favorite color is: Blue');
- $this->verifyTextNotPresent('Please let us know your preference');
- $this->verifyTextPresent('Thank you for your answer');
- }
-}
-
+<?php + +class Wizard2TestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample2&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // step 1 + $this->verifyTextPresent('Please let us know your preference'); + $this->verifyTextNotPresent('Thank you for your answer'); + $this->verifyVisible('ctl0_body_Wizard1_SideBarList_ctl0_SideBarButton'); + $this->verifyAttribute('ctl0_body_Wizard1_SideBarList_ctl1_SideBarButton@disabled','regexp:true|disabled'); + $this->select('ctl0$body$Wizard1$DropDownList1', "label=Blue"); + $this->clickAndWait('ctl0$body$Wizard1$ctl6$ctl1'); + + // step 2 + $this->verifyTextPresent('Your favorite color is: Blue'); + $this->verifyTextNotPresent('Please let us know your preference'); + $this->verifyTextPresent('Thank you for your answer'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/Wizard3TestCase.php b/tests/FunctionalTests/quickstart/Controls/Wizard3TestCase.php index 1172d31c..04224bb4 100644 --- a/tests/FunctionalTests/quickstart/Controls/Wizard3TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/Wizard3TestCase.php @@ -1,46 +1,46 @@ -<?php
-
-class Wizard3TestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample3&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // step 1
- $this->verifyTextPresent('A Mini Survey');
- $this->verifyTextPresent('PRADO QuickStart Sample');
- $this->click('ctl0_body_Wizard3_StudentCheckBox');
- $this->clickAndWait('ctl0$body$Wizard3$ctl4$ctl0');
-
- // step 2
- $this->select('ctl0$body$Wizard3$DropDownList11', "label=Chemistry");
- $this->clickAndWait('ctl0$body$Wizard3$ctl5$ctl1');
-
- // step 3
- $this->select('ctl0$body$Wizard3$DropDownList22', "label=Tennis");
- $this->clickAndWait('ctl0$body$Wizard3$ctl6$ctl1');
-
- // step 4
- $this->verifyTextPresent('You are a college student');
- $this->verifyTextPresent('You are in major: Chemistry');
- $this->verifyTextPresent('Your favorite sport is: Tennis');
-
- // run the example again. this time we skip the page asking about major
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample3&notheme=true", "");
-
- // step 1
- $this->clickAndWait('ctl0$body$Wizard3$ctl4$ctl0');
-
- // step 3
- $this->select('ctl0$body$Wizard3$DropDownList22', "label=Baseball");
- $this->clickAndWait('ctl0$body$Wizard3$ctl6$ctl1');
-
- // step 4
- $this->verifyTextNotPresent('You are a college student');
- $this->verifyTextPresent('Your favorite sport is: Baseball');
- }
-}
-
+<?php + +class Wizard3TestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample3&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // step 1 + $this->verifyTextPresent('A Mini Survey'); + $this->verifyTextPresent('PRADO QuickStart Sample'); + $this->click('ctl0_body_Wizard3_StudentCheckBox'); + $this->clickAndWait('ctl0$body$Wizard3$ctl4$ctl0'); + + // step 2 + $this->select('ctl0$body$Wizard3$DropDownList11', "label=Chemistry"); + $this->clickAndWait('ctl0$body$Wizard3$ctl5$ctl1'); + + // step 3 + $this->select('ctl0$body$Wizard3$DropDownList22', "label=Tennis"); + $this->clickAndWait('ctl0$body$Wizard3$ctl6$ctl1'); + + // step 4 + $this->verifyTextPresent('You are a college student'); + $this->verifyTextPresent('You are in major: Chemistry'); + $this->verifyTextPresent('Your favorite sport is: Tennis'); + + // run the example again. this time we skip the page asking about major + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample3&notheme=true", ""); + + // step 1 + $this->clickAndWait('ctl0$body$Wizard3$ctl4$ctl0'); + + // step 3 + $this->select('ctl0$body$Wizard3$DropDownList22', "label=Baseball"); + $this->clickAndWait('ctl0$body$Wizard3$ctl6$ctl1'); + + // step 4 + $this->verifyTextNotPresent('You are a college student'); + $this->verifyTextPresent('Your favorite sport is: Baseball'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/Wizard4TestCase.php b/tests/FunctionalTests/quickstart/Controls/Wizard4TestCase.php index d0cc8ac1..b2d757dc 100644 --- a/tests/FunctionalTests/quickstart/Controls/Wizard4TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/Wizard4TestCase.php @@ -1,44 +1,44 @@ -<?php
-
-class Wizard4TestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample4&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // step 1
- $this->verifyTextPresent('Step 1 of 3');
- $this->select('ctl0_body_Wizard1_DropDownList1', "label=Cyan");
- $this->clickAndWait('ctl0_body_Wizard1_SideBarList_ctl2_SideBarButton');
-
- // step 3
- $this->verifyTextPresent('Step 3 of 3');
- $this->verifyTextPresent('Thank you for completing this survey.');
- $this->clickAndWait('ctl0_body_Wizard1_SideBarList_ctl0_SideBarButton');
-
- // step 1
- $this->verifySelected('ctl0_body_Wizard1_DropDownList1', "label=Cyan");
- $this->select('ctl0_body_Wizard1_DropDownList1', "label=Black");
- $this->clickAndWait('ctl0_body_Wizard1_ctl4_ctl0');
-
- // step 2
- $this->verifyTextPresent('Step 2 of 3');
- $this->verifyTextPresent('Your favorite color is: Black');
- $this->clickAndWait('ctl0_body_Wizard1_ctl5_ctl0');
-
- // step 1
- $this->verifyTextPresent('Step 1 of 3');
- $this->verifySelected('ctl0_body_Wizard1_DropDownList1', "label=Black");
- $this->clickAndWait('ctl0_body_Wizard1_ctl4_ctl0');
-
- // step 2
- $this->clickAndWait('ctl0_body_Wizard1_ctl5_ctl1');
-
- // step 3
- $this->verifyTextPresent('Step 3 of 3');
- }
-}
-
+<?php + +class Wizard4TestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample4&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // step 1 + $this->verifyTextPresent('Step 1 of 3'); + $this->select('ctl0_body_Wizard1_DropDownList1', "label=Cyan"); + $this->clickAndWait('ctl0_body_Wizard1_SideBarList_ctl2_SideBarButton'); + + // step 3 + $this->verifyTextPresent('Step 3 of 3'); + $this->verifyTextPresent('Thank you for completing this survey.'); + $this->clickAndWait('ctl0_body_Wizard1_SideBarList_ctl0_SideBarButton'); + + // step 1 + $this->verifySelected('ctl0_body_Wizard1_DropDownList1', "label=Cyan"); + $this->select('ctl0_body_Wizard1_DropDownList1', "label=Black"); + $this->clickAndWait('ctl0_body_Wizard1_ctl4_ctl0'); + + // step 2 + $this->verifyTextPresent('Step 2 of 3'); + $this->verifyTextPresent('Your favorite color is: Black'); + $this->clickAndWait('ctl0_body_Wizard1_ctl5_ctl0'); + + // step 1 + $this->verifyTextPresent('Step 1 of 3'); + $this->verifySelected('ctl0_body_Wizard1_DropDownList1', "label=Black"); + $this->clickAndWait('ctl0_body_Wizard1_ctl4_ctl0'); + + // step 2 + $this->clickAndWait('ctl0_body_Wizard1_ctl5_ctl1'); + + // step 3 + $this->verifyTextPresent('Step 3 of 3'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Controls/Wizard5TestCase.php b/tests/FunctionalTests/quickstart/Controls/Wizard5TestCase.php index d892cd3b..631167b9 100644 --- a/tests/FunctionalTests/quickstart/Controls/Wizard5TestCase.php +++ b/tests/FunctionalTests/quickstart/Controls/Wizard5TestCase.php @@ -1,37 +1,37 @@ -<?php
-
-class Wizard5TestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample5&notheme=true&lang=en", "");
-
- $this->verifyTitle("PRADO QuickStart Sample", "");
-
- // step 1
- $this->verifyTextPresent('Please let us know your preference');
- $this->verifyVisible('ctl0_body_Wizard1_SideBarList_ctl0_SideBarButton');
- $this->verifyVisible('ctl0_body_Wizard1_SideBarList_ctl1_SideBarButton');
- $this->verifyAttribute('ctl0_body_Wizard1_SideBarList_ctl2_SideBarButton@disabled','regexp:true|disabled');
- $this->select('ctl0_body_Wizard1_DropDownList1', "label=Cyan");
- $this->clickAndWait('ctl0$body$Wizard1$ctl4$ctl0');
-
- // step 2
- $this->select('ctl0_body_Wizard1_Step2_DropDownList2','label=Football');
- $this->clickAndWait('ctl0$body$Wizard1$ctl6$ctl0');
-
- // step 1
- $this->verifySelected('ctl0_body_Wizard1_DropDownList1','label=Cyan');
- $this->clickAndWait('ctl0_body_Wizard1_SideBarList_ctl1_SideBarButton');
-
- // step 2
- $this->verifySelected('ctl0_body_Wizard1_Step2_DropDownList2','label=Football');
- $this->clickAndWait('ctl0$body$Wizard1$ctl6$ctl1');
-
- // step 3
- $this->verifyTextPresent('Your favorite color is: Cyan');
- $this->verifyTextPresent('Your favorite sport is: Football');
- }
-}
-
+<?php + +class Wizard5TestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Controls.Samples.TWizard.Sample5&notheme=true&lang=en", ""); + + $this->verifyTitle("PRADO QuickStart Sample", ""); + + // step 1 + $this->verifyTextPresent('Please let us know your preference'); + $this->verifyVisible('ctl0_body_Wizard1_SideBarList_ctl0_SideBarButton'); + $this->verifyVisible('ctl0_body_Wizard1_SideBarList_ctl1_SideBarButton'); + $this->verifyAttribute('ctl0_body_Wizard1_SideBarList_ctl2_SideBarButton@disabled','regexp:true|disabled'); + $this->select('ctl0_body_Wizard1_DropDownList1', "label=Cyan"); + $this->clickAndWait('ctl0$body$Wizard1$ctl4$ctl0'); + + // step 2 + $this->select('ctl0_body_Wizard1_Step2_DropDownList2','label=Football'); + $this->clickAndWait('ctl0$body$Wizard1$ctl6$ctl0'); + + // step 1 + $this->verifySelected('ctl0_body_Wizard1_DropDownList1','label=Cyan'); + $this->clickAndWait('ctl0_body_Wizard1_SideBarList_ctl1_SideBarButton'); + + // step 2 + $this->verifySelected('ctl0_body_Wizard1_Step2_DropDownList2','label=Football'); + $this->clickAndWait('ctl0$body$Wizard1$ctl6$ctl1'); + + // step 3 + $this->verifyTextPresent('Your favorite color is: Cyan'); + $this->verifyTextPresent('Your favorite sport is: Football'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/quickstart/Fundamentals/HangmanTestCase.php b/tests/FunctionalTests/quickstart/Fundamentals/HangmanTestCase.php index fd685412..8803e352 100644 --- a/tests/FunctionalTests/quickstart/Fundamentals/HangmanTestCase.php +++ b/tests/FunctionalTests/quickstart/Fundamentals/HangmanTestCase.php @@ -1,34 +1,34 @@ -<?php
-
-class HangmanTestCase extends SeleniumTestCase
-{
- function test ()
- {
- $this->open("../../demos/quickstart/index.php?page=Fundamentals.Samples.Hangman.Home&notheme=true&lang=en", "");
- $this->verifyTitle("Hangman Game", "");
- $this->verifyTextPresent("Medium game; you are allowed 5 misses.", "");
- $this->clickAndWait("//input[@type='submit' and @value='Play!']", "");
- $this->verifyTextPresent("You must choose a difficulty level", "");
- $this->clickAndWait("//input[@type='submit' and @value='Play!']", "");
- $this->click("//input[@name='ctl0\$body\$LevelSelection' and @value='3']", "");
- $this->clickAndWait("//input[@type='submit' and @value='Play!']", "");
- $this->verifyTextPresent("Please make a guess", "");
- $this->verifyTextPresent("maximum of 3", "");
- $this->clickAndWait("link=B", "");
- $this->clickAndWait("link=F", "");
- $this->clickAndWait("link=Give up?", "");
- $this->verifyTextPresent("You Lose", "");
- $this->clickAndWait("link=Start Again", "");
- $this->clickAndWait("//input[@type='submit' and @value='Play!']", "");
- $this->verifyTextPresent("Please make a guess", "");
- $this->verifyTextPresent("maximum of 3", "");
- $this->clickAndWait("link=Give up?", "");
- $this->verifyTextPresent("You Lose", "");
- $this->clickAndWait("link=Start Again", "");
- $this->click("//input[@name='ctl0\$body\$LevelSelection' and @value='5']", "");
- $this->clickAndWait("//input[@type='submit' and @value='Play!']", "");
- $this->verifyTextPresent("maximum of 5", "");
- }
-}
-
+<?php + +class HangmanTestCase extends SeleniumTestCase +{ + function test () + { + $this->open("../../demos/quickstart/index.php?page=Fundamentals.Samples.Hangman.Home&notheme=true&lang=en", ""); + $this->verifyTitle("Hangman Game", ""); + $this->verifyTextPresent("Medium game; you are allowed 5 misses.", ""); + $this->clickAndWait("//input[@type='submit' and @value='Play!']", ""); + $this->verifyTextPresent("You must choose a difficulty level", ""); + $this->clickAndWait("//input[@type='submit' and @value='Play!']", ""); + $this->click("//input[@name='ctl0\$body\$LevelSelection' and @value='3']", ""); + $this->clickAndWait("//input[@type='submit' and @value='Play!']", ""); + $this->verifyTextPresent("Please make a guess", ""); + $this->verifyTextPresent("maximum of 3", ""); + $this->clickAndWait("link=B", ""); + $this->clickAndWait("link=F", ""); + $this->clickAndWait("link=Give up?", ""); + $this->verifyTextPresent("You Lose", ""); + $this->clickAndWait("link=Start Again", ""); + $this->clickAndWait("//input[@type='submit' and @value='Play!']", ""); + $this->verifyTextPresent("Please make a guess", ""); + $this->verifyTextPresent("maximum of 3", ""); + $this->clickAndWait("link=Give up?", ""); + $this->verifyTextPresent("You Lose", ""); + $this->clickAndWait("link=Start Again", ""); + $this->click("//input[@name='ctl0\$body\$LevelSelection' and @value='5']", ""); + $this->clickAndWait("//input[@type='submit' and @value='Play!']", ""); + $this->verifyTextPresent("maximum of 5", ""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/DActiveDropDownList2.php b/tests/FunctionalTests/tickets/protected/pages/DActiveDropDownList2.php index 81fdfea7..532b17b0 100644 --- a/tests/FunctionalTests/tickets/protected/pages/DActiveDropDownList2.php +++ b/tests/FunctionalTests/tickets/protected/pages/DActiveDropDownList2.php @@ -1,34 +1,34 @@ -<?php
-Prado::using('System.Web.UI.ActiveControls.*');
-class DActiveDropDownList2 extends TActiveDropDownList
-{
- public function setOpcoes($val)
- {
- $this->setViewState('Opcoes', $val);
- }
-
- public function loadOptions()
- {
- $opcao = $this->getViewState('Opcoes');
-
- switch ($opcao) {
- case "turnos":
- $this->DataTextField="descricao";
- $this->DataValueField="id_turno";
- $opts = array(
- array('id_turno' => 'M', 'descricao' => 'Manhã'),
- array('id_turno' => 'T', 'descricao' => 'Tarde'),
- array('id_turno' => 'N', 'descricao' => 'Noite')
- );
- break;
-
- default:
- throw new TConfigurationException('Falta argumento OPCOES no DActiveDropDownList');
- break;
- }
- $this->setDataSource($opts);
- $this->dataBind();
- }
-}
-
+<?php +Prado::using('System.Web.UI.ActiveControls.*'); +class DActiveDropDownList2 extends TActiveDropDownList +{ + public function setOpcoes($val) + { + $this->setViewState('Opcoes', $val); + } + + public function loadOptions() + { + $opcao = $this->getViewState('Opcoes'); + + switch ($opcao) { + case "turnos": + $this->DataTextField="descricao"; + $this->DataValueField="id_turno"; + $opts = array( + array('id_turno' => 'M', 'descricao' => 'Manhã'), + array('id_turno' => 'T', 'descricao' => 'Tarde'), + array('id_turno' => 'N', 'descricao' => 'Noite') + ); + break; + + default: + throw new TConfigurationException('Falta argumento OPCOES no DActiveDropDownList'); + break; + } + $this->setDataSource($opts); + $this->dataBind(); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Issue120.php b/tests/FunctionalTests/tickets/protected/pages/Issue120.php index c04ae93d..ad6431a0 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Issue120.php +++ b/tests/FunctionalTests/tickets/protected/pages/Issue120.php @@ -1,22 +1,22 @@ -<?php
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Issue120 extends TPage
-{
- public function buttonClickCallback($sender, $param)
- {
-
- $this -> ddl1 -> setDataSource(
- array(
- 'callback value 1' => 'callback item 1',
- 'callback value 2' => 'callback item 2',
- 'callback value 3' => 'callback item 3',
- 'callback value 4' => 'callback item 4'
- )
- );
- $this -> ddl1 -> dataBind();
-
- }
-}
-
+<?php +Prado::using('System.Web.UI.ActiveControls.*'); + +class Issue120 extends TPage +{ + public function buttonClickCallback($sender, $param) + { + + $this -> ddl1 -> setDataSource( + array( + 'callback value 1' => 'callback item 1', + 'callback value 2' => 'callback item 2', + 'callback value 3' => 'callback item 3', + 'callback value 4' => 'callback item 4' + ) + ); + $this -> ddl1 -> dataBind(); + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Issue216.php b/tests/FunctionalTests/tickets/protected/pages/Issue216.php index 15491e2e..41eac5e9 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Issue216.php +++ b/tests/FunctionalTests/tickets/protected/pages/Issue216.php @@ -1,14 +1,14 @@ -<?php
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Issue216 extends TPage
-{
- public function buttonClickCallback($sender, $param)
- {
-
- $this->result->setText('Tab ActiveIndex is : '.$this->tabpanel->ActiveViewIndex);
-
- }
-}
-
+<?php +Prado::using('System.Web.UI.ActiveControls.*'); + +class Issue216 extends TPage +{ + public function buttonClickCallback($sender, $param) + { + + $this->result->setText('Tab ActiveIndex is : '.$this->tabpanel->ActiveViewIndex); + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Layout.php b/tests/FunctionalTests/tickets/protected/pages/Layout.php index 6d455371..da23db77 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Layout.php +++ b/tests/FunctionalTests/tickets/protected/pages/Layout.php @@ -1,23 +1,23 @@ -<?php
-
-class Layout extends TTemplateControl
-{
- public function onLoad($param)
- {
- $num = str_replace(array('Ticket', 'Issue'), '', $this->getPage()->getPagePath());
- $type = str_replace($num, '', $this->getPage()->getPagePath());
-
- $this->getPage()->setTitle("Verifying $type $num");
- $this->ticketlink->setText("Verifying $type $num");
-
- if(strToLower($type) === 'issue') {
- $this->ticketlink->setNavigateUrl("http://code.google.com/p/prado3/issues/detail?id={$num}");
- }
- else {
- $this->ticketlink->setNavigateUrl("http://trac.pradosoft.com/prado/ticket/{$num}");
- }
-
- }
-}
-
+<?php + +class Layout extends TTemplateControl +{ + public function onLoad($param) + { + $num = str_replace(array('Ticket', 'Issue'), '', $this->getPage()->getPagePath()); + $type = str_replace($num, '', $this->getPage()->getPagePath()); + + $this->getPage()->setTitle("Verifying $type $num"); + $this->ticketlink->setText("Verifying $type $num"); + + if(strToLower($type) === 'issue') { + $this->ticketlink->setNavigateUrl("http://code.google.com/p/prado3/issues/detail?id={$num}"); + } + else { + $this->ticketlink->setNavigateUrl("http://trac.pradosoft.com/prado/ticket/{$num}"); + } + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket121.php b/tests/FunctionalTests/tickets/protected/pages/Ticket121.php index 1a625d83..d913805c 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket121.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket121.php @@ -1,11 +1,11 @@ -<?php
-
-class Ticket121 extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- $this->Result->Text="clicked at ({$param->X},{$param->Y})";
- }
-}
-
+<?php + +class Ticket121 extends TPage +{ + public function buttonClicked($sender,$param) + { + $this->Result->Text="clicked at ({$param->X},{$param->Y})"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket191.php b/tests/FunctionalTests/tickets/protected/pages/Ticket191.php index 61c2a253..1b111bed 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket191.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket191.php @@ -1,22 +1,22 @@ -<?php
-
-class Ticket191 extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- if($this->IsValid)
- $this->Application->clearGlobalState('ticket190');
- }
-
- public function customValidation($sender,$param)
- {
- $param->IsValid=$this->Application->getGlobalState('ticket190')===$this->TextBox->Text;
- }
-
- public function updateGlobal($sender,$param)
- {
- $this->Application->setGlobalState('ticket190',$this->TextBox2->Text);
- }
-}
-
+<?php + +class Ticket191 extends TPage +{ + public function buttonClicked($sender,$param) + { + if($this->IsValid) + $this->Application->clearGlobalState('ticket190'); + } + + public function customValidation($sender,$param) + { + $param->IsValid=$this->Application->getGlobalState('ticket190')===$this->TextBox->Text; + } + + public function updateGlobal($sender,$param) + { + $this->Application->setGlobalState('ticket190',$this->TextBox2->Text); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket21.php b/tests/FunctionalTests/tickets/protected/pages/Ticket21.php index 041ba4b7..6a06a0f4 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket21.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket21.php @@ -1,22 +1,22 @@ -<?php
-
-class Ticket21 extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
-
- if(!$this->IsPostBack)
- $this->setViewState("clicks", 0);
- }
-
- public function doClick($sender, $param)
- {
- $clicks = $this->getViewState("clicks");
- $clicks++;
- $this->label1->setText("Radio button clicks: $clicks");
- $this->setViewState("clicks", $clicks);
- }
-}
-
+<?php + +class Ticket21 extends TPage +{ + public function onLoad($param) + { + parent::onLoad($param); + + if(!$this->IsPostBack) + $this->setViewState("clicks", 0); + } + + public function doClick($sender, $param) + { + $clicks = $this->getViewState("clicks"); + $clicks++; + $this->label1->setText("Radio button clicks: $clicks"); + $this->setViewState("clicks", $clicks); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket239.php b/tests/FunctionalTests/tickets/protected/pages/Ticket239.php index a40c94b5..bbf908b1 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket239.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket239.php @@ -1,16 +1,16 @@ -<?php
-
-class Ticket239 extends TPage
-{
- public function activateView($sender,$param)
- {
- $this->Result->Text.=$sender->ID." is activated. ";
- }
-
- public function deactivateView($sender,$param)
- {
- $this->Result->Text.=$sender->ID." is deactivated. ";
- }
-}
-
+<?php + +class Ticket239 extends TPage +{ + public function activateView($sender,$param) + { + $this->Result->Text.=$sender->ID." is activated. "; + } + + public function deactivateView($sender,$param) + { + $this->Result->Text.=$sender->ID." is deactivated. "; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket278.php b/tests/FunctionalTests/tickets/protected/pages/Ticket278.php index 1aadee77..2e18fd54 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket278.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket278.php @@ -1,23 +1,23 @@ -<?php
-
-class Ticket278 extends TPage
-{
- function validator2_onValidate($sender, $param)
- {
- $sender->Enabled = $this->check1->Checked;
- }
-
- function validate2_onPostValidate($sender, $param)
- {
- $sender->Enabled = true;
- }
-
- function onPreRender($param)
- {
- parent::onPreRender($param);
- $this->panel1->Style =
- $this->check1->Checked ? "display:block" : "display:none";
- }
-}
-
+<?php + +class Ticket278 extends TPage +{ + function validator2_onValidate($sender, $param) + { + $sender->Enabled = $this->check1->Checked; + } + + function validate2_onPostValidate($sender, $param) + { + $sender->Enabled = true; + } + + function onPreRender($param) + { + parent::onPreRender($param); + $this->panel1->Style = + $this->check1->Checked ? "display:block" : "display:none"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket283.php b/tests/FunctionalTests/tickets/protected/pages/Ticket283.php index 8426eae4..302ad2da 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket283.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket283.php @@ -1,11 +1,11 @@ -<?php
-
-class Ticket283 extends TPage
-{
- function button_clicked($sender, $param)
- {
- $this->label1->Text = $sender->Text.' Clicked!';
- }
-}
-
+<?php + +class Ticket283 extends TPage +{ + function button_clicked($sender, $param) + { + $this->label1->Text = $sender->Text.' Clicked!'; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket284.php b/tests/FunctionalTests/tickets/protected/pages/Ticket284.php index 332789ff..f9380b12 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket284.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket284.php @@ -1,11 +1,11 @@ -<?php
-
-class Ticket284 extends TPage
-{
- function checkUserAvailability()
- {
-
- }
-}
-
+<?php + +class Ticket284 extends TPage +{ + function checkUserAvailability() + { + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php b/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php index da6ad153..4405ca44 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php @@ -1,103 +1,103 @@ -<?php
-
-class Ticket284Component extends TTemplateControl implements IValidatable
-{
- private $_isValid;
- public function onPreRender($param)
- {
- if (!$this->ShowHours && $this->ShowMinutes)
- {
- throw new TConfigurationException(
- 'Invalid OPSDatePicker Config: You cannot specify ShowMinutes="true" while ShowHours="false"'
- );
- }
- }
-
- public function getDatePicker()
- {
- $this->ensureChildControls();
- return $this->getRegisteredObject('datePicker');
- }
-
- public function getHourPicker()
- {
- $this->ensureChildControls();
- return $this->getRegisteredObject('hourPicker');
- }
-
- public function getMinutePicker()
- {
- $this->ensureChildControls();
- return $this->getRegisteredObject('minutePicker');
- }
-
- public function getShowHours()
- {
- return $this->HourPicker->Visible;
- }
-
- public function setShowHours($value)
- {
- $this->HourPicker->Visible = TPropertyValue::ensureBoolean($value);
- }
-
- public function getShowMinutes()
- {
- return $this->MinutePicker->Visible;
- }
-
- public function setShowMinutes($value)
- {
- $this->MinutePicker->Visible = TPropertyValue::ensureBoolean($value);
- }
-
- public function getTimeStamp()
- {
- return strtotime($this->Date);
- }
-
- public function setTimeStamp($value)
- {
- $ts = TPropertyValue::ensureInteger($value);
- $this->DatePicker->TimeStamp = $ts;
- $this->HourPicker->SelectedValue = date('H', $ts);
- $this->MinutePicker->SelectedValue = date('i', $ts);
- }
-
- public function getDate()
- {
- $dateStr = $this->DatePicker->Date;
- if ($this->ShowHours){
- $dateStr .= ' '.$this->HourPicker->SelectedValue;
- }
- if ($this->ShowMinutes){
- $dateStr .= ':'.$this->MinutePicker->SelectedValue;
- }
- return $dateStr;
- }
-
- public function setDate($value)
- {
- $dateStr = TPropertyValue::ensureString($value);
- $this->TimeStamp = strtotime($dateStr);
- }
-
- public function getValidationPropertyValue()
- {
- if ($this->DatePicker->Date === ''){
- return '';
- }
- else{
- return $this->TimeStamp;
- }
- }
- public function getIsValid()
- {
- return $this->_isValid;
- }
- public function setIsValid($value)
- {
- $this->_isValid=TPropertyValue::ensureBoolean($value);
- }
-}
-?>
+<?php + +class Ticket284Component extends TTemplateControl implements IValidatable +{ + private $_isValid; + public function onPreRender($param) + { + if (!$this->ShowHours && $this->ShowMinutes) + { + throw new TConfigurationException( + 'Invalid OPSDatePicker Config: You cannot specify ShowMinutes="true" while ShowHours="false"' + ); + } + } + + public function getDatePicker() + { + $this->ensureChildControls(); + return $this->getRegisteredObject('datePicker'); + } + + public function getHourPicker() + { + $this->ensureChildControls(); + return $this->getRegisteredObject('hourPicker'); + } + + public function getMinutePicker() + { + $this->ensureChildControls(); + return $this->getRegisteredObject('minutePicker'); + } + + public function getShowHours() + { + return $this->HourPicker->Visible; + } + + public function setShowHours($value) + { + $this->HourPicker->Visible = TPropertyValue::ensureBoolean($value); + } + + public function getShowMinutes() + { + return $this->MinutePicker->Visible; + } + + public function setShowMinutes($value) + { + $this->MinutePicker->Visible = TPropertyValue::ensureBoolean($value); + } + + public function getTimeStamp() + { + return strtotime($this->Date); + } + + public function setTimeStamp($value) + { + $ts = TPropertyValue::ensureInteger($value); + $this->DatePicker->TimeStamp = $ts; + $this->HourPicker->SelectedValue = date('H', $ts); + $this->MinutePicker->SelectedValue = date('i', $ts); + } + + public function getDate() + { + $dateStr = $this->DatePicker->Date; + if ($this->ShowHours){ + $dateStr .= ' '.$this->HourPicker->SelectedValue; + } + if ($this->ShowMinutes){ + $dateStr .= ':'.$this->MinutePicker->SelectedValue; + } + return $dateStr; + } + + public function setDate($value) + { + $dateStr = TPropertyValue::ensureString($value); + $this->TimeStamp = strtotime($dateStr); + } + + public function getValidationPropertyValue() + { + if ($this->DatePicker->Date === ''){ + return ''; + } + else{ + return $this->TimeStamp; + } + } + public function getIsValid() + { + return $this->_isValid; + } + public function setIsValid($value) + { + $this->_isValid=TPropertyValue::ensureBoolean($value); + } +} +?> diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket359.php b/tests/FunctionalTests/tickets/protected/pages/Ticket359.php index 1e544e9b..6b15f699 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket359.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket359.php @@ -1,13 +1,13 @@ <?php -
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket359 extends TPage
-{
- function validate_text1($sender, $param)
- {
- $param->IsValid = $param->Value == 'Prado';
- }
-}
+ +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket359 extends TPage +{ + function validate_text1($sender, $param) + { + $param->IsValid = $param->Value == 'Prado'; + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket384.php b/tests/FunctionalTests/tickets/protected/pages/Ticket384.php index e928632d..b485ef2b 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket384.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket384.php @@ -1,46 +1,46 @@ <?php -
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket384 extends TPage
-{
- public function initRecursive($namingContainer=null)
- {
- parent::initRecursive($namingContainer);
- $this->AutoCompleteRepeater->setDataSource(array(1, 2));
- $this->AutoCompleteRepeater->dataBind();
- }
-
- public function submitCallback($sender, $param)
- {
- $this->AutoCompleteRepeater->setDataSource(array(1,2,3,4));
- $this->AutoCompleteRepeater->dataBind();
- $this->AutoCompletePanel->render($this->getResponse()->createHtmlWriter());
- }
-
- public function suggestCountries($sender, $param)
- {
- $sender->setDataSource($this->matchCountries($param->getCallbackParameter()));
- $sender->dataBind();
- }
-
- protected function matchCountries($token)
- {
- $info = Prado::createComponent('System.I18N.core.CultureInfo', 'en');
- $list = array();
- $count = 0;
- $token = strtolower($token);
- foreach($info->getCountries() as $country)
- {
- if(strpos(strtolower($country), $token) === 0)
- {
- $list[] = $country;
- $count++;
- if($count > 10) break;
- }
- }
- return $list;
- }
-}
+ +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket384 extends TPage +{ + public function initRecursive($namingContainer=null) + { + parent::initRecursive($namingContainer); + $this->AutoCompleteRepeater->setDataSource(array(1, 2)); + $this->AutoCompleteRepeater->dataBind(); + } + + public function submitCallback($sender, $param) + { + $this->AutoCompleteRepeater->setDataSource(array(1,2,3,4)); + $this->AutoCompleteRepeater->dataBind(); + $this->AutoCompletePanel->render($this->getResponse()->createHtmlWriter()); + } + + public function suggestCountries($sender, $param) + { + $sender->setDataSource($this->matchCountries($param->getCallbackParameter())); + $sender->dataBind(); + } + + protected function matchCountries($token) + { + $info = Prado::createComponent('System.I18N.core.CultureInfo', 'en'); + $list = array(); + $count = 0; + $token = strtolower($token); + foreach($info->getCountries() as $country) + { + if(strpos(strtolower($country), $token) === 0) + { + $list[] = $country; + $count++; + if($count > 10) break; + } + } + return $list; + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket413.php b/tests/FunctionalTests/tickets/protected/pages/Ticket413.php index 1da32b52..c7a7081a 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket413.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket413.php @@ -1,31 +1,31 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket413 extends TPage
-{
- private $_data = array(
- array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
- array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
- array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true),
- array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false));
- public function onLoad($param)
- {
- parent::onLoad($param);
-
- if (!$this->IsPostBack)
- {
- $this->locations_datagrid->setDataSource($this->_data);
- $this->locations_datagrid->dataBind();
- }
-
- }
-
- public function bla($sender, $param)
- {
- $sender->Text = 'a';
- }
-
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket413 extends TPage +{ + private $_data = array( + array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true), + array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true), + array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true), + array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false)); + public function onLoad($param) + { + parent::onLoad($param); + + if (!$this->IsPostBack) + { + $this->locations_datagrid->setDataSource($this->_data); + $this->locations_datagrid->dataBind(); + } + + } + + public function bla($sender, $param) + { + $sender->Text = 'a'; + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket422.php b/tests/FunctionalTests/tickets/protected/pages/Ticket422.php index 9a46ff75..85647ae2 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket422.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket422.php @@ -1,108 +1,108 @@ <?php -
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket422 extends TPage
-{
- private $_listItemsA;
- private $_listItemsB;
-
- public function onInit($param)
- {
- parent::onInit($param);
- $this->_listItemsA[] = array("title" => "Please select", "id" => -1,"category" => -1);
- $this->_listItemsA[] = array("title" => "Item A", "id" => 1,"category" => 1);
- $this->_listItemsA[] = array("title" => "Item B", "id" => 2,"category" => 1);
- $this->_listItemsA[] = array("title" => "Item C", "id" => 3,"category" => 1);
- $this->_listItemsA[] = array("title" => "Item D", "id" => 4,"category" => 1);
- $this->_listItemsA[] = array("title" => "Item E", "id" => 5,"category" => 1);
-
- $this->_listItemsB[] = array("title" => "List 2 Item A", "id" => 1,"category" => 1);
- $this->_listItemsB[] = array("title" => "List 2 Item B", "id" => 2,"category" => 1);
- $this->_listItemsB[] = array("title" => "List 2 Item C", "id" => 3,"category" => 1);
- $this->_listItemsB[] = array("title" => "List 2 Item D", "id" => 4,"category" => 2);
- $this->_listItemsB[] = array("title" => "List 2 Item E", "id" => 5,"category" => 2);
- $this->_listItemsB[] = array("title" => "List 2 Item F", "id" => 6,"category" => 2);
- $this->_listItemsB[] = array("title" => "List 2 Item G", "id" => 7,"category" => 3);
- $this->_listItemsB[] = array("title" => "List 2 Item H", "id" => 8,"category" => 3);
- $this->_listItemsB[] = array("title" => "List 2 Item I", "id" => 9,"category" => 3);
- $this->_listItemsB[] = array("title" => "List 2 Item J", "id" => 10,"category" => 4);
- $this->_listItemsB[] = array("title" => "List 2 Item K", "id" => 11,"category" => 4);
- $this->_listItemsB[] = array("title" => "List 2 Item L", "id" => 12,"category" => 4);
-
- $this->list1->DataValueField ='id';
- $this->list1->DataTextField = 'title';
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if(!$this->IsPostBack)
- {
- $this->list1->DataSource = $this->_listItemsA;
- $this->list1->dataBind();
- }
- }
-
- function list1_changed($sender)
- {
- if ($sender->getSelectedValue() == -1)
- {
- $this->label1->setText("Please select a category");
- $this->list2->setEnabled(false);
- return;
- }
-
- $this->addOptionsToListProblem($sender->getSelectedValue());
- }
-
- function addOptionsToListProblem($parent)
- {
- $foo = array();
- $bar = 0;
- $sel = array("title" => "Please select", "id" => -1,"category" => -1);
- $foo[] = $sel;
- foreach ($this->_listItemsB as $p)
- {
- if ($p["category"] == $parent)
- {
- $foo[] = $p;
- }
- }
-
- $this->list2->DataValueField = 'id';
- $this->list2->DataTextField = 'title';
- $this->list2->DataSource = $foo;
- $this->list2->dataBind();
- $this->list2->setEnabled(true);
- }
-
- function list2_changed($sender)
- {
- $this->label1->setText("Selection 2: ".$sender->getSelectedValue());
- }
-
- function select_index_3()
- {
- $this->list1->setSelectedIndex(3);
- }
-
- function clear_selections()
- {
- $this->list1->clearSelection();
- }
-
- function select_value_2()
- {
- $this->list1->setSelectedValue("value 2");
- }
-
- function select_index_3_plus()
- {
- $this->list1->setSelectedValue("value 3");
- $this->list1_changed($this->list1);
- $this->list2->setSelectedValue("value 3 - item 3");
- }
-}
+ +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket422 extends TPage +{ + private $_listItemsA; + private $_listItemsB; + + public function onInit($param) + { + parent::onInit($param); + $this->_listItemsA[] = array("title" => "Please select", "id" => -1,"category" => -1); + $this->_listItemsA[] = array("title" => "Item A", "id" => 1,"category" => 1); + $this->_listItemsA[] = array("title" => "Item B", "id" => 2,"category" => 1); + $this->_listItemsA[] = array("title" => "Item C", "id" => 3,"category" => 1); + $this->_listItemsA[] = array("title" => "Item D", "id" => 4,"category" => 1); + $this->_listItemsA[] = array("title" => "Item E", "id" => 5,"category" => 1); + + $this->_listItemsB[] = array("title" => "List 2 Item A", "id" => 1,"category" => 1); + $this->_listItemsB[] = array("title" => "List 2 Item B", "id" => 2,"category" => 1); + $this->_listItemsB[] = array("title" => "List 2 Item C", "id" => 3,"category" => 1); + $this->_listItemsB[] = array("title" => "List 2 Item D", "id" => 4,"category" => 2); + $this->_listItemsB[] = array("title" => "List 2 Item E", "id" => 5,"category" => 2); + $this->_listItemsB[] = array("title" => "List 2 Item F", "id" => 6,"category" => 2); + $this->_listItemsB[] = array("title" => "List 2 Item G", "id" => 7,"category" => 3); + $this->_listItemsB[] = array("title" => "List 2 Item H", "id" => 8,"category" => 3); + $this->_listItemsB[] = array("title" => "List 2 Item I", "id" => 9,"category" => 3); + $this->_listItemsB[] = array("title" => "List 2 Item J", "id" => 10,"category" => 4); + $this->_listItemsB[] = array("title" => "List 2 Item K", "id" => 11,"category" => 4); + $this->_listItemsB[] = array("title" => "List 2 Item L", "id" => 12,"category" => 4); + + $this->list1->DataValueField ='id'; + $this->list1->DataTextField = 'title'; + } + + public function onLoad($param) + { + parent::onLoad($param); + if(!$this->IsPostBack) + { + $this->list1->DataSource = $this->_listItemsA; + $this->list1->dataBind(); + } + } + + function list1_changed($sender) + { + if ($sender->getSelectedValue() == -1) + { + $this->label1->setText("Please select a category"); + $this->list2->setEnabled(false); + return; + } + + $this->addOptionsToListProblem($sender->getSelectedValue()); + } + + function addOptionsToListProblem($parent) + { + $foo = array(); + $bar = 0; + $sel = array("title" => "Please select", "id" => -1,"category" => -1); + $foo[] = $sel; + foreach ($this->_listItemsB as $p) + { + if ($p["category"] == $parent) + { + $foo[] = $p; + } + } + + $this->list2->DataValueField = 'id'; + $this->list2->DataTextField = 'title'; + $this->list2->DataSource = $foo; + $this->list2->dataBind(); + $this->list2->setEnabled(true); + } + + function list2_changed($sender) + { + $this->label1->setText("Selection 2: ".$sender->getSelectedValue()); + } + + function select_index_3() + { + $this->list1->setSelectedIndex(3); + } + + function clear_selections() + { + $this->list1->clearSelection(); + } + + function select_value_2() + { + $this->list1->setSelectedValue("value 2"); + } + + function select_index_3_plus() + { + $this->list1->setSelectedValue("value 3"); + $this->list1_changed($this->list1); + $this->list2->setSelectedValue("value 3 - item 3"); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket433.php b/tests/FunctionalTests/tickets/protected/pages/Ticket433.php index 2e5c1ff7..a87f8f82 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket433.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket433.php @@ -1,24 +1,24 @@ <?php -
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket433 extends TPage
-{
- public function onLoad($param)
- {
- if(!$this->IsPostBack)
- $this->VoteClick->Text = "BEFORE click";
- }
-
- public function onUpdateVoteClick($sender, $param)
- {
- $sender->Text = 'AFTER click';
- }
-
- public function onUpdateVoteCallback($sender, $param)
- {
- $sender->Text .= ' CALLBACK DONE';
- }
-}
+ +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket433 extends TPage +{ + public function onLoad($param) + { + if(!$this->IsPostBack) + $this->VoteClick->Text = "BEFORE click"; + } + + public function onUpdateVoteClick($sender, $param) + { + $sender->Text = 'AFTER click'; + } + + public function onUpdateVoteCallback($sender, $param) + { + $sender->Text .= ' CALLBACK DONE'; + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket439.php b/tests/FunctionalTests/tickets/protected/pages/Ticket439.php index eaebc250..dcb46412 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket439.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket439.php @@ -1,15 +1,15 @@ <?php -
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket439 extends TPage
-{
-
- function button_clicked($sender, $param)
- {
- $page = $this->Service->constructUrl('Home');
- $this->Response->redirect($page);
- }
-}
+ +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket439 extends TPage +{ + + function button_clicked($sender, $param) + { + $page = $this->Service->constructUrl('Home'); + $this->Response->redirect($page); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket470.php b/tests/FunctionalTests/tickets/protected/pages/Ticket470.php index 45741176..2e023242 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket470.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket470.php @@ -1,24 +1,24 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket470 extends TPage
-{
- /**
- * Increase the reload counter and render the activepanel content
- */
- public function Reload($sender, $param){
- $this->Results->Text = "";
- $this->counter->Text = $this->counter->Text +1;
- $this->activePanelTest->renderControl($param->getNewWriter());
- }
-
- /**
- *function to call when the form is valid (and the linkbutton fired his callback event)
- */
- public function Valid($sender, $param){
- $this->Results->Text = "OK!!!";
- }
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket470 extends TPage +{ + /** + * Increase the reload counter and render the activepanel content + */ + public function Reload($sender, $param){ + $this->Results->Text = ""; + $this->counter->Text = $this->counter->Text +1; + $this->activePanelTest->renderControl($param->getNewWriter()); + } + + /** + *function to call when the form is valid (and the linkbutton fired his callback event) + */ + public function Valid($sender, $param){ + $this->Results->Text = "OK!!!"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket477.php b/tests/FunctionalTests/tickets/protected/pages/Ticket477.php index 49c72b9e..a6309958 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket477.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket477.php @@ -1,16 +1,16 @@ <?php -
-class Ticket477 extends TPage
-{
- function do_validate_1($sender, $param)
- {
- $param->IsValid=false;
- }
-
- function do_validate_2($sender, $param)
- {
- $param->IsValid=false;
- }
-}
+ +class Ticket477 extends TPage +{ + function do_validate_1($sender, $param) + { + $param->IsValid=false; + } + + function do_validate_2($sender, $param) + { + $param->IsValid=false; + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket484.php b/tests/FunctionalTests/tickets/protected/pages/Ticket484.php index 813ccc23..89dac261 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket484.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket484.php @@ -1,30 +1,30 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket484 extends TPage
-{
-
- function onLoad($param)
- {
- new TActiveButton;
- for ($i = 0; $i<1500; $i++)
- {
- $ctl = Prado::createComponent("TLabel");
- $ctl->Text = "Label ".$i;
- $this->Controls[] = $ctl;
- }
- }
-
- function button2_onclick($sender, $param)
- {
- $this->label1->Text = "Button 1 was clicked ";
- }
-
- function button2_oncallback($sender, $param)
- {
- $this->label1->Text .= "using callback!";
- }
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket484 extends TPage +{ + + function onLoad($param) + { + new TActiveButton; + for ($i = 0; $i<1500; $i++) + { + $ctl = Prado::createComponent("TLabel"); + $ctl->Text = "Label ".$i; + $this->Controls[] = $ctl; + } + } + + function button2_onclick($sender, $param) + { + $this->label1->Text = "Button 1 was clicked "; + } + + function button2_oncallback($sender, $param) + { + $this->label1->Text .= "using callback!"; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket488.php b/tests/FunctionalTests/tickets/protected/pages/Ticket488.php index e9610d1d..97334f21 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket488.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket488.php @@ -1,13 +1,13 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket488 extends TPage
-{
- function login($sender,$param)
- {
- //$param->IsValid = $this->Password == 'Prado';
- }
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket488 extends TPage +{ + function login($sender,$param) + { + //$param->IsValid = $this->Password == 'Prado'; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket500.php b/tests/FunctionalTests/tickets/protected/pages/Ticket500.php index fc7af222..a0b96ed5 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket500.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket500.php @@ -1,13 +1,13 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket500 extends TPage
-{
- function set_url()
- {
- $url=$this->Service->constructUrl('Cats.Buy.Browse',array('filter' => 'basket'));
- $this->link1->NavigateUrl = $url;
- }
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket500 extends TPage +{ + function set_url() + { + $url=$this->Service->constructUrl('Cats.Buy.Browse',array('filter' => 'basket')); + $this->link1->NavigateUrl = $url; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket504.php b/tests/FunctionalTests/tickets/protected/pages/Ticket504.php index 7ad8e989..3d1bdfb6 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket504.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket504.php @@ -1,25 +1,25 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket504 extends TPage
-{
- private $panels = array('panelA', 'panelB', 'panelC','panelD',);
- private function showPanel($id, $param) {
- foreach($this->panels as $panel) {
- if($id == $panel) {
- $this->$panel->setVisible(true);
- } else {
- $this->$panel->setVisible(false);
- }
- }
- }
- public function changePanel($sender,$param){
- $this->showPanel($param->CallbackParameter, $param);
- }
- public function loadData_Callback($sender, $param){
- die("parameter is ".$param->CallbackParameter);
- }
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket504 extends TPage +{ + private $panels = array('panelA', 'panelB', 'panelC','panelD',); + private function showPanel($id, $param) { + foreach($this->panels as $panel) { + if($id == $panel) { + $this->$panel->setVisible(true); + } else { + $this->$panel->setVisible(false); + } + } + } + public function changePanel($sender,$param){ + $this->showPanel($param->CallbackParameter, $param); + } + public function loadData_Callback($sender, $param){ + die("parameter is ".$param->CallbackParameter); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket507.php b/tests/FunctionalTests/tickets/protected/pages/Ticket507.php index 94cd8aed..ea358e65 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket507.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket507.php @@ -1,25 +1,25 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket507 extends TPage
-{
-
- public function onLoad($s)
- {
- //the following fixed the static declaration on the above
- $this->list1->SelectionMode="Multiple";
- }
-
- function list1_callback($sender, $param)
- {
- $values = $sender->getSelectedValues();
- $this->label1->setText("Selection: ".implode(', ', $values));
- }
-
- function enable_list()
- {
- $this->list1->enabled = true;
- }
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket507 extends TPage +{ + + public function onLoad($s) + { + //the following fixed the static declaration on the above + $this->list1->SelectionMode="Multiple"; + } + + function list1_callback($sender, $param) + { + $values = $sender->getSelectedValues(); + $this->label1->setText("Selection: ".implode(', ', $values)); + } + + function enable_list() + { + $this->list1->enabled = true; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket521.php b/tests/FunctionalTests/tickets/protected/pages/Ticket521.php index d28a777a..e7e65b86 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket521.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket521.php @@ -1,16 +1,16 @@ -<?php
-
-class Ticket521 extends TPage
-{
-
- public function doOnClick($s, $p){
- $this->label1->Text = "Button 1 was clicked ";
- }
- public function doSave($s, $p){
- $this->label1->Text .= " on callback ";
-
- }
-
-
-}
+<?php + +class Ticket521 extends TPage +{ + + public function doOnClick($s, $p){ + $this->label1->Text = "Button 1 was clicked "; + } + public function doSave($s, $p){ + $this->label1->Text .= " on callback "; + + } + + +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket526.php b/tests/FunctionalTests/tickets/protected/pages/Ticket526.php index 9afaf28f..1500ad73 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket526.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket526.php @@ -1,15 +1,15 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket526 extends TPage
-{
- public function callback($s, $p)
- {
- $this->dp->Mode="Button";
- $this->textbox->Text = 'callback';
- $this->activePanel->Enabled="false";
- $this->activePanel->render($p->NewWriter);
- }
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket526 extends TPage +{ + public function callback($s, $p) + { + $this->dp->Mode="Button"; + $this->textbox->Text = 'callback'; + $this->activePanel->Enabled="false"; + $this->activePanel->render($p->NewWriter); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket528.php b/tests/FunctionalTests/tickets/protected/pages/Ticket528.php index c2d1fcbe..2e05dbfd 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket528.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket528.php @@ -1,35 +1,35 @@ -<?php
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket528 extends TPage
-{
- public static $turnos = array(
- 'M' => array('id_turno' => 'M', 'descricao' => 'Manhã'),
- 'T' => array('id_turno' => 'T', 'descricao' => 'Tarde'),
- 'N' => array('id_turno' => 'N', 'descricao' => 'Noite')
- );
-
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- if (!$this->IsPostBack) {
- $this->DDropTurno->loadOptions();
- $this->loadDadosTurno($this->DDropTurno->getSelectedValue());
- }
- }
-
-
- protected function loadDadosTurno($id)
- {
- $this->Codigo->setText(self::$turnos[$id]['id_turno']);
- $this->Descricao->setText(self::$turnos[$id]['descricao']);
- }
-
-
- public function trocaTurno($sender,$param)
- {
- $this->loadDadosTurno($sender->getSelectedValue());
- }
-}
-
+<?php +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket528 extends TPage +{ + public static $turnos = array( + 'M' => array('id_turno' => 'M', 'descricao' => 'Manhã'), + 'T' => array('id_turno' => 'T', 'descricao' => 'Tarde'), + 'N' => array('id_turno' => 'N', 'descricao' => 'Noite') + ); + + + public function onLoad($param) + { + parent::onLoad($param); + if (!$this->IsPostBack) { + $this->DDropTurno->loadOptions(); + $this->loadDadosTurno($this->DDropTurno->getSelectedValue()); + } + } + + + protected function loadDadosTurno($id) + { + $this->Codigo->setText(self::$turnos[$id]['id_turno']); + $this->Descricao->setText(self::$turnos[$id]['descricao']); + } + + + public function trocaTurno($sender,$param) + { + $this->loadDadosTurno($sender->getSelectedValue()); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket535.php b/tests/FunctionalTests/tickets/protected/pages/Ticket535.php index 4f9b2f51..705a5474 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket535.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket535.php @@ -1,16 +1,16 @@ -<?php
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket535 extends TPage
-{
- public function noGroup($sender, $param)
- {
- $this->label1->Text = "radio1 checked:{".$this->radio1->getChecked()."} radio2 checked:{".$this->radio2->getChecked()."} ";
- }
-
- public function group($sender, $param)
- {
- $this->label1->Text = "bad_radio1 checked:{".$this->bad_radio1->getChecked()."} bad_radio2 checked:{".$this->bad_radio2->getChecked()."} ";
- }
-}
-
+<?php +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket535 extends TPage +{ + public function noGroup($sender, $param) + { + $this->label1->Text = "radio1 checked:{".$this->radio1->getChecked()."} radio2 checked:{".$this->radio2->getChecked()."} "; + } + + public function group($sender, $param) + { + $this->label1->Text = "bad_radio1 checked:{".$this->bad_radio1->getChecked()."} bad_radio2 checked:{".$this->bad_radio2->getChecked()."} "; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket538.php b/tests/FunctionalTests/tickets/protected/pages/Ticket538.php index 2ad9fd43..2ba0d841 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket538.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket538.php @@ -1,102 +1,102 @@ -<?php
-// $Id: Home.php 1405 2006-09-10 01:03:56Z wei $
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket538 extends TPage
-{
- public function checkboxClicked($sender,$param)
- {
- $sender->Text= $sender->ClientID . " clicked";
- }
-
- public function checkboxCallback($sender, $param)
- {
- $sender->Text .= ' using callback';
- }
-
- public function readData()
- {
- $data=array(
- array('id'=>'001','name'=>'John','age'=>31),
- array('id'=>'002','name'=>'Mary','age'=>30),
- array('id'=>'003','name'=>'Cary','age'=>20),
- array('id'=>'004','name'=>'Kevin','age'=>65),
- array('id'=>'005','name'=>'Steven','age'=>10),
- array('id'=>'006','name'=>'Josh','age'=>23),
- array('id'=>'007','name'=>'Lary','age'=>54));
- return $data;
- }
-
- //--------------------------------------------------------------------
- // TListBox
- //--------------------------------------------------------------------
-
- public function dataSelector2_Clicked($sender, $param)
- {
- $this->DataViewer2->DataTextField='name';
- $this->DataViewer2->Items->clear();
- foreach ($this->readData() as $index=>$person)
- {
- $item = new TListItem('G1: '.$person['name'].'=>'.$person['age'],$index);
- $item->Attributes->Group = 'test1';
- $this->DataViewer2->Items->add($item);
- }
- foreach ($this->readData() as $index=>$person)
- {
- $item2 = new TListItem('G2: '.$person['name'].'=>'.$person['age'],$index+100);
- $item2->Attributes->Group = 'test2';
- $this->DataViewer2->Items->add($item2);
- }
- $this->DataViewer2->dataBind();
- }
-
- public function selectBtn2_Clicked()
- {
- $text = '';
- foreach ($this->DataViewer2->SelectedIndices as $index)
- {
- $text .= '"'.$this->DataViewer2->Items[$index]->Attributes->Group.'", ';
- }
- $this->ALLog->setText($text);
- }
-
- //--------------------------------------------------------------------
- // TActiveListBox
- //--------------------------------------------------------------------
-
-
- public function dataSelector_Clicked($sender, $param)
- {
- $this->DataViewer->DataTextField='name';
- $this->DataViewer->Items->clear();
- foreach ($this->readData() as $index=>$person)
- {
- $item = new TListItem('G1: '.$person['name'].'=>'.$person['age'],$index);
- $item->Attributes->Group = 'test1';
- $this->DataViewer->Items->add($item);
- }
-
- foreach ($this->readData() as $index=>$person)
- {
- $item2 = new TListItem('G2: '.$person['name'].'=>'.$person['age'],$index+100);
- $item2->Attributes->Group = 'test2';
- $this->DataViewer->Items->add($item2);
- }
- $this->DataViewer->dataBind();
- }
-
- public function selectBtn_Clicked()
- {
- $text = '';
- foreach ($this->DataViewer->SelectedIndices as $index)
- {
- if($this->DataViewer->Items[$index]->Attributes['Group'])
- $text .= $index .'- "'.$this->DataViewer->Items[$index]->Attributes->Group.'", ';
- else
- $text .= $index.',';
- }
- $this->ALLog->setText($text);
- }
-
-}
-
+<?php +// $Id: Home.php 1405 2006-09-10 01:03:56Z wei $ +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket538 extends TPage +{ + public function checkboxClicked($sender,$param) + { + $sender->Text= $sender->ClientID . " clicked"; + } + + public function checkboxCallback($sender, $param) + { + $sender->Text .= ' using callback'; + } + + public function readData() + { + $data=array( + array('id'=>'001','name'=>'John','age'=>31), + array('id'=>'002','name'=>'Mary','age'=>30), + array('id'=>'003','name'=>'Cary','age'=>20), + array('id'=>'004','name'=>'Kevin','age'=>65), + array('id'=>'005','name'=>'Steven','age'=>10), + array('id'=>'006','name'=>'Josh','age'=>23), + array('id'=>'007','name'=>'Lary','age'=>54)); + return $data; + } + + //-------------------------------------------------------------------- + // TListBox + //-------------------------------------------------------------------- + + public function dataSelector2_Clicked($sender, $param) + { + $this->DataViewer2->DataTextField='name'; + $this->DataViewer2->Items->clear(); + foreach ($this->readData() as $index=>$person) + { + $item = new TListItem('G1: '.$person['name'].'=>'.$person['age'],$index); + $item->Attributes->Group = 'test1'; + $this->DataViewer2->Items->add($item); + } + foreach ($this->readData() as $index=>$person) + { + $item2 = new TListItem('G2: '.$person['name'].'=>'.$person['age'],$index+100); + $item2->Attributes->Group = 'test2'; + $this->DataViewer2->Items->add($item2); + } + $this->DataViewer2->dataBind(); + } + + public function selectBtn2_Clicked() + { + $text = ''; + foreach ($this->DataViewer2->SelectedIndices as $index) + { + $text .= '"'.$this->DataViewer2->Items[$index]->Attributes->Group.'", '; + } + $this->ALLog->setText($text); + } + + //-------------------------------------------------------------------- + // TActiveListBox + //-------------------------------------------------------------------- + + + public function dataSelector_Clicked($sender, $param) + { + $this->DataViewer->DataTextField='name'; + $this->DataViewer->Items->clear(); + foreach ($this->readData() as $index=>$person) + { + $item = new TListItem('G1: '.$person['name'].'=>'.$person['age'],$index); + $item->Attributes->Group = 'test1'; + $this->DataViewer->Items->add($item); + } + + foreach ($this->readData() as $index=>$person) + { + $item2 = new TListItem('G2: '.$person['name'].'=>'.$person['age'],$index+100); + $item2->Attributes->Group = 'test2'; + $this->DataViewer->Items->add($item2); + } + $this->DataViewer->dataBind(); + } + + public function selectBtn_Clicked() + { + $text = ''; + foreach ($this->DataViewer->SelectedIndices as $index) + { + if($this->DataViewer->Items[$index]->Attributes['Group']) + $text .= $index .'- "'.$this->DataViewer->Items[$index]->Attributes->Group.'", '; + else + $text .= $index.','; + } + $this->ALLog->setText($text); + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket542.php b/tests/FunctionalTests/tickets/protected/pages/Ticket542.php index bcd32a04..59169d64 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket542.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket542.php @@ -1,23 +1,23 @@ -<?php
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket542 extends TPage {
-
- public function slideUp($sender, $param) {
- $this->CallbackClient->slideUp($this->TheBox);
- }
-
- public function blindUp($sender, $param) {
- $this->CallbackClient->blindUp($this->TheBox);
- }
-
- public function slideDown($sender, $param) {
- $this->CallbackClient->slideDown($this->TheBox);
- }
-
- public function blindDown($sender, $param) {
- $this->CallbackClient->blindDown($this->TheBox);
- }
-
-}
-
+<?php +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket542 extends TPage { + + public function slideUp($sender, $param) { + $this->CallbackClient->slideUp($this->TheBox); + } + + public function blindUp($sender, $param) { + $this->CallbackClient->blindUp($this->TheBox); + } + + public function slideDown($sender, $param) { + $this->CallbackClient->slideDown($this->TheBox); + } + + public function blindDown($sender, $param) { + $this->CallbackClient->blindDown($this->TheBox); + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket54Master.php b/tests/FunctionalTests/tickets/protected/pages/Ticket54Master.php index 817e7c45..917f45cf 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket54Master.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket54Master.php @@ -1,7 +1,7 @@ -<?php
-
-class Ticket54Master extends TTemplateControl
-{
-}
-
+<?php + +class Ticket54Master extends TTemplateControl +{ +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket578.php b/tests/FunctionalTests/tickets/protected/pages/Ticket578.php index 7d7dbaac..7b7463a2 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket578.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket578.php @@ -1,13 +1,13 @@ -<?php
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket578 extends TPage
-{
-
- function button2_onclick($sender, $param)
- {
- $this->label1->Text = "Button 1 was clicked : " . htmlspecialchars($this->text1->Text);
- }
-
-}
-
+<?php +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket578 extends TPage +{ + + function button2_onclick($sender, $param) + { + $this->label1->Text = "Button 1 was clicked : " . htmlspecialchars($this->text1->Text); + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket585.php b/tests/FunctionalTests/tickets/protected/pages/Ticket585.php index 5932146d..1cda7900 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket585.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket585.php @@ -1,18 +1,18 @@ -<?php
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket585 extends TPage
-{
-
- public function ChkDate ($sender, $param)
- {
- if ($param->Value == "15-03-2007")
- {
- $param->IsValid=false;
- }
- else
- $param->IsValid=true;
- }
-
-}
-
+<?php +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket585 extends TPage +{ + + public function ChkDate ($sender, $param) + { + if ($param->Value == "15-03-2007") + { + $param->IsValid=false; + } + else + $param->IsValid=true; + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket586.php b/tests/FunctionalTests/tickets/protected/pages/Ticket586.php index d6fafd0d..574d6f72 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket586.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket586.php @@ -1,11 +1,11 @@ -<?php
-
-class Ticket586 extends TPage
-{
- function button_clicked($sender, $param)
- {
- $this->label1->Text = $sender->Text . ' Clicked!';
- }
-}
-
+<?php + +class Ticket586 extends TPage +{ + function button_clicked($sender, $param) + { + $this->label1->Text = $sender->Text . ' Clicked!'; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket587.php b/tests/FunctionalTests/tickets/protected/pages/Ticket587.php index a84a876c..21ce7a64 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket587.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket587.php @@ -1,12 +1,12 @@ -<?php
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket587 extends TPage
-{
- public function onTriggerCallback( $sender, $param )
- {
- $count = (int) $this->count->getText();
- $this->count->setText( ++$count );
- }
-}
-
+<?php +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket587 extends TPage +{ + public function onTriggerCallback( $sender, $param ) + { + $count = (int) $this->count->getText(); + $this->count->setText( ++$count ); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket587_reopened.php b/tests/FunctionalTests/tickets/protected/pages/Ticket587_reopened.php index 7d24e5f6..fea88274 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket587_reopened.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket587_reopened.php @@ -1,62 +1,62 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket587_reopened extends TPage
-{
- function list1_changed($sender)
- {
- $this->label1->setText("Selection 1: ".$sender->getSelectedValue());
- $this->addOptionsToList2($sender->getSelectedValue(),$sender->getSelectedIndex());
- }
-
- function suggest($sender, $param)
- {
- $this->list2->Items->clear();
- for($i = 0; $i < 2; $i++)
- $this->list2->Items[$i] = 'asd 3 - item '.($i+1);
- }
-
- function addOptionsToList2($parent,$index)
- {
- $this->list2->Items->clear();
- for($i = 0; $i < 2+$index; $i++)
- $this->list2->Items[$i] = $parent.' - item '.($i+1);
- $this->list2->setEnabled(true);
- }
-
- function list2_changed($sender)
- {
- $this->label1->setText("Selection 2: ".$sender->getSelectedValue());
- }
-
- function select_index_3()
- {
- $this->list1->setSelectedIndex(3);
- }
-
- function clear_selections()
- {
- $this->list1->clearSelection();
- }
-
- function select_value_2()
- {
- $this->list1->setSelectedValue("value 2");
- }
-
- function select_index_3_plus()
- {
- $this->list1->setSelectedValue("value 3");
- $this->list1_changed($this->list1);
- $this->list2->setSelectedValue("value 3 - item 3");
- }
-
- function do_postback()
- {
- $value = 'List 1: '.$this->list1->selectedValue. ', List 2: '. $this->list2->selectedValue;
- $this->label1->Text = $value;
- }
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket587_reopened extends TPage +{ + function list1_changed($sender) + { + $this->label1->setText("Selection 1: ".$sender->getSelectedValue()); + $this->addOptionsToList2($sender->getSelectedValue(),$sender->getSelectedIndex()); + } + + function suggest($sender, $param) + { + $this->list2->Items->clear(); + for($i = 0; $i < 2; $i++) + $this->list2->Items[$i] = 'asd 3 - item '.($i+1); + } + + function addOptionsToList2($parent,$index) + { + $this->list2->Items->clear(); + for($i = 0; $i < 2+$index; $i++) + $this->list2->Items[$i] = $parent.' - item '.($i+1); + $this->list2->setEnabled(true); + } + + function list2_changed($sender) + { + $this->label1->setText("Selection 2: ".$sender->getSelectedValue()); + } + + function select_index_3() + { + $this->list1->setSelectedIndex(3); + } + + function clear_selections() + { + $this->list1->clearSelection(); + } + + function select_value_2() + { + $this->list1->setSelectedValue("value 2"); + } + + function select_index_3_plus() + { + $this->list1->setSelectedValue("value 3"); + $this->list1_changed($this->list1); + $this->list2->setSelectedValue("value 3 - item 3"); + } + + function do_postback() + { + $value = 'List 1: '.$this->list1->selectedValue. ', List 2: '. $this->list2->selectedValue; + $this->label1->Text = $value; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket591.php b/tests/FunctionalTests/tickets/protected/pages/Ticket591.php index 9e49e835..8616ac02 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket591.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket591.php @@ -1,9 +1,9 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket591 extends TPage
-{
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket591 extends TPage +{ +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket598.php b/tests/FunctionalTests/tickets/protected/pages/Ticket598.php index 0456725f..a8c4c397 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket598.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket598.php @@ -1,19 +1,19 @@ -<?php
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket598 extends TPage
-{
-public function onLoad ($param) {
- parent::onLoad($param);
- if (!$this->isPostBack and !$this->isCallBack) {
- $this->Lbl->setText(date("h:m:s"));
- }
- }
- public function startBigTask ($sender, $param) {
- sleep(10); // Simulate task
- }
-
- public function updateLbl($sender, $param) {
- $this->Lbl->SetText(date("h:m:s"));
- }
-}
+<?php +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket598 extends TPage +{ +public function onLoad ($param) { + parent::onLoad($param); + if (!$this->isPostBack and !$this->isCallBack) { + $this->Lbl->setText(date("h:m:s")); + } + } + public function startBigTask ($sender, $param) { + sleep(10); // Simulate task + } + + public function updateLbl($sender, $param) { + $this->Lbl->SetText(date("h:m:s")); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket603.php b/tests/FunctionalTests/tickets/protected/pages/Ticket603.php index 6af0cf6d..138ffbd4 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket603.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket603.php @@ -1,30 +1,30 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-
-class Ticket603 extends TPage
-{
- protected $_isHtml;
-
- public function onLoad($param) {
- parent::onLoad($param);
- $this->_isHtml = true;
- }
-
- public function switchContentTypeClicked( $sender, $param ) {
- $this->_isHtml = !$this->_isHtml;
- if ( $this->_isHtml ) {
- $this->EditHtmlTextBox->EnableVisualEdit = true;
- $this->EditHtmlTextBox->Text = '<b>somehtml</b>';
- } else {
- $this->EditHtmlTextBox->EnableVisualEdit = false;
- $this->EditHtmlTextBox->Text = 'plai bla bla';
- }
- }
-
- public function switchContentTypeCallback( $sender, $param ) {
- $this->ContentPanel->render( $param->NewWriter );
- }
-}
-
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); + +class Ticket603 extends TPage +{ + protected $_isHtml; + + public function onLoad($param) { + parent::onLoad($param); + $this->_isHtml = true; + } + + public function switchContentTypeClicked( $sender, $param ) { + $this->_isHtml = !$this->_isHtml; + if ( $this->_isHtml ) { + $this->EditHtmlTextBox->EnableVisualEdit = true; + $this->EditHtmlTextBox->Text = '<b>somehtml</b>'; + } else { + $this->EditHtmlTextBox->EnableVisualEdit = false; + $this->EditHtmlTextBox->Text = 'plai bla bla'; + } + } + + public function switchContentTypeCallback( $sender, $param ) { + $this->ContentPanel->render( $param->NewWriter ); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket660.php b/tests/FunctionalTests/tickets/protected/pages/Ticket660.php index 2785a816..457e3ed8 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket660.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket660.php @@ -12,15 +12,15 @@ class Ticket660 extends TPage { $this->A->setText($this->T->getText() . $iso_text); } - public function suggest($sender, $param)
- {
+ public function suggest($sender, $param) + { $token=$param->getCallbackParameter(); $sender->setDataSource(array( 1 => 'ABC Token:'.$token, 2 => iconv('UTF-8', 'ISO-8859-1//IGNORE', 'ÄÖÜ').' Token:'.$token )); - $sender->dataBind();
- }
-
+ $sender->dataBind(); + } + } ?> diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket703/Ticket703.php b/tests/FunctionalTests/tickets/protected/pages/Ticket703/Ticket703.php index 1b5b638a..eb446077 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket703/Ticket703.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket703/Ticket703.php @@ -1,31 +1,31 @@ -<?php
-
-class Ticket703 extends TPage {
- public function onLoad ($param)
- {
- parent::onLoad($param);
- if (!$this->isPostBack && !$this->isCallback)
- {
- $this->refreshLog();
- }
- }
-
- public function refreshLog ()
- {
- $this->logBox->Text=file_get_contents(prado::getPathOfNameSpace('Ticket703.Logs.LogFile', '.txt'));
- }
-
- public function clearLog ($sender, $param)
- {
- $file=prado::getPathOfNameSpace('Ticket703.Logs.LogFile', '.txt');
- $f=fopen($file,"w");
- fclose($f);
- $this->refreshLog();
- }
-
- public function addLog($sender,$param)
- {
- prado::log($this->logMessage->getText(), TLogger::DEBUG, "Tickets");
- }
-}
+<?php + +class Ticket703 extends TPage { + public function onLoad ($param) + { + parent::onLoad($param); + if (!$this->isPostBack && !$this->isCallback) + { + $this->refreshLog(); + } + } + + public function refreshLog () + { + $this->logBox->Text=file_get_contents(prado::getPathOfNameSpace('Ticket703.Logs.LogFile', '.txt')); + } + + public function clearLog ($sender, $param) + { + $file=prado::getPathOfNameSpace('Ticket703.Logs.LogFile', '.txt'); + $f=fopen($file,"w"); + fclose($f); + $this->refreshLog(); + } + + public function addLog($sender,$param) + { + prado::log($this->logMessage->getText(), TLogger::DEBUG, "Tickets"); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket708.php b/tests/FunctionalTests/tickets/protected/pages/Ticket708.php index b57aa444..2eca39d9 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket708.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket708.php @@ -1,30 +1,30 @@ -<?php
-
-Prado::using('System.Web.UI.ActiveControls.*');
-class Ticket708 extends TPage
-{
- public function onLoad ($param)
- {
- if (!$this->getIsCallback() && !$this->getIsPostBack())
- {
- $this->grid->dataSource=$this->getData();
- $this->grid->dataBind();
- }
- }
-
- protected function getData()
- {
- return array (
- array ('RadioValue' => 1, 'Text' => 'Radio 1'),
- array ('RadioValue' => 2, 'Text' => 'Radio 2'),
- array ('RadioValue' => 3, 'Text' => 'Radio 3'),
- array ('RadioValue' => 4, 'Text' => 'Radio 4'),
- );
- }
-
- public function ChangeRadio ($sender, $param)
- {
- $this->Result->setText("You have selected Radio Button #".$sender->getValue());
- }
-}
+<?php + +Prado::using('System.Web.UI.ActiveControls.*'); +class Ticket708 extends TPage +{ + public function onLoad ($param) + { + if (!$this->getIsCallback() && !$this->getIsPostBack()) + { + $this->grid->dataSource=$this->getData(); + $this->grid->dataBind(); + } + } + + protected function getData() + { + return array ( + array ('RadioValue' => 1, 'Text' => 'Radio 1'), + array ('RadioValue' => 2, 'Text' => 'Radio 2'), + array ('RadioValue' => 3, 'Text' => 'Radio 3'), + array ('RadioValue' => 4, 'Text' => 'Radio 4'), + ); + } + + public function ChangeRadio ($sender, $param) + { + $this->Result->setText("You have selected Radio Button #".$sender->getValue()); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket72.php b/tests/FunctionalTests/tickets/protected/pages/Ticket72.php index 02432886..14a8a112 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket72.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket72.php @@ -1,13 +1,13 @@ -<?php
-
-class Ticket72 extends TPage
-{
- public function ButtonClick($sender,$param)
- {
- $a1 = $this->K1->SafeText;
- $a2 = $this->K2->SafeText;
- $this->ResultLabel->Text = $a2;
- }
-}
-
+<?php + +class Ticket72 extends TPage +{ + public function ButtonClick($sender,$param) + { + $a1 = $this->K1->SafeText; + $a2 = $this->K2->SafeText; + $this->ResultLabel->Text = $a2; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket93.php b/tests/FunctionalTests/tickets/protected/pages/Ticket93.php index dbdf2cab..dbee4556 100644 --- a/tests/FunctionalTests/tickets/protected/pages/Ticket93.php +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket93.php @@ -1,14 +1,14 @@ -<?php
-/*
- * Created on 13/04/2006
- */
-
-class Ticket93 extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- echo 'postback triggered with value '.$param->PostBackValue;
- }
-}
-
-?>
+<?php +/* + * Created on 13/04/2006 + */ + +class Ticket93 extends TPage +{ + public function buttonClicked($sender,$param) + { + echo 'postback triggered with value '.$param->PostBackValue; + } +} + +?> diff --git a/tests/FunctionalTests/tickets/protected700/common/BasePage.php b/tests/FunctionalTests/tickets/protected700/common/BasePage.php index 1e40f754..bbb93650 100644 --- a/tests/FunctionalTests/tickets/protected700/common/BasePage.php +++ b/tests/FunctionalTests/tickets/protected700/common/BasePage.php @@ -1,68 +1,68 @@ -<?php
-
-class BasePage extends TPage
-{
- private $_param1='default 1';
- private $_param2='default 2';
- private $_param3='default 3';
- private $_param4='default 4';
- private $_param5='default 5';
-
- public function onInit($param)
- {
- parent::onInit($param);
- $this->Title=$this->PagePath;
- }
-
- public function getParam1()
- {
- return $this->_param1;
- }
-
- public function setParam1($value)
- {
- $this->_param1=$value;
- }
-
- public function getParam2()
- {
- return $this->_param2;
- }
-
- public function setParam2($value)
- {
- $this->_param2=$value;
- }
-
- public function getParam3()
- {
- return $this->_param3;
- }
-
- public function setParam3($value)
- {
- $this->_param3=$value;
- }
-
- public function getParam4()
- {
- return $this->_param4;
- }
-
- public function setParam4($value)
- {
- $this->_param4=$value;
- }
-
- public function getParam5()
- {
- return $this->_param5;
- }
-
- public function setParam5($value)
- {
- $this->_param5=$value;
- }
-}
-
+<?php + +class BasePage extends TPage +{ + private $_param1='default 1'; + private $_param2='default 2'; + private $_param3='default 3'; + private $_param4='default 4'; + private $_param5='default 5'; + + public function onInit($param) + { + parent::onInit($param); + $this->Title=$this->PagePath; + } + + public function getParam1() + { + return $this->_param1; + } + + public function setParam1($value) + { + $this->_param1=$value; + } + + public function getParam2() + { + return $this->_param2; + } + + public function setParam2($value) + { + $this->_param2=$value; + } + + public function getParam3() + { + return $this->_param3; + } + + public function setParam3($value) + { + $this->_param3=$value; + } + + public function getParam4() + { + return $this->_param4; + } + + public function setParam4($value) + { + $this->_param4=$value; + } + + public function getParam5() + { + return $this->_param5; + } + + public function setParam5($value) + { + $this->_param5=$value; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected700/layout/MainLayout.php b/tests/FunctionalTests/tickets/protected700/layout/MainLayout.php index 3e0a3d19..6f385ce8 100644 --- a/tests/FunctionalTests/tickets/protected700/layout/MainLayout.php +++ b/tests/FunctionalTests/tickets/protected700/layout/MainLayout.php @@ -1,12 +1,12 @@ -<?php
-
-class MainLayout extends TTemplateControl
-{
- public function logout($sender,$param)
- {
- $this->Application->getModule('auth')->logout();
- $this->Response->reload();
- }
-}
-
+<?php + +class MainLayout extends TTemplateControl +{ + public function logout($sender,$param) + { + $this->Application->getModule('auth')->logout(); + $this->Response->reload(); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected700/pages/UserLogin.php b/tests/FunctionalTests/tickets/protected700/pages/UserLogin.php index 37258879..8071fb29 100644 --- a/tests/FunctionalTests/tickets/protected700/pages/UserLogin.php +++ b/tests/FunctionalTests/tickets/protected700/pages/UserLogin.php @@ -1,13 +1,13 @@ -<?php
-
-class UserLogin extends BasePage
-{
- public function loginButtonClicked($sender,$param)
- {
- $authManager=$this->Application->getModule('auth');
- $authManager->login($this->Username->Text,$this->Password->Text);
- $this->Response->redirect($this->Service->constructUrl('Home'));
- }
-}
-
+<?php + +class UserLogin extends BasePage +{ + public function loginButtonClicked($sender,$param) + { + $authManager=$this->Application->getModule('auth'); + $authManager->login($this->Username->Text,$this->Password->Text); + $this->Response->redirect($this->Service->constructUrl('Home')); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Issue120TestCase.php b/tests/FunctionalTests/tickets/tests/Issue120TestCase.php index a2823c9d..07afd06c 100644 --- a/tests/FunctionalTests/tickets/tests/Issue120TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Issue120TestCase.php @@ -1,21 +1,21 @@ -<?php
-
-class Issue120TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Issue120');
- $this->assertTextPresent('TActiveDropDownList PromptValue Test');
-
- $this->assertSelectedIndex("ctl0_Content_ddl1", 0);
- $this->assertSelectedValue("ctl0_Content_ddl1", 'PromptValue');
-
- $this->click("ctl0_Content_btn1");
- $this->pause(800);
-
- $this->assertSelectedIndex("ctl0_Content_ddl1", 0);
- $this->assertSelectedValue("ctl0_Content_ddl1", 'PromptValue');
- }
-}
-
+<?php + +class Issue120TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Issue120'); + $this->assertTextPresent('TActiveDropDownList PromptValue Test'); + + $this->assertSelectedIndex("ctl0_Content_ddl1", 0); + $this->assertSelectedValue("ctl0_Content_ddl1", 'PromptValue'); + + $this->click("ctl0_Content_btn1"); + $this->pause(800); + + $this->assertSelectedIndex("ctl0_Content_ddl1", 0); + $this->assertSelectedValue("ctl0_Content_ddl1", 'PromptValue'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Issue216TestCase.php b/tests/FunctionalTests/tickets/tests/Issue216TestCase.php index 1cfdf0cd..0c351f33 100644 --- a/tests/FunctionalTests/tickets/tests/Issue216TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Issue216TestCase.php @@ -1,28 +1,28 @@ -<?php
-
-class Issue216TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Issue216');
- $this->assertTextPresent('TTabPanel doesn\'t preserve active tab on callback request');
-
- $this->assertVisible('ctl0_Content_tab1');
-
- $this->click("ctl0_Content_btn1");
- $this->pause(800);
-
- $this->assertText("ctl0_Content_result", "Tab ActiveIndex is : 0");
-
- $this->click("ctl0_Content_tab2_0");
- $this->pause(800);
-
- $this->assertVisible('ctl0_Content_tab2');
-
- $this->click("ctl0_Content_btn1");
- $this->pause(800);
- $this->assertText("ctl0_Content_result", "Tab ActiveIndex is : 1");
- }
-}
-
+<?php + +class Issue216TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Issue216'); + $this->assertTextPresent('TTabPanel doesn\'t preserve active tab on callback request'); + + $this->assertVisible('ctl0_Content_tab1'); + + $this->click("ctl0_Content_btn1"); + $this->pause(800); + + $this->assertText("ctl0_Content_result", "Tab ActiveIndex is : 0"); + + $this->click("ctl0_Content_tab2_0"); + $this->pause(800); + + $this->assertVisible('ctl0_Content_tab2'); + + $this->click("ctl0_Content_btn1"); + $this->pause(800); + $this->assertText("ctl0_Content_result", "Tab ActiveIndex is : 1"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket121TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket121TestCase.php index 7453aeef..3cad6c77 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket121TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket121TestCase.php @@ -1,19 +1,19 @@ -<?php
-
-class Ticket121TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket121');
- $this->type("ctl0\$Content\$FooTextBox", "");
- $this->verifyNotVisible('ctl0_Content_ctl1');
- $this->click("//input[@type='image' and @id='ctl0_Content_ctl0']", "");
- $this->verifyVisible('ctl0_Content_ctl1');
- $this->type("ctl0\$Content\$FooTextBox", "content");
- $this->clickAndWait("//input[@type='image' and @id='ctl0_Content_ctl0']", "");
- $this->verifyNotVisible('ctl0_Content_ctl1');
- $this->verifyTextPresent("clicked at", "");
- }
-}
-
+<?php + +class Ticket121TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket121'); + $this->type("ctl0\$Content\$FooTextBox", ""); + $this->verifyNotVisible('ctl0_Content_ctl1'); + $this->click("//input[@type='image' and @id='ctl0_Content_ctl0']", ""); + $this->verifyVisible('ctl0_Content_ctl1'); + $this->type("ctl0\$Content\$FooTextBox", "content"); + $this->clickAndWait("//input[@type='image' and @id='ctl0_Content_ctl0']", ""); + $this->verifyNotVisible('ctl0_Content_ctl1'); + $this->verifyTextPresent("clicked at", ""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket191TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket191TestCase.php index d899aab5..616a578a 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket191TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket191TestCase.php @@ -1,16 +1,16 @@ -<?php
-
-class Ticket191TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket191');
- $this->type("ctl0\$Content\$TextBox2", "test");
- $this->clickAndWait("name=ctl0\$Content\$ctl0");
- $this->type("ctl0\$Content\$TextBox", "test");
- $this->clickAndWait("name=ctl0\$Content\$ctl1");
- $this->verifyNotVisible('ctl0_Content_ctl2');
- }
-}
-
+<?php + +class Ticket191TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket191'); + $this->type("ctl0\$Content\$TextBox2", "test"); + $this->clickAndWait("name=ctl0\$Content\$ctl0"); + $this->type("ctl0\$Content\$TextBox", "test"); + $this->clickAndWait("name=ctl0\$Content\$ctl1"); + $this->verifyNotVisible('ctl0_Content_ctl2'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket21TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket21TestCase.php index 394f8c95..24c5e346 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket21TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket21TestCase.php @@ -1,19 +1,19 @@ -<?php
-
-class Ticket21TestCase extends SeleniumTestCase
-{
- function test()
- {
- //problem with test runner clicking on radio buttons
- $this->skipBrowsers(self::OPERA);
-
- $this->open('tickets/index.php?page=Ticket21');
- $this->assertTitle("Verifying Ticket 21");
- $this->clickAndWait("ctl0_Content_button1");
- $this->verifyTextPresent("Radio button clicks: 1", "");
- $this->click("ctl0_Content_button1");
- $this->verifyTextPresent("Radio button clicks: 1", "");
- }
-}
-
+<?php + +class Ticket21TestCase extends SeleniumTestCase +{ + function test() + { + //problem with test runner clicking on radio buttons + $this->skipBrowsers(self::OPERA); + + $this->open('tickets/index.php?page=Ticket21'); + $this->assertTitle("Verifying Ticket 21"); + $this->clickAndWait("ctl0_Content_button1"); + $this->verifyTextPresent("Radio button clicks: 1", ""); + $this->click("ctl0_Content_button1"); + $this->verifyTextPresent("Radio button clicks: 1", ""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket239TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket239TestCase.php index 9d895cb4..2fe84397 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket239TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket239TestCase.php @@ -1,55 +1,55 @@ -<?php
-
-class Ticket239TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket239');
-
- // view1
- $this->verifyTextPresent('view1 is activated','');
- $this->verifyTextNotPresent('view1 is deactivated','');
- $this->verifyTextNotPresent('view2 is activated','');
- $this->verifyTextNotPresent('view2 is deactivated','');
- $this->verifyTextNotPresent('view3 is activated','');
- $this->verifyTextNotPresent('view3 is deactivated','');
-
- // goto view2
- $this->clickAndWait('name=ctl0$Content$ctl1');
- $this->verifyTextNotPresent('view1 is activated','');
- $this->verifyTextPresent('view1 is deactivated','');
- $this->verifyTextPresent('view2 is activated','');
- $this->verifyTextNotPresent('view2 is deactivated','');
- $this->verifyTextNotPresent('view3 is activated','');
- $this->verifyTextNotPresent('view3 is deactivated','');
-
- // goto view3
- $this->clickAndWait('name=ctl0$Content$ctl3');
- $this->verifyTextNotPresent('view1 is activated','');
- $this->verifyTextNotPresent('view1 is deactivated','');
- $this->verifyTextNotPresent('view2 is activated','');
- $this->verifyTextPresent('view2 is deactivated','');
- $this->verifyTextPresent('view3 is activated','');
- $this->verifyTextNotPresent('view3 is deactivated','');
-
- // goto view2
- $this->clickAndWait('name=ctl0$Content$ctl4');
- $this->verifyTextNotPresent('view1 is activated','');
- $this->verifyTextNotPresent('view1 is deactivated','');
- $this->verifyTextPresent('view2 is activated','');
- $this->verifyTextNotPresent('view2 is deactivated','');
- $this->verifyTextNotPresent('view3 is activated','');
- $this->verifyTextPresent('view3 is deactivated','');
-
- // goto view1
- $this->clickAndWait('name=ctl0$Content$ctl2');
- $this->verifyTextPresent('view1 is activated','');
- $this->verifyTextNotPresent('view1 is deactivated','');
- $this->verifyTextNotPresent('view2 is activated','');
- $this->verifyTextPresent('view2 is deactivated','');
- $this->verifyTextNotPresent('view3 is activated','');
- $this->verifyTextNotPresent('view3 is deactivated','');
- }
-}
-
+<?php + +class Ticket239TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket239'); + + // view1 + $this->verifyTextPresent('view1 is activated',''); + $this->verifyTextNotPresent('view1 is deactivated',''); + $this->verifyTextNotPresent('view2 is activated',''); + $this->verifyTextNotPresent('view2 is deactivated',''); + $this->verifyTextNotPresent('view3 is activated',''); + $this->verifyTextNotPresent('view3 is deactivated',''); + + // goto view2 + $this->clickAndWait('name=ctl0$Content$ctl1'); + $this->verifyTextNotPresent('view1 is activated',''); + $this->verifyTextPresent('view1 is deactivated',''); + $this->verifyTextPresent('view2 is activated',''); + $this->verifyTextNotPresent('view2 is deactivated',''); + $this->verifyTextNotPresent('view3 is activated',''); + $this->verifyTextNotPresent('view3 is deactivated',''); + + // goto view3 + $this->clickAndWait('name=ctl0$Content$ctl3'); + $this->verifyTextNotPresent('view1 is activated',''); + $this->verifyTextNotPresent('view1 is deactivated',''); + $this->verifyTextNotPresent('view2 is activated',''); + $this->verifyTextPresent('view2 is deactivated',''); + $this->verifyTextPresent('view3 is activated',''); + $this->verifyTextNotPresent('view3 is deactivated',''); + + // goto view2 + $this->clickAndWait('name=ctl0$Content$ctl4'); + $this->verifyTextNotPresent('view1 is activated',''); + $this->verifyTextNotPresent('view1 is deactivated',''); + $this->verifyTextPresent('view2 is activated',''); + $this->verifyTextNotPresent('view2 is deactivated',''); + $this->verifyTextNotPresent('view3 is activated',''); + $this->verifyTextPresent('view3 is deactivated',''); + + // goto view1 + $this->clickAndWait('name=ctl0$Content$ctl2'); + $this->verifyTextPresent('view1 is activated',''); + $this->verifyTextNotPresent('view1 is deactivated',''); + $this->verifyTextNotPresent('view2 is activated',''); + $this->verifyTextPresent('view2 is deactivated',''); + $this->verifyTextNotPresent('view3 is activated',''); + $this->verifyTextNotPresent('view3 is deactivated',''); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket274TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket274TestCase.php index 8b74e565..b7ba1251 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket274TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket274TestCase.php @@ -1,24 +1,24 @@ -<?php
-
-class Ticket274TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket274');
- $this->assertTitle('Verifying Ticket 274');
- $this->assertNotVisible($base.'validator1');
- $this->assertNotVisible($base.'validator2');
-
- $this->clickAndWait($base.'button1');
- $this->assertVisible($base.'validator1');
- $this->assertNotVisible($base.'validator2');
-
- $this->type($base.'MyDate', 'asd');
- $this->clickAndWait($base.'button1');
- $this->assertNotVisible($base.'validator1');
- $this->assertVisible($base.'validator2');
- }
-}
-
+<?php + +class Ticket274TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket274'); + $this->assertTitle('Verifying Ticket 274'); + $this->assertNotVisible($base.'validator1'); + $this->assertNotVisible($base.'validator2'); + + $this->clickAndWait($base.'button1'); + $this->assertVisible($base.'validator1'); + $this->assertNotVisible($base.'validator2'); + + $this->type($base.'MyDate', 'asd'); + $this->clickAndWait($base.'button1'); + $this->assertNotVisible($base.'validator1'); + $this->assertVisible($base.'validator2'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket278TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket278TestCase.php index 6e3666b9..a559ca14 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket278TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket278TestCase.php @@ -1,57 +1,57 @@ -<?php
-
-class Ticket278TestCase extends SeleniumTestCase
-{
- function test()
- {
- //problem with test runner clicking on radio buttons
- $this->skipBrowsers(self::OPERA);
-
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket278');
- $this->assertTitle('Verifying Ticket 278');
- $this->assertNotVisible($base.'validator1');
- $this->assertNotVisible($base.'validator2');
- $this->assertNotVisible($base.'panel1');
-
- $this->click($base.'button1');
- $this->assertVisible($base.'validator1');
- $this->assertNotVisible($base.'validator2');
-
- $this->type($base.'text1', 'asd');
- $this->clickAndWait($base.'button1');
- $this->assertNotVisible($base.'validator1');
- $this->assertNotVisible($base.'validator2');
- $this->assertNotVisible($base.'panel1');
-
- $this->click($base.'check1');
- $this->click($base.'button1');
- $this->assertNotVisible($base.'validator1');
- $this->assertVisible($base.'validator2');
- $this->assertVisible($base.'panel1');
-
-
- $this->type($base.'text1', '');
- $this->type($base.'text2', 'asd');
- $this->click($base.'button1');
- $this->assertVisible($base.'validator1');
- $this->assertNotVisible($base.'validator2');
- $this->assertVisible($base.'panel1');
-
-
- $this->type($base.'text1', 'asd');
- $this->clickAndWait($base.'button1');
- $this->assertNotVisible($base.'validator1');
- $this->assertNotVisible($base.'validator2');
- $this->assertVisible($base.'panel1');
-
- $this->type($base.'text1', '');
- $this->type($base.'text2', '');
- $this->click($base.'button1');
- $this->assertVisible($base.'validator1');
- $this->assertVisible($base.'validator2');
- $this->assertVisible($base.'panel1');
- }
-}
-
+<?php + +class Ticket278TestCase extends SeleniumTestCase +{ + function test() + { + //problem with test runner clicking on radio buttons + $this->skipBrowsers(self::OPERA); + + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket278'); + $this->assertTitle('Verifying Ticket 278'); + $this->assertNotVisible($base.'validator1'); + $this->assertNotVisible($base.'validator2'); + $this->assertNotVisible($base.'panel1'); + + $this->click($base.'button1'); + $this->assertVisible($base.'validator1'); + $this->assertNotVisible($base.'validator2'); + + $this->type($base.'text1', 'asd'); + $this->clickAndWait($base.'button1'); + $this->assertNotVisible($base.'validator1'); + $this->assertNotVisible($base.'validator2'); + $this->assertNotVisible($base.'panel1'); + + $this->click($base.'check1'); + $this->click($base.'button1'); + $this->assertNotVisible($base.'validator1'); + $this->assertVisible($base.'validator2'); + $this->assertVisible($base.'panel1'); + + + $this->type($base.'text1', ''); + $this->type($base.'text2', 'asd'); + $this->click($base.'button1'); + $this->assertVisible($base.'validator1'); + $this->assertNotVisible($base.'validator2'); + $this->assertVisible($base.'panel1'); + + + $this->type($base.'text1', 'asd'); + $this->clickAndWait($base.'button1'); + $this->assertNotVisible($base.'validator1'); + $this->assertNotVisible($base.'validator2'); + $this->assertVisible($base.'panel1'); + + $this->type($base.'text1', ''); + $this->type($base.'text2', ''); + $this->click($base.'button1'); + $this->assertVisible($base.'validator1'); + $this->assertVisible($base.'validator2'); + $this->assertVisible($base.'panel1'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket27TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket27TestCase.php index 6a5ccdb9..dac852e2 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket27TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket27TestCase.php @@ -1,18 +1,18 @@ -<?php
-
-class Ticket27TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket27');
- $this->verifyTitle("Verifying Ticket 27", "");
- $this->click("//input[@value='Agree']", "");
- $this->assertVisible("ctl0_Content_validator1", "");
- $this->type("ctl0_Content_TextBox", "122");
- $this->assertNotVisible("ctl0_Content_validator1", "");
- $this->clickAndWait("//input[@value='Disagree']", "");
- $this->assertNotVisible("ctl0_Content_validator1", "");
- }
-}
-
+<?php + +class Ticket27TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket27'); + $this->verifyTitle("Verifying Ticket 27", ""); + $this->click("//input[@value='Agree']", ""); + $this->assertVisible("ctl0_Content_validator1", ""); + $this->type("ctl0_Content_TextBox", "122"); + $this->assertNotVisible("ctl0_Content_validator1", ""); + $this->clickAndWait("//input[@value='Disagree']", ""); + $this->assertNotVisible("ctl0_Content_validator1", ""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket284TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket284TestCase.php index 9a6fa7c3..15194f60 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket284TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket284TestCase.php @@ -1,14 +1,14 @@ -<?php
-
-class Ticket284TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket284');
- $this->assertTextPresent('Verifying Ticket 284');
- $this->click('ctl0_Content_ctl1');
-
- }
-}
-
+<?php + +class Ticket284TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket284'); + $this->assertTextPresent('Verifying Ticket 284'); + $this->click('ctl0_Content_ctl1'); + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket285TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket285TestCase.php index cd681c58..6f4a2a8e 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket285TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket285TestCase.php @@ -1,12 +1,12 @@ -<?php
-
-class Ticket285TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket285');
- $this->assertTextPresent('350.00');
- $this->assertTextPresent('349.99');
- }
-}
+<?php + +class Ticket285TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket285'); + $this->assertTextPresent('350.00'); + $this->assertTextPresent('349.99'); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket433TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket433TestCase.php index 1bbfb7ec..b855edc8 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket433TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket433TestCase.php @@ -1,18 +1,18 @@ <?php -
-class Ticket433TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket433');
- $this->assertTitle("Verifying Ticket 433");
- $this->assertText("{$base}VoteClick", "BEFORE click");
-
- $this->click("{$base}VoteClick");
- $this->pause(800);
- $this->assertText("{$base}VoteClick", "AFTER click CALLBACK DONE");
- }
-}
+ +class Ticket433TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket433'); + $this->assertTitle("Verifying Ticket 433"); + $this->assertText("{$base}VoteClick", "BEFORE click"); + + $this->click("{$base}VoteClick"); + $this->pause(800); + $this->assertText("{$base}VoteClick", "AFTER click CALLBACK DONE"); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket439TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket439TestCase.php index 651e322c..e097a9ce 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket439TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket439TestCase.php @@ -1,16 +1,16 @@ -<?php
-
-class Ticket439TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket439');
- $this->assertTitle("Verifying Ticket 439");
- $this->click("{$base}button1");
- $this->waitForPageToLoad(3000);
- $this->pause(800);
- $this->assertTitle("Verifying Home");
- }
-}
+<?php + +class Ticket439TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket439'); + $this->assertTitle("Verifying Ticket 439"); + $this->click("{$base}button1"); + $this->waitForPageToLoad(3000); + $this->pause(800); + $this->assertTitle("Verifying Home"); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket463TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket463TestCase.php index 51b27b87..9da3be34 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket463TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket463TestCase.php @@ -1,13 +1,13 @@ -<?php
-
-class Ticket463TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket463');
- $this->verifyTitle("Verifying Ticket 463", "");
- $this->assertTextPresent('May 1, 2005 12:00:00 AM');
- }
-}
-
+<?php + +class Ticket463TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket463'); + $this->verifyTitle("Verifying Ticket 463", ""); + $this->assertTextPresent('May 1, 2005 12:00:00 AM'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket470TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket470TestCase.php index 05ad6fb6..a2c4826e 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket470TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket470TestCase.php @@ -1,51 +1,51 @@ -<?php
-
-class Ticket470TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket470');
- $this->verifyTitle("Verifying Ticket 470");
- $this->assertText("{$base}counter", "0");
- $this->assertText("{$base}Results", "");
- $this->assertNotVisible("{$base}validator1");
-
- $this->click("{$base}button1");
- $this->pause(800);
- $this->assertText("{$base}counter", "0");
- $this->assertText("{$base}Results", "");
- $this->assertVisible("{$base}validator1");
-
- $this->type("{$base}TextBox", "hello");
- $this->click("{$base}button1");
- $this->pause(800);
- $this->assertText("{$base}counter", "0");
- $this->assertText("{$base}Results", "OK!!!");
- $this->assertNotVisible("{$base}validator1");
-
- //reload
- $this->click("{$base}reloadButton");
- $this->pause(800);
- $this->assertValue("{$base}TextBox", "hello");
- $this->assertText("{$base}counter", "1");
- $this->assertText("{$base}Results", "");
- $this->assertNotVisible("{$base}validator1");
-
- $this->type("{$base}TextBox", "");
- $this->click("{$base}button1");
- $this->pause(800);
- $this->assertText("{$base}counter", "1");
- $this->assertText("{$base}Results", "");
- $this->assertVisible("{$base}validator1");
-
- $this->type("{$base}TextBox", "test");
- $this->click("{$base}button1");
- $this->pause(800);
- $this->assertText("{$base}counter", "1");
- $this->assertText("{$base}Results", "OK!!!");
- $this->assertNotVisible("{$base}validator1");
- }
-}
-
+<?php + +class Ticket470TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket470'); + $this->verifyTitle("Verifying Ticket 470"); + $this->assertText("{$base}counter", "0"); + $this->assertText("{$base}Results", ""); + $this->assertNotVisible("{$base}validator1"); + + $this->click("{$base}button1"); + $this->pause(800); + $this->assertText("{$base}counter", "0"); + $this->assertText("{$base}Results", ""); + $this->assertVisible("{$base}validator1"); + + $this->type("{$base}TextBox", "hello"); + $this->click("{$base}button1"); + $this->pause(800); + $this->assertText("{$base}counter", "0"); + $this->assertText("{$base}Results", "OK!!!"); + $this->assertNotVisible("{$base}validator1"); + + //reload + $this->click("{$base}reloadButton"); + $this->pause(800); + $this->assertValue("{$base}TextBox", "hello"); + $this->assertText("{$base}counter", "1"); + $this->assertText("{$base}Results", ""); + $this->assertNotVisible("{$base}validator1"); + + $this->type("{$base}TextBox", ""); + $this->click("{$base}button1"); + $this->pause(800); + $this->assertText("{$base}counter", "1"); + $this->assertText("{$base}Results", ""); + $this->assertVisible("{$base}validator1"); + + $this->type("{$base}TextBox", "test"); + $this->click("{$base}button1"); + $this->pause(800); + $this->assertText("{$base}counter", "1"); + $this->assertText("{$base}Results", "OK!!!"); + $this->assertNotVisible("{$base}validator1"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket477TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket477TestCase.php index ea32ff5f..10c36e7d 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket477TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket477TestCase.php @@ -1,24 +1,24 @@ <?php -
-class Ticket477TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket477');
- $this->assertTitle("Verifying Ticket 477");
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
-
- $this->clickAndWait("{$base}list1_c1");
- $this->assertVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
-
-
- $this->clickAndWait("{$base}list2_c1");
- $this->assertNotVisible("{$base}validator1");
- $this->assertVisible("{$base}validator2");
- }
-}
+ +class Ticket477TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket477'); + $this->assertTitle("Verifying Ticket 477"); + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + + $this->clickAndWait("{$base}list1_c1"); + $this->assertVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + + + $this->clickAndWait("{$base}list2_c1"); + $this->assertNotVisible("{$base}validator1"); + $this->assertVisible("{$base}validator2"); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket488TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket488TestCase.php index 2a83fac9..d96b92f1 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket488TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket488TestCase.php @@ -1,42 +1,42 @@ -<?php
-
-class Ticket488TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('active-controls/index.php?page=CustomValidatorByPass');
- $this->assertTextPresent('Custom Login');
- $this->assertNotVisible('loginBox');
- $this->click("showLogin");
- $this->assertVisible("loginBox");
- $this->assertNotVisible("validator1");
- $this->assertNotVisible("validator2");
-
- $this->click("checkLogin");
- $this->pause(800);
- $this->assertVisible("validator1");
- $this->assertNotVisible("validator2");
-
- $this->type('Username', 'tea');
- $this->type('Password', 'mmama');
-
- $this->click("checkLogin");
- $this->pause(800);
- $this->assertNotVisible("validator1");
- $this->assertVisible("validator2");
-
- $this->type('Password', 'test');
- $this->click("checkLogin");
- $this->pause(800);
- $this->assertNotVisible("validator1");
- $this->assertNotVisible("validator2");
- }
-
- function test_more()
- {
- $this->open('tickets/index.php?page=Ticket488');
- //add test assertions here.
- }
-}
-
+<?php + +class Ticket488TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('active-controls/index.php?page=CustomValidatorByPass'); + $this->assertTextPresent('Custom Login'); + $this->assertNotVisible('loginBox'); + $this->click("showLogin"); + $this->assertVisible("loginBox"); + $this->assertNotVisible("validator1"); + $this->assertNotVisible("validator2"); + + $this->click("checkLogin"); + $this->pause(800); + $this->assertVisible("validator1"); + $this->assertNotVisible("validator2"); + + $this->type('Username', 'tea'); + $this->type('Password', 'mmama'); + + $this->click("checkLogin"); + $this->pause(800); + $this->assertNotVisible("validator1"); + $this->assertVisible("validator2"); + + $this->type('Password', 'test'); + $this->click("checkLogin"); + $this->pause(800); + $this->assertNotVisible("validator1"); + $this->assertNotVisible("validator2"); + } + + function test_more() + { + $this->open('tickets/index.php?page=Ticket488'); + //add test assertions here. + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket504TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket504TestCase.php index 7c74a1d1..5629e5f3 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket504TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket504TestCase.php @@ -1,53 +1,53 @@ -<?php
-
-class Ticket504TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket504');
- $this->verifyTitle("Verifying Ticket 504", "");
-
- $this->assertText("status", "");
-
- $this->assertVisible("{$base}panelA");
- $this->assertVisible("{$base}panelB");
- $this->assertVisible("{$base}panelC");
- $this->assertVisible("{$base}panelD");
-
- $this->click("{$base}linka");
- $this->pause(800);
- $this->assertVisible("{$base}panelA");
- $this->assertNotVisible("{$base}panelB");
- $this->assertNotVisible("{$base}panelC");
- $this->assertNotVisible("{$base}panelD");
- $this->assertText("status", "panelA updated");
-
- $this->click("{$base}linkb");
- $this->pause(800);
- $this->assertNotVisible("{$base}panelA");
- $this->assertVisible("{$base}panelB");
- $this->assertNotVisible("{$base}panelC");
- $this->assertNotVisible("{$base}panelD");
- $this->assertText("status", "panelB updated");
-
- $this->click("{$base}linkc");
- $this->pause(800);
- $this->assertNotVisible("{$base}panelA");
- $this->assertNotVisible("{$base}panelB");
- $this->assertVisible("{$base}panelC");
- $this->assertNotVisible("{$base}panelD");
- $this->assertText("status", "panelC updated");
-
- $this->click("{$base}linkd");
- $this->pause(800);
- $this->assertNotVisible("{$base}panelA");
- $this->assertNotVisible("{$base}panelB");
- $this->assertNotVisible("{$base}panelC");
- $this->assertVisible("{$base}panelD");
- $this->assertText("status", "panelD updated");
-
- }
-}
-
+<?php + +class Ticket504TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket504'); + $this->verifyTitle("Verifying Ticket 504", ""); + + $this->assertText("status", ""); + + $this->assertVisible("{$base}panelA"); + $this->assertVisible("{$base}panelB"); + $this->assertVisible("{$base}panelC"); + $this->assertVisible("{$base}panelD"); + + $this->click("{$base}linka"); + $this->pause(800); + $this->assertVisible("{$base}panelA"); + $this->assertNotVisible("{$base}panelB"); + $this->assertNotVisible("{$base}panelC"); + $this->assertNotVisible("{$base}panelD"); + $this->assertText("status", "panelA updated"); + + $this->click("{$base}linkb"); + $this->pause(800); + $this->assertNotVisible("{$base}panelA"); + $this->assertVisible("{$base}panelB"); + $this->assertNotVisible("{$base}panelC"); + $this->assertNotVisible("{$base}panelD"); + $this->assertText("status", "panelB updated"); + + $this->click("{$base}linkc"); + $this->pause(800); + $this->assertNotVisible("{$base}panelA"); + $this->assertNotVisible("{$base}panelB"); + $this->assertVisible("{$base}panelC"); + $this->assertNotVisible("{$base}panelD"); + $this->assertText("status", "panelC updated"); + + $this->click("{$base}linkd"); + $this->pause(800); + $this->assertNotVisible("{$base}panelA"); + $this->assertNotVisible("{$base}panelB"); + $this->assertNotVisible("{$base}panelC"); + $this->assertVisible("{$base}panelD"); + $this->assertText("status", "panelD updated"); + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket507TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket507TestCase.php index e8ddbfce..a430fb4e 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket507TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket507TestCase.php @@ -1,27 +1,27 @@ -<?php
-
-class Ticket507TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base='ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket507');
- $this->verifyTitle("Verifying Ticket 507", "");
-
- $this->assertText("{$base}label1", "Label 1");
-
- $this->click("{$base}button1");
- $this->pause(800);
-
- $this->select("{$base}list1", "item 1");
- $this->pause(800);
- $this->assertText("{$base}label1", "Selection: value 1");
-
- $this->addSelection("{$base}list1", "item 3");
-
- $this->pause(800);
- $this->assertText("{$base}label1", "Selection: value 1, value 3");
- }
-}
-
+<?php + +class Ticket507TestCase extends SeleniumTestCase +{ + function test() + { + $base='ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket507'); + $this->verifyTitle("Verifying Ticket 507", ""); + + $this->assertText("{$base}label1", "Label 1"); + + $this->click("{$base}button1"); + $this->pause(800); + + $this->select("{$base}list1", "item 1"); + $this->pause(800); + $this->assertText("{$base}label1", "Selection: value 1"); + + $this->addSelection("{$base}list1", "item 3"); + + $this->pause(800); + $this->assertText("{$base}label1", "Selection: value 1, value 3"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket521TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket521TestCase.php index ea9feae8..b0cdd8af 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket521TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket521TestCase.php @@ -1,20 +1,20 @@ -<?php
-
-class Ticket521TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open("tickets/index.php?page=Ticket521");
- $this->assertTitle("Verifying Ticket 521");
- $this->assertText("{$base}label1", "Label 1");
-
- $this->click("{$base}button1");
- $this->pause(1200);
-
- $this->assertText("{$base}label1", "Button 1 was clicked on callback");
- }
-
-}
-
+<?php + +class Ticket521TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open("tickets/index.php?page=Ticket521"); + $this->assertTitle("Verifying Ticket 521"); + $this->assertText("{$base}label1", "Label 1"); + + $this->click("{$base}button1"); + $this->pause(1200); + + $this->assertText("{$base}label1", "Button 1 was clicked on callback"); + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket526TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket526TestCase.php index abba3a96..c8894082 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket526TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket526TestCase.php @@ -1,18 +1,18 @@ -<?php
-
-class Ticket526TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base="ctl0_Content_";
- $this->open('tickets/index.php?page=Ticket526');
- $this->verifyTitle("Verifying Ticket 526", "");
-
- $this->assertElementNotPresent("{$base}dpbutton");
-
- $this->click("{$base}btn");
- $this->pause(800);
- $this->assertElementPresent("{$base}dpbutton");
- }
-}
+<?php + +class Ticket526TestCase extends SeleniumTestCase +{ + function test() + { + $base="ctl0_Content_"; + $this->open('tickets/index.php?page=Ticket526'); + $this->verifyTitle("Verifying Ticket 526", ""); + + $this->assertElementNotPresent("{$base}dpbutton"); + + $this->click("{$base}btn"); + $this->pause(800); + $this->assertElementPresent("{$base}dpbutton"); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket528TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket528TestCase.php index 86b28378..79791444 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket528TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket528TestCase.php @@ -1,32 +1,32 @@ -<?php
-
-class Ticket528TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket528');
- $this->assertTitle("Verifying Ticket 528");
-
- $this->select("{$base}DDropTurno", "Tarde");
- $this->pause(800);
-
- $this->assertValue("{$base}Codigo", "T");
- $this->assertValue("{$base}Descricao", "Tarde");
-
- $this->select("{$base}DDropTurno", "Manhã");
- $this->pause(800);
-
- $this->assertValue("{$base}Codigo", "M");
- $this->assertValue("{$base}Descricao", "Manhã");
-
- $this->select("{$base}DDropTurno", "Noite");
- $this->pause(800);
-
- $this->assertValue("{$base}Codigo", "N");
- $this->assertValue("{$base}Descricao", "Noite");
-
- }
-}
-
+<?php + +class Ticket528TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket528'); + $this->assertTitle("Verifying Ticket 528"); + + $this->select("{$base}DDropTurno", "Tarde"); + $this->pause(800); + + $this->assertValue("{$base}Codigo", "T"); + $this->assertValue("{$base}Descricao", "Tarde"); + + $this->select("{$base}DDropTurno", "Manhã"); + $this->pause(800); + + $this->assertValue("{$base}Codigo", "M"); + $this->assertValue("{$base}Descricao", "Manhã"); + + $this->select("{$base}DDropTurno", "Noite"); + $this->pause(800); + + $this->assertValue("{$base}Codigo", "N"); + $this->assertValue("{$base}Descricao", "Noite"); + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket535TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket535TestCase.php index 26f70803..222f4b7b 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket535TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket535TestCase.php @@ -1,36 +1,36 @@ -<?php
-
-class Ticket535TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket535');
- $this->assertTitle("Verifying Ticket 535");
-
- $this->assertText("{$base}label1", "Label 1");
-
- $this->click("{$base}radio1");
- $this->click("{$base}button1");
- $this->pause(800);
- $this->assertText("{$base}label1", 'radio1 checked:{1} radio2 checked:{}');
-
- $this->click("{$base}radio2");
- $this->click("{$base}button1");
- $this->pause(800);
- $this->assertText("{$base}label1", 'radio1 checked:{1} radio2 checked:{1}');
-
- $this->click("{$base}bad_radio1");
- $this->click("{$base}button2");
- $this->pause(800);
- $this->assertText("{$base}label1", 'bad_radio1 checked:{1} bad_radio2 checked:{}');
-
- $this->click("{$base}bad_radio2");
- $this->click("{$base}button2");
- $this->pause(800);
- $this->assertText("{$base}label1", 'bad_radio1 checked:{} bad_radio2 checked:{1}');
- }
-
-}
-
+<?php + +class Ticket535TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket535'); + $this->assertTitle("Verifying Ticket 535"); + + $this->assertText("{$base}label1", "Label 1"); + + $this->click("{$base}radio1"); + $this->click("{$base}button1"); + $this->pause(800); + $this->assertText("{$base}label1", 'radio1 checked:{1} radio2 checked:{}'); + + $this->click("{$base}radio2"); + $this->click("{$base}button1"); + $this->pause(800); + $this->assertText("{$base}label1", 'radio1 checked:{1} radio2 checked:{1}'); + + $this->click("{$base}bad_radio1"); + $this->click("{$base}button2"); + $this->pause(800); + $this->assertText("{$base}label1", 'bad_radio1 checked:{1} bad_radio2 checked:{}'); + + $this->click("{$base}bad_radio2"); + $this->click("{$base}button2"); + $this->pause(800); + $this->assertText("{$base}label1", 'bad_radio1 checked:{} bad_radio2 checked:{1}'); + } + +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket538TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket538TestCase.php index 712ff24b..20730b25 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket538TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket538TestCase.php @@ -1,30 +1,30 @@ -<?php
-
-class Ticket538TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base="ctl0_Content_";
- $this->open('tickets/index.php?page=Ticket538');
- $this->verifyTitle("Verifying Ticket 538", "");
-
- $this->assertText("{$base}ALLog", 'waiting for response...');
-
- $this->select("{$base}DataViewer", "empty :(");
- $this->click("{$base}selectBtn");
- $this->pause(800);
-
- $this->assertText("{$base}ALLog", '0,');
-
- $this->select("{$base}DataSelector", "select data set 2");
- $this->pause(800);
- $this->select("{$base}DataViewer", "G1: Steven=>10");
- $this->addSelection("{$base}DataViewer", "G2: Kevin=>65");
-
- $this->click("{$base}selectBtn");
- $this->pause(800);
- $this->assertText("{$base}ALLog", '4- "test1", 10- "test2",');
- }
-}
-
+<?php + +class Ticket538TestCase extends SeleniumTestCase +{ + function test() + { + $base="ctl0_Content_"; + $this->open('tickets/index.php?page=Ticket538'); + $this->verifyTitle("Verifying Ticket 538", ""); + + $this->assertText("{$base}ALLog", 'waiting for response...'); + + $this->select("{$base}DataViewer", "empty :("); + $this->click("{$base}selectBtn"); + $this->pause(800); + + $this->assertText("{$base}ALLog", '0,'); + + $this->select("{$base}DataSelector", "select data set 2"); + $this->pause(800); + $this->select("{$base}DataViewer", "G1: Steven=>10"); + $this->addSelection("{$base}DataViewer", "G2: Kevin=>65"); + + $this->click("{$base}selectBtn"); + $this->pause(800); + $this->assertText("{$base}ALLog", '4- "test1", 10- "test2",'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket54TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket54TestCase.php index 1698f1cb..62d2599d 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket54TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket54TestCase.php @@ -1,12 +1,12 @@ -<?php
-
-class Ticket54TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket54');
- $this->verifyTextPresent("|A|a|B|b|C|", "");
- }
-}
-
+<?php + +class Ticket54TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket54'); + $this->verifyTextPresent("|A|a|B|b|C|", ""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket573TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket573TestCase.php index 60a8d453..755d5dd6 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket573TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket573TestCase.php @@ -1,14 +1,14 @@ -<?php
-
-class Ticket573TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket573');
- $this->verifyTitle("Verifying Ticket 573", "");
-
- $this->assertText('test1', '10.00');
- }
-}
-
+<?php + +class Ticket573TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket573'); + $this->verifyTitle("Verifying Ticket 573", ""); + + $this->assertText('test1', '10.00'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket578TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket578TestCase.php index f95af91b..5f3bd4d6 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket578TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket578TestCase.php @@ -1,29 +1,29 @@ -<?php
-
-class Ticket578TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket578');
- $this->verifyTitle("Verifying Ticket 578", "");
-
- $this->assertText("{$base}label1", "Label 1");
- $this->click("{$base}button1", "");
- $this->pause(800);
- $this->assertText("{$base}label1", "Button 1 was clicked : ");
-
- $this->store($this->setTinymceHtml("{$base}text1", "helloworld"),"t2");
- $this->click("{$base}button1", "");
- $this->pause(800);
- $this->assertText("{$base}label1", "Button 1 was clicked : helloworld");
- }
-
- function setTinymceHtml($id, $text)
- {
- $tinymce = "this.browserbot.getCurrentWindow().tinyMCE.getInstanceById('{$id}')";
- return 'javascript{'."{$tinymce}.setHTML('{$text}') ? 0 : 1".'}';
- }
-}
-
+<?php + +class Ticket578TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket578'); + $this->verifyTitle("Verifying Ticket 578", ""); + + $this->assertText("{$base}label1", "Label 1"); + $this->click("{$base}button1", ""); + $this->pause(800); + $this->assertText("{$base}label1", "Button 1 was clicked : "); + + $this->store($this->setTinymceHtml("{$base}text1", "helloworld"),"t2"); + $this->click("{$base}button1", ""); + $this->pause(800); + $this->assertText("{$base}label1", "Button 1 was clicked : helloworld"); + } + + function setTinymceHtml($id, $text) + { + $tinymce = "this.browserbot.getCurrentWindow().tinyMCE.getInstanceById('{$id}')"; + return 'javascript{'."{$tinymce}.setHTML('{$text}') ? 0 : 1".'}'; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket585TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket585TestCase.php index cbcb7bb2..2b3f671b 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket585TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket585TestCase.php @@ -1,27 +1,27 @@ -<?php
-
-class Ticket585TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket585');
- $this->verifyTitle("Verifying Ticket 585", "");
-
- $this->assertText("error", "");
- $this->assertNotVisible("{$base}validator1");
-
- $this->click("{$base}button1");
- $this->pause(800);
- $this->assertText("error", "Success");
- $this->assertNotVisible("{$base}validator1");
-
- $this->type("{$base}test", "15-03-2007");
- $this->click("{$base}button1");
- $this->pause(800);
- $this->assertText("error", "Error");
- $this->assertVisible("{$base}validator1");
- }
-}
-
+<?php + +class Ticket585TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket585'); + $this->verifyTitle("Verifying Ticket 585", ""); + + $this->assertText("error", ""); + $this->assertNotVisible("{$base}validator1"); + + $this->click("{$base}button1"); + $this->pause(800); + $this->assertText("error", "Success"); + $this->assertNotVisible("{$base}validator1"); + + $this->type("{$base}test", "15-03-2007"); + $this->click("{$base}button1"); + $this->pause(800); + $this->assertText("error", "Error"); + $this->assertVisible("{$base}validator1"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket586TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket586TestCase.php index 4b5619cd..037b9223 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket586TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket586TestCase.php @@ -1,21 +1,21 @@ -<?php
-
-class Ticket586TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket586');
- $this->verifyTitle("Verifying Ticket 586", "");
-
- $this->assertText("{$base}label1", "Status");
- $this->clickAndWait("{$base}button1");
- $this->assertText("{$base}label1", "Button 1 Clicked!");
-
- $this->type("{$base}text1", "testing");
- $this->keyDownAndWait("{$base}text1", '\13');
- $this->assertText("{$base}label1", "Button 2 (default) Clicked!");
- }
-}
-
+<?php + +class Ticket586TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket586'); + $this->verifyTitle("Verifying Ticket 586", ""); + + $this->assertText("{$base}label1", "Status"); + $this->clickAndWait("{$base}button1"); + $this->assertText("{$base}label1", "Button 1 Clicked!"); + + $this->type("{$base}text1", "testing"); + $this->keyDownAndWait("{$base}text1", '\13'); + $this->assertText("{$base}label1", "Button 2 (default) Clicked!"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket587TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket587TestCase.php index 6624b5ba..f8255a2f 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket587TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket587TestCase.php @@ -1,47 +1,47 @@ -<?php
-
-class Ticket587TestCase extends SeleniumTestCase
-{
- function testKeyPress()
- {
- $this->skipBrowsers(self::INTERNET_EXPLORER);
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket587_reopened');
- $this->assertTitle("Verifying Ticket 587_reopened");
-
- $this->assertText($base."label1", "Label 1");
- $this->select($base."list1", "item 3");
- $this->pause(800);
- $this->select($base."list2", "value 3 - item 4");
- $this->pause(800);
- $this->assertText($base."label1", "Selection 2: value 3 - item 4");
-
- $this->keyPress($base.'text1', 't');
- $this->pause(800);
- $this->select($base."list2", "asd 3 - item 2");
- $this->pause(800);
- $this->assertText($base."label1", "Selection 2: asd 3 - item 2");
- }
-
- function testButtonClick()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket587_reopened');
- $this->assertTitle("Verifying Ticket 587_reopened");
-
- $this->assertText($base."label1", "Label 1");
- $this->select($base."list1", "item 3");
- $this->pause(800);
- $this->select($base."list2", "value 3 - item 4");
- $this->pause(800);
- $this->assertText($base."label1", "Selection 2: value 3 - item 4");
-
- $this->click($base.'button6');
- $this->pause(800);
- $this->select($base."list2", "asd 3 - item 2");
- $this->pause(800);
- $this->assertText($base."label1", "Selection 2: asd 3 - item 2");
- }
-}
-
+<?php + +class Ticket587TestCase extends SeleniumTestCase +{ + function testKeyPress() + { + $this->skipBrowsers(self::INTERNET_EXPLORER); + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket587_reopened'); + $this->assertTitle("Verifying Ticket 587_reopened"); + + $this->assertText($base."label1", "Label 1"); + $this->select($base."list1", "item 3"); + $this->pause(800); + $this->select($base."list2", "value 3 - item 4"); + $this->pause(800); + $this->assertText($base."label1", "Selection 2: value 3 - item 4"); + + $this->keyPress($base.'text1', 't'); + $this->pause(800); + $this->select($base."list2", "asd 3 - item 2"); + $this->pause(800); + $this->assertText($base."label1", "Selection 2: asd 3 - item 2"); + } + + function testButtonClick() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket587_reopened'); + $this->assertTitle("Verifying Ticket 587_reopened"); + + $this->assertText($base."label1", "Label 1"); + $this->select($base."list1", "item 3"); + $this->pause(800); + $this->select($base."list2", "value 3 - item 4"); + $this->pause(800); + $this->assertText($base."label1", "Selection 2: value 3 - item 4"); + + $this->click($base.'button6'); + $this->pause(800); + $this->select($base."list2", "asd 3 - item 2"); + $this->pause(800); + $this->assertText($base."label1", "Selection 2: asd 3 - item 2"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket653TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket653TestCase.php index c25eb25f..d4a05fd8 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket653TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket653TestCase.php @@ -1,15 +1,15 @@ -<?php
-
-class Ticket653TestCase extends SeleniumTestCase
-{
- function test()
- {
- // Open with 'Friendly URL'
- $this->open('tickets/index.php/ticket653');
- $this->verifyTitle("Verifying Ticket 653", "");
-
- $this->assertText('textspan', 'This is the page for Ticket653');
- }
-}
-
+<?php + +class Ticket653TestCase extends SeleniumTestCase +{ + function test() + { + // Open with 'Friendly URL' + $this->open('tickets/index.php/ticket653'); + $this->verifyTitle("Verifying Ticket 653", ""); + + $this->assertText('textspan', 'This is the page for Ticket653'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket659TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket659TestCase.php index 70c52f35..8d705772 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket659TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket659TestCase.php @@ -1,23 +1,23 @@ -<?php
-
-class Ticket659TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- // Normal component (working)
- $this->open('tickets/index.php?page=ToggleTest');
- $this->assertText("${base}lbl", "Down");
- $this->click("${base}btn", "");
- $this->pause(800);
- $this->assertText("${base}lbl", "Up");
- // Extended component (not working)
- $this->open('tickets/index.php?page=Ticket659');
- $this->assertText("${base}lbl", "Down");
- $this->click("${base}btn", "");
- $this->pause(800);
- $this->assertText("${base}lbl", "Up");
- }
-}
-
+<?php + +class Ticket659TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + // Normal component (working) + $this->open('tickets/index.php?page=ToggleTest'); + $this->assertText("${base}lbl", "Down"); + $this->click("${base}btn", ""); + $this->pause(800); + $this->assertText("${base}lbl", "Up"); + // Extended component (not working) + $this->open('tickets/index.php?page=Ticket659'); + $this->assertText("${base}lbl", "Down"); + $this->click("${base}btn", ""); + $this->pause(800); + $this->assertText("${base}lbl", "Up"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket700TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket700TestCase.php index e7ff30b3..c8929693 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket700TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket700TestCase.php @@ -1,72 +1,72 @@ -<?php
-class Ticket700TestCase extends SeleniumTestCase
-{
- function test()
- {
- // page: Home
- $this->open('tickets/index700.php');
- $this->clickAndWait('ctl0_Logout');
- $this->clickAndWait('pageHome');
- $this->assertTitle("Home");
- $this->assertTextPresent('|Param1: Set at app config|');
- $this->assertTextPresent('|Param2: Set at root|');
- $this->assertTextPresent('|Param3: default 3|');
- $this->assertTextPresent('|Param4: default 4|');
- $this->assertTextPresent('|Param5: Set at root|');
-
- // page: admin.Home
- $this->clickAndWait('pageAdminHome');
- $this->assertTitle('UserLogin');
- $this->type('ctl0_Main_Username','AdminUser');
- $this->type('ctl0_Main_Password','demo');
- $this->clickAndWait('ctl0_Main_LoginButton');
- $this->clickAndWait('pageAdminHome');
- $this->assertTitle('admin.Home');
- $this->assertTextPresent('|Param1: Set at app config|');
- $this->assertTextPresent('|Param2: Set at admin|');
- $this->assertTextPresent('|Param3: Set at admin|');
- $this->assertTextPresent('|Param4: Set at app config|');
- $this->assertTextPresent('|Param5: Set at app config|');
-
- // page: admin.Home2
- $this->clickAndWait('pageAdminHome2');
- $this->assertTitle('admin.Home2');
- $this->clickAndWait('ctl0_Logout');
- $this->clickAndWait('pageAdminHome2');
- $this->assertTitle('admin.Home2');
-
- // page: admin.users.Home
- $this->clickAndWait('pageAdminUsersHome');
- $this->assertTitle('UserLogin');
- $this->type('ctl0_Main_Username','NormalUser');
- $this->type('ctl0_Main_Password','demo');
- $this->clickAndWait('ctl0_Main_LoginButton');
- $this->clickAndWait('pageAdminUsersHome');
- $this->assertTitle('UserLogin');
- $this->type('ctl0_Main_Username','AdminUser');
- $this->type('ctl0_Main_Password','demo');
- $this->clickAndWait('ctl0_Main_LoginButton');
- $this->clickAndWait('pageAdminUsersHome');
- $this->assertTitle('admin.users.Home');
- $this->assertTextPresent('|Param1: Set at admin|');
- $this->assertTextPresent('|Param2: Set at admin.users|');
- $this->assertTextPresent('|Param3: default 3|');
- $this->assertTextPresent('|Param4: Set at admin|');
- $this->assertTextPresent('|Param5: Set at app config|');
-
- // page: admin.users.Home2
- $this->clickAndWait('pageAdminUsersHome2');
- $this->assertTitle('admin.users.Home2');
-
- // page: content.Home
- $this->clickAndWait('pageContentHome');
- $this->assertTitle('content.Home');
- $this->assertTextPresent('|Param1: Set at app config|');
- $this->assertTextPresent('|Param2: Set at root|');
- $this->assertTextPresent('|Param3: default 3|');
- $this->assertTextPresent('|Param4: default 4|');
- $this->assertTextPresent('|Param5: Set at app config|');
- $this->clickAndWait('ctl0_Logout');
- }
-}
+<?php +class Ticket700TestCase extends SeleniumTestCase +{ + function test() + { + // page: Home + $this->open('tickets/index700.php'); + $this->clickAndWait('ctl0_Logout'); + $this->clickAndWait('pageHome'); + $this->assertTitle("Home"); + $this->assertTextPresent('|Param1: Set at app config|'); + $this->assertTextPresent('|Param2: Set at root|'); + $this->assertTextPresent('|Param3: default 3|'); + $this->assertTextPresent('|Param4: default 4|'); + $this->assertTextPresent('|Param5: Set at root|'); + + // page: admin.Home + $this->clickAndWait('pageAdminHome'); + $this->assertTitle('UserLogin'); + $this->type('ctl0_Main_Username','AdminUser'); + $this->type('ctl0_Main_Password','demo'); + $this->clickAndWait('ctl0_Main_LoginButton'); + $this->clickAndWait('pageAdminHome'); + $this->assertTitle('admin.Home'); + $this->assertTextPresent('|Param1: Set at app config|'); + $this->assertTextPresent('|Param2: Set at admin|'); + $this->assertTextPresent('|Param3: Set at admin|'); + $this->assertTextPresent('|Param4: Set at app config|'); + $this->assertTextPresent('|Param5: Set at app config|'); + + // page: admin.Home2 + $this->clickAndWait('pageAdminHome2'); + $this->assertTitle('admin.Home2'); + $this->clickAndWait('ctl0_Logout'); + $this->clickAndWait('pageAdminHome2'); + $this->assertTitle('admin.Home2'); + + // page: admin.users.Home + $this->clickAndWait('pageAdminUsersHome'); + $this->assertTitle('UserLogin'); + $this->type('ctl0_Main_Username','NormalUser'); + $this->type('ctl0_Main_Password','demo'); + $this->clickAndWait('ctl0_Main_LoginButton'); + $this->clickAndWait('pageAdminUsersHome'); + $this->assertTitle('UserLogin'); + $this->type('ctl0_Main_Username','AdminUser'); + $this->type('ctl0_Main_Password','demo'); + $this->clickAndWait('ctl0_Main_LoginButton'); + $this->clickAndWait('pageAdminUsersHome'); + $this->assertTitle('admin.users.Home'); + $this->assertTextPresent('|Param1: Set at admin|'); + $this->assertTextPresent('|Param2: Set at admin.users|'); + $this->assertTextPresent('|Param3: default 3|'); + $this->assertTextPresent('|Param4: Set at admin|'); + $this->assertTextPresent('|Param5: Set at app config|'); + + // page: admin.users.Home2 + $this->clickAndWait('pageAdminUsersHome2'); + $this->assertTitle('admin.users.Home2'); + + // page: content.Home + $this->clickAndWait('pageContentHome'); + $this->assertTitle('content.Home'); + $this->assertTextPresent('|Param1: Set at app config|'); + $this->assertTextPresent('|Param2: Set at root|'); + $this->assertTextPresent('|Param3: default 3|'); + $this->assertTextPresent('|Param4: default 4|'); + $this->assertTextPresent('|Param5: Set at app config|'); + $this->clickAndWait('ctl0_Logout'); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket703TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket703TestCase.php index d497bb34..b001aa28 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket703TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket703TestCase.php @@ -1,21 +1,21 @@ -<?php
-class Ticket703TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket703.Ticket703');
- $this->assertTitle("Verifying Ticket703.Ticket703 703.703");
- // Start with an empty log
- $this->click($base.'ctl2');
- // Wait for callback to be lanched
- $this->pause(2000);
- $this->assertText($base.'logBox', "");
- $this->type($base.'logMessage', "Test of prado logging system");
- $this->click($base.'ctl0');
- $this->pause(800);
- $this->click($base.'ctl1');
- $this->assertTextPresent($base.'logBox', "Test of prado logging system");
- }
-}
+<?php +class Ticket703TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket703.Ticket703'); + $this->assertTitle("Verifying Ticket703.Ticket703 703.703"); + // Start with an empty log + $this->click($base.'ctl2'); + // Wait for callback to be lanched + $this->pause(2000); + $this->assertText($base.'logBox', ""); + $this->type($base.'logMessage', "Test of prado logging system"); + $this->click($base.'ctl0'); + $this->pause(800); + $this->click($base.'ctl1'); + $this->assertTextPresent($base.'logBox', "Test of prado logging system"); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket708TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket708TestCase.php index 77978141..7c9f706b 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket708TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket708TestCase.php @@ -1,28 +1,28 @@ -<?php
-class Ticket708TestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = 'ctl0_Content_';
- $this->open('tickets/index.php?page=Ticket708');
- $this->assertTitle("Verifying Ticket 708");
-
- $this->click($base."grid_ctl1_RadioButton");
- $this->pause(800);
- $this->assertText($base."Result", "You have selected Radio Button #1");
-
- $this->click($base."grid_ctl2_RadioButton");
- $this->pause(800);
- $this->assertText($base."Result", "You have selected Radio Button #2");
-
- $this->click($base."grid_ctl3_RadioButton");
- $this->pause(800);
- $this->assertText($base."Result", "You have selected Radio Button #3");
-
- $this->click($base."grid_ctl4_RadioButton");
- $this->pause(800);
- $this->assertText($base."Result", "You have selected Radio Button #4");
- }
-
-}
+<?php +class Ticket708TestCase extends SeleniumTestCase +{ + function test() + { + $base = 'ctl0_Content_'; + $this->open('tickets/index.php?page=Ticket708'); + $this->assertTitle("Verifying Ticket 708"); + + $this->click($base."grid_ctl1_RadioButton"); + $this->pause(800); + $this->assertText($base."Result", "You have selected Radio Button #1"); + + $this->click($base."grid_ctl2_RadioButton"); + $this->pause(800); + $this->assertText($base."Result", "You have selected Radio Button #2"); + + $this->click($base."grid_ctl3_RadioButton"); + $this->pause(800); + $this->assertText($base."Result", "You have selected Radio Button #3"); + + $this->click($base."grid_ctl4_RadioButton"); + $this->pause(800); + $this->assertText($base."Result", "You have selected Radio Button #4"); + } + +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket72TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket72TestCase.php index 6d864899..346b08e3 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket72TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket72TestCase.php @@ -1,16 +1,16 @@ -<?php
-
-class Ticket72TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket72');
- $this->type("ctl0\$Content\$K1", "abc");
- $this->type("ctl0\$Content\$K2", "efg");
- $this->clickAndWait("//input[@type='submit' and @value='Send']", "");
- $this->verifyTextPresent("efg", "");
- $this->verifyTextNotPresent("abcefg", "");
- }
-}
-
+<?php + +class Ticket72TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket72'); + $this->type("ctl0\$Content\$K1", "abc"); + $this->type("ctl0\$Content\$K2", "efg"); + $this->clickAndWait("//input[@type='submit' and @value='Send']", ""); + $this->verifyTextPresent("efg", ""); + $this->verifyTextNotPresent("abcefg", ""); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket93TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket93TestCase.php index 6a286ffe..8d11f98b 100644 --- a/tests/FunctionalTests/tickets/tests/Ticket93TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket93TestCase.php @@ -1,16 +1,16 @@ -<?php
-/*
- * Created on 13/04/2006
- *
- */
-
-class Ticket93TestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('tickets/index.php?page=Ticket93');
- $this->verifyTextPresent("ValidationGroups without any inputs with grouping");
- }
-
-}
-?>
+<?php +/* + * Created on 13/04/2006 + * + */ + +class Ticket93TestCase extends SeleniumTestCase +{ + function test() + { + $this->open('tickets/index.php?page=Ticket93'); + $this->verifyTextPresent("ValidationGroups without any inputs with grouping"); + } + +} +?> diff --git a/tests/FunctionalTests/validators/protected/pages/Button.php b/tests/FunctionalTests/validators/protected/pages/Button.php index 3dbbc7d6..94aaf6c8 100644 --- a/tests/FunctionalTests/validators/protected/pages/Button.php +++ b/tests/FunctionalTests/validators/protected/pages/Button.php @@ -1,27 +1,27 @@ -<?php
-
-class Button extends TPage
-{
- public function button1Clicked($sender,$param)
- {
- $this->Result1->Text="Button1 is clicked";
- if($this->IsValid)
- $this->Result1->Text.=' and valid';
- }
-
- public function button2Clicked($sender,$param)
- {
- $this->Result2->Text="Button2 is clicked";
- if($this->IsValid)
- $this->Result2->Text.=' and valid';
- }
-
- public function button3Clicked($sender,$param)
- {
- $this->Result3->Text="Button3 is clicked";
- if($this->IsValid)
- $this->Result3->Text.=' and valid';
- }
-}
-
+<?php + +class Button extends TPage +{ + public function button1Clicked($sender,$param) + { + $this->Result1->Text="Button1 is clicked"; + if($this->IsValid) + $this->Result1->Text.=' and valid'; + } + + public function button2Clicked($sender,$param) + { + $this->Result2->Text="Button2 is clicked"; + if($this->IsValid) + $this->Result2->Text.=' and valid'; + } + + public function button3Clicked($sender,$param) + { + $this->Result3->Text="Button3 is clicked"; + if($this->IsValid) + $this->Result3->Text.=' and valid'; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/protected/pages/CheckBox.php b/tests/FunctionalTests/validators/protected/pages/CheckBox.php index 700ac171..f29792e0 100644 --- a/tests/FunctionalTests/validators/protected/pages/CheckBox.php +++ b/tests/FunctionalTests/validators/protected/pages/CheckBox.php @@ -1,27 +1,27 @@ -<?php
-
-class CheckBox extends TPage
-{
- public function button1Clicked($sender,$param)
- {
- $this->Result1->Text="Button1 is clicked";
- if($this->IsValid)
- $this->Result1->Text.=' and valid';
- }
-
- public function button2Clicked($sender,$param)
- {
- $this->Result2->Text="Button2 is clicked";
- if($this->IsValid)
- $this->Result2->Text.=' and valid';
- }
-
- public function button3Clicked($sender,$param)
- {
- $this->Result3->Text="Button3 is clicked";
- if($this->IsValid)
- $this->Result3->Text.=' and valid';
- }
-}
-
+<?php + +class CheckBox extends TPage +{ + public function button1Clicked($sender,$param) + { + $this->Result1->Text="Button1 is clicked"; + if($this->IsValid) + $this->Result1->Text.=' and valid'; + } + + public function button2Clicked($sender,$param) + { + $this->Result2->Text="Button2 is clicked"; + if($this->IsValid) + $this->Result2->Text.=' and valid'; + } + + public function button3Clicked($sender,$param) + { + $this->Result3->Text="Button3 is clicked"; + if($this->IsValid) + $this->Result3->Text.=' and valid'; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php b/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php index 7756566c..83546617 100644 --- a/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php +++ b/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php @@ -1,20 +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;
- }
-}
-
-?>
+<?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/protected/pages/CustomValidator.php b/tests/FunctionalTests/validators/protected/pages/CustomValidator.php index ed1f9433..b56a9d8b 100644 --- a/tests/FunctionalTests/validators/protected/pages/CustomValidator.php +++ b/tests/FunctionalTests/validators/protected/pages/CustomValidator.php @@ -1,14 +1,14 @@ -<?php
-/*
- * Created on 16/04/2006
- */
-
-class CustomValidator extends TPage
-{
- function CustomValidation($sender, $params)
- {
- $params->isValid = $this->text1->Text == "Prado";
- }
-}
-
-?>
+<?php +/* + * Created on 16/04/2006 + */ + +class CustomValidator extends TPage +{ + function CustomValidation($sender, $params) + { + $params->isValid = $this->text1->Text == "Prado"; + } +} + +?> diff --git a/tests/FunctionalTests/validators/protected/pages/ImageButton.php b/tests/FunctionalTests/validators/protected/pages/ImageButton.php index ecedd5bf..65392b75 100644 --- a/tests/FunctionalTests/validators/protected/pages/ImageButton.php +++ b/tests/FunctionalTests/validators/protected/pages/ImageButton.php @@ -1,27 +1,27 @@ -<?php
-
-class ImageButton extends TPage
-{
- public function button1Clicked($sender,$param)
- {
- $this->Result1->Text="Button1 is clicked";
- if($this->IsValid)
- $this->Result1->Text.=' and valid';
- }
-
- public function button2Clicked($sender,$param)
- {
- $this->Result2->Text="Button2 is clicked";
- if($this->IsValid)
- $this->Result2->Text.=' and valid';
- }
-
- public function button3Clicked($sender,$param)
- {
- $this->Result3->Text="Button3 is clicked";
- if($this->IsValid)
- $this->Result3->Text.=' and valid';
- }
-}
-
+<?php + +class ImageButton extends TPage +{ + public function button1Clicked($sender,$param) + { + $this->Result1->Text="Button1 is clicked"; + if($this->IsValid) + $this->Result1->Text.=' and valid'; + } + + public function button2Clicked($sender,$param) + { + $this->Result2->Text="Button2 is clicked"; + if($this->IsValid) + $this->Result2->Text.=' and valid'; + } + + public function button3Clicked($sender,$param) + { + $this->Result3->Text="Button3 is clicked"; + if($this->IsValid) + $this->Result3->Text.=' and valid'; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/protected/pages/Layout.php b/tests/FunctionalTests/validators/protected/pages/Layout.php index ba96038b..7f5e5802 100644 --- a/tests/FunctionalTests/validators/protected/pages/Layout.php +++ b/tests/FunctionalTests/validators/protected/pages/Layout.php @@ -1,7 +1,7 @@ -<?php
-
-class Layout extends TTemplateControl
-{
-}
-
+<?php + +class Layout extends TTemplateControl +{ +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/protected/pages/LinkButton.php b/tests/FunctionalTests/validators/protected/pages/LinkButton.php index 5130dd01..2b5a3c23 100644 --- a/tests/FunctionalTests/validators/protected/pages/LinkButton.php +++ b/tests/FunctionalTests/validators/protected/pages/LinkButton.php @@ -1,27 +1,27 @@ -<?php
-
-class LinkButton extends TPage
-{
- public function button1Clicked($sender,$param)
- {
- $this->Result1->Text="Button1 is clicked";
- if($this->IsValid)
- $this->Result1->Text.=' and valid';
- }
-
- public function button2Clicked($sender,$param)
- {
- $this->Result2->Text="Button2 is clicked";
- if($this->IsValid)
- $this->Result2->Text.=' and valid';
- }
-
- public function button3Clicked($sender,$param)
- {
- $this->Result3->Text="Button3 is clicked";
- if($this->IsValid)
- $this->Result3->Text.=' and valid';
- }
-}
-
+<?php + +class LinkButton extends TPage +{ + public function button1Clicked($sender,$param) + { + $this->Result1->Text="Button1 is clicked"; + if($this->IsValid) + $this->Result1->Text.=' and valid'; + } + + public function button2Clicked($sender,$param) + { + $this->Result2->Text="Button2 is clicked"; + if($this->IsValid) + $this->Result2->Text.=' and valid'; + } + + public function button3Clicked($sender,$param) + { + $this->Result3->Text="Button3 is clicked"; + if($this->IsValid) + $this->Result3->Text.=' and valid'; + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/ButtonTestCase.php b/tests/FunctionalTests/validators/tests/ButtonTestCase.php index 46e037dc..99ebf4a4 100644 --- a/tests/FunctionalTests/validators/tests/ButtonTestCase.php +++ b/tests/FunctionalTests/validators/tests/ButtonTestCase.php @@ -1,65 +1,65 @@ -<?php
-
-class ButtonTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('validators/index.php?page=Button');
-
-
- // verify all error messages are invisible
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the first validator shows the error
- $this->click("ctl0_Content_ctl1");
- $this->verifyVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the first validation is passed
- $this->pause(500);
- $this->verifyTextNotPresent('Button1 is clicked');
- $this->type("ctl0_Content_TextBox1", "test");
- $this->clickAndWait("ctl0_Content_ctl1");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button1 is clicked and valid');
-
- // verify the second validator shows the error
- $this->click("ctl0_Content_ctl3");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the second validation is passed
- $this->pause(500);
- $this->verifyTextNotPresent('Button2 is clicked');
- $this->type("ctl0_Content_TextBox2", "test");
- $this->clickAndWait("ctl0_Content_ctl3");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button2 is clicked and valid');
-
- // verify the third validator shows the error
- $this->clickAndWait("ctl0_Content_ctl5");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyVisible('ctl0_Content_ctl4');
-
- // verify the third validation is passed
- $this->verifyTextPresent('Button3 is clicked');
- $this->verifyTextNotPresent('Button3 is clicked and valid');
- $this->type("ctl0_Content_TextBox3", "test");
- $this->clickAndWait("ctl0_Content_ctl5");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button3 is clicked and valid');
- }
-}
-
+<?php + +class ButtonTestCase extends SeleniumTestCase +{ + function test() + { + $this->open('validators/index.php?page=Button'); + + + // verify all error messages are invisible + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the first validator shows the error + $this->click("ctl0_Content_ctl1"); + $this->verifyVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the first validation is passed + $this->pause(500); + $this->verifyTextNotPresent('Button1 is clicked'); + $this->type("ctl0_Content_TextBox1", "test"); + $this->clickAndWait("ctl0_Content_ctl1"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button1 is clicked and valid'); + + // verify the second validator shows the error + $this->click("ctl0_Content_ctl3"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the second validation is passed + $this->pause(500); + $this->verifyTextNotPresent('Button2 is clicked'); + $this->type("ctl0_Content_TextBox2", "test"); + $this->clickAndWait("ctl0_Content_ctl3"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button2 is clicked and valid'); + + // verify the third validator shows the error + $this->clickAndWait("ctl0_Content_ctl5"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyVisible('ctl0_Content_ctl4'); + + // verify the third validation is passed + $this->verifyTextPresent('Button3 is clicked'); + $this->verifyTextNotPresent('Button3 is clicked and valid'); + $this->type("ctl0_Content_TextBox3", "test"); + $this->clickAndWait("ctl0_Content_ctl5"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button3 is clicked and valid'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/CheckBoxTestCase.php b/tests/FunctionalTests/validators/tests/CheckBoxTestCase.php index 41c588ee..957a7cbf 100644 --- a/tests/FunctionalTests/validators/tests/CheckBoxTestCase.php +++ b/tests/FunctionalTests/validators/tests/CheckBoxTestCase.php @@ -1,70 +1,70 @@ -<?php
-
-class CheckBoxTestCase extends SeleniumTestCase
-{
- function test()
- {
- //problem with test runner clicking on radio buttons
- $this->skipBrowsers(self::OPERA);
-
- $this->open('validators/index.php?page=CheckBox');
-
-
- // verify all error messages are invisible
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the first validator shows the error
- $this->click("ctl0_Content_ctl1");
- $this->verifyVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the first validation is passed
- $this->pause(500);
- $this->verifyTextNotPresent('Button1 is clicked');
- $this->type("ctl0_Content_TextBox1", "test");
- $this->clickAndWait("ctl0_Content_ctl1");
- $this->clickAndWait("ctl0_Content_ctl1");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button1 is clicked and valid');
-
- // verify the second validator shows the error
- $this->click("ctl0_Content_ctl3");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the second validation is passed
- $this->pause(500);
- $this->verifyTextNotPresent('Button2 is clicked');
- $this->type("ctl0_Content_TextBox2", "test");
- $this->clickAndWait("ctl0_Content_ctl3");
- $this->clickAndWait("ctl0_Content_ctl3");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button2 is clicked and valid');
-
- // verify the third validator shows the error
- $this->clickAndWait("ctl0_Content_ctl5");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyVisible('ctl0_Content_ctl4');
-
- // verify the third validation is passed
- $this->verifyTextPresent('Button3 is clicked');
- $this->verifyTextNotPresent('Button3 is clicked and valid');
- $this->type("ctl0_Content_TextBox3", "test");
- $this->clickAndWait("ctl0_Content_ctl5");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button3 is clicked and valid');
- }
-}
-
+<?php + +class CheckBoxTestCase extends SeleniumTestCase +{ + function test() + { + //problem with test runner clicking on radio buttons + $this->skipBrowsers(self::OPERA); + + $this->open('validators/index.php?page=CheckBox'); + + + // verify all error messages are invisible + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the first validator shows the error + $this->click("ctl0_Content_ctl1"); + $this->verifyVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the first validation is passed + $this->pause(500); + $this->verifyTextNotPresent('Button1 is clicked'); + $this->type("ctl0_Content_TextBox1", "test"); + $this->clickAndWait("ctl0_Content_ctl1"); + $this->clickAndWait("ctl0_Content_ctl1"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button1 is clicked and valid'); + + // verify the second validator shows the error + $this->click("ctl0_Content_ctl3"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the second validation is passed + $this->pause(500); + $this->verifyTextNotPresent('Button2 is clicked'); + $this->type("ctl0_Content_TextBox2", "test"); + $this->clickAndWait("ctl0_Content_ctl3"); + $this->clickAndWait("ctl0_Content_ctl3"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button2 is clicked and valid'); + + // verify the third validator shows the error + $this->clickAndWait("ctl0_Content_ctl5"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyVisible('ctl0_Content_ctl4'); + + // verify the third validation is passed + $this->verifyTextPresent('Button3 is clicked'); + $this->verifyTextNotPresent('Button3 is clicked and valid'); + $this->type("ctl0_Content_TextBox3", "test"); + $this->clickAndWait("ctl0_Content_ctl5"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button3 is clicked and valid'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/CompareValidatorTestCase.php b/tests/FunctionalTests/validators/tests/CompareValidatorTestCase.php index b0f7c407..5a7dbc80 100644 --- a/tests/FunctionalTests/validators/tests/CompareValidatorTestCase.php +++ b/tests/FunctionalTests/validators/tests/CompareValidatorTestCase.php @@ -1,46 +1,46 @@ -<?php
-
-//New Test
-class CompareValidatorTestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = "ctl0_Content_";
-
- $this->open("validators/index.php?page=CompareValidator", "");
- $this->verifyTextPresent("Prado CompareValidator Tests", "");
-
- $this->type("{$base}text1", "qwe");
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
-
- $this->click("//input[@type='submit' and @value='Test']", "");
-
- $this->type("{$base}text2", "1234");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1");
-
- $this->type("{$base}text2", "qwe");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
-
-
- $this->type("{$base}text3", "12312");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator2");
-
- $this->type("{$base}text3", "13/1/2005");
- $this->assertVisible("{$base}validator2");
-
-
- $this->type("{$base}text3", "12/1/2005");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
-
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
-
- }
-}
-
+<?php + +//New Test +class CompareValidatorTestCase extends SeleniumTestCase +{ + function test() + { + $base = "ctl0_Content_"; + + $this->open("validators/index.php?page=CompareValidator", ""); + $this->verifyTextPresent("Prado CompareValidator Tests", ""); + + $this->type("{$base}text1", "qwe"); + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + + $this->click("//input[@type='submit' and @value='Test']", ""); + + $this->type("{$base}text2", "1234"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1"); + + $this->type("{$base}text2", "qwe"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + + + $this->type("{$base}text3", "12312"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator2"); + + $this->type("{$base}text3", "13/1/2005"); + $this->assertVisible("{$base}validator2"); + + + $this->type("{$base}text3", "12/1/2005"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php b/tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php index 7191ff9f..0c0ffc51 100644 --- a/tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php +++ b/tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php @@ -1,55 +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", "");
-
- }
-
-}
-
-?>
+<?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", ""); + + } + +} + +?> diff --git a/tests/FunctionalTests/validators/tests/CustomValidatorTestCase.php b/tests/FunctionalTests/validators/tests/CustomValidatorTestCase.php index 3a5daa6a..c5cbae8e 100644 --- a/tests/FunctionalTests/validators/tests/CustomValidatorTestCase.php +++ b/tests/FunctionalTests/validators/tests/CustomValidatorTestCase.php @@ -1,31 +1,31 @@ -<?php
-
-//New Test
-class CustomValidatorTestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = "ctl0_Content_";
- $this->open("validators/index.php?page=CustomValidator", "");
- $this->assertTextPresent("Prado CustomValidator Tests", "");
- $this->assertNotVisible("{$base}validator1");
-
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1");
-
- $this->type("{$base}text1", "Prado");
- $this->pause(250);
- $this->assertNotVisible("{$base}validator1");
- $this->type("{$base}text1", "Testing");
- $this->pause(250);
- $this->assertVisible("{$base}validator1");
- $this->type("{$base}text1", "Prado");
- $this->pause(250);
- $this->assertNotVisible("{$base}validator1");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator1");
-
- }
-}
-
+<?php + +//New Test +class CustomValidatorTestCase extends SeleniumTestCase +{ + function test() + { + $base = "ctl0_Content_"; + $this->open("validators/index.php?page=CustomValidator", ""); + $this->assertTextPresent("Prado CustomValidator Tests", ""); + $this->assertNotVisible("{$base}validator1"); + + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1"); + + $this->type("{$base}text1", "Prado"); + $this->pause(250); + $this->assertNotVisible("{$base}validator1"); + $this->type("{$base}text1", "Testing"); + $this->pause(250); + $this->assertVisible("{$base}validator1"); + $this->type("{$base}text1", "Prado"); + $this->pause(250); + $this->assertNotVisible("{$base}validator1"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator1"); + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/DataTypeValidatorTestCase.php b/tests/FunctionalTests/validators/tests/DataTypeValidatorTestCase.php index 153be373..c7c4bdb6 100644 --- a/tests/FunctionalTests/validators/tests/DataTypeValidatorTestCase.php +++ b/tests/FunctionalTests/validators/tests/DataTypeValidatorTestCase.php @@ -1,49 +1,49 @@ -<?php
-/*
- * Created on 25/04/2006
- */
-
-class DataTypeValidatorTestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = "ctl0_Content_";
- $this->open("validators/index.php?page=DataTypeValidator", "");
- $this->verifyTextPresent("Data Type Validator Tests", "");
- $this->click("//input[@type='submit' and @value='submit!']", "");
-
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
- $this->assertNotVisible("{$base}validator3");
-
- $this->type("{$base}textbox1", "a");
- $this->type("{$base}textbox2", "b");
- $this->type("{$base}textbox3", "c");
- $this->click("//input[@type='submit' and @value='submit!']", "");
-
- $this->assertVisible("{$base}validator1");
- $this->assertVisible("{$base}validator2");
- $this->assertVisible("{$base}validator3");
-
- $this->type("{$base}textbox1", "12");
- $this->type("{$base}textbox2", "12.5");
- $this->type("{$base}textbox3", "2/10/2005");
- $this->clickAndWait("//input[@type='submit' and @value='submit!']", "");
-
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
- $this->assertNotVisible("{$base}validator3");
-
- $this->type("{$base}textbox1", "12.2");
- $this->type("{$base}textbox2", "-12.5");
- $this->type("{$base}textbox3", "2/13/2005");
- $this->click("//input[@type='submit' and @value='submit!']", "");
-
- $this->assertVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
- $this->assertVisible("{$base}validator3");
- }
-
-}
-
-?>
+<?php +/* + * Created on 25/04/2006 + */ + +class DataTypeValidatorTestCase extends SeleniumTestCase +{ + function test() + { + $base = "ctl0_Content_"; + $this->open("validators/index.php?page=DataTypeValidator", ""); + $this->verifyTextPresent("Data Type Validator Tests", ""); + $this->click("//input[@type='submit' and @value='submit!']", ""); + + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + $this->assertNotVisible("{$base}validator3"); + + $this->type("{$base}textbox1", "a"); + $this->type("{$base}textbox2", "b"); + $this->type("{$base}textbox3", "c"); + $this->click("//input[@type='submit' and @value='submit!']", ""); + + $this->assertVisible("{$base}validator1"); + $this->assertVisible("{$base}validator2"); + $this->assertVisible("{$base}validator3"); + + $this->type("{$base}textbox1", "12"); + $this->type("{$base}textbox2", "12.5"); + $this->type("{$base}textbox3", "2/10/2005"); + $this->clickAndWait("//input[@type='submit' and @value='submit!']", ""); + + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + $this->assertNotVisible("{$base}validator3"); + + $this->type("{$base}textbox1", "12.2"); + $this->type("{$base}textbox2", "-12.5"); + $this->type("{$base}textbox3", "2/13/2005"); + $this->click("//input[@type='submit' and @value='submit!']", ""); + + $this->assertVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + $this->assertVisible("{$base}validator3"); + } + +} + +?> diff --git a/tests/FunctionalTests/validators/tests/DatePickerTestCase.php b/tests/FunctionalTests/validators/tests/DatePickerTestCase.php index cdab46ab..12368448 100644 --- a/tests/FunctionalTests/validators/tests/DatePickerTestCase.php +++ b/tests/FunctionalTests/validators/tests/DatePickerTestCase.php @@ -1,72 +1,72 @@ -<?php
-
-class DatePickerTestCase extends SeleniumTestCase
-{
- function test()
- {
- $year=2012;
- $year2=2013;
- $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", "");
-
- //the range validator is visible because the date is a drop down list
- //thus has default value != ""
- $this->assertVisible("{$base}validator4", "");
- $this->assertVisible("{$base}validator5", "");
- $this->assertNotVisible("{$base}validator6", "");
- $this->assertVisible("{$base}validator8", "");
-
- $this->click("{$base}submit1");
- $this->pause(250);
- $this->type("{$base}picker1", "13/4/$year");
- $this->select("{$base}picker2_month", "label=9");
- $this->select("{$base}picker2_day", "label=10");
- $this->select("{$base}picker2_year", "label=$year");
- $this->pause(250);
- $this->type("{$base}picker3", "14/4/$year");
- $this->pause(250);
- $this->type("{$base}picker4", "7/4/$year");
- $this->select("{$base}picker5_day", "label=6");
- $this->select("{$base}picker5_month", "label=3");
- $this->select("{$base}picker5_year", "label=$year2");
- $this->select("{$base}picker6_month", "label=3");
- $this->select("{$base}picker6_year", "label=$year2");
- $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/$year2");
- $this->type("{$base}picker4", "29/4/$year");
- $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", "");
- }
-
-}
-
-?>
+<?php + +class DatePickerTestCase extends SeleniumTestCase +{ + function test() + { + $year=2012; + $year2=2013; + $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", ""); + + //the range validator is visible because the date is a drop down list + //thus has default value != "" + $this->assertVisible("{$base}validator4", ""); + $this->assertVisible("{$base}validator5", ""); + $this->assertNotVisible("{$base}validator6", ""); + $this->assertVisible("{$base}validator8", ""); + + $this->click("{$base}submit1"); + $this->pause(250); + $this->type("{$base}picker1", "13/4/$year"); + $this->select("{$base}picker2_month", "label=9"); + $this->select("{$base}picker2_day", "label=10"); + $this->select("{$base}picker2_year", "label=$year"); + $this->pause(250); + $this->type("{$base}picker3", "14/4/$year"); + $this->pause(250); + $this->type("{$base}picker4", "7/4/$year"); + $this->select("{$base}picker5_day", "label=6"); + $this->select("{$base}picker5_month", "label=3"); + $this->select("{$base}picker5_year", "label=$year2"); + $this->select("{$base}picker6_month", "label=3"); + $this->select("{$base}picker6_year", "label=$year2"); + $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/$year2"); + $this->type("{$base}picker4", "29/4/$year"); + $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", ""); + } + +} + +?> diff --git a/tests/FunctionalTests/validators/tests/ImageButtonTestCase.php b/tests/FunctionalTests/validators/tests/ImageButtonTestCase.php index 1a4d88c1..a83c4f89 100644 --- a/tests/FunctionalTests/validators/tests/ImageButtonTestCase.php +++ b/tests/FunctionalTests/validators/tests/ImageButtonTestCase.php @@ -1,65 +1,65 @@ -<?php
-
-class ImageButtonTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('validators/index.php?page=ImageButton');
-
-
- // verify all error messages are invisible
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the first validator shows the error
- $this->click("ctl0_Content_ctl1");
- $this->verifyVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the first validation is passed
- $this->pause(500);
- $this->verifyTextNotPresent('Button1 is clicked');
- $this->type("ctl0_Content_TextBox1", "test");
- $this->clickAndWait("ctl0_Content_ctl1");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button1 is clicked and valid');
-
- // verify the second validator shows the error
- $this->click("ctl0_Content_ctl3");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the second validation is passed
- $this->pause(500);
- $this->verifyTextNotPresent('Button2 is clicked');
- $this->type("ctl0_Content_TextBox2", "test");
- $this->clickAndWait("ctl0_Content_ctl3");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button2 is clicked and valid');
-
- // verify the third validator shows the error
- $this->clickAndWait("ctl0_Content_ctl5");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyVisible('ctl0_Content_ctl4');
-
- // verify the third validation is passed
- $this->verifyTextPresent('Button3 is clicked');
- $this->verifyTextNotPresent('Button3 is clicked and valid');
- $this->type("ctl0_Content_TextBox3", "test");
- $this->clickAndWait("ctl0_Content_ctl5");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button3 is clicked and valid');
- }
-}
-
+<?php + +class ImageButtonTestCase extends SeleniumTestCase +{ + function test() + { + $this->open('validators/index.php?page=ImageButton'); + + + // verify all error messages are invisible + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the first validator shows the error + $this->click("ctl0_Content_ctl1"); + $this->verifyVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the first validation is passed + $this->pause(500); + $this->verifyTextNotPresent('Button1 is clicked'); + $this->type("ctl0_Content_TextBox1", "test"); + $this->clickAndWait("ctl0_Content_ctl1"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button1 is clicked and valid'); + + // verify the second validator shows the error + $this->click("ctl0_Content_ctl3"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the second validation is passed + $this->pause(500); + $this->verifyTextNotPresent('Button2 is clicked'); + $this->type("ctl0_Content_TextBox2", "test"); + $this->clickAndWait("ctl0_Content_ctl3"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button2 is clicked and valid'); + + // verify the third validator shows the error + $this->clickAndWait("ctl0_Content_ctl5"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyVisible('ctl0_Content_ctl4'); + + // verify the third validation is passed + $this->verifyTextPresent('Button3 is clicked'); + $this->verifyTextNotPresent('Button3 is clicked and valid'); + $this->type("ctl0_Content_TextBox3", "test"); + $this->clickAndWait("ctl0_Content_ctl5"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button3 is clicked and valid'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/LinkButtonTestCase.php b/tests/FunctionalTests/validators/tests/LinkButtonTestCase.php index 47122442..fa9508fb 100644 --- a/tests/FunctionalTests/validators/tests/LinkButtonTestCase.php +++ b/tests/FunctionalTests/validators/tests/LinkButtonTestCase.php @@ -1,64 +1,64 @@ -<?php
-
-class LinkButtonTestCase extends SeleniumTestCase
-{
- function test()
- {
- $this->open('validators/index.php?page=LinkButton');
-
- // verify all error messages are invisible
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the first validator shows the error
- $this->click("ctl0_Content_ctl1");
- $this->verifyVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the first validation is passed
- $this->pause(500);
- $this->verifyTextNotPresent('Button1 is clicked');
- $this->type("ctl0_Content_TextBox1", "test");
- $this->clickAndWait("ctl0_Content_ctl1");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button1 is clicked and valid');
-
- // verify the second validator shows the error
- $this->click("ctl0_Content_ctl3");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
-
- // verify the second validation is passed
- $this->pause(500);
- $this->verifyTextNotPresent('Button2 is clicked');
- $this->type("ctl0_Content_TextBox2", "test");
- $this->clickAndWait("ctl0_Content_ctl3");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button2 is clicked and valid');
-
- // verify the third validator shows the error
- $this->clickAndWait("ctl0_Content_ctl5");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyVisible('ctl0_Content_ctl4');
-
- // verify the third validation is passed
- $this->verifyTextPresent('Button3 is clicked');
- $this->verifyTextNotPresent('Button3 is clicked and valid');
- $this->type("ctl0_Content_TextBox3", "test");
- $this->clickAndWait("ctl0_Content_ctl5");
- $this->verifyNotVisible('ctl0_Content_ctl0');
- $this->verifyNotVisible('ctl0_Content_ctl2');
- $this->verifyNotVisible('ctl0_Content_ctl4');
- $this->verifyTextPresent('Button3 is clicked and valid');
- }
-}
-
+<?php + +class LinkButtonTestCase extends SeleniumTestCase +{ + function test() + { + $this->open('validators/index.php?page=LinkButton'); + + // verify all error messages are invisible + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the first validator shows the error + $this->click("ctl0_Content_ctl1"); + $this->verifyVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the first validation is passed + $this->pause(500); + $this->verifyTextNotPresent('Button1 is clicked'); + $this->type("ctl0_Content_TextBox1", "test"); + $this->clickAndWait("ctl0_Content_ctl1"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button1 is clicked and valid'); + + // verify the second validator shows the error + $this->click("ctl0_Content_ctl3"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + + // verify the second validation is passed + $this->pause(500); + $this->verifyTextNotPresent('Button2 is clicked'); + $this->type("ctl0_Content_TextBox2", "test"); + $this->clickAndWait("ctl0_Content_ctl3"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button2 is clicked and valid'); + + // verify the third validator shows the error + $this->clickAndWait("ctl0_Content_ctl5"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyVisible('ctl0_Content_ctl4'); + + // verify the third validation is passed + $this->verifyTextPresent('Button3 is clicked'); + $this->verifyTextNotPresent('Button3 is clicked and valid'); + $this->type("ctl0_Content_TextBox3", "test"); + $this->clickAndWait("ctl0_Content_ctl5"); + $this->verifyNotVisible('ctl0_Content_ctl0'); + $this->verifyNotVisible('ctl0_Content_ctl2'); + $this->verifyNotVisible('ctl0_Content_ctl4'); + $this->verifyTextPresent('Button3 is clicked and valid'); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/ListControlTestCase.php b/tests/FunctionalTests/validators/tests/ListControlTestCase.php index 37f35d1b..e4281794 100644 --- a/tests/FunctionalTests/validators/tests/ListControlTestCase.php +++ b/tests/FunctionalTests/validators/tests/ListControlTestCase.php @@ -1,51 +1,51 @@ -<?php
-/*
- * Created on 24/04/2006
- */
-
-class ListControlTestCase extends SeleniumTestCase
-{
- function test()
- {
- //problem with test runner clicking on radio buttons
- $this->skipBrowsers(self::OPERA);
-
- $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_c1' and @value='Red']", "");
- $this->select("{$base}list2", "label=Red");
- $this->select("{$base}list3", "label=Blue");
- $this->click("{$base}list4_c3", "");
- $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_c0");
- $this->select("{$base}list2", "label=--- Select a color ---");
- $this->click("//input[@type='submit' and @value='Submit!']", "");
- $this->click("//input[@id='{$base}list1_c1' and @value='Red']", "");
- $this->click("//input[@id='{$base}list1_c0' 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");
-
- }
-
-}
-
-?>
+<?php +/* + * Created on 24/04/2006 + */ + +class ListControlTestCase extends SeleniumTestCase +{ + function test() + { + //problem with test runner clicking on radio buttons + $this->skipBrowsers(self::OPERA); + + $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_c1' and @value='Red']", ""); + $this->select("{$base}list2", "label=Red"); + $this->select("{$base}list3", "label=Blue"); + $this->click("{$base}list4_c3", ""); + $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_c0"); + $this->select("{$base}list2", "label=--- Select a color ---"); + $this->click("//input[@type='submit' and @value='Submit!']", ""); + $this->click("//input[@id='{$base}list1_c1' and @value='Red']", ""); + $this->click("//input[@id='{$base}list1_c0' 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/RangeValidatorTestCase.php b/tests/FunctionalTests/validators/tests/RangeValidatorTestCase.php index c22ecf8b..31ad6c23 100644 --- a/tests/FunctionalTests/validators/tests/RangeValidatorTestCase.php +++ b/tests/FunctionalTests/validators/tests/RangeValidatorTestCase.php @@ -1,167 +1,167 @@ -<?php
-
-//New Test
-class RangeValidatorTestCase extends SeleniumTestCase
-{
- function testIntegerRange()
- {
- $base = "ctl0_Content_";
- $this->open("validators/index.php?page=RangeValidatorInteger", "");
- $this->verifyTextPresent("Prado RangeValidator Tests Integer", "");
-
- //between 1 and 4
- $this->type("{$base}text1", "ad");
- $this->assertNotVisible("{$base}validator1", "");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1", "");
- $this->type("{$base}text1", "12");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1", "");
- $this->type("{$base}text1", "2");
- $this->assertNotVisible("{$base}validator1", "");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator1", "");
-
-
- // >= 2
- $this->assertNotVisible("{$base}validator2", "");
- $this->type("{$base}text2", "1");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator2", "");
- $this->type("{$base}text2", "10");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator2", "");
-
- // <= 20
- $this->assertNotVisible("{$base}validator3", "");
- $this->type("{$base}text3", "100");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator3", "");
- $this->type("{$base}text3", "10");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator3", "");
-
- }
-
- function testFloatRange()
- {
- $base = "ctl0_Content_";
- $this->open("validators/index.php?page=RangeValidatorFloat", "");
- $this->verifyTextPresent("Prado RangeValidator Tests Float", "");
-
- //between 1 and 4
- $this->type("{$base}text1", "ad");
- $this->assertNotVisible("{$base}validator1", "");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1", "");
- $this->type("{$base}text1", "12");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1", "");
- $this->type("{$base}text1", "2");
- $this->assertNotVisible("{$base}validator1", "");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator1", "");
-
-
- // >= 2
- $this->assertNotVisible("{$base}validator2", "");
- $this->type("{$base}text2", "1");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator2", "");
- $this->type("{$base}text2", "10");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator2", "");
-
- // <= 20
- $this->assertNotVisible("{$base}validator3", "");
- $this->type("{$base}text3", "100");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator3", "");
- $this->type("{$base}text3", "10");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator3", "");
- }
-
- function testDateRange()
- {
- $base = "ctl0_Content_";
- $this->open("validators/index.php?page=RangeValidatorDate", "");
- $this->verifyTextPresent("Prado RangeValidator Tests Date", "");
-
- //between 22/1/2005 and 3/2/2005
- $this->type("{$base}text1", "ad");
- $this->assertNotVisible("{$base}validator1", "");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1", "");
- $this->type("{$base}text1", "27/2/2005");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1", "");
- $this->type("{$base}text1", "1/2/2005");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator1", "");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator1", "");
-
-
- // >= 22/1/2005
- $this->assertNotVisible("{$base}validator2", "");
- $this->type("{$base}text2", "1/1/2005");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->pause(250);
- $this->assertVisible("{$base}validator2", "");
- $this->type("{$base}text2", "1/4/2005");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator2", "");
-
- // <= 3/2/2005
- $this->assertNotVisible("{$base}validator3", "");
- $this->type("{$base}text3", "4/5/2005");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->pause(250);
- $this->assertVisible("{$base}validator3", "");
- $this->type("{$base}text3", "1/2/2005");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator3", "");
- }
-
- function testStringRange()
- {
- $base = "ctl0_Content_";
- $this->open("validators/index.php?page=RangeValidatorString", "");
- $this->verifyTextPresent("Prado RangeValidator Tests String", "");
-
- //between 'd' and 'y'
- $this->type("{$base}text1", "a");
- $this->assertNotVisible("{$base}validator1", "");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1", "");
- $this->type("{$base}text1", "b");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1", "");
- $this->type("{$base}text1", "f");
- $this->assertNotVisible("{$base}validator1", "");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator1", "");
-
-
- // >= 'd'
- $this->assertNotVisible("{$base}validator2", "");
- $this->type("{$base}text2", "a");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator2", "");
- $this->type("{$base}text2", "g");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator2", "");
-
- // <= 'y'
- $this->assertNotVisible("{$base}validator3", "");
- $this->type("{$base}text3", "z");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator3", "");
- $this->type("{$base}text3", "t");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator3", "");
- }
-}
-
-?>
+<?php + +//New Test +class RangeValidatorTestCase extends SeleniumTestCase +{ + function testIntegerRange() + { + $base = "ctl0_Content_"; + $this->open("validators/index.php?page=RangeValidatorInteger", ""); + $this->verifyTextPresent("Prado RangeValidator Tests Integer", ""); + + //between 1 and 4 + $this->type("{$base}text1", "ad"); + $this->assertNotVisible("{$base}validator1", ""); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1", ""); + $this->type("{$base}text1", "12"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1", ""); + $this->type("{$base}text1", "2"); + $this->assertNotVisible("{$base}validator1", ""); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator1", ""); + + + // >= 2 + $this->assertNotVisible("{$base}validator2", ""); + $this->type("{$base}text2", "1"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator2", ""); + $this->type("{$base}text2", "10"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator2", ""); + + // <= 20 + $this->assertNotVisible("{$base}validator3", ""); + $this->type("{$base}text3", "100"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator3", ""); + $this->type("{$base}text3", "10"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator3", ""); + + } + + function testFloatRange() + { + $base = "ctl0_Content_"; + $this->open("validators/index.php?page=RangeValidatorFloat", ""); + $this->verifyTextPresent("Prado RangeValidator Tests Float", ""); + + //between 1 and 4 + $this->type("{$base}text1", "ad"); + $this->assertNotVisible("{$base}validator1", ""); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1", ""); + $this->type("{$base}text1", "12"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1", ""); + $this->type("{$base}text1", "2"); + $this->assertNotVisible("{$base}validator1", ""); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator1", ""); + + + // >= 2 + $this->assertNotVisible("{$base}validator2", ""); + $this->type("{$base}text2", "1"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator2", ""); + $this->type("{$base}text2", "10"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator2", ""); + + // <= 20 + $this->assertNotVisible("{$base}validator3", ""); + $this->type("{$base}text3", "100"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator3", ""); + $this->type("{$base}text3", "10"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator3", ""); + } + + function testDateRange() + { + $base = "ctl0_Content_"; + $this->open("validators/index.php?page=RangeValidatorDate", ""); + $this->verifyTextPresent("Prado RangeValidator Tests Date", ""); + + //between 22/1/2005 and 3/2/2005 + $this->type("{$base}text1", "ad"); + $this->assertNotVisible("{$base}validator1", ""); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1", ""); + $this->type("{$base}text1", "27/2/2005"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1", ""); + $this->type("{$base}text1", "1/2/2005"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator1", ""); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator1", ""); + + + // >= 22/1/2005 + $this->assertNotVisible("{$base}validator2", ""); + $this->type("{$base}text2", "1/1/2005"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->pause(250); + $this->assertVisible("{$base}validator2", ""); + $this->type("{$base}text2", "1/4/2005"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator2", ""); + + // <= 3/2/2005 + $this->assertNotVisible("{$base}validator3", ""); + $this->type("{$base}text3", "4/5/2005"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->pause(250); + $this->assertVisible("{$base}validator3", ""); + $this->type("{$base}text3", "1/2/2005"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator3", ""); + } + + function testStringRange() + { + $base = "ctl0_Content_"; + $this->open("validators/index.php?page=RangeValidatorString", ""); + $this->verifyTextPresent("Prado RangeValidator Tests String", ""); + + //between 'd' and 'y' + $this->type("{$base}text1", "a"); + $this->assertNotVisible("{$base}validator1", ""); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1", ""); + $this->type("{$base}text1", "b"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1", ""); + $this->type("{$base}text1", "f"); + $this->assertNotVisible("{$base}validator1", ""); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator1", ""); + + + // >= 'd' + $this->assertNotVisible("{$base}validator2", ""); + $this->type("{$base}text2", "a"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator2", ""); + $this->type("{$base}text2", "g"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator2", ""); + + // <= 'y' + $this->assertNotVisible("{$base}validator3", ""); + $this->type("{$base}text3", "z"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator3", ""); + $this->type("{$base}text3", "t"); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator3", ""); + } +} + +?> diff --git a/tests/FunctionalTests/validators/tests/RegExpValidatorTestCase.php b/tests/FunctionalTests/validators/tests/RegExpValidatorTestCase.php index 751ab80a..40719cf3 100644 --- a/tests/FunctionalTests/validators/tests/RegExpValidatorTestCase.php +++ b/tests/FunctionalTests/validators/tests/RegExpValidatorTestCase.php @@ -1,34 +1,34 @@ -<?php
-
-//New Test
-class RegExpValidatorTestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = "ctl0_Content_";
- $this->open("validators/index.php?page=RegularExpressionValidator", "");
- $this->verifyTextPresent("Prado RegularExpressionValidator Tests", "");
- $this->assertNotVisible("{$base}validator1", "");
- $this->assertNotVisible("{$base}validator2", "");
- $this->type("{$base}text1", "1");
- $this->type("{$base}text2", "2");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1", "");
- $this->assertVisible("{$base}validator2", "");
- $this->type("{$base}text1", "asdasd");
- $this->click("//input[@type='submit' and @value='Test']", "");
- $this->assertVisible("{$base}validator1", "");
- $this->type("{$base}text1", "12345");
- $this->assertNotVisible("{$base}validator1", "");
- $this->assertVisible("{$base}validator2", "");
- $this->type("{$base}text2", "wei@gmail.com");
- $this->assertNotVisible("{$base}validator1", "");
- $this->assertNotVisible("{$base}validator2", "");
- $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
- $this->assertNotVisible("{$base}validator1", "");
- $this->assertNotVisible("{$base}validator2", "");
-
- }
-}
-
+<?php + +//New Test +class RegExpValidatorTestCase extends SeleniumTestCase +{ + function test() + { + $base = "ctl0_Content_"; + $this->open("validators/index.php?page=RegularExpressionValidator", ""); + $this->verifyTextPresent("Prado RegularExpressionValidator Tests", ""); + $this->assertNotVisible("{$base}validator1", ""); + $this->assertNotVisible("{$base}validator2", ""); + $this->type("{$base}text1", "1"); + $this->type("{$base}text2", "2"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1", ""); + $this->assertVisible("{$base}validator2", ""); + $this->type("{$base}text1", "asdasd"); + $this->click("//input[@type='submit' and @value='Test']", ""); + $this->assertVisible("{$base}validator1", ""); + $this->type("{$base}text1", "12345"); + $this->assertNotVisible("{$base}validator1", ""); + $this->assertVisible("{$base}validator2", ""); + $this->type("{$base}text2", "wei@gmail.com"); + $this->assertNotVisible("{$base}validator1", ""); + $this->assertNotVisible("{$base}validator2", ""); + $this->clickAndWait("//input[@type='submit' and @value='Test']", ""); + $this->assertNotVisible("{$base}validator1", ""); + $this->assertNotVisible("{$base}validator2", ""); + + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/RequiredFieldTestCase.php b/tests/FunctionalTests/validators/tests/RequiredFieldTestCase.php index 5ba23133..69765238 100644 --- a/tests/FunctionalTests/validators/tests/RequiredFieldTestCase.php +++ b/tests/FunctionalTests/validators/tests/RequiredFieldTestCase.php @@ -1,90 +1,90 @@ -<?php
-
-class RequiredFieldTestCase extends SeleniumTestCase
-{
- function test()
- {
- //problem with test runner clicking on radio buttons
- $this->skipBrowsers(self::OPERA);
-
- $base = "ctl0_Content_";
- $this->open("validators/index.php?page=RequiredFieldValidator");
- $this->assertTextPresent("RequiredFieldValidator Tests");
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
- $this->click("{$base}submit1");
- $this->assertVisible("{$base}validator1");
- $this->assertVisible("{$base}validator2");
- $this->type("{$base}text1", "testing");
- $this->click("{$base}submit1");
- $this->assertNotVisible("{$base}validator1");
- $this->click("{$base}submit2");
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
- $this->assertVisible("{$base}validator3");
- $this->assertVisible("{$base}validator4");
- $this->type("{$base}text2", "testing2");
- $this->click("{$base}submit2");
- $this->assertNotVisible("{$base}validator3");
- $this->click("{$base}submit3");
- $this->assertVisible("{$base}summary3");
- $this->clickAndWait("{$base}submit4");
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
- $this->assertNotVisible("{$base}validator3");
- $this->assertNotVisible("{$base}validator4");
- $this->click("{$base}submit1");
- $this->assertVisible("{$base}validator2");
- $this->click("{$base}check1");
- $this->click("{$base}submit2");
- $this->assertVisible("{$base}validator4");
- $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->click("{$base}check2");
- $this->clickAndWait("{$base}submit2");
-
- $this->type("{$base}text1", "Hello");
- $this->click("{$base}check1");
- $this->click("{$base}submit2");
-
- $this->assertNotVisible("{$base}validator5");
- $this->assertNotVisible("{$base}validator6");
- $this->assertNotVisible("{$base}validator7");
- $this->assertNotVisible("{$base}validator8");
- $this->type("{$base}text1");
- $this->type("{$base}text2");
- $this->click("{$base}check1");
- $this->click("{$base}check2");
- $this->click("{$base}submit3");
- $this->assertVisible("{$base}validator5");
- $this->assertVisible("{$base}validator6");
- $this->assertVisible("{$base}validator7");
- $this->assertVisible("{$base}validator8");
- $this->clickAndWait("{$base}submit4");
- $this->assertNotVisible("{$base}validator5");
- $this->assertNotVisible("{$base}validator6");
- $this->assertNotVisible("{$base}validator7");
- $this->assertNotVisible("{$base}validator8");
- }
-
- function testInitialValue()
- {
- $base = "ctl0_Content_";
- $this->open("validators/index.php?page=RequiredFieldValidator");
- $this->assertTextPresent("InitialValue Test");
- $this->assertNotVisible("{$base}validator9");
- $this->click("{$base}submit5");
- $this->pause(250);
- $this->assertVisible("{$base}validator9");
- $this->type("{$base}text5", "adasd");
- $this->pause(250);
- $this->assertNotVisible("{$base}validator9");
- }
-}
+<?php + +class RequiredFieldTestCase extends SeleniumTestCase +{ + function test() + { + //problem with test runner clicking on radio buttons + $this->skipBrowsers(self::OPERA); + + $base = "ctl0_Content_"; + $this->open("validators/index.php?page=RequiredFieldValidator"); + $this->assertTextPresent("RequiredFieldValidator Tests"); + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + $this->click("{$base}submit1"); + $this->assertVisible("{$base}validator1"); + $this->assertVisible("{$base}validator2"); + $this->type("{$base}text1", "testing"); + $this->click("{$base}submit1"); + $this->assertNotVisible("{$base}validator1"); + $this->click("{$base}submit2"); + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + $this->assertVisible("{$base}validator3"); + $this->assertVisible("{$base}validator4"); + $this->type("{$base}text2", "testing2"); + $this->click("{$base}submit2"); + $this->assertNotVisible("{$base}validator3"); + $this->click("{$base}submit3"); + $this->assertVisible("{$base}summary3"); + $this->clickAndWait("{$base}submit4"); + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + $this->assertNotVisible("{$base}validator3"); + $this->assertNotVisible("{$base}validator4"); + $this->click("{$base}submit1"); + $this->assertVisible("{$base}validator2"); + $this->click("{$base}check1"); + $this->click("{$base}submit2"); + $this->assertVisible("{$base}validator4"); + $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->click("{$base}check2"); + $this->clickAndWait("{$base}submit2"); + + $this->type("{$base}text1", "Hello"); + $this->click("{$base}check1"); + $this->click("{$base}submit2"); + + $this->assertNotVisible("{$base}validator5"); + $this->assertNotVisible("{$base}validator6"); + $this->assertNotVisible("{$base}validator7"); + $this->assertNotVisible("{$base}validator8"); + $this->type("{$base}text1"); + $this->type("{$base}text2"); + $this->click("{$base}check1"); + $this->click("{$base}check2"); + $this->click("{$base}submit3"); + $this->assertVisible("{$base}validator5"); + $this->assertVisible("{$base}validator6"); + $this->assertVisible("{$base}validator7"); + $this->assertVisible("{$base}validator8"); + $this->clickAndWait("{$base}submit4"); + $this->assertNotVisible("{$base}validator5"); + $this->assertNotVisible("{$base}validator6"); + $this->assertNotVisible("{$base}validator7"); + $this->assertNotVisible("{$base}validator8"); + } + + function testInitialValue() + { + $base = "ctl0_Content_"; + $this->open("validators/index.php?page=RequiredFieldValidator"); + $this->assertTextPresent("InitialValue Test"); + $this->assertNotVisible("{$base}validator9"); + $this->click("{$base}submit5"); + $this->pause(250); + $this->assertVisible("{$base}validator9"); + $this->type("{$base}text5", "adasd"); + $this->pause(250); + $this->assertNotVisible("{$base}validator9"); + } +} ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/RequiredListTestCase.php b/tests/FunctionalTests/validators/tests/RequiredListTestCase.php index 9f652583..2151e492 100644 --- a/tests/FunctionalTests/validators/tests/RequiredListTestCase.php +++ b/tests/FunctionalTests/validators/tests/RequiredListTestCase.php @@ -1,43 +1,43 @@ -<?php
-
-class RequiredListTestCase extends SeleniumTestCase
-{
-
- function test()
- {
- //problem with test runner clicking on radio buttons
- $this->skipBrowsers(self::OPERA);
-
- $base = "ctl0_Content_";
- $this->open("validators/index.php?page=RequiredListValidator");
- $this->click("{$base}submit1");
- $this->assertVisible("{$base}validator1");
- $this->assertVisible("{$base}validator2");
- $this->assertVisible("{$base}validator3");
- $this->click("{$base}list1_c0");
- $this->addSelection("{$base}list2", "label=One");
- $this->addSelection("{$base}list2", "label=Two");
- $this->click("{$base}list3_c3");
- $this->clickAndWait("{$base}submit1");
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
- $this->assertNotVisible("{$base}validator3");
- $this->click("{$base}list1_c1");
- $this->click("{$base}list1_c2");
- $this->click("{$base}list1_c3");
- $this->addSelection("{$base}list2", "label=Two");
- $this->click("{$base}list1_c3");
- $this->clickAndWait("{$base}submit1");
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
- $this->assertNotVisible("{$base}validator3");
- $this->click("{$base}list3_c3");
- $this->clickAndWait("{$base}submit1");
- $this->pause(200);
- $this->assertNotVisible("{$base}validator1");
- $this->assertNotVisible("{$base}validator2");
- $this->assertNotVisible("{$base}validator3");
- }
-}
-
+<?php + +class RequiredListTestCase extends SeleniumTestCase +{ + + function test() + { + //problem with test runner clicking on radio buttons + $this->skipBrowsers(self::OPERA); + + $base = "ctl0_Content_"; + $this->open("validators/index.php?page=RequiredListValidator"); + $this->click("{$base}submit1"); + $this->assertVisible("{$base}validator1"); + $this->assertVisible("{$base}validator2"); + $this->assertVisible("{$base}validator3"); + $this->click("{$base}list1_c0"); + $this->addSelection("{$base}list2", "label=One"); + $this->addSelection("{$base}list2", "label=Two"); + $this->click("{$base}list3_c3"); + $this->clickAndWait("{$base}submit1"); + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + $this->assertNotVisible("{$base}validator3"); + $this->click("{$base}list1_c1"); + $this->click("{$base}list1_c2"); + $this->click("{$base}list1_c3"); + $this->addSelection("{$base}list2", "label=Two"); + $this->click("{$base}list1_c3"); + $this->clickAndWait("{$base}submit1"); + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + $this->assertNotVisible("{$base}validator3"); + $this->click("{$base}list3_c3"); + $this->clickAndWait("{$base}submit1"); + $this->pause(200); + $this->assertNotVisible("{$base}validator1"); + $this->assertNotVisible("{$base}validator2"); + $this->assertNotVisible("{$base}validator3"); + } +} + ?>
\ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/ValidationSummaryTestCase.php b/tests/FunctionalTests/validators/tests/ValidationSummaryTestCase.php index 3b6225f3..802392ac 100644 --- a/tests/FunctionalTests/validators/tests/ValidationSummaryTestCase.php +++ b/tests/FunctionalTests/validators/tests/ValidationSummaryTestCase.php @@ -1,50 +1,50 @@ -<?php
-
-//New Test
-class ValidationSummaryTestCase extends SeleniumTestCase
-{
- function test()
- {
- $base = "ctl0_Content_";
-
- $this->open("validators/index.php?page=ValidationSummary", "");
- $this->verifyTextPresent("Validation Summary Test", "");
- //$this->verifyText("{$base}summary1", "");
- //$this->verifyText("{$base}summary2", "");
-
- $this->click("//input[@type='submit' and @value='Create New Account']", "");
- $this->assertVisible("{$base}summary1");
- $this->assertNotVisible("{$base}summary2");
-
- $this->click("//input[@type='submit' and @value='Sign In']", "");
- $this->assertNotVisible("{$base}summary1");
- $this->assertVisible("{$base}summary2");
-
- $this->type("{$base}Username", "qwe");
- $this->type("{$base}Password", "ewwq");
- $this->click("//input[@type='submit' and @value='Sign In']", "");
- $this->assertNotVisible("{$base}summary1");
- $this->assertVisible("{$base}summary2");
-
- /*$this->clickAndWait("//input[@type='submit' and @value='Create New Account']", "");
- $this->type("{$base}UserID", "123");
- $this->type("{$base}Pass", "123");
- $this->clickAndWait("//input[@type='submit' and @value='Sign In']", "");
- //$this->verifyText("{$base}summary1", "");
- //$this->verifyText("{$base}summary2", "");
- $this->clickAndWait("//input[@type='submit' and @value='Create New Account']", "");
- //$this->verifyText("{$base}summary1", "");
- //$this->verifyText("{$base}summary2", "");
-
- $this->type("{$base}Password", "");
- $this->click("//input[@type='submit' and @value='Create New Account']", "");
- $this->assertVisible("{$base}summary1");
- $this->assertNotVisible("{$base}summary2");
-
- $this->type("{$base}Password", "12312");
- $this->assertVisible("{$base}summary1");
- */
- }
-}
-
+<?php + +//New Test +class ValidationSummaryTestCase extends SeleniumTestCase +{ + function test() + { + $base = "ctl0_Content_"; + + $this->open("validators/index.php?page=ValidationSummary", ""); + $this->verifyTextPresent("Validation Summary Test", ""); + //$this->verifyText("{$base}summary1", ""); + //$this->verifyText("{$base}summary2", ""); + + $this->click("//input[@type='submit' and @value='Create New Account']", ""); + $this->assertVisible("{$base}summary1"); + $this->assertNotVisible("{$base}summary2"); + + $this->click("//input[@type='submit' and @value='Sign In']", ""); + $this->assertNotVisible("{$base}summary1"); + $this->assertVisible("{$base}summary2"); + + $this->type("{$base}Username", "qwe"); + $this->type("{$base}Password", "ewwq"); + $this->click("//input[@type='submit' and @value='Sign In']", ""); + $this->assertNotVisible("{$base}summary1"); + $this->assertVisible("{$base}summary2"); + + /*$this->clickAndWait("//input[@type='submit' and @value='Create New Account']", ""); + $this->type("{$base}UserID", "123"); + $this->type("{$base}Pass", "123"); + $this->clickAndWait("//input[@type='submit' and @value='Sign In']", ""); + //$this->verifyText("{$base}summary1", ""); + //$this->verifyText("{$base}summary2", ""); + $this->clickAndWait("//input[@type='submit' and @value='Create New Account']", ""); + //$this->verifyText("{$base}summary1", ""); + //$this->verifyText("{$base}summary2", ""); + + $this->type("{$base}Password", ""); + $this->click("//input[@type='submit' and @value='Create New Account']", ""); + $this->assertVisible("{$base}summary1"); + $this->assertNotVisible("{$base}summary2"); + + $this->type("{$base}Password", "12312"); + $this->assertVisible("{$base}summary1"); + */ + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ActiveRecordDynamicCallTestCase.php b/tests/simple_unit/ActiveRecord/ActiveRecordDynamicCallTestCase.php index 07e810aa..8d7fa46a 100644 --- a/tests/simple_unit/ActiveRecord/ActiveRecordDynamicCallTestCase.php +++ b/tests/simple_unit/ActiveRecord/ActiveRecordDynamicCallTestCase.php @@ -1,69 +1,69 @@ -<?php
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
-require_once(dirname(__FILE__).'/records/DepSections.php');
-
-class ActiveRecordDynamicCallTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function test_multiple_field_and_or()
- {
- $finder = DepartmentRecord::finder();
- $r2 = $finder->findAllByName_And_Description_Or_Active_Or_Order('Facilities', null, false, 1);
- $this->assertNotNull($r2);
- }
-
- function test_dynamic_call()
- {
- $finder = DepartmentRecord::finder();
- $r2 = $finder->findByName('Facilities');
- $this->assertNotNull($r2);
- }
-
- function test_dynamic_multiple_field_call()
- {
- $finder = DepartmentRecord::finder();
- $rs = $finder->findByNameAndActive('Marketing',true);
- $this->assertNotNull($rs);
- }
-
- function test_dynamic_call_missing_parameters_throws_exception()
- {
- $finder = DepartmentRecord::finder();
- try
- {
- $rs = $finder->findByNameAndActive('Marketing');
- $this->fail();
- }
- catch(TDbException $e)
- {
- $this->pass();
- }
- }
-
- function test_dynamic_call_extras_parameters_ok()
- {
- $finder = DepartmentRecord::finder();
- $rs = $finder->findByNameAndActive('Marketing',true,true);
- $this->assertNotNull($rs);
- }
-
- function test_dynamic_delete_by()
- {
- $finder = DepartmentRecord::finder();
- //$finder->RecordManager->OnDelete[] = array($this, 'assertDeleteSql');
- $this->assertEqual($finder->deleteByName('tasds'), 0);
- }
-
- function assertDeleteSql($sender, $param)
- {
- var_dump($param);
- }
-}
+<?php +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/DepartmentRecord.php'); +require_once(dirname(__FILE__).'/records/DepSections.php'); + +class ActiveRecordDynamicCallTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function test_multiple_field_and_or() + { + $finder = DepartmentRecord::finder(); + $r2 = $finder->findAllByName_And_Description_Or_Active_Or_Order('Facilities', null, false, 1); + $this->assertNotNull($r2); + } + + function test_dynamic_call() + { + $finder = DepartmentRecord::finder(); + $r2 = $finder->findByName('Facilities'); + $this->assertNotNull($r2); + } + + function test_dynamic_multiple_field_call() + { + $finder = DepartmentRecord::finder(); + $rs = $finder->findByNameAndActive('Marketing',true); + $this->assertNotNull($rs); + } + + function test_dynamic_call_missing_parameters_throws_exception() + { + $finder = DepartmentRecord::finder(); + try + { + $rs = $finder->findByNameAndActive('Marketing'); + $this->fail(); + } + catch(TDbException $e) + { + $this->pass(); + } + } + + function test_dynamic_call_extras_parameters_ok() + { + $finder = DepartmentRecord::finder(); + $rs = $finder->findByNameAndActive('Marketing',true,true); + $this->assertNotNull($rs); + } + + function test_dynamic_delete_by() + { + $finder = DepartmentRecord::finder(); + //$finder->RecordManager->OnDelete[] = array($this, 'assertDeleteSql'); + $this->assertEqual($finder->deleteByName('tasds'), 0); + } + + function assertDeleteSql($sender, $param) + { + var_dump($param); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ActiveRecordFinderTestCase.php b/tests/simple_unit/ActiveRecord/ActiveRecordFinderTestCase.php index 597f8a6b..e962046b 100644 --- a/tests/simple_unit/ActiveRecord/ActiveRecordFinderTestCase.php +++ b/tests/simple_unit/ActiveRecord/ActiveRecordFinderTestCase.php @@ -1,45 +1,45 @@ <?php -Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
-
-class ActiveRecordFinderTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function testFindBySQL_returns_one_record()
- {
- $department = DepartmentRecord::finder()->find('department_id < ?', 5);
- $this->assertNotNull($department);
- }
-
- function testFindBySQL_returns_zero_records()
- {
- $department = DepartmentRecord::finder()->find('department_id > ?', 15);
- $this->assertNull($department);
- }
-
- function test_find_by_sql_returns_iterator()
- {
- $deps = DepartmentRecord::finder()->findAll('department_id < :id', array('id'=>5));
- $this->assertEqual(count($deps),4);
- }
-
- function test_find_by_multiple_parameters()
- {
- $department = DepartmentRecord::finder()->find('department_id < ? AND "order" > ?', 5,2);
- $this->assertNotNull($department);
- }
-
- function test_find_by_array_parameter()
- {
- $department = DepartmentRecord::finder()->find('department_id < ? AND "order" > ?', array(5,2));
- $this->assertNotNull($department);
- }
-
-}
+Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/DepartmentRecord.php'); + +class ActiveRecordFinderTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function testFindBySQL_returns_one_record() + { + $department = DepartmentRecord::finder()->find('department_id < ?', 5); + $this->assertNotNull($department); + } + + function testFindBySQL_returns_zero_records() + { + $department = DepartmentRecord::finder()->find('department_id > ?', 15); + $this->assertNull($department); + } + + function test_find_by_sql_returns_iterator() + { + $deps = DepartmentRecord::finder()->findAll('department_id < :id', array('id'=>5)); + $this->assertEqual(count($deps),4); + } + + function test_find_by_multiple_parameters() + { + $department = DepartmentRecord::finder()->find('department_id < ? AND "order" > ?', 5,2); + $this->assertNotNull($department); + } + + function test_find_by_array_parameter() + { + $department = DepartmentRecord::finder()->find('department_id < ? AND "order" > ?', array(5,2)); + $this->assertNotNull($department); + } + +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ActiveRecordMySql5TestCase.php b/tests/simple_unit/ActiveRecord/ActiveRecordMySql5TestCase.php index b0d7ccf4..d173f005 100644 --- a/tests/simple_unit/ActiveRecord/ActiveRecordMySql5TestCase.php +++ b/tests/simple_unit/ActiveRecord/ActiveRecordMySql5TestCase.php @@ -1,46 +1,46 @@ -<?php
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/Blogs.php');
-
-class ActiveRecordMySql5TestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('mysql:host=localhost;dbname=ar_test;port=3307', 'test5','test5');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function test_find_first_blog()
- {
- $blog = Blogs::finder()->findByPk(1);
- $this->assertNotNull($blog);
- }
-
- function test_insert_new_blog()
- {
- $blog = new Blogs();
- $blog->blog_name = 'test1';
- $blog->blog_author = 'wei';
-
- $this->assertTrue($blog->save());
-
- $blog->blog_name = 'test2';
-
- $this->assertTrue($blog->save());
-
- $check = Blogs::finder()->findByPk($blog->blog_id);
-
- $this->assertSameBlog($check,$blog);
-
- $this->assertTrue($blog->delete());
- }
-
- function assertSameBlog($check, $blog)
- {
- $props = array('blog_id', 'blog_name', 'blog_author');
- foreach($props as $prop)
- $this->assertEqual($check->{$prop}, $blog->{$prop});
- }
-
+<?php +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/Blogs.php'); + +class ActiveRecordMySql5TestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('mysql:host=localhost;dbname=ar_test;port=3307', 'test5','test5'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function test_find_first_blog() + { + $blog = Blogs::finder()->findByPk(1); + $this->assertNotNull($blog); + } + + function test_insert_new_blog() + { + $blog = new Blogs(); + $blog->blog_name = 'test1'; + $blog->blog_author = 'wei'; + + $this->assertTrue($blog->save()); + + $blog->blog_name = 'test2'; + + $this->assertTrue($blog->save()); + + $check = Blogs::finder()->findByPk($blog->blog_id); + + $this->assertSameBlog($check,$blog); + + $this->assertTrue($blog->delete()); + } + + function assertSameBlog($check, $blog) + { + $props = array('blog_id', 'blog_name', 'blog_author'); + foreach($props as $prop) + $this->assertEqual($check->{$prop}, $blog->{$prop}); + } + } ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ActiveRecordRegistryTestCase.php b/tests/simple_unit/ActiveRecord/ActiveRecordRegistryTestCase.php index fbae5a4b..fe1507cd 100644 --- a/tests/simple_unit/ActiveRecord/ActiveRecordRegistryTestCase.php +++ b/tests/simple_unit/ActiveRecord/ActiveRecordRegistryTestCase.php @@ -1,167 +1,167 @@ -<?php
-Prado::using('System.Data.ActiveRecord.TActiveRecordStateRegistry');
-Prado::using('System.Data.ActiveRecord.Exceptions.*');
-
-class StateTestObject
-{
- public $propA = 'a';
- public $propB;
-}
-
-class ActiveRecordRegistryTestCase extends UnitTestCase
-{
- function test_new_object()
- {
- $obj = new StateTestObject();
- $registry = new TActiveRecordStateRegistry();
-
- $this->assertTrue($registry->isNewObject($obj));
- $this->assertFalse($registry->isDirtyObject($obj));
- $this->assertFalse($registry->isRemovedObject($obj));
- $this->assertFalse($registry->isCleanObject($obj));
- }
-
- function test_clean_object_registers_without_error()
- {
- $obj = new StateTestObject();
- $registry = new TActiveRecordStateRegistry();
- $registry->registerClean($obj);
-
- $this->assertFalse($registry->isNewObject($obj));
- $this->assertFalse($registry->isDirtyObject($obj));
- $this->assertFalse($registry->isRemovedObject($obj));
- $this->assertTrue($registry->isCleanObject($obj));
- }
-
- function test_clean_object_becomes_dirty_when_changed()
- {
- $obj = new StateTestObject();
- $registry = new TActiveRecordStateRegistry();
-
- $registry->registerClean($obj);
-
- $obj->propB='b';
-
- $this->assertFalse($registry->isNewObject($obj));
- $this->assertTrue($registry->isDirtyObject($obj));
- $this->assertFalse($registry->isRemovedObject($obj));
- $this->assertFalse($registry->isCleanObject($obj));
- }
-
- function test_removed_object_must_register_as_clean_first()
- {
- $obj = new StateTestObject();
- $registry = new TActiveRecordStateRegistry();
-
- try
- {
- $registry->registerRemoved($obj);
- $this->fail();
- }
- catch(TActiveRecordException $e)
- {
- $this->pass();
- }
- }
-
- function test_removed_object_registers_without_error()
- {
- $obj = new StateTestObject();
- $registry = new TActiveRecordStateRegistry();
- $registry->registerClean($obj);
-
- $registry->registerRemoved($obj);
-
- $this->assertFalse($registry->isNewObject($obj));
- $this->assertFalse($registry->isDirtyObject($obj));
- $this->assertTrue($registry->isRemovedObject($obj));
- $this->assertFalse($registry->isCleanObject($obj));
- }
-
-
- function test_removed_object_can_not_become_clean()
- {
- $obj = new StateTestObject();
- $registry = new TActiveRecordStateRegistry();
- $registry->registerClean($obj);
-
- $registry->registerRemoved($obj);
-
- try
- {
- $registry->registerClean($obj);
- $this->fail();
- }
- catch(TActiveRecordException $e)
- {
- $this->pass();
- }
-
- $this->assertFalse($registry->isNewObject($obj));
- $this->assertFalse($registry->isDirtyObject($obj));
- $this->assertTrue($registry->isRemovedObject($obj));
- $this->assertFalse($registry->isCleanObject($obj));
- }
-
- function test_remove_dirty_object()
- {
- $obj = new StateTestObject();
- $registry = new TActiveRecordStateRegistry();
-
- $registry->registerClean($obj);
-
- $obj->propB='b';
-
- $this->assertFalse($registry->isNewObject($obj));
- $this->assertTrue($registry->isDirtyObject($obj));
- $this->assertFalse($registry->isRemovedObject($obj));
- $this->assertFalse($registry->isCleanObject($obj));
-
- $registry->registerRemoved($obj);
-
- $this->assertFalse($registry->isNewObject($obj));
- $this->assertFalse($registry->isDirtyObject($obj));
- $this->assertTrue($registry->isRemovedObject($obj));
- $this->assertFalse($registry->isCleanObject($obj));
-
- try
- {
- $registry->registerClean($obj);
- $this->fail();
- }
- catch(TActiveRecordException $e)
- {
- $this->pass();
- }
- }
-
- function test_clean_dirty_clean_object()
- {
- $obj = new StateTestObject();
- $registry = new TActiveRecordStateRegistry();
-
- $registry->registerClean($obj);
-
- $this->assertFalse($registry->isNewObject($obj));
- $this->assertFalse($registry->isDirtyObject($obj));
- $this->assertFalse($registry->isRemovedObject($obj));
- $this->assertTrue($registry->isCleanObject($obj));
-
- $obj->propB='b';
-
- $this->assertFalse($registry->isNewObject($obj));
- $this->assertTrue($registry->isDirtyObject($obj));
- $this->assertFalse($registry->isRemovedObject($obj));
- $this->assertFalse($registry->isCleanObject($obj));
-
- $registry->registerClean($obj);
-
- $this->assertFalse($registry->isNewObject($obj));
- $this->assertFalse($registry->isDirtyObject($obj));
- $this->assertFalse($registry->isRemovedObject($obj));
- $this->assertTrue($registry->isCleanObject($obj));
- }
-
-}
+<?php +Prado::using('System.Data.ActiveRecord.TActiveRecordStateRegistry'); +Prado::using('System.Data.ActiveRecord.Exceptions.*'); + +class StateTestObject +{ + public $propA = 'a'; + public $propB; +} + +class ActiveRecordRegistryTestCase extends UnitTestCase +{ + function test_new_object() + { + $obj = new StateTestObject(); + $registry = new TActiveRecordStateRegistry(); + + $this->assertTrue($registry->isNewObject($obj)); + $this->assertFalse($registry->isDirtyObject($obj)); + $this->assertFalse($registry->isRemovedObject($obj)); + $this->assertFalse($registry->isCleanObject($obj)); + } + + function test_clean_object_registers_without_error() + { + $obj = new StateTestObject(); + $registry = new TActiveRecordStateRegistry(); + $registry->registerClean($obj); + + $this->assertFalse($registry->isNewObject($obj)); + $this->assertFalse($registry->isDirtyObject($obj)); + $this->assertFalse($registry->isRemovedObject($obj)); + $this->assertTrue($registry->isCleanObject($obj)); + } + + function test_clean_object_becomes_dirty_when_changed() + { + $obj = new StateTestObject(); + $registry = new TActiveRecordStateRegistry(); + + $registry->registerClean($obj); + + $obj->propB='b'; + + $this->assertFalse($registry->isNewObject($obj)); + $this->assertTrue($registry->isDirtyObject($obj)); + $this->assertFalse($registry->isRemovedObject($obj)); + $this->assertFalse($registry->isCleanObject($obj)); + } + + function test_removed_object_must_register_as_clean_first() + { + $obj = new StateTestObject(); + $registry = new TActiveRecordStateRegistry(); + + try + { + $registry->registerRemoved($obj); + $this->fail(); + } + catch(TActiveRecordException $e) + { + $this->pass(); + } + } + + function test_removed_object_registers_without_error() + { + $obj = new StateTestObject(); + $registry = new TActiveRecordStateRegistry(); + $registry->registerClean($obj); + + $registry->registerRemoved($obj); + + $this->assertFalse($registry->isNewObject($obj)); + $this->assertFalse($registry->isDirtyObject($obj)); + $this->assertTrue($registry->isRemovedObject($obj)); + $this->assertFalse($registry->isCleanObject($obj)); + } + + + function test_removed_object_can_not_become_clean() + { + $obj = new StateTestObject(); + $registry = new TActiveRecordStateRegistry(); + $registry->registerClean($obj); + + $registry->registerRemoved($obj); + + try + { + $registry->registerClean($obj); + $this->fail(); + } + catch(TActiveRecordException $e) + { + $this->pass(); + } + + $this->assertFalse($registry->isNewObject($obj)); + $this->assertFalse($registry->isDirtyObject($obj)); + $this->assertTrue($registry->isRemovedObject($obj)); + $this->assertFalse($registry->isCleanObject($obj)); + } + + function test_remove_dirty_object() + { + $obj = new StateTestObject(); + $registry = new TActiveRecordStateRegistry(); + + $registry->registerClean($obj); + + $obj->propB='b'; + + $this->assertFalse($registry->isNewObject($obj)); + $this->assertTrue($registry->isDirtyObject($obj)); + $this->assertFalse($registry->isRemovedObject($obj)); + $this->assertFalse($registry->isCleanObject($obj)); + + $registry->registerRemoved($obj); + + $this->assertFalse($registry->isNewObject($obj)); + $this->assertFalse($registry->isDirtyObject($obj)); + $this->assertTrue($registry->isRemovedObject($obj)); + $this->assertFalse($registry->isCleanObject($obj)); + + try + { + $registry->registerClean($obj); + $this->fail(); + } + catch(TActiveRecordException $e) + { + $this->pass(); + } + } + + function test_clean_dirty_clean_object() + { + $obj = new StateTestObject(); + $registry = new TActiveRecordStateRegistry(); + + $registry->registerClean($obj); + + $this->assertFalse($registry->isNewObject($obj)); + $this->assertFalse($registry->isDirtyObject($obj)); + $this->assertFalse($registry->isRemovedObject($obj)); + $this->assertTrue($registry->isCleanObject($obj)); + + $obj->propB='b'; + + $this->assertFalse($registry->isNewObject($obj)); + $this->assertTrue($registry->isDirtyObject($obj)); + $this->assertFalse($registry->isRemovedObject($obj)); + $this->assertFalse($registry->isCleanObject($obj)); + + $registry->registerClean($obj); + + $this->assertFalse($registry->isNewObject($obj)); + $this->assertFalse($registry->isDirtyObject($obj)); + $this->assertFalse($registry->isRemovedObject($obj)); + $this->assertTrue($registry->isCleanObject($obj)); + } + +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php b/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php index fbb1c927..c356216b 100644 --- a/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php +++ b/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php @@ -1,33 +1,33 @@ -<?php
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-
-class BaseRecordTest extends TActiveRecord
-{
-
-}
-
-class BaseActiveRecordTestCase extends UnitTestCase
-{
- function test_finder_returns_same_instance()
- {
- $obj1 = TActiveRecord::finder('BaseRecordTest');
- $obj2 = TActiveRecord::finder('BaseRecordTest');
- $this->assertIdentical($obj1,$obj2);
- }
-
- function test_finder_throw_exception_when_save()
- {
- $obj = TActiveRecord::finder('BaseRecordTest');
- try
- {
- $obj->save();
- $this->fail();
- }
- catch(TActiveRecordException $e)
- {
- $this->pass();
- }
- }
-}
+<?php +Prado::using('System.Data.ActiveRecord.TActiveRecord'); + +class BaseRecordTest extends TActiveRecord +{ + +} + +class BaseActiveRecordTestCase extends UnitTestCase +{ + function test_finder_returns_same_instance() + { + $obj1 = TActiveRecord::finder('BaseRecordTest'); + $obj2 = TActiveRecord::finder('BaseRecordTest'); + $this->assertIdentical($obj1,$obj2); + } + + function test_finder_throw_exception_when_save() + { + $obj = TActiveRecord::finder('BaseRecordTest'); + try + { + $obj->save(); + $this->fail(); + } + catch(TActiveRecordException $e) + { + $this->pass(); + } + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/CountRecordsTestCase.php b/tests/simple_unit/ActiveRecord/CountRecordsTestCase.php index 4d1cf51d..4c489d49 100644 --- a/tests/simple_unit/ActiveRecord/CountRecordsTestCase.php +++ b/tests/simple_unit/ActiveRecord/CountRecordsTestCase.php @@ -1,35 +1,35 @@ <?php -
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
-
-class CountRecordsTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function test_count()
- {
- $finder = DepartmentRecord::finder();
- $count = $finder->count('"order" > ?', 2);
- $this->assertTrue($count > 0);
- }
-
- function test_count_zero()
- {
- $finder = DepartmentRecord::finder();
- $count = $finder->count('"order" > ?', 11);
- $this->assertEqual($count,0);
- }
-
- function test_count_without_parameter()
- {
- $finder = DepartmentRecord::finder();
- $this->assertEqual($finder->count(), 8);
- }
-}
+ +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/DepartmentRecord.php'); + +class CountRecordsTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function test_count() + { + $finder = DepartmentRecord::finder(); + $count = $finder->count('"order" > ?', 2); + $this->assertTrue($count > 0); + } + + function test_count_zero() + { + $finder = DepartmentRecord::finder(); + $count = $finder->count('"order" > ?', 11); + $this->assertEqual($count,0); + } + + function test_count_without_parameter() + { + $finder = DepartmentRecord::finder(); + $this->assertEqual($finder->count(), 8); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/CriteriaTestCase.php b/tests/simple_unit/ActiveRecord/CriteriaTestCase.php index 17f691d7..de5b3b71 100644 --- a/tests/simple_unit/ActiveRecord/CriteriaTestCase.php +++ b/tests/simple_unit/ActiveRecord/CriteriaTestCase.php @@ -1,50 +1,50 @@ -<?php
-
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
-require_once(dirname(__FILE__).'/records/DepSections.php');
-
-class CriteriaTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function test_orderby_only()
- {
- $criteria = new TActiveRecordCriteria;
- $criteria->OrdersBy['name'] = 'asc';
- $records = DepartmentRecord::finder()->findAll($criteria);
- $this->assertEqual(count($records), 8);
- $this->assertEqual($records[0]->name, '+GX Service');
- $this->assertEqual($records[7]->name, 'Marketing');
- }
-
- function test_orderby_only_desc()
- {
- $criteria = new TActiveRecordCriteria;
- $criteria->OrdersBy['name'] = 'desc';
- $records = DepartmentRecord::finder()->findAll($criteria);
- $this->assertEqual(count($records), 8);
- $this->assertEqual($records[7]->name, '+GX Service');
- $this->assertEqual($records[0]->name, 'Marketing');
- }
-
- function test_criteria_parameters()
- {
- $criteria = new TActiveRecordCriteria('sql', "One", "two", 3);
- $expect = array("One", "two", 3);
- $this->assertEqual($criteria->getParameters()->toArray(), $expect);
- }
-
- function test_criteria_parameters_array()
- {
- $expect = array("One", "two", 3);
- $criteria = new TActiveRecordCriteria('sql', $expect);
- $this->assertEqual($criteria->getParameters()->toArray(), $expect);
- }
-}
-
+<?php + +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/DepartmentRecord.php'); +require_once(dirname(__FILE__).'/records/DepSections.php'); + +class CriteriaTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function test_orderby_only() + { + $criteria = new TActiveRecordCriteria; + $criteria->OrdersBy['name'] = 'asc'; + $records = DepartmentRecord::finder()->findAll($criteria); + $this->assertEqual(count($records), 8); + $this->assertEqual($records[0]->name, '+GX Service'); + $this->assertEqual($records[7]->name, 'Marketing'); + } + + function test_orderby_only_desc() + { + $criteria = new TActiveRecordCriteria; + $criteria->OrdersBy['name'] = 'desc'; + $records = DepartmentRecord::finder()->findAll($criteria); + $this->assertEqual(count($records), 8); + $this->assertEqual($records[7]->name, '+GX Service'); + $this->assertEqual($records[0]->name, 'Marketing'); + } + + function test_criteria_parameters() + { + $criteria = new TActiveRecordCriteria('sql', "One", "two", 3); + $expect = array("One", "two", 3); + $this->assertEqual($criteria->getParameters()->toArray(), $expect); + } + + function test_criteria_parameters_array() + { + $expect = array("One", "two", 3); + $criteria = new TActiveRecordCriteria('sql', $expect); + $this->assertEqual($criteria->getParameters()->toArray(), $expect); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/DeleteByPkTestCase.php b/tests/simple_unit/ActiveRecord/DeleteByPkTestCase.php index 45415b90..f848033c 100644 --- a/tests/simple_unit/ActiveRecord/DeleteByPkTestCase.php +++ b/tests/simple_unit/ActiveRecord/DeleteByPkTestCase.php @@ -1,31 +1,31 @@ <?php -
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
-require_once(dirname(__FILE__).'/records/DepSections.php');
-
-class DeleteByPkTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function test_delete_by_pks()
- {
- $finder = DepartmentRecord::finder();
- $this->assertEqual($finder->deleteByPk(100),0);
- $this->assertEqual($finder->deleteByPk(100, 101),0);
- $this->assertEqual($finder->deleteByPk(array(100, 101)),0);
- }
-
- function test_delete_by_composite_pks()
- {
- $finder = DepSections::finder();
- $this->assertEqual($finder->deleteByPk(array(100,101)),0);
- $this->assertEqual($finder->deleteByPk(array(100, 101), array(102, 103)),0);
- $this->assertEqual($finder->deleteByPk(array(array(100, 101), array(102, 103))),0);
- }
+ +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/DepartmentRecord.php'); +require_once(dirname(__FILE__).'/records/DepSections.php'); + +class DeleteByPkTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function test_delete_by_pks() + { + $finder = DepartmentRecord::finder(); + $this->assertEqual($finder->deleteByPk(100),0); + $this->assertEqual($finder->deleteByPk(100, 101),0); + $this->assertEqual($finder->deleteByPk(array(100, 101)),0); + } + + function test_delete_by_composite_pks() + { + $finder = DepSections::finder(); + $this->assertEqual($finder->deleteByPk(array(100,101)),0); + $this->assertEqual($finder->deleteByPk(array(100, 101), array(102, 103)),0); + $this->assertEqual($finder->deleteByPk(array(array(100, 101), array(102, 103))),0); + } } ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/FindByPksTestCase.php b/tests/simple_unit/ActiveRecord/FindByPksTestCase.php index e3ba0358..4ccbddd5 100644 --- a/tests/simple_unit/ActiveRecord/FindByPksTestCase.php +++ b/tests/simple_unit/ActiveRecord/FindByPksTestCase.php @@ -1,64 +1,64 @@ -<?php
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
-require_once(dirname(__FILE__).'/records/DepSections.php');
-
-class FindByPksTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function test_find_by_1pk()
- {
- $dep = DepartmentRecord::finder()->findByPk(1);
- $this->assertNotNull($dep);
- $this->assertEqual($dep->department_id, 1);
- }
-
- function test_find_by_1pk_array()
- {
- $dep = DepartmentRecord::finder()->findByPk(array(1));
- $this->assertNotNull($dep);
- $this->assertEqual($dep->department_id, 1);
- }
-
- function test_find_by_pks()
- {
- $deps = DepartmentRecord::finder()->findAllByPks(1,2,4);
- $this->assertEqual(count($deps), 3);
-
- $this->assertEqual($deps[0]->department_id, 1);
- $this->assertEqual($deps[1]->department_id, 2);
- $this->assertEqual($deps[2]->department_id, 4);
- }
-
- function test_find_by_pks_with_invalid()
- {
- $deps = DepartmentRecord::finder()->findAllByPks(4,2,14);
- $this->assertEqual(count($deps), 2);
-
- $this->assertEqual($deps[0]->department_id, 2);
- $this->assertEqual($deps[1]->department_id, 4);
- }
-
- function test_find_by_composite_pks()
- {
- $ds = DepSections::finder()->findAllByPks(array(1,1), array(2,5));
- $this->assertEqual(count($ds), 2);
-
- $this->assertIsDepSection($ds[0], 1, 1);
- $this->assertIsDepSection($ds[1], 2, 5);
- }
-
- function assertIsDepSection($dep, $dep_id, $sec_id)
- {
- $this->assertTrue($dep instanceof DepSections);
- $this->assertEqual($dep->department_id, $dep_id);
- $this->assertEqual($dep->section_id, $sec_id);
- }
-}
+<?php +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/DepartmentRecord.php'); +require_once(dirname(__FILE__).'/records/DepSections.php'); + +class FindByPksTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function test_find_by_1pk() + { + $dep = DepartmentRecord::finder()->findByPk(1); + $this->assertNotNull($dep); + $this->assertEqual($dep->department_id, 1); + } + + function test_find_by_1pk_array() + { + $dep = DepartmentRecord::finder()->findByPk(array(1)); + $this->assertNotNull($dep); + $this->assertEqual($dep->department_id, 1); + } + + function test_find_by_pks() + { + $deps = DepartmentRecord::finder()->findAllByPks(1,2,4); + $this->assertEqual(count($deps), 3); + + $this->assertEqual($deps[0]->department_id, 1); + $this->assertEqual($deps[1]->department_id, 2); + $this->assertEqual($deps[2]->department_id, 4); + } + + function test_find_by_pks_with_invalid() + { + $deps = DepartmentRecord::finder()->findAllByPks(4,2,14); + $this->assertEqual(count($deps), 2); + + $this->assertEqual($deps[0]->department_id, 2); + $this->assertEqual($deps[1]->department_id, 4); + } + + function test_find_by_composite_pks() + { + $ds = DepSections::finder()->findAllByPks(array(1,1), array(2,5)); + $this->assertEqual(count($ds), 2); + + $this->assertIsDepSection($ds[0], 1, 1); + $this->assertIsDepSection($ds[1], 2, 5); + } + + function assertIsDepSection($dep, $dep_id, $sec_id) + { + $this->assertTrue($dep instanceof DepSections); + $this->assertEqual($dep->department_id, $dep_id); + $this->assertEqual($dep->section_id, $sec_id); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/FindBySqlTestCase.php b/tests/simple_unit/ActiveRecord/FindBySqlTestCase.php index 7f22afc5..e613cc30 100644 --- a/tests/simple_unit/ActiveRecord/FindBySqlTestCase.php +++ b/tests/simple_unit/ActiveRecord/FindBySqlTestCase.php @@ -1,46 +1,46 @@ -<?php
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
-require_once(dirname(__FILE__).'/records/UserRecord.php');
-
-class UserRecord2 extends UserRecord
-{
- public $another_value;
-}
-
-class SqlTest extends TActiveRecord
-{
- public $category;
- public $item;
-
- const TABLE='items';
-}
-
-class FindBySqlTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function test_find_by_sql()
- {
- $deps = DepartmentRecord::finder()->findBySql('SELECT * FROM departments');
- $this->assertTrue(count($deps) > 0);
- }
-
- function test_find_by_sql_arb()
- {
- $sql = 'SELECT c.name as category, i.name as item
- FROM items i, categories c
- WHERE i.category_id = c.category_id LIMIT 2';
- $items = TActiveRecord::finder('SqlTest')->findBySql($sql);
-
- $sql = "SELECT users.*, 'hello' as another_value FROM users LIMIT 2";
- $users = TActiveRecord::finder('UserRecord2')->findBySql($sql);
- var_dump($users);
- }
-}
+<?php +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/DepartmentRecord.php'); +require_once(dirname(__FILE__).'/records/UserRecord.php'); + +class UserRecord2 extends UserRecord +{ + public $another_value; +} + +class SqlTest extends TActiveRecord +{ + public $category; + public $item; + + const TABLE='items'; +} + +class FindBySqlTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function test_find_by_sql() + { + $deps = DepartmentRecord::finder()->findBySql('SELECT * FROM departments'); + $this->assertTrue(count($deps) > 0); + } + + function test_find_by_sql_arb() + { + $sql = 'SELECT c.name as category, i.name as item + FROM items i, categories c + WHERE i.category_id = c.category_id LIMIT 2'; + $items = TActiveRecord::finder('SqlTest')->findBySql($sql); + + $sql = "SELECT users.*, 'hello' as another_value FROM users LIMIT 2"; + $users = TActiveRecord::finder('UserRecord2')->findBySql($sql); + var_dump($users); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php b/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php index d8017aeb..b960760e 100644 --- a/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php +++ b/tests/simple_unit/ActiveRecord/ForeignKeyTestCase.php @@ -1,175 +1,175 @@ -<?php
-
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/ItemRecord.php');
-
-abstract class SqliteRecord extends TActiveRecord
-{
- protected static $conn;
-
- public function getDbConnection()
- {
- if(self::$conn===null)
- self::$conn = new TDbConnection('sqlite:'.dirname(__FILE__).'/fk_tests.db');
- return self::$conn;
- }
-}
-
-class Album extends SqliteRecord
-{
- public $title;
-
- public $Tracks = array();
- public $Artists = array();
-
- public $cover;
-
- public static $RELATIONS = array(
- 'Tracks' => array(self::HAS_MANY, 'Track'),
- 'Artists' => array(self::MANY_TO_MANY, 'Artist', 'album_artists'),
- 'cover' => array(self::HAS_ONE, 'Cover')
- );
-
- public static function finder($class=__CLASS__)
- {
- return parent::finder($class);
- }
-}
-
-class Artist extends SqliteRecord
-{
- public $name;
-
- public $Albums = array();
-
- public static $RELATIONS=array
- (
- 'Albums' => array(self::MANY_TO_MANY, 'Album', 'album_artists')
- );
-
- public static function finder($class=__CLASS__)
- {
- return parent::finder($class);
- }
-}
-
-class Track extends SqliteRecord
-{
- public $id;
- public $song_name;
- public $album_id; //FK -> Album.id
-
- public $Album;
-
- public static $RELATIONS = array(
- 'Album' => array(self::BELONGS_TO, 'Album'),
- );
-
- public static function finder($class=__CLASS__)
- {
- return parent::finder($class);
- }
-}
-
-class Cover extends SqliteRecord
-{
- public $album;
- public $content;
-}
-
-class ForeignKeyTestCase extends UnitTestCase
-{
- function test_has_many()
- {
- $albums = Album::finder()->withTracks()->findAll();
- $this->assertEqual(count($albums), 2);
-
- $this->assertEqual($albums[0]->title, 'Album 1');
- $this->assertEqual($albums[1]->title, 'Album 2');
-
- $this->assertEqual(count($albums[0]->Artists), 0);
- $this->assertEqual(count($albums[1]->Artists), 0);
-
- $this->assertEqual(count($albums[0]->Tracks), 3);
- $this->assertEqual(count($albums[1]->Tracks), 2);
-
- $this->assertEqual($albums[0]->Tracks[0]->song_name, 'Track 1');
- $this->assertEqual($albums[0]->Tracks[1]->song_name, 'Song 2');
- $this->assertEqual($albums[0]->Tracks[2]->song_name, 'Song 3');
-
- $this->assertEqual($albums[1]->Tracks[0]->song_name, 'Track A');
- $this->assertEqual($albums[1]->Tracks[1]->song_name, 'Track B');
- }
-
- function test_has_one()
- {
- $albums = Album::finder()->with_cover()->findAll();
- $this->assertEqual(count($albums), 2);
-
- $this->assertEqual($albums[0]->title, 'Album 1');
- $this->assertEqual($albums[1]->title, 'Album 2');
-
- $this->assertEqual($albums[0]->cover->content, 'lalala');
- $this->assertEqual($albums[1]->cover->content, 'conver content');
-
- $this->assertEqual(count($albums[0]->Artists), 0);
- $this->assertEqual(count($albums[1]->Artists), 0);
-
- $this->assertEqual(count($albums[0]->Tracks), 0);
- $this->assertEqual(count($albums[1]->Tracks), 0);
- }
-
- function test_belongs_to()
- {
- $track = Track::finder()->withAlbum()->find('id = ?', 1);
-
- $this->assertEqual($track->id, "1");
- $this->assertEqual($track->song_name, "Track 1");
- $this->assertEqual($track->Album->title, "Album 1");
- }
-
- function test_has_many_associate()
- {
- $album = Album::finder()->withArtists()->find('title = ?', 'Album 2');
- $this->assertEqual($album->title, 'Album 2');
- $this->assertEqual(count($album->Artists), 3);
-
- $this->assertEqual($album->Artists[0]->name, 'Dan');
- $this->assertEqual($album->Artists[1]->name, 'Karl');
- $this->assertEqual($album->Artists[2]->name, 'Tom');
- }
-
- function test_multiple_fk()
- {
- $album = Album::finder()->withArtists()->withTracks()->with_cover()->find('title = ?', 'Album 1');
-
- $this->assertEqual($album->title, 'Album 1');
- $this->assertEqual(count($album->Artists), 2);
-
- $this->assertEqual($album->Artists[0]->name, 'Dan');
- $this->assertEqual($album->Artists[1]->name, 'Jenny');
-
- $this->assertEqual($album->Tracks[0]->song_name, 'Track 1');
- $this->assertEqual($album->Tracks[1]->song_name, 'Song 2');
- $this->assertEqual($album->Tracks[2]->song_name, 'Song 3');
-
- $this->assertEqual($album->cover->content, 'lalala');
- }
-
- function test_self_reference_fk()
- {
- $item = ItemRecord::finder()->withRelated_Items()->findByPk(1);
- $this->assertNotNull($item);
- $this->assertEqual($item->name, "Professional Work Attire");
-
- $this->assertEqual(count($item->related_items),2);
- $this->assertEqual($item->related_items[0]->name, "Nametags");
- $this->assertEqual($item->related_items[0]->item_id, 2);
-
- $this->assertEqual($item->related_items[1]->name, "Grooming and Hygiene");
- $this->assertEqual($item->related_items[1]->item_id, 3);
- }
-
-}
-
+<?php + +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/ItemRecord.php'); + +abstract class SqliteRecord extends TActiveRecord +{ + protected static $conn; + + public function getDbConnection() + { + if(self::$conn===null) + self::$conn = new TDbConnection('sqlite:'.dirname(__FILE__).'/fk_tests.db'); + return self::$conn; + } +} + +class Album extends SqliteRecord +{ + public $title; + + public $Tracks = array(); + public $Artists = array(); + + public $cover; + + public static $RELATIONS = array( + 'Tracks' => array(self::HAS_MANY, 'Track'), + 'Artists' => array(self::MANY_TO_MANY, 'Artist', 'album_artists'), + 'cover' => array(self::HAS_ONE, 'Cover') + ); + + public static function finder($class=__CLASS__) + { + return parent::finder($class); + } +} + +class Artist extends SqliteRecord +{ + public $name; + + public $Albums = array(); + + public static $RELATIONS=array + ( + 'Albums' => array(self::MANY_TO_MANY, 'Album', 'album_artists') + ); + + public static function finder($class=__CLASS__) + { + return parent::finder($class); + } +} + +class Track extends SqliteRecord +{ + public $id; + public $song_name; + public $album_id; //FK -> Album.id + + public $Album; + + public static $RELATIONS = array( + 'Album' => array(self::BELONGS_TO, 'Album'), + ); + + public static function finder($class=__CLASS__) + { + return parent::finder($class); + } +} + +class Cover extends SqliteRecord +{ + public $album; + public $content; +} + +class ForeignKeyTestCase extends UnitTestCase +{ + function test_has_many() + { + $albums = Album::finder()->withTracks()->findAll(); + $this->assertEqual(count($albums), 2); + + $this->assertEqual($albums[0]->title, 'Album 1'); + $this->assertEqual($albums[1]->title, 'Album 2'); + + $this->assertEqual(count($albums[0]->Artists), 0); + $this->assertEqual(count($albums[1]->Artists), 0); + + $this->assertEqual(count($albums[0]->Tracks), 3); + $this->assertEqual(count($albums[1]->Tracks), 2); + + $this->assertEqual($albums[0]->Tracks[0]->song_name, 'Track 1'); + $this->assertEqual($albums[0]->Tracks[1]->song_name, 'Song 2'); + $this->assertEqual($albums[0]->Tracks[2]->song_name, 'Song 3'); + + $this->assertEqual($albums[1]->Tracks[0]->song_name, 'Track A'); + $this->assertEqual($albums[1]->Tracks[1]->song_name, 'Track B'); + } + + function test_has_one() + { + $albums = Album::finder()->with_cover()->findAll(); + $this->assertEqual(count($albums), 2); + + $this->assertEqual($albums[0]->title, 'Album 1'); + $this->assertEqual($albums[1]->title, 'Album 2'); + + $this->assertEqual($albums[0]->cover->content, 'lalala'); + $this->assertEqual($albums[1]->cover->content, 'conver content'); + + $this->assertEqual(count($albums[0]->Artists), 0); + $this->assertEqual(count($albums[1]->Artists), 0); + + $this->assertEqual(count($albums[0]->Tracks), 0); + $this->assertEqual(count($albums[1]->Tracks), 0); + } + + function test_belongs_to() + { + $track = Track::finder()->withAlbum()->find('id = ?', 1); + + $this->assertEqual($track->id, "1"); + $this->assertEqual($track->song_name, "Track 1"); + $this->assertEqual($track->Album->title, "Album 1"); + } + + function test_has_many_associate() + { + $album = Album::finder()->withArtists()->find('title = ?', 'Album 2'); + $this->assertEqual($album->title, 'Album 2'); + $this->assertEqual(count($album->Artists), 3); + + $this->assertEqual($album->Artists[0]->name, 'Dan'); + $this->assertEqual($album->Artists[1]->name, 'Karl'); + $this->assertEqual($album->Artists[2]->name, 'Tom'); + } + + function test_multiple_fk() + { + $album = Album::finder()->withArtists()->withTracks()->with_cover()->find('title = ?', 'Album 1'); + + $this->assertEqual($album->title, 'Album 1'); + $this->assertEqual(count($album->Artists), 2); + + $this->assertEqual($album->Artists[0]->name, 'Dan'); + $this->assertEqual($album->Artists[1]->name, 'Jenny'); + + $this->assertEqual($album->Tracks[0]->song_name, 'Track 1'); + $this->assertEqual($album->Tracks[1]->song_name, 'Song 2'); + $this->assertEqual($album->Tracks[2]->song_name, 'Song 3'); + + $this->assertEqual($album->cover->content, 'lalala'); + } + + function test_self_reference_fk() + { + $item = ItemRecord::finder()->withRelated_Items()->findByPk(1); + $this->assertNotNull($item); + $this->assertEqual($item->name, "Professional Work Attire"); + + $this->assertEqual(count($item->related_items),2); + $this->assertEqual($item->related_items[0]->name, "Nametags"); + $this->assertEqual($item->related_items[0]->item_id, 2); + + $this->assertEqual($item->related_items[1]->name, "Grooming and Hygiene"); + $this->assertEqual($item->related_items[1]->item_id, 3); + } + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ForeignObjectUpdateTest.php b/tests/simple_unit/ActiveRecord/ForeignObjectUpdateTest.php index 026efb4d..672c2d0f 100644 --- a/tests/simple_unit/ActiveRecord/ForeignObjectUpdateTest.php +++ b/tests/simple_unit/ActiveRecord/ForeignObjectUpdateTest.php @@ -1,242 +1,242 @@ -<?php
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-
-class BaseFkRecord extends TActiveRecord
-{
- public function getDbConnection()
- {
- static $conn;
- if($conn===null)
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- //$this->OnExecuteCommand[] = array($this,'logger');
- }
- return $conn;
- }
-
- function logger($sender,$param)
- {
- }
-}
-
-class TeamRecord extends BaseFkRecord
-{
- const TABLE='teams';
- public $name;
- public $location;
-
- public $players=array();
-
- //define the $player member having has many relationship with PlayerRecord
- public static $RELATIONS=array
- (
- 'players' => array(self::HAS_MANY, 'PlayerRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
-
-class PlayerRecord extends BaseFkRecord
-{
- const TABLE='players';
- public $player_id;
- public $age;
- public $team_name;
-
- public $team;
- private $_skills;
- public $profile;
-
- public static $RELATIONS=array
- (
- 'skills' => array(self::MANY_TO_MANY, 'SkillRecord', 'player_skills'),
- 'team' => array(self::BELONGS_TO, 'TeamRecord'),
- 'profile' => array(self::HAS_ONE, 'ProfileRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-
- public function getSkills()
- {
- if($this->_skills===null && $this->player_id !==null)
- {
- //lazy load the skill records
- $this->setSkills($this->withSkills()->findByPk($this->player_id)->skills);
- }
- else if($this->_skills===null)
- {
- //create new TList;
- $this->setSkills(new TList());
- }
- return $this->_skills;
- }
-
- public function setSkills($value)
- {
- $this->_skills = $value instanceof TList ? $value : new TList($value);
- }
-}
-
-class ProfileRecord extends BaseFkRecord
-{
- const TABLE='profiles';
- public $fk_player_id;
- public $salary;
-
- public $player;
-
- public static $RELATIONS=array
- (
- 'player' => array(self::BELONGS_TO, 'PlayerRecord'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
-
-class SkillRecord extends BaseFkRecord
-{
- const TABLE='skills';
- public $skill_id;
- public $name;
-
- public $players=array();
-
- public static $RELATIONS=array
- (
- 'players' => array(self::MANY_TO_MANY, 'PlayerRecord', 'player_skills'),
- );
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-
-
-}
-
-class ForeignObjectUpdateTest extends UnitTestCase
-{
- function test_add_has_one()
- {
- ProfileRecord::finder()->deleteByPk(3);
-
- $player = PlayerRecord::finder()->findByPk(3);
- $player->profile = new ProfileRecord(array('salary'=>50000));
- $player->save();
-
- //test insert
- $player2 = PlayerRecord::finder()->withProfile()->findByPk(3);
- $this->assertEqual($player2->profile->salary,50000);
-
- $player2->profile->salary = 45000;
- $player2->save();
- $this->assertEqual($player2->profile->salary,45000);
-
- //test update
- $player3 = PlayerRecord::finder()->withProfile()->findByPk(3);
- $this->assertEqual($player3->profile->salary,45000);
- }
-
- function test_add_many()
- {
- PlayerRecord::finder()->deleteAll("player_id > ?", 3);
-
- $team = TeamRecord::finder()->findByPk('Team b');
- $team->players[] = new PlayerRecord(array('age'=>20));
- $team->players[] = new PlayerRecord(array('age'=>25));
- $team->save();
-
- //test insert
- $team1 = TeamRecord::finder()->withPlayers()->findByPk('Team b');
- $this->assertEqual(count($team1->players),3);
- $this->assertEqual($team1->players[0]->age, 18);
- $this->assertEqual($team1->players[1]->age, 20);
- $this->assertEqual($team1->players[2]->age, 25);
-
- //test update
- $team1->players[1]->age = 55;
- $team1->save();
-
- $this->assertEqual($team1->players[0]->age, 18);
- $this->assertEqual($team1->players[1]->age, 55);
- $this->assertEqual($team1->players[2]->age, 25);
-
- $criteria = new TActiveRecordCriteria();
- $criteria->OrdersBy['age'] = 'desc';
- $team2 = TeamRecord::finder()->withPlayers($criteria)->findByPk('Team b');
- $this->assertEqual(count($team2->players),3);
- //ordered by age
- $this->assertEqual($team2->players[0]->age, 55);
- $this->assertEqual($team2->players[1]->age, 25);
- $this->assertEqual($team2->players[2]->age, 18);
- }
-
- function test_add_belongs_to()
- {
- TeamRecord::finder()->deleteByPk('Team c');
- PlayerRecord::finder()->deleteAll("player_id > ?", 3);
-
- $player = new PlayerRecord(array('age'=>27));
- $player->team = new TeamRecord(array('name'=>'Team c', 'location'=>'Sydney'));
- $player->save();
-
- //test insert
- $player1 = PlayerRecord::finder()->withTeam()->findByAge(27);
- $this->assertNotNull($player1);
- $this->assertNotNull($player1->team);
- $this->assertEqual($player1->team->name, 'Team c');
- $this->assertEqual($player1->team->location, 'Sydney');
- }
-
- function test_add_many_via_association()
- {
- PlayerRecord::finder()->deleteAll("player_id > ?", 3);
- SkillRecord::finder()->deleteAll("skill_id > ?", 3);
-
- $player = new PlayerRecord(array('age'=>37));
- $player->skills[] = new SkillRecord(array('name'=>'Bash'));
- $player->skills[] = new SkillRecord(array('name'=>'Jump'));
- $player->save();
-
- //test insert
- $player2 = PlayerRecord::finder()->withSkills()->findByAge(37);
- $this->assertNotNull($player2);
- $this->assertEqual(count($player2->skills), 2);
- $this->assertEqual($player2->skills[0]->name, 'Bash');
- $this->assertEqual($player2->skills[1]->name, 'Jump');
-
- //test update
- $player2->skills[1]->name = "Skip";
- $player2->skills[] = new SkillRecord(array('name'=>'Push'));
- $player2->save();
-
- $criteria = new TActiveRecordCriteria();
- $criteria->OrdersBy['name'] = 'asc';
- $player3 = PlayerRecord::finder()->withSkills($criteria)->findByAge(37);
- $this->assertNotNull($player3);
- $this->assertEqual(count($player3->skills), 3);
- $this->assertEqual($player3->skills[0]->name, 'Bash');
- $this->assertEqual($player3->skills[1]->name, 'Push');
- $this->assertEqual($player3->skills[2]->name, 'Skip');
-
- //test lazy load
- $player4 = PlayerRecord::finder()->findByAge(37);
- $this->assertEqual(count($player4->skills), 3);
-
- $this->assertEqual($player4->skills[0]->name, 'Bash');
- $this->assertEqual($player4->skills[1]->name, 'Skip');
- $this->assertEqual($player4->skills[2]->name, 'Push');
- }
-//*/
-}
-
+<?php +Prado::using('System.Data.ActiveRecord.TActiveRecord'); + +class BaseFkRecord extends TActiveRecord +{ + public function getDbConnection() + { + static $conn; + if($conn===null) + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + //$this->OnExecuteCommand[] = array($this,'logger'); + } + return $conn; + } + + function logger($sender,$param) + { + } +} + +class TeamRecord extends BaseFkRecord +{ + const TABLE='teams'; + public $name; + public $location; + + public $players=array(); + + //define the $player member having has many relationship with PlayerRecord + public static $RELATIONS=array + ( + 'players' => array(self::HAS_MANY, 'PlayerRecord'), + ); + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } +} + +class PlayerRecord extends BaseFkRecord +{ + const TABLE='players'; + public $player_id; + public $age; + public $team_name; + + public $team; + private $_skills; + public $profile; + + public static $RELATIONS=array + ( + 'skills' => array(self::MANY_TO_MANY, 'SkillRecord', 'player_skills'), + 'team' => array(self::BELONGS_TO, 'TeamRecord'), + 'profile' => array(self::HAS_ONE, 'ProfileRecord'), + ); + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } + + public function getSkills() + { + if($this->_skills===null && $this->player_id !==null) + { + //lazy load the skill records + $this->setSkills($this->withSkills()->findByPk($this->player_id)->skills); + } + else if($this->_skills===null) + { + //create new TList; + $this->setSkills(new TList()); + } + return $this->_skills; + } + + public function setSkills($value) + { + $this->_skills = $value instanceof TList ? $value : new TList($value); + } +} + +class ProfileRecord extends BaseFkRecord +{ + const TABLE='profiles'; + public $fk_player_id; + public $salary; + + public $player; + + public static $RELATIONS=array + ( + 'player' => array(self::BELONGS_TO, 'PlayerRecord'), + ); + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } +} + +class SkillRecord extends BaseFkRecord +{ + const TABLE='skills'; + public $skill_id; + public $name; + + public $players=array(); + + public static $RELATIONS=array + ( + 'players' => array(self::MANY_TO_MANY, 'PlayerRecord', 'player_skills'), + ); + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } + + +} + +class ForeignObjectUpdateTest extends UnitTestCase +{ + function test_add_has_one() + { + ProfileRecord::finder()->deleteByPk(3); + + $player = PlayerRecord::finder()->findByPk(3); + $player->profile = new ProfileRecord(array('salary'=>50000)); + $player->save(); + + //test insert + $player2 = PlayerRecord::finder()->withProfile()->findByPk(3); + $this->assertEqual($player2->profile->salary,50000); + + $player2->profile->salary = 45000; + $player2->save(); + $this->assertEqual($player2->profile->salary,45000); + + //test update + $player3 = PlayerRecord::finder()->withProfile()->findByPk(3); + $this->assertEqual($player3->profile->salary,45000); + } + + function test_add_many() + { + PlayerRecord::finder()->deleteAll("player_id > ?", 3); + + $team = TeamRecord::finder()->findByPk('Team b'); + $team->players[] = new PlayerRecord(array('age'=>20)); + $team->players[] = new PlayerRecord(array('age'=>25)); + $team->save(); + + //test insert + $team1 = TeamRecord::finder()->withPlayers()->findByPk('Team b'); + $this->assertEqual(count($team1->players),3); + $this->assertEqual($team1->players[0]->age, 18); + $this->assertEqual($team1->players[1]->age, 20); + $this->assertEqual($team1->players[2]->age, 25); + + //test update + $team1->players[1]->age = 55; + $team1->save(); + + $this->assertEqual($team1->players[0]->age, 18); + $this->assertEqual($team1->players[1]->age, 55); + $this->assertEqual($team1->players[2]->age, 25); + + $criteria = new TActiveRecordCriteria(); + $criteria->OrdersBy['age'] = 'desc'; + $team2 = TeamRecord::finder()->withPlayers($criteria)->findByPk('Team b'); + $this->assertEqual(count($team2->players),3); + //ordered by age + $this->assertEqual($team2->players[0]->age, 55); + $this->assertEqual($team2->players[1]->age, 25); + $this->assertEqual($team2->players[2]->age, 18); + } + + function test_add_belongs_to() + { + TeamRecord::finder()->deleteByPk('Team c'); + PlayerRecord::finder()->deleteAll("player_id > ?", 3); + + $player = new PlayerRecord(array('age'=>27)); + $player->team = new TeamRecord(array('name'=>'Team c', 'location'=>'Sydney')); + $player->save(); + + //test insert + $player1 = PlayerRecord::finder()->withTeam()->findByAge(27); + $this->assertNotNull($player1); + $this->assertNotNull($player1->team); + $this->assertEqual($player1->team->name, 'Team c'); + $this->assertEqual($player1->team->location, 'Sydney'); + } + + function test_add_many_via_association() + { + PlayerRecord::finder()->deleteAll("player_id > ?", 3); + SkillRecord::finder()->deleteAll("skill_id > ?", 3); + + $player = new PlayerRecord(array('age'=>37)); + $player->skills[] = new SkillRecord(array('name'=>'Bash')); + $player->skills[] = new SkillRecord(array('name'=>'Jump')); + $player->save(); + + //test insert + $player2 = PlayerRecord::finder()->withSkills()->findByAge(37); + $this->assertNotNull($player2); + $this->assertEqual(count($player2->skills), 2); + $this->assertEqual($player2->skills[0]->name, 'Bash'); + $this->assertEqual($player2->skills[1]->name, 'Jump'); + + //test update + $player2->skills[1]->name = "Skip"; + $player2->skills[] = new SkillRecord(array('name'=>'Push')); + $player2->save(); + + $criteria = new TActiveRecordCriteria(); + $criteria->OrdersBy['name'] = 'asc'; + $player3 = PlayerRecord::finder()->withSkills($criteria)->findByAge(37); + $this->assertNotNull($player3); + $this->assertEqual(count($player3->skills), 3); + $this->assertEqual($player3->skills[0]->name, 'Bash'); + $this->assertEqual($player3->skills[1]->name, 'Push'); + $this->assertEqual($player3->skills[2]->name, 'Skip'); + + //test lazy load + $player4 = PlayerRecord::finder()->findByAge(37); + $this->assertEqual(count($player4->skills), 3); + + $this->assertEqual($player4->skills[0]->name, 'Bash'); + $this->assertEqual($player4->skills[1]->name, 'Skip'); + $this->assertEqual($player4->skills[2]->name, 'Push'); + } +//*/ +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php b/tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php index 77408631..c43db032 100644 --- a/tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php +++ b/tests/simple_unit/ActiveRecord/MultipleForeignKeyTestCase.php @@ -1,192 +1,192 @@ -<?php
-
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-
-abstract class MultipleFKSqliteRecord extends TActiveRecord
-{
- protected static $conn;
-
- public function getDbConnection()
- {
- if(self::$conn===null)
- self::$conn = new TDbConnection('sqlite:'.dirname(__FILE__).'/test1.sqlite');
- return self::$conn;
- }
-}
-
-/**
- *
-CREATE TABLE table1 (
-id integer PRIMARY KEY AUTOINCREMENT,
-field1 varchar,
-fk1 integer CONSTRAINT fk_id1 REFERENCES table2(id) ON DELETE CASCADE,
-fk2 integer CONSTRAINT fk_id2 REFERENCES table2(id) ON DELETE CASCADE,
-fk3 integer CONSTRAINT fk_id3 REFERENCES table2(id) ON DELETE CASCADE)
- */
-class Table1 extends MultipleFKSqliteRecord
-{
- public $id;
- public $field1;
- public $fk1;
- public $fk2;
- public $fk3;
-
- public $object1;
- //public $object2; //commented out for testing __get/__set
- public $object3;
-
- public static $RELATIONS = array
- (
- 'object1' => array(self::BELONGS_TO, 'Table2', 'fk1'),
- 'object2' => array(self::BELONGS_TO, 'Table2', 'fk2'),
- 'object3' => array(self::BELONGS_TO, 'Table2', 'fk3'),
- );
-
- public static function finder($class=__CLASS__)
- {
- return parent::finder($class);
- }
-}
-
-/**
- * CREATE TABLE table2 (id integer PRIMARY KEY AUTOINCREMENT,field1 varchar)
- */
-class Table2 extends MultipleFKSqliteRecord
-{
- public $id;
- public $field1;
-
- private $_state1;
- //public $state2; //commented out for testing __get/__set
- public $state3;
-
- public static $RELATIONS = array
- (
- 'state1' => array(self::HAS_MANY, 'Table1', 'fk1'),
- 'state2' => array(self::HAS_MANY, 'Table1', 'fk2'),
- 'state3' => array(self::HAS_ONE, 'Table1', 'fk3'),
- );
-
- public function setState1($obj)
- {
- $this->_state1 = $obj;
- }
-
- public function getState1()
- {
- if(is_null($this->_state1))
- $this->fetchResultsFor('state1');
- return $this->_state1;
- }
-
- public static function finder($class=__CLASS__)
- {
- return parent::finder($class);
- }
-}
-
-
-class Category extends MultipleFKSqliteRecord
-{
- public $cat_id;
- public $category_name;
- public $parent_cat;
-
- public $parent_category;
- public $child_categories=array();
-
- public static $RELATIONS=array
- (
- 'parent_category' => array(self::BELONGS_TO, 'Category'),
- 'child_categories' => array(self::HAS_MANY, 'Category'),
- );
-
- public static function finder($class=__CLASS__)
- {
- return parent::finder($class);
- }
-}
-
-class MultipleForeignKeyTestCase extends UnitTestCase
-{
- function testBelongsTo()
- {
- $obj = Table1::finder()->withObject1()->findAll();
- $this->assertEqual(count($obj), 3);
- $this->assertEqual($obj[0]->id, '1');
- $this->assertEqual($obj[1]->id, '2');
- $this->assertEqual($obj[2]->id, '3');
-
- $this->assertEqual($obj[0]->object1->id, '1');
- $this->assertEqual($obj[1]->object1->id, '2');
- $this->assertEqual($obj[2]->object1->id, '2');
- }
-
- function testHasMany()
- {
- $obj = Table2::finder()->withState1()->findAll();
- $this->assertEqual(count($obj), 5);
-
- $this->assertEqual(count($obj[0]->state1), 1);
- $this->assertEqual($obj[0]->state1[0]->id, '1');
-
- $this->assertEqual(count($obj[1]->state1), 2);
- $this->assertEqual($obj[1]->state1[0]->id, '2');
- $this->assertEqual($obj[1]->state1[1]->id, '3');
-
- $this->assertEqual(count($obj[2]->state1), 0);
- $this->assertEqual($obj[2]->id, '3');
-
- $this->assertEqual(count($obj[3]->state1), 0);
- $this->assertEqual($obj[3]->id, '4');
- }
-
- function testHasOne()
- {
- $obj = Table2::finder()->withState3('id = 3')->findAll();
-
- $this->assertEqual(count($obj), 5);
-
- $this->assertEqual($obj[0]->id, '1');
- $this->assertNull($obj[0]->state3);
-
- $this->assertEqual($obj[1]->id, '2');
- $this->assertNull($obj[1]->state3);
-
- $this->assertEqual($obj[2]->id, '3');
- $this->assertNotNull($obj[2]->state3);
- $this->assertEqual($obj[2]->state3->id, '3');
-
- $this->assertEqual($obj[3]->id, '4');
- $this->assertNull($obj[3]->state3);
- }
-
- function testParentChild()
- {
- $obj = Category::finder()->withChild_Categories()->withParent_Category()->findByPk(2);
-
- $this->assertEqual($obj->cat_id, '2');
- $this->assertEqual(count($obj->child_categories), 2);
- $this->assertNotNull($obj->parent_category);
-
- $this->assertEqual($obj->child_categories[0]->cat_id, 3);
- $this->assertEqual($obj->child_categories[1]->cat_id, 4);
-
- $this->assertEqual($obj->parent_category->cat_id, 1);
- }
-
- function testLazyLoadingGetterSetter_hasMany()
- {
- $arr = Table2::finder()->findByPk(2);
-
- $this->assertNotNull($arr->state2); //lazy load
- $this->assertEqual(count($arr->state2), 1);
- $this->assertEqual($arr->state2[0]->id, "1");
- $this->assertNotNull($arr->state2[0]->object2);
- $this->assertEqual($arr->state2[0]->object2->id, "2");
-
- $this->assertNotIdentical($arr, $arr->state2[0]->object2);
- }
-}
-
+<?php + +Prado::using('System.Data.ActiveRecord.TActiveRecord'); + +abstract class MultipleFKSqliteRecord extends TActiveRecord +{ + protected static $conn; + + public function getDbConnection() + { + if(self::$conn===null) + self::$conn = new TDbConnection('sqlite:'.dirname(__FILE__).'/test1.sqlite'); + return self::$conn; + } +} + +/** + * +CREATE TABLE table1 ( +id integer PRIMARY KEY AUTOINCREMENT, +field1 varchar, +fk1 integer CONSTRAINT fk_id1 REFERENCES table2(id) ON DELETE CASCADE, +fk2 integer CONSTRAINT fk_id2 REFERENCES table2(id) ON DELETE CASCADE, +fk3 integer CONSTRAINT fk_id3 REFERENCES table2(id) ON DELETE CASCADE) + */ +class Table1 extends MultipleFKSqliteRecord +{ + public $id; + public $field1; + public $fk1; + public $fk2; + public $fk3; + + public $object1; + //public $object2; //commented out for testing __get/__set + public $object3; + + public static $RELATIONS = array + ( + 'object1' => array(self::BELONGS_TO, 'Table2', 'fk1'), + 'object2' => array(self::BELONGS_TO, 'Table2', 'fk2'), + 'object3' => array(self::BELONGS_TO, 'Table2', 'fk3'), + ); + + public static function finder($class=__CLASS__) + { + return parent::finder($class); + } +} + +/** + * CREATE TABLE table2 (id integer PRIMARY KEY AUTOINCREMENT,field1 varchar) + */ +class Table2 extends MultipleFKSqliteRecord +{ + public $id; + public $field1; + + private $_state1; + //public $state2; //commented out for testing __get/__set + public $state3; + + public static $RELATIONS = array + ( + 'state1' => array(self::HAS_MANY, 'Table1', 'fk1'), + 'state2' => array(self::HAS_MANY, 'Table1', 'fk2'), + 'state3' => array(self::HAS_ONE, 'Table1', 'fk3'), + ); + + public function setState1($obj) + { + $this->_state1 = $obj; + } + + public function getState1() + { + if(is_null($this->_state1)) + $this->fetchResultsFor('state1'); + return $this->_state1; + } + + public static function finder($class=__CLASS__) + { + return parent::finder($class); + } +} + + +class Category extends MultipleFKSqliteRecord +{ + public $cat_id; + public $category_name; + public $parent_cat; + + public $parent_category; + public $child_categories=array(); + + public static $RELATIONS=array + ( + 'parent_category' => array(self::BELONGS_TO, 'Category'), + 'child_categories' => array(self::HAS_MANY, 'Category'), + ); + + public static function finder($class=__CLASS__) + { + return parent::finder($class); + } +} + +class MultipleForeignKeyTestCase extends UnitTestCase +{ + function testBelongsTo() + { + $obj = Table1::finder()->withObject1()->findAll(); + $this->assertEqual(count($obj), 3); + $this->assertEqual($obj[0]->id, '1'); + $this->assertEqual($obj[1]->id, '2'); + $this->assertEqual($obj[2]->id, '3'); + + $this->assertEqual($obj[0]->object1->id, '1'); + $this->assertEqual($obj[1]->object1->id, '2'); + $this->assertEqual($obj[2]->object1->id, '2'); + } + + function testHasMany() + { + $obj = Table2::finder()->withState1()->findAll(); + $this->assertEqual(count($obj), 5); + + $this->assertEqual(count($obj[0]->state1), 1); + $this->assertEqual($obj[0]->state1[0]->id, '1'); + + $this->assertEqual(count($obj[1]->state1), 2); + $this->assertEqual($obj[1]->state1[0]->id, '2'); + $this->assertEqual($obj[1]->state1[1]->id, '3'); + + $this->assertEqual(count($obj[2]->state1), 0); + $this->assertEqual($obj[2]->id, '3'); + + $this->assertEqual(count($obj[3]->state1), 0); + $this->assertEqual($obj[3]->id, '4'); + } + + function testHasOne() + { + $obj = Table2::finder()->withState3('id = 3')->findAll(); + + $this->assertEqual(count($obj), 5); + + $this->assertEqual($obj[0]->id, '1'); + $this->assertNull($obj[0]->state3); + + $this->assertEqual($obj[1]->id, '2'); + $this->assertNull($obj[1]->state3); + + $this->assertEqual($obj[2]->id, '3'); + $this->assertNotNull($obj[2]->state3); + $this->assertEqual($obj[2]->state3->id, '3'); + + $this->assertEqual($obj[3]->id, '4'); + $this->assertNull($obj[3]->state3); + } + + function testParentChild() + { + $obj = Category::finder()->withChild_Categories()->withParent_Category()->findByPk(2); + + $this->assertEqual($obj->cat_id, '2'); + $this->assertEqual(count($obj->child_categories), 2); + $this->assertNotNull($obj->parent_category); + + $this->assertEqual($obj->child_categories[0]->cat_id, 3); + $this->assertEqual($obj->child_categories[1]->cat_id, 4); + + $this->assertEqual($obj->parent_category->cat_id, 1); + } + + function testLazyLoadingGetterSetter_hasMany() + { + $arr = Table2::finder()->findByPk(2); + + $this->assertNotNull($arr->state2); //lazy load + $this->assertEqual(count($arr->state2), 1); + $this->assertEqual($arr->state2[0]->id, "1"); + $this->assertNotNull($arr->state2[0]->object2); + $this->assertEqual($arr->state2[0]->object2->id, "2"); + + $this->assertNotIdentical($arr, $arr->state2[0]->object2); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/RecordEventTestCase.php b/tests/simple_unit/ActiveRecord/RecordEventTestCase.php index f6009608..3e98d46b 100644 --- a/tests/simple_unit/ActiveRecord/RecordEventTestCase.php +++ b/tests/simple_unit/ActiveRecord/RecordEventTestCase.php @@ -1,37 +1,37 @@ -<?php
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/UserRecord.php');
-
-class RecordEventTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function testFindByPk()
- {
- $user1 = UserRecord::finder()->findByPk('admin');
- $this->assertNotNull($user1);
- }
-
- function test_same_data_returns_same_object()
- {
- $criteria = new TActiveRecordCriteria('username = ?', 'admin');
- $finder = new UserRecord();
- $finder->OnCreateCommand[] = array($this, 'logger');
- $finder->OnExecuteCommand[] = array($this, 'logger');
- $user1 = $finder->find($criteria);
- //var_dump($user1);
-
- //var_dump(UserRecord::finder()->find($criteria));
- }
-
- function logger($sender, $param)
- {
- //var_dump($param);
- }
-}
-
+<?php +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/UserRecord.php'); + +class RecordEventTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function testFindByPk() + { + $user1 = UserRecord::finder()->findByPk('admin'); + $this->assertNotNull($user1); + } + + function test_same_data_returns_same_object() + { + $criteria = new TActiveRecordCriteria('username = ?', 'admin'); + $finder = new UserRecord(); + $finder->OnCreateCommand[] = array($this, 'logger'); + $finder->OnExecuteCommand[] = array($this, 'logger'); + $user1 = $finder->find($criteria); + //var_dump($user1); + + //var_dump(UserRecord::finder()->find($criteria)); + } + + function logger($sender, $param) + { + //var_dump($param); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/SqliteTestCase.php b/tests/simple_unit/ActiveRecord/SqliteTestCase.php index 94af6200..7d860b9a 100644 --- a/tests/simple_unit/ActiveRecord/SqliteTestCase.php +++ b/tests/simple_unit/ActiveRecord/SqliteTestCase.php @@ -1,21 +1,21 @@ -<?php
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/SqliteUsers.php');
-
-class SqliteTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('sqlite2:'.dirname(__FILE__).'/ar_test.db');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function test_finder()
- {
- $finder = SqliteUsers::finder();
- $user = $finder->findByPk('test');
- $this->assertNotNull($user);
- }
-}
+<?php +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/SqliteUsers.php'); + +class SqliteTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('sqlite2:'.dirname(__FILE__).'/ar_test.db'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function test_finder() + { + $finder = SqliteUsers::finder(); + $user = $finder->findByPk('test'); + $this->assertNotNull($user); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/UserRecordTestCase.php b/tests/simple_unit/ActiveRecord/UserRecordTestCase.php index 057455f7..34e45ca8 100644 --- a/tests/simple_unit/ActiveRecord/UserRecordTestCase.php +++ b/tests/simple_unit/ActiveRecord/UserRecordTestCase.php @@ -1,66 +1,66 @@ -<?php
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/UserRecord.php');
-
-class UserRecordTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function testFindByPk()
- {
- $user1 = UserRecord::finder()->findByPk('admin');
- $this->assertNotNull($user1);
- }
-
- function test_same_data_returns_different_instance()
- {
- $user1 = UserRecord::finder()->findByPk('admin');
- $this->assertNotNull($user1);
-
- $user2 = UserRecord::finder()->findByPk('admin');
- $this->assertFalse($user1===$user2);
- }
-
- function testFindByPk_returns_null()
- {
- $user = UserRecord::finder()->findByPk('me');
- $this->assertNull($user);
- }
-
- function test_Create_new_user_returns_true()
- {
- $user = new UserRecord;
- $user->username = 'hello';
- $user->password = md5('asd');
- $user->email = 'asdasd';
- $user->first_name = 'wei';
- $user->last_name = 'zhuo';
-
- $this->assertTrue($user->save());
-
- $user->password = md5('more');
-
- $this->assertTrue($user->save());
-
- $check = UserRecord::finder()->findByPk('hello');
-
- $this->assertSameUser($user, $check);
-
- $this->assertTrue($user->delete());
- }
-
- function assertSameUser($user,$check)
- {
- $props = array('username', 'password', 'email', 'first_name', 'last_name', 'job_title',
- 'work_phone', 'work_fax', 'active', 'department_id', 'salutation',
- 'hint_question', 'hint_answer');
- foreach($props as $prop)
- $this->assertEqual($user->$prop,$check->$prop);
- }
-}
-
+<?php +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/UserRecord.php'); + +class UserRecordTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function testFindByPk() + { + $user1 = UserRecord::finder()->findByPk('admin'); + $this->assertNotNull($user1); + } + + function test_same_data_returns_different_instance() + { + $user1 = UserRecord::finder()->findByPk('admin'); + $this->assertNotNull($user1); + + $user2 = UserRecord::finder()->findByPk('admin'); + $this->assertFalse($user1===$user2); + } + + function testFindByPk_returns_null() + { + $user = UserRecord::finder()->findByPk('me'); + $this->assertNull($user); + } + + function test_Create_new_user_returns_true() + { + $user = new UserRecord; + $user->username = 'hello'; + $user->password = md5('asd'); + $user->email = 'asdasd'; + $user->first_name = 'wei'; + $user->last_name = 'zhuo'; + + $this->assertTrue($user->save()); + + $user->password = md5('more'); + + $this->assertTrue($user->save()); + + $check = UserRecord::finder()->findByPk('hello'); + + $this->assertSameUser($user, $check); + + $this->assertTrue($user->delete()); + } + + function assertSameUser($user,$check) + { + $props = array('username', 'password', 'email', 'first_name', 'last_name', 'job_title', + 'work_phone', 'work_fax', 'active', 'department_id', 'salutation', + 'hint_question', 'hint_answer'); + foreach($props as $prop) + $this->assertEqual($user->$prop,$check->$prop); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ViewRecordTestCase.php b/tests/simple_unit/ActiveRecord/ViewRecordTestCase.php index db23f01a..adf0beed 100644 --- a/tests/simple_unit/ActiveRecord/ViewRecordTestCase.php +++ b/tests/simple_unit/ActiveRecord/ViewRecordTestCase.php @@ -1,76 +1,76 @@ <?php -
-
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-require_once(dirname(__FILE__).'/records/SimpleUser.php');
-
-class ViewRecordTestCase extends UnitTestCase
-{
- function setup()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- TActiveRecordManager::getInstance()->setDbConnection($conn);
- }
-
- function test_view_record()
- {
- $users = SimpleUser::finder()->findAll();
- $this->assertTrue(count($users) > 0);
- }
-
- function test_save_view_record_throws_exception()
- {
- $user = new SimpleUser();
- try
- {
- $user->save();
- $this->fail();
- }
- catch(TActiveRecordException $e)
- {
- $this->pass();
- }
- }
-
- function test_update_view_record_throws_exception()
- {
- $user = SimpleUser::finder()->findByUsername('admin');
- $user->username = 'ads';
- try
- {
- $user->save();
- $this->fail();
- }
- catch(TActiveRecordException $e)
- {
- $this->pass();
- }
- }
-
- function test_find_by_pk_throws_exception()
- {
- try
- {
- $user = SimpleUser::finder()->findByPk('admin');
- $this->fail();
- }
- catch(TDbException $e)
- {
- $this->pass();
- }
- }
-
- function test_delete_by_pk_throws_exception()
- {
- try
- {
- SimpleUser::finder()->deleteByPk('admin');
- $this->fail();
- }
- catch(TDbException $e)
- {
- $this->pass();
- }
- }
+ + +Prado::using('System.Data.ActiveRecord.TActiveRecord'); +require_once(dirname(__FILE__).'/records/SimpleUser.php'); + +class ViewRecordTestCase extends UnitTestCase +{ + function setup() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + TActiveRecordManager::getInstance()->setDbConnection($conn); + } + + function test_view_record() + { + $users = SimpleUser::finder()->findAll(); + $this->assertTrue(count($users) > 0); + } + + function test_save_view_record_throws_exception() + { + $user = new SimpleUser(); + try + { + $user->save(); + $this->fail(); + } + catch(TActiveRecordException $e) + { + $this->pass(); + } + } + + function test_update_view_record_throws_exception() + { + $user = SimpleUser::finder()->findByUsername('admin'); + $user->username = 'ads'; + try + { + $user->save(); + $this->fail(); + } + catch(TActiveRecordException $e) + { + $this->pass(); + } + } + + function test_find_by_pk_throws_exception() + { + try + { + $user = SimpleUser::finder()->findByPk('admin'); + $this->fail(); + } + catch(TDbException $e) + { + $this->pass(); + } + } + + function test_delete_by_pk_throws_exception() + { + try + { + SimpleUser::finder()->deleteByPk('admin'); + $this->fail(); + } + catch(TDbException $e) + { + $this->pass(); + } + } } ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/Blogs.php b/tests/simple_unit/ActiveRecord/records/Blogs.php index c32ca6b6..680b3141 100644 --- a/tests/simple_unit/ActiveRecord/records/Blogs.php +++ b/tests/simple_unit/ActiveRecord/records/Blogs.php @@ -1,14 +1,14 @@ -<?php
-class Blogs extends TActiveRecord
-{
- public $blog_id;
- public $blog_name;
- public $blog_author;
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+<?php +class Blogs extends TActiveRecord +{ + public $blog_id; + public $blog_name; + public $blog_author; + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/DepSections.php b/tests/simple_unit/ActiveRecord/records/DepSections.php index 7b213c33..6f37ae3e 100644 --- a/tests/simple_unit/ActiveRecord/records/DepSections.php +++ b/tests/simple_unit/ActiveRecord/records/DepSections.php @@ -1,16 +1,16 @@ -<?php
-class DepSections extends TActiveRecord
-{
- public $department_id;
- public $section_id;
- public $order;
-
- const TABLE='department_sections';
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+<?php +class DepSections extends TActiveRecord +{ + public $department_id; + public $section_id; + public $order; + + const TABLE='department_sections'; + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php b/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php index 61307826..732610ae 100644 --- a/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php +++ b/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php @@ -1,18 +1,18 @@ -<?php
-class DepartmentRecord extends TActiveRecord
-{
- public $department_id;
- public $name;
- public $description;
- public $active;
- public $order;
-
- const TABLE = 'departments';
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+<?php +class DepartmentRecord extends TActiveRecord +{ + public $department_id; + public $name; + public $description; + public $active; + public $order; + + const TABLE = 'departments'; + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/ItemRecord.php b/tests/simple_unit/ActiveRecord/records/ItemRecord.php index 52a1a658..8585ebaf 100644 --- a/tests/simple_unit/ActiveRecord/records/ItemRecord.php +++ b/tests/simple_unit/ActiveRecord/records/ItemRecord.php @@ -1,49 +1,49 @@ -<?php
-
-class ItemRecord extends TActiveRecord
-{
- const TABLE='items';
- public $item_id;
- public $name;
- public $brand_specific;
- public $description;
- public $meta;
- public $active;
- public $need_review;
- public $category_id;
- public $type_id;
- public $content;
- public $standard_id;
- public $timestamp;
-
- public $related_items = array();
- public $related_item_id;
-
- public static $RELATIONS=array
- (
- 'related_items' => array(self::MANY_TO_MANY, 'ItemRecord', 'related_items.related_item_id'),
- );
-
- public function getDbConnection()
- {
- static $conn;
- if($conn===null)
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- $this->OnExecuteCommand[] = array($this,'logger');
- }
- return $conn;
- }
-
- public function logger($sender,$param)
- {
- //var_dump($param->Command->Text);
- }
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
-
+<?php + +class ItemRecord extends TActiveRecord +{ + const TABLE='items'; + public $item_id; + public $name; + public $brand_specific; + public $description; + public $meta; + public $active; + public $need_review; + public $category_id; + public $type_id; + public $content; + public $standard_id; + public $timestamp; + + public $related_items = array(); + public $related_item_id; + + public static $RELATIONS=array + ( + 'related_items' => array(self::MANY_TO_MANY, 'ItemRecord', 'related_items.related_item_id'), + ); + + public function getDbConnection() + { + static $conn; + if($conn===null) + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + $this->OnExecuteCommand[] = array($this,'logger'); + } + return $conn; + } + + public function logger($sender,$param) + { + //var_dump($param->Command->Text); + } + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/SimpleUser.php b/tests/simple_unit/ActiveRecord/records/SimpleUser.php index 4ff0b982..cfba272e 100644 --- a/tests/simple_unit/ActiveRecord/records/SimpleUser.php +++ b/tests/simple_unit/ActiveRecord/records/SimpleUser.php @@ -1,14 +1,14 @@ -<?php
-class SimpleUser extends TActiveRecord
-{
- public $username;
-
- const TABLE='simple_users';
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+<?php +class SimpleUser extends TActiveRecord +{ + public $username; + + const TABLE='simple_users'; + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/SqliteUsers.php b/tests/simple_unit/ActiveRecord/records/SqliteUsers.php index ffa47c72..8e5b9fde 100644 --- a/tests/simple_unit/ActiveRecord/records/SqliteUsers.php +++ b/tests/simple_unit/ActiveRecord/records/SqliteUsers.php @@ -1,16 +1,16 @@ -<?php
-class SqliteUsers extends TActiveRecord
-{
- public $username;
- public $password;
- public $email;
-
- const TABLE='users';
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+<?php +class SqliteUsers extends TActiveRecord +{ + public $username; + public $password; + public $email; + + const TABLE='users'; + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/UserRecord.php b/tests/simple_unit/ActiveRecord/records/UserRecord.php index c3cb78b2..c4e8ce60 100644 --- a/tests/simple_unit/ActiveRecord/records/UserRecord.php +++ b/tests/simple_unit/ActiveRecord/records/UserRecord.php @@ -1,38 +1,38 @@ -<?php
-class UserRecord extends TActiveRecord
-{
- public $username;
- public $password;
- public $email;
- public $first_name;
- public $last_name;
- public $job_title;
- public $work_phone;
- public $work_fax;
- public $active=true;
- public $department_id;
- public $salutation;
- public $hint_question;
- public $hint_answer;
-
- private $_level=-1;
-
- const TABLE='users';
-
- public function getLevel()
- {
- return $this->_level;
- }
-
- public function setLevel($level)
- {
- $this->_level=TPropertyValue::ensureInteger($level);
- }
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
+<?php +class UserRecord extends TActiveRecord +{ + public $username; + public $password; + public $email; + public $first_name; + public $last_name; + public $job_title; + public $work_phone; + public $work_fax; + public $active=true; + public $department_id; + public $salutation; + public $hint_question; + public $hint_answer; + + private $_level=-1; + + const TABLE='users'; + + public function getLevel() + { + return $this->_level; + } + + public function setLevel($level) + { + $this->_level=TPropertyValue::ensureInteger($level); + } + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/DbCommon/CommandBuilderMssqlTest.php b/tests/simple_unit/DbCommon/CommandBuilderMssqlTest.php index cc7b8b45..f8a4257c 100644 --- a/tests/simple_unit/DbCommon/CommandBuilderMssqlTest.php +++ b/tests/simple_unit/DbCommon/CommandBuilderMssqlTest.php @@ -1,46 +1,46 @@ <?php -
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Mssql.TMssqlCommandBuilder');
-
-class CommandBuilderMssqlTest extends UnitTestCase
-{
- protected static $sql = array(
- 'simple' => 'SELECT username, age FROM accounts',
- 'multiple' => 'select a.username, b.name from accounts a, table1 b where a.age = b.id1',
- 'ordering' => 'select a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 order by age DESC, name',
- 'index' => 'select a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 ORDER BY 1 DESC, 2 ASC',
- //'compute' => 'SELECT username, age FROM accounts order by age compute avg(age)',
- );
-
- function test_limit()
- {
- $builder = new TMssqlCommandBuilder();
-
- $sql = $builder->applyLimitOffset(self::$sql['simple'], 3);
- $expect = 'SELECT TOP 3 username, age FROM accounts';
- $this->assertEqual($expect, $sql);
-
-
- $sql = $builder->applyLimitOffset(self::$sql['simple'], 3, 2);
- $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 username, age FROM accounts) as [__inner top table__] ) as [__outer top table__] ';
- $this->assertEqual($expect, $sql);
-
- $sql = $builder->applyLimitOffset(self::$sql['multiple'], 3, 2);
- $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name from accounts a, table1 b where a.age = b.id1) as [__inner top table__] ) as [__outer top table__] ';
- $this->assertEqual($sql, $expect);
-
- $sql = $builder->applyLimitOffset(self::$sql['ordering'], 3, 2);
- $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 order by age DESC, name) as [__inner top table__] ORDER BY age ASC, name DESC) as [__outer top table__] ORDER BY age DESC, name ASC';
- $this->assertEqual($sql, $expect);
-
- $sql = $builder->applyLimitOffset(self::$sql['index'], 3, 2);
- $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 ORDER BY 1 DESC, 2 ASC) as [__inner top table__] ORDER BY 1 ASC, 2 DESC) as [__outer top table__] ORDER BY 1 DESC, 2 ASC';
- $this->assertEqual($expect, $sql);
-
- // $sql = $builder->applyLimitOffset(self::$sql['compute'], 3, 2);
- // var_dump($sql);
- }
-}
+ +Prado::using('System.Data.*'); +Prado::using('System.Data.Common.Mssql.TMssqlCommandBuilder'); + +class CommandBuilderMssqlTest extends UnitTestCase +{ + protected static $sql = array( + 'simple' => 'SELECT username, age FROM accounts', + 'multiple' => 'select a.username, b.name from accounts a, table1 b where a.age = b.id1', + 'ordering' => 'select a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 order by age DESC, name', + 'index' => 'select a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 ORDER BY 1 DESC, 2 ASC', + //'compute' => 'SELECT username, age FROM accounts order by age compute avg(age)', + ); + + function test_limit() + { + $builder = new TMssqlCommandBuilder(); + + $sql = $builder->applyLimitOffset(self::$sql['simple'], 3); + $expect = 'SELECT TOP 3 username, age FROM accounts'; + $this->assertEqual($expect, $sql); + + + $sql = $builder->applyLimitOffset(self::$sql['simple'], 3, 2); + $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 username, age FROM accounts) as [__inner top table__] ) as [__outer top table__] '; + $this->assertEqual($expect, $sql); + + $sql = $builder->applyLimitOffset(self::$sql['multiple'], 3, 2); + $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name from accounts a, table1 b where a.age = b.id1) as [__inner top table__] ) as [__outer top table__] '; + $this->assertEqual($sql, $expect); + + $sql = $builder->applyLimitOffset(self::$sql['ordering'], 3, 2); + $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 order by age DESC, name) as [__inner top table__] ORDER BY age ASC, name DESC) as [__outer top table__] ORDER BY age DESC, name ASC'; + $this->assertEqual($sql, $expect); + + $sql = $builder->applyLimitOffset(self::$sql['index'], 3, 2); + $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 ORDER BY 1 DESC, 2 ASC) as [__inner top table__] ORDER BY 1 ASC, 2 DESC) as [__outer top table__] ORDER BY 1 DESC, 2 ASC'; + $this->assertEqual($expect, $sql); + + // $sql = $builder->applyLimitOffset(self::$sql['compute'], 3, 2); + // var_dump($sql); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/DbCommon/CommandBuilderMysqlTest.php b/tests/simple_unit/DbCommon/CommandBuilderMysqlTest.php index 6b744a4b..e248defd 100644 --- a/tests/simple_unit/DbCommon/CommandBuilderMysqlTest.php +++ b/tests/simple_unit/DbCommon/CommandBuilderMysqlTest.php @@ -1,19 +1,19 @@ <?php -Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
-
-class CommandBuilderMysqlTest extends UnitTestCase
-{
- function mysql_meta_data()
- {
- $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3307', 'test5','test5');
- return new TMysqlMetaData($conn);
- }
-
- function test()
- {
- $this->mysql_meta_data()->getTableInfo("tests.table1");
- }
-}
+Prado::using('System.Data.*'); +Prado::using('System.Data.Common.Mysql.TMysqlMetaData'); + +class CommandBuilderMysqlTest extends UnitTestCase +{ + function mysql_meta_data() + { + $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3307', 'test5','test5'); + return new TMysqlMetaData($conn); + } + + function test() + { + $this->mysql_meta_data()->getTableInfo("tests.table1"); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php b/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php index 9ee9c411..63660aee 100644 --- a/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php +++ b/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php @@ -1,76 +1,76 @@ -<?php
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData');
-
-class CommandBuilderPgsqlTest extends UnitTestCase
-{
- function pgsql_meta_data()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- return new TPgsqlMetaData($conn);
- }
-
- function test_insert_command_using_named_array()
- {
- $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
- $address=array(
- 'username' => 'Username',
- 'phone' => 121987,
- 'field1_boolean' => true,
- 'field2_date' => '1213',
- 'field3_double' => 121.1,
- 'field4_integer' => 345,
- 'field6_time' => time(),
- 'field7_timestamp' => time(),
- 'field8_money' => '121.12',
- 'field9_numeric' => 984.22,
- 'int_fk1'=>1,
- 'int_fk2'=>1,
- );
- $insert = $builder->createInsertCommand($address);
- $sql = 'INSERT INTO public.address("username", "phone", "field1_boolean", "field2_date", "field3_double", "field4_integer", "field6_time", "field7_timestamp", "field8_money", "field9_numeric", "int_fk1", "int_fk2") VALUES (:username, :phone, :field1_boolean, :field2_date, :field3_double, :field4_integer, :field6_time, :field7_timestamp, :field8_money, :field9_numeric, :int_fk1, :int_fk2)';
- $this->assertEqual($sql, $insert->Text);
- }
-
- function test_update_command()
- {
- $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
- $data = array(
- 'phone' => 9809,
- 'int_fk1' => 1212,
- );
- $update = $builder->createUpdateCommand($data, '1');
- $sql = 'UPDATE public.address SET "phone" = :phone, "int_fk1" = :int_fk1 WHERE 1';
- $this->assertEqual($sql, $update->Text);
- }
-
- function test_delete_command()
- {
- $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
- $where = 'phone is NULL';
- $delete = $builder->createDeleteCommand($where);
- $sql = 'DELETE FROM public.address WHERE phone is NULL';
- $this->assertEqual($sql, $delete->Text);
- }
-
- function test_select_limit()
- {
- $meta = $this->pgsql_meta_data();
- $builder = $meta->createCommandBuilder('address');
- $query = 'SELECT * FROM '.$meta->getTableInfo('address')->getTableFullName();
-
- $limit = $builder->applyLimitOffset($query, 1);
- $expect = $query.' LIMIT 1';
- $this->assertEqual($expect, $limit);
-
- $limit = $builder->applyLimitOffset($query, -1, 10);
- $expect = $query.' OFFSET 10';
- $this->assertEqual($expect, $limit);
-
- $limit = $builder->applyLimitOffset($query, 2, 3);
- $expect = $query.' LIMIT 2 OFFSET 3';
- $this->assertEqual($expect, $limit);
- }
-}
+<?php +Prado::using('System.Data.*'); +Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData'); + +class CommandBuilderPgsqlTest extends UnitTestCase +{ + function pgsql_meta_data() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + return new TPgsqlMetaData($conn); + } + + function test_insert_command_using_named_array() + { + $builder = $this->pgsql_meta_data()->createCommandBuilder('address'); + $address=array( + 'username' => 'Username', + 'phone' => 121987, + 'field1_boolean' => true, + 'field2_date' => '1213', + 'field3_double' => 121.1, + 'field4_integer' => 345, + 'field6_time' => time(), + 'field7_timestamp' => time(), + 'field8_money' => '121.12', + 'field9_numeric' => 984.22, + 'int_fk1'=>1, + 'int_fk2'=>1, + ); + $insert = $builder->createInsertCommand($address); + $sql = 'INSERT INTO public.address("username", "phone", "field1_boolean", "field2_date", "field3_double", "field4_integer", "field6_time", "field7_timestamp", "field8_money", "field9_numeric", "int_fk1", "int_fk2") VALUES (:username, :phone, :field1_boolean, :field2_date, :field3_double, :field4_integer, :field6_time, :field7_timestamp, :field8_money, :field9_numeric, :int_fk1, :int_fk2)'; + $this->assertEqual($sql, $insert->Text); + } + + function test_update_command() + { + $builder = $this->pgsql_meta_data()->createCommandBuilder('address'); + $data = array( + 'phone' => 9809, + 'int_fk1' => 1212, + ); + $update = $builder->createUpdateCommand($data, '1'); + $sql = 'UPDATE public.address SET "phone" = :phone, "int_fk1" = :int_fk1 WHERE 1'; + $this->assertEqual($sql, $update->Text); + } + + function test_delete_command() + { + $builder = $this->pgsql_meta_data()->createCommandBuilder('address'); + $where = 'phone is NULL'; + $delete = $builder->createDeleteCommand($where); + $sql = 'DELETE FROM public.address WHERE phone is NULL'; + $this->assertEqual($sql, $delete->Text); + } + + function test_select_limit() + { + $meta = $this->pgsql_meta_data(); + $builder = $meta->createCommandBuilder('address'); + $query = 'SELECT * FROM '.$meta->getTableInfo('address')->getTableFullName(); + + $limit = $builder->applyLimitOffset($query, 1); + $expect = $query.' LIMIT 1'; + $this->assertEqual($expect, $limit); + + $limit = $builder->applyLimitOffset($query, -1, 10); + $expect = $query.' OFFSET 10'; + $this->assertEqual($expect, $limit); + + $limit = $builder->applyLimitOffset($query, 2, 3); + $expect = $query.' LIMIT 2 OFFSET 3'; + $this->assertEqual($expect, $limit); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/DbCommon/MssqlColumnTest.php b/tests/simple_unit/DbCommon/MssqlColumnTest.php index db2df03b..16d73bc4 100644 --- a/tests/simple_unit/DbCommon/MssqlColumnTest.php +++ b/tests/simple_unit/DbCommon/MssqlColumnTest.php @@ -1,48 +1,48 @@ <?php -
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Mssql.TMssqlMetaData');
-Prado::using('System.Data.DataGateway.TTableGateway');
-
-class MssqlColumnTest extends UnitTestCase
-{
- function get_conn()
- {
- return new TDbConnection('mssql:host=localhost\\sqlexpress', 'test', 'test01');
- }
-
- /**
- * @return TMssqlMetaData
- */
- function meta_data()
- {
- return new TMssqlMetaData($this->get_conn());
- }
-
- function test_insert()
- {
- $table = new TTableGateway('table1', $this->get_conn());
- $this->assertTrue(is_int($table->insert(array('name'=>'cool'))));
- }
-
-/* function test_meta()
- {
- $result = $this->meta_data()->getTableInfo("bar");
- var_dump($result);
- }
-*/
- /*function test_insert()
- {
- $table = new TTableGateway('table1', $this->get_conn());
- //var_dump($table->insert(array('name'=>'cool')));
- //var_dump($table->getLastInsertId());
- $criteria = new TSqlCriteria();
- $criteria->Limit = 5;
- $criteria->Offset = 2;
-
- $result = $table->findAll($criteria)->readAll();
- var_dump($result);
- }*/
-}
+ +Prado::using('System.Data.*'); +Prado::using('System.Data.Common.Mssql.TMssqlMetaData'); +Prado::using('System.Data.DataGateway.TTableGateway'); + +class MssqlColumnTest extends UnitTestCase +{ + function get_conn() + { + return new TDbConnection('mssql:host=localhost\\sqlexpress', 'test', 'test01'); + } + + /** + * @return TMssqlMetaData + */ + function meta_data() + { + return new TMssqlMetaData($this->get_conn()); + } + + function test_insert() + { + $table = new TTableGateway('table1', $this->get_conn()); + $this->assertTrue(is_int($table->insert(array('name'=>'cool')))); + } + +/* function test_meta() + { + $result = $this->meta_data()->getTableInfo("bar"); + var_dump($result); + } +*/ + /*function test_insert() + { + $table = new TTableGateway('table1', $this->get_conn()); + //var_dump($table->insert(array('name'=>'cool'))); + //var_dump($table->getLastInsertId()); + $criteria = new TSqlCriteria(); + $criteria->Limit = 5; + $criteria->Offset = 2; + + $result = $table->findAll($criteria)->readAll(); + var_dump($result); + }*/ +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/DbCommon/Mysql4ColumnTest.php b/tests/simple_unit/DbCommon/Mysql4ColumnTest.php index d69f3093..234a212f 100644 --- a/tests/simple_unit/DbCommon/Mysql4ColumnTest.php +++ b/tests/simple_unit/DbCommon/Mysql4ColumnTest.php @@ -1,254 +1,254 @@ -<?php
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
-
-class Mysql4ColumnTest extends UnitTestCase
-{
- function create_meta_data()
- {
- $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3306', 'test4','test4');
- return new TMysqlMetaData($conn);
- }
-
- function test_columns()
- {
- $table = $this->create_meta_data()->getTableInfo('table1');
- $this->assertEqual(count($table->getColumns()), 18);
-
- $columns['id'] = array(
- 'ColumnName' => '`id`',
- 'ColumnSize' => 10,
- 'ColumnIndex' => 0,
- 'DbType' => 'int unsigned',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => true,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => true,
- );
-
- $columns['name'] = array(
- 'ColumnName' => '`name`',
- 'ColumnSize' => 45,
- 'ColumnIndex' => 1,
- 'DbType' => 'varchar',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => true,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field1'] = array(
- 'ColumnName' => '`field1`',
- 'ColumnSize' => 4,
- 'ColumnIndex' => 2,
- 'DbType' => 'tinyint',
- 'AllowNull' => false,
- 'DefaultValue' => '0',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field2_text'] = array(
- 'ColumnName' => '`field2_text`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 3,
- 'DbType' => 'text',
- 'AllowNull' => true,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field3_date'] = array(
- 'ColumnName' => '`field3_date`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 4,
- 'DbType' => 'date',
- 'AllowNull' => true,
- 'DefaultValue' => '2007-02-25',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field4_float'] = array(
- 'ColumnName' => '`field4_float`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 5,
- 'DbType' => 'float',
- 'AllowNull' => false,
- 'DefaultValue' => 10,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field5_float'] = array(
- 'ColumnName' => '`field5_float`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 6,
- 'DbType' => 'float',
- 'AllowNull' => false,
- 'DefaultValue' => '0.0000',
- 'NumericPrecision' => 5,
- 'NumericScale' => 4,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field6_double'] = array(
- 'ColumnName' => '`field6_double`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 7,
- 'DbType' => 'double',
- 'AllowNull' => false,
- 'DefaultValue' => '0',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field7_datetime'] = array(
- 'ColumnName' => '`field7_datetime`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 8,
- 'DbType' => 'datetime',
- 'AllowNull' => false,
- 'DefaultValue' => '0000-00-00 00:00:00',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field8_timestamp'] = array(
- 'ColumnName' => '`field8_timestamp`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 9,
- 'DbType' => 'timestamp',
- 'AllowNull' => true,
- 'DefaultValue' => 'CURRENT_TIMESTAMP',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field9_time'] = array(
- 'ColumnName' => '`field9_time`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 10,
- 'DbType' => 'time',
- 'AllowNull' => false,
- 'DefaultValue' => '00:00:00',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field10_year'] = array(
- 'ColumnName' => '`field10_year`',
- 'ColumnSize' => 4,
- 'ColumnIndex' => 11,
- 'DbType' => 'year',
- 'AllowNull' => false,
- 'DefaultValue' => '0000',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field11_enum'] = array(
- 'ColumnName' => '`field11_enum`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 12,
- 'DbType' => 'enum',
- 'AllowNull' => false,
- 'DefaultValue' => 'one',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- 'DbTypeValues' => array('one', 'two', 'three'),
- );
-
- $columns['field12_SET'] = array(
- 'ColumnName' => '`field12_SET`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 13,
- 'DbType' => 'set',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- 'DbTypeValues' => array('blue', 'red', 'green'),
- );
-
- $this->assertColumn($columns, $table);
-
- $this->assertNull($table->getSchemaName());
- $this->assertEqual('table1', $table->getTableName());
- $this->assertEqual(array('id', 'name'), $table->getPrimaryKeys());
- }
-
- function assertColumn($columns, $table)
- {
- foreach($columns as $id=>$asserts)
- {
- $column = $table->Columns[$id];
- foreach($asserts as $property=>$assert)
- {
- $ofAssert= var_export($assert,true);
- $value = $column->{$property};
- $ofValue = var_export($value, true);
- $this->assertEqual($value, $assert,
- "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
- }
- }
- }
-}
+<?php +Prado::using('System.Data.*'); +Prado::using('System.Data.Common.Mysql.TMysqlMetaData'); + +class Mysql4ColumnTest extends UnitTestCase +{ + function create_meta_data() + { + $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3306', 'test4','test4'); + return new TMysqlMetaData($conn); + } + + function test_columns() + { + $table = $this->create_meta_data()->getTableInfo('table1'); + $this->assertEqual(count($table->getColumns()), 18); + + $columns['id'] = array( + 'ColumnName' => '`id`', + 'ColumnSize' => 10, + 'ColumnIndex' => 0, + 'DbType' => 'int unsigned', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => true, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => true, + ); + + $columns['name'] = array( + 'ColumnName' => '`name`', + 'ColumnSize' => 45, + 'ColumnIndex' => 1, + 'DbType' => 'varchar', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => true, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field1'] = array( + 'ColumnName' => '`field1`', + 'ColumnSize' => 4, + 'ColumnIndex' => 2, + 'DbType' => 'tinyint', + 'AllowNull' => false, + 'DefaultValue' => '0', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field2_text'] = array( + 'ColumnName' => '`field2_text`', + 'ColumnSize' => null, + 'ColumnIndex' => 3, + 'DbType' => 'text', + 'AllowNull' => true, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field3_date'] = array( + 'ColumnName' => '`field3_date`', + 'ColumnSize' => null, + 'ColumnIndex' => 4, + 'DbType' => 'date', + 'AllowNull' => true, + 'DefaultValue' => '2007-02-25', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field4_float'] = array( + 'ColumnName' => '`field4_float`', + 'ColumnSize' => null, + 'ColumnIndex' => 5, + 'DbType' => 'float', + 'AllowNull' => false, + 'DefaultValue' => 10, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field5_float'] = array( + 'ColumnName' => '`field5_float`', + 'ColumnSize' => null, + 'ColumnIndex' => 6, + 'DbType' => 'float', + 'AllowNull' => false, + 'DefaultValue' => '0.0000', + 'NumericPrecision' => 5, + 'NumericScale' => 4, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field6_double'] = array( + 'ColumnName' => '`field6_double`', + 'ColumnSize' => null, + 'ColumnIndex' => 7, + 'DbType' => 'double', + 'AllowNull' => false, + 'DefaultValue' => '0', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field7_datetime'] = array( + 'ColumnName' => '`field7_datetime`', + 'ColumnSize' => null, + 'ColumnIndex' => 8, + 'DbType' => 'datetime', + 'AllowNull' => false, + 'DefaultValue' => '0000-00-00 00:00:00', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field8_timestamp'] = array( + 'ColumnName' => '`field8_timestamp`', + 'ColumnSize' => null, + 'ColumnIndex' => 9, + 'DbType' => 'timestamp', + 'AllowNull' => true, + 'DefaultValue' => 'CURRENT_TIMESTAMP', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field9_time'] = array( + 'ColumnName' => '`field9_time`', + 'ColumnSize' => null, + 'ColumnIndex' => 10, + 'DbType' => 'time', + 'AllowNull' => false, + 'DefaultValue' => '00:00:00', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field10_year'] = array( + 'ColumnName' => '`field10_year`', + 'ColumnSize' => 4, + 'ColumnIndex' => 11, + 'DbType' => 'year', + 'AllowNull' => false, + 'DefaultValue' => '0000', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field11_enum'] = array( + 'ColumnName' => '`field11_enum`', + 'ColumnSize' => null, + 'ColumnIndex' => 12, + 'DbType' => 'enum', + 'AllowNull' => false, + 'DefaultValue' => 'one', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + 'DbTypeValues' => array('one', 'two', 'three'), + ); + + $columns['field12_SET'] = array( + 'ColumnName' => '`field12_SET`', + 'ColumnSize' => null, + 'ColumnIndex' => 13, + 'DbType' => 'set', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + 'DbTypeValues' => array('blue', 'red', 'green'), + ); + + $this->assertColumn($columns, $table); + + $this->assertNull($table->getSchemaName()); + $this->assertEqual('table1', $table->getTableName()); + $this->assertEqual(array('id', 'name'), $table->getPrimaryKeys()); + } + + function assertColumn($columns, $table) + { + foreach($columns as $id=>$asserts) + { + $column = $table->Columns[$id]; + foreach($asserts as $property=>$assert) + { + $ofAssert= var_export($assert,true); + $value = $column->{$property}; + $ofValue = var_export($value, true); + $this->assertEqual($value, $assert, + "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}"); + } + } + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/DbCommon/MysqlColumnTest.php b/tests/simple_unit/DbCommon/MysqlColumnTest.php index 1508f2c6..08fdb545 100644 --- a/tests/simple_unit/DbCommon/MysqlColumnTest.php +++ b/tests/simple_unit/DbCommon/MysqlColumnTest.php @@ -1,254 +1,254 @@ -<?php
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
-
-class MysqlColumnTest extends UnitTestCase
-{
- function create_meta_data()
- {
- $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3307', 'test5','test5');
- return new TMysqlMetaData($conn);
- }
-
- function test_columns()
- {
- $table = $this->create_meta_data()->getTableInfo('table1');
- $this->assertEqual(count($table->getColumns()), 18);
-
- $columns['id'] = array(
- 'ColumnName' => '`id`',
- 'ColumnSize' => 10,
- 'ColumnIndex' => 0,
- 'DbType' => 'int unsigned',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => true,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => true,
- );
-
- $columns['name'] = array(
- 'ColumnName' => '`name`',
- 'ColumnSize' => 45,
- 'ColumnIndex' => 1,
- 'DbType' => 'varchar',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => true,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field1'] = array(
- 'ColumnName' => '`field1`',
- 'ColumnSize' => 4,
- 'ColumnIndex' => 2,
- 'DbType' => 'tinyint',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field2_text'] = array(
- 'ColumnName' => '`field2_text`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 3,
- 'DbType' => 'text',
- 'AllowNull' => true,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field3_date'] = array(
- 'ColumnName' => '`field3_date`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 4,
- 'DbType' => 'date',
- 'AllowNull' => true,
- 'DefaultValue' => '2007-02-25',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field4_float'] = array(
- 'ColumnName' => '`field4_float`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 5,
- 'DbType' => 'float',
- 'AllowNull' => false,
- 'DefaultValue' => 10,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field5_float'] = array(
- 'ColumnName' => '`field5_float`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 6,
- 'DbType' => 'float',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => 5,
- 'NumericScale' => 4,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field6_double'] = array(
- 'ColumnName' => '`field6_double`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 7,
- 'DbType' => 'double',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field7_datetime'] = array(
- 'ColumnName' => '`field7_datetime`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 8,
- 'DbType' => 'datetime',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field8_timestamp'] = array(
- 'ColumnName' => '`field8_timestamp`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 9,
- 'DbType' => 'timestamp',
- 'AllowNull' => true,
- 'DefaultValue' => 'CURRENT_TIMESTAMP',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field9_time'] = array(
- 'ColumnName' => '`field9_time`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 10,
- 'DbType' => 'time',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field10_year'] = array(
- 'ColumnName' => '`field10_year`',
- 'ColumnSize' => 4,
- 'ColumnIndex' => 11,
- 'DbType' => 'year',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field11_enum'] = array(
- 'ColumnName' => '`field11_enum`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 12,
- 'DbType' => 'enum',
- 'AllowNull' => false,
- 'DefaultValue' => 'one',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- 'DbTypeValues' => array('one', 'two', 'three'),
- );
-
- $columns['field12_SET'] = array(
- 'ColumnName' => '`field12_SET`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 13,
- 'DbType' => 'set',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- 'DbTypeValues' => array('blue', 'red', 'green'),
- );
-
- $this->assertColumn($columns, $table);
-
- $this->assertNull($table->getSchemaName());
- $this->assertEqual('table1', $table->getTableName());
- $this->assertEqual(array('id', 'name'), $table->getPrimaryKeys());
- }
-
- function assertColumn($columns, $table)
- {
- foreach($columns as $id=>$asserts)
- {
- $column = $table->Columns[$id];
- foreach($asserts as $property=>$assert)
- {
- $ofAssert= var_export($assert,true);
- $value = $column->{$property};
- $ofValue = var_export($value, true);
- $this->assertEqual($value, $assert,
- "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
- }
- }
- }
-}
+<?php +Prado::using('System.Data.*'); +Prado::using('System.Data.Common.Mysql.TMysqlMetaData'); + +class MysqlColumnTest extends UnitTestCase +{ + function create_meta_data() + { + $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3307', 'test5','test5'); + return new TMysqlMetaData($conn); + } + + function test_columns() + { + $table = $this->create_meta_data()->getTableInfo('table1'); + $this->assertEqual(count($table->getColumns()), 18); + + $columns['id'] = array( + 'ColumnName' => '`id`', + 'ColumnSize' => 10, + 'ColumnIndex' => 0, + 'DbType' => 'int unsigned', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => true, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => true, + ); + + $columns['name'] = array( + 'ColumnName' => '`name`', + 'ColumnSize' => 45, + 'ColumnIndex' => 1, + 'DbType' => 'varchar', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => true, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field1'] = array( + 'ColumnName' => '`field1`', + 'ColumnSize' => 4, + 'ColumnIndex' => 2, + 'DbType' => 'tinyint', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field2_text'] = array( + 'ColumnName' => '`field2_text`', + 'ColumnSize' => null, + 'ColumnIndex' => 3, + 'DbType' => 'text', + 'AllowNull' => true, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field3_date'] = array( + 'ColumnName' => '`field3_date`', + 'ColumnSize' => null, + 'ColumnIndex' => 4, + 'DbType' => 'date', + 'AllowNull' => true, + 'DefaultValue' => '2007-02-25', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field4_float'] = array( + 'ColumnName' => '`field4_float`', + 'ColumnSize' => null, + 'ColumnIndex' => 5, + 'DbType' => 'float', + 'AllowNull' => false, + 'DefaultValue' => 10, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field5_float'] = array( + 'ColumnName' => '`field5_float`', + 'ColumnSize' => null, + 'ColumnIndex' => 6, + 'DbType' => 'float', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => 5, + 'NumericScale' => 4, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field6_double'] = array( + 'ColumnName' => '`field6_double`', + 'ColumnSize' => null, + 'ColumnIndex' => 7, + 'DbType' => 'double', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field7_datetime'] = array( + 'ColumnName' => '`field7_datetime`', + 'ColumnSize' => null, + 'ColumnIndex' => 8, + 'DbType' => 'datetime', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field8_timestamp'] = array( + 'ColumnName' => '`field8_timestamp`', + 'ColumnSize' => null, + 'ColumnIndex' => 9, + 'DbType' => 'timestamp', + 'AllowNull' => true, + 'DefaultValue' => 'CURRENT_TIMESTAMP', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field9_time'] = array( + 'ColumnName' => '`field9_time`', + 'ColumnSize' => null, + 'ColumnIndex' => 10, + 'DbType' => 'time', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field10_year'] = array( + 'ColumnName' => '`field10_year`', + 'ColumnSize' => 4, + 'ColumnIndex' => 11, + 'DbType' => 'year', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + ); + + $columns['field11_enum'] = array( + 'ColumnName' => '`field11_enum`', + 'ColumnSize' => null, + 'ColumnIndex' => 12, + 'DbType' => 'enum', + 'AllowNull' => false, + 'DefaultValue' => 'one', + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + 'DbTypeValues' => array('one', 'two', 'three'), + ); + + $columns['field12_SET'] = array( + 'ColumnName' => '`field12_SET`', + 'ColumnSize' => null, + 'ColumnIndex' => 13, + 'DbType' => 'set', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + 'AutoIncrement' => false, + 'DbTypeValues' => array('blue', 'red', 'green'), + ); + + $this->assertColumn($columns, $table); + + $this->assertNull($table->getSchemaName()); + $this->assertEqual('table1', $table->getTableName()); + $this->assertEqual(array('id', 'name'), $table->getPrimaryKeys()); + } + + function assertColumn($columns, $table) + { + foreach($columns as $id=>$asserts) + { + $column = $table->Columns[$id]; + foreach($asserts as $property=>$assert) + { + $ofAssert= var_export($assert,true); + $value = $column->{$property}; + $ofValue = var_export($value, true); + $this->assertEqual($value, $assert, + "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}"); + } + } + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/DbCommon/PgsqlColumnTest.php b/tests/simple_unit/DbCommon/PgsqlColumnTest.php index de12083e..a16de964 100644 --- a/tests/simple_unit/DbCommon/PgsqlColumnTest.php +++ b/tests/simple_unit/DbCommon/PgsqlColumnTest.php @@ -1,139 +1,139 @@ <?php -
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData');
-class PgsqlColumnTest extends UnitTestCase
-{
- function create_meta_data()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- return new TPgsqlMetaData($conn);
- }
-
- function test_text_column_def()
- {
- $table = $this->create_meta_data()->getTableInfo('public.address');
- $this->assertEqual(count($table->getColumns()), 14);
-
- $columns['id'] = array(
- 'ColumnName' => '"id"',
- 'ColumnSize' => null,
- 'ColumnIndex' => 0,
- 'DbType' => 'integer',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => true,
- 'IsForeignKey' => false,
- 'SequenceName' => 'public.address_id_seq',
- );
-
- $columns['username'] = array(
- 'ColumnName' => '"username"',
- 'ColumnSize' => 128,
- 'ColumnIndex' => 1,
- 'DbType' => 'character varying',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- );
-
- $columns['phone'] = array(
- 'ColumnName' => '"phone"',
- 'ColumnSize' => 40,
- 'ColumnIndex' => 2,
- 'DbType' => 'character',
- 'AllowNull' => false,
- 'DefaultValue' => "'hello'::bpchar",
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- );
-
- $columns['field1_boolean'] = array(
- 'ColumnName' => '"field1_boolean"',
- 'ColumnSize' => null,
- 'ColumnIndex' => 3,
- 'DbType' => 'boolean',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- );
-
- $columns['field4_integer'] = array(
- 'ColumnName' => '"field4_integer"',
- 'ColumnSize' => null,
- 'ColumnIndex' => 6,
- 'DbType' => 'integer',
- 'AllowNull' => false,
- 'DefaultValue' => "1",
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => true,
- 'SequenceName' => null,
- );
-
- $columns['field7_timestamp'] = array(
- 'ColumnName' => '"field7_timestamp"',
- 'ColumnSize' => 2,
- 'ColumnIndex' => 9,
- 'DbType' => 'timestamp without time zone',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => 6,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- );
-
- $columns['field9_numeric'] = array(
- 'ColumnName' => '"field9_numeric"',
- 'ColumnSize' => 393220,
- 'ColumnIndex' => 11,
- 'DbType' => 'numeric',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => 6,
- 'NumericScale' => 4,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- );
- $this->assertColumn($columns, $table);
-
- $this->assertEqual('public', $table->getSchemaName());
- $this->assertEqual('address', $table->getTableName());
- $this->assertEqual(array('id'), $table->getPrimaryKeys());
- }
-
- function assertColumn($columns, $table)
- {
- foreach($columns as $id=>$asserts)
- {
- $column = $table->Columns[$id];
- foreach($asserts as $property=>$assert)
- {
- $ofAssert= var_export($assert,true);
- $value = $column->{$property};
- $ofValue = var_export($value, true);
- $this->assertEqual($value, $assert,
- "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
- }
- }
- }
-}
+ +Prado::using('System.Data.*'); +Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData'); +class PgsqlColumnTest extends UnitTestCase +{ + function create_meta_data() + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + return new TPgsqlMetaData($conn); + } + + function test_text_column_def() + { + $table = $this->create_meta_data()->getTableInfo('public.address'); + $this->assertEqual(count($table->getColumns()), 14); + + $columns['id'] = array( + 'ColumnName' => '"id"', + 'ColumnSize' => null, + 'ColumnIndex' => 0, + 'DbType' => 'integer', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => true, + 'IsForeignKey' => false, + 'SequenceName' => 'public.address_id_seq', + ); + + $columns['username'] = array( + 'ColumnName' => '"username"', + 'ColumnSize' => 128, + 'ColumnIndex' => 1, + 'DbType' => 'character varying', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + ); + + $columns['phone'] = array( + 'ColumnName' => '"phone"', + 'ColumnSize' => 40, + 'ColumnIndex' => 2, + 'DbType' => 'character', + 'AllowNull' => false, + 'DefaultValue' => "'hello'::bpchar", + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + ); + + $columns['field1_boolean'] = array( + 'ColumnName' => '"field1_boolean"', + 'ColumnSize' => null, + 'ColumnIndex' => 3, + 'DbType' => 'boolean', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + ); + + $columns['field4_integer'] = array( + 'ColumnName' => '"field4_integer"', + 'ColumnSize' => null, + 'ColumnIndex' => 6, + 'DbType' => 'integer', + 'AllowNull' => false, + 'DefaultValue' => "1", + 'NumericPrecision' => null, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => true, + 'SequenceName' => null, + ); + + $columns['field7_timestamp'] = array( + 'ColumnName' => '"field7_timestamp"', + 'ColumnSize' => 2, + 'ColumnIndex' => 9, + 'DbType' => 'timestamp without time zone', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => 6, + 'NumericScale' => null, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + ); + + $columns['field9_numeric'] = array( + 'ColumnName' => '"field9_numeric"', + 'ColumnSize' => 393220, + 'ColumnIndex' => 11, + 'DbType' => 'numeric', + 'AllowNull' => false, + 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE, + 'NumericPrecision' => 6, + 'NumericScale' => 4, + 'IsPrimaryKey' => false, + 'IsForeignKey' => false, + 'SequenceName' => null, + ); + $this->assertColumn($columns, $table); + + $this->assertEqual('public', $table->getSchemaName()); + $this->assertEqual('address', $table->getTableName()); + $this->assertEqual(array('id'), $table->getPrimaryKeys()); + } + + function assertColumn($columns, $table) + { + foreach($columns as $id=>$asserts) + { + $column = $table->Columns[$id]; + foreach($asserts as $property=>$assert) + { + $ofAssert= var_export($assert,true); + $value = $column->{$property}; + $ofValue = var_export($value, true); + $this->assertEqual($value, $assert, + "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}"); + } + } + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/DbCommon/SqliteColumnTest.php b/tests/simple_unit/DbCommon/SqliteColumnTest.php index 36a4baab..246c4a27 100644 --- a/tests/simple_unit/DbCommon/SqliteColumnTest.php +++ b/tests/simple_unit/DbCommon/SqliteColumnTest.php @@ -1,29 +1,29 @@ -<?php
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Sqlite.TSqliteMetaData');
-Prado::using('System.Data.DataGateway.TTableGateway');
-class SqliteColumnTest extends UnitTestCase
-{
- /**
- * @return TSqliteMetaData
- */
- function meta_data()
- {
- $conn = new TDbConnection('sqlite:c:/test.db');
- return new TSqliteMetaData($conn);
- }
-
- function test_it()
- {
- //$table = $this->meta_data()->getTableInfo('foo');
- //var_dump($table);
- }
-
- function test_table()
- {
- $conn = new TDbConnection('sqlite:c:/test.db');
- //$table = new TTableGateway('Accounts', $conn);
-// var_dump($table->findAll()->readAll());
- }
+<?php +Prado::using('System.Data.*'); +Prado::using('System.Data.Common.Sqlite.TSqliteMetaData'); +Prado::using('System.Data.DataGateway.TTableGateway'); +class SqliteColumnTest extends UnitTestCase +{ + /** + * @return TSqliteMetaData + */ + function meta_data() + { + $conn = new TDbConnection('sqlite:c:/test.db'); + return new TSqliteMetaData($conn); + } + + function test_it() + { + //$table = $this->meta_data()->getTableInfo('foo'); + //var_dump($table); + } + + function test_table() + { + $conn = new TDbConnection('sqlite:c:/test.db'); + //$table = new TTableGateway('Accounts', $conn); +// var_dump($table->findAll()->readAll()); + } } ?>
\ No newline at end of file diff --git a/tests/simple_unit/I18N/ChoiceFormatTest.php b/tests/simple_unit/I18N/ChoiceFormatTest.php index 3a95b5a8..809d46b4 100644 --- a/tests/simple_unit/I18N/ChoiceFormatTest.php +++ b/tests/simple_unit/I18N/ChoiceFormatTest.php @@ -1,98 +1,98 @@ -<?php
-
-Prado::using('System.I18N.core.ChoiceFormat');
-
-class ChoiceFormatTest extends UnitTestCase
-{
- function testChoices()
- {
- $choice = new ChoiceFormat();
- $string = '[0] are no files |[1] is one file |(1,Inf] are {number} files';
-
- $want = 'are no files';
- $this->assertEqual($want, $choice->format($string, 0));
-
- $want = 'is one file';
- $this->assertEqual($want, $choice->format($string, 1));
-
- $want = 'are {number} files';
- $this->assertEqual($want, $choice->format($string, 5));
-
- $this->assertFalse($choice->format($string, -1));
-
- $string = '{1,2} one two |{3,4} three four |[2,5] two to five inclusive';
- $this->assertEqual($choice->format($string,1),'one two');
- $this->assertEqual($choice->format($string,2.1),'two to five inclusive');
- $this->assertEqual($choice->format($string,3),'three four');
- }
-
- function test_set_notation()
- {
- $choice = new ChoiceFormat();
- $string = '{n: n%2 == 0} are even numbers |{n: n >= 5} are not even and greater than or equal to 5';
-
- $want = 'are even numbers';
- $this->assertEqual($want, $choice->format($string, 0));
- $this->assertEqual($want, $choice->format($string, 2));
- $this->assertEqual($want, $choice->format($string, 4));
- $this->assertNotEqual($want, $choice->format($string, 1));
-
- $want = 'are not even and greater than or equal to 5';
- $this->assertEqual($want, $choice->format($string, 5));
- }
-
- function test_polish()
- {
- $choice = new ChoiceFormat();
- $string = '[1] plik |{2,3,4} pliki
- |[5,21] pliko\'w |{n: n % 10 > 1 && n %10 < 5} pliki |{n: n%10 >= 5 || n%10 <=1} pliko\'w';
-
- $wants = array( 'plik' => array(1),
- 'pliki' => array(2,3,4,22,23,24),
- 'pliko\'w' => array(5,6,7,11,12,15,17,20,21,25,26,30));
- foreach($wants as $want => $numbers)
- {
- foreach($numbers as $n)
- $this->assertEqual($want, $choice->format($string, $n));
- }
- }
-
- function test_russian()
- {
- $choice = new ChoiceFormat();
- $string = '
- {n: n % 10 == 1 && n % 100 != 11} test1
- |{n: n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20 )} test2
- |{n: 2} test3';
-
- $wants = array('test1' => array(1,21,31,41),
- 'test2' => array(2,4, 22, 24, 32, 34),
- 'test3' => array(0, 5,6,7,8,9,10,11,12,13,14, 20,25,26,30)
- );
- foreach($wants as $want => $numbers)
- {
- foreach($numbers as $n)
- $this->assertEqual($want, $choice->format($string, $n));
- }
- }
-
- function test_english()
- {
- $choice = new ChoiceFormat();
- $string = '[0] none |{n: n % 10 == 1} 1st |{n: n % 10 == 2} 2nd |{n: n % 10 == 3} 3rd |{n:n} th';
-
- $wants = array('none' => array(0),
- '1st' => array(1,11,21),
- '2nd' => array(2,12,22),
- '3rd' => array(3,13,23),
- 'th' => array(4,5,6,7,14,15)
- );
- foreach($wants as $want => $numbers)
- {
- foreach($numbers as $n)
- $this->assertEqual($want, $choice->format($string, $n));
- }
- }
-}
-
+<?php + +Prado::using('System.I18N.core.ChoiceFormat'); + +class ChoiceFormatTest extends UnitTestCase +{ + function testChoices() + { + $choice = new ChoiceFormat(); + $string = '[0] are no files |[1] is one file |(1,Inf] are {number} files'; + + $want = 'are no files'; + $this->assertEqual($want, $choice->format($string, 0)); + + $want = 'is one file'; + $this->assertEqual($want, $choice->format($string, 1)); + + $want = 'are {number} files'; + $this->assertEqual($want, $choice->format($string, 5)); + + $this->assertFalse($choice->format($string, -1)); + + $string = '{1,2} one two |{3,4} three four |[2,5] two to five inclusive'; + $this->assertEqual($choice->format($string,1),'one two'); + $this->assertEqual($choice->format($string,2.1),'two to five inclusive'); + $this->assertEqual($choice->format($string,3),'three four'); + } + + function test_set_notation() + { + $choice = new ChoiceFormat(); + $string = '{n: n%2 == 0} are even numbers |{n: n >= 5} are not even and greater than or equal to 5'; + + $want = 'are even numbers'; + $this->assertEqual($want, $choice->format($string, 0)); + $this->assertEqual($want, $choice->format($string, 2)); + $this->assertEqual($want, $choice->format($string, 4)); + $this->assertNotEqual($want, $choice->format($string, 1)); + + $want = 'are not even and greater than or equal to 5'; + $this->assertEqual($want, $choice->format($string, 5)); + } + + function test_polish() + { + $choice = new ChoiceFormat(); + $string = '[1] plik |{2,3,4} pliki + |[5,21] pliko\'w |{n: n % 10 > 1 && n %10 < 5} pliki |{n: n%10 >= 5 || n%10 <=1} pliko\'w'; + + $wants = array( 'plik' => array(1), + 'pliki' => array(2,3,4,22,23,24), + 'pliko\'w' => array(5,6,7,11,12,15,17,20,21,25,26,30)); + foreach($wants as $want => $numbers) + { + foreach($numbers as $n) + $this->assertEqual($want, $choice->format($string, $n)); + } + } + + function test_russian() + { + $choice = new ChoiceFormat(); + $string = ' + {n: n % 10 == 1 && n % 100 != 11} test1 + |{n: n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 10 || n % 100 >= 20 )} test2 + |{n: 2} test3'; + + $wants = array('test1' => array(1,21,31,41), + 'test2' => array(2,4, 22, 24, 32, 34), + 'test3' => array(0, 5,6,7,8,9,10,11,12,13,14, 20,25,26,30) + ); + foreach($wants as $want => $numbers) + { + foreach($numbers as $n) + $this->assertEqual($want, $choice->format($string, $n)); + } + } + + function test_english() + { + $choice = new ChoiceFormat(); + $string = '[0] none |{n: n % 10 == 1} 1st |{n: n % 10 == 2} 2nd |{n: n % 10 == 3} 3rd |{n:n} th'; + + $wants = array('none' => array(0), + '1st' => array(1,11,21), + '2nd' => array(2,12,22), + '3rd' => array(3,13,23), + 'th' => array(4,5,6,7,14,15) + ); + foreach($wants as $want => $numbers) + { + foreach($numbers as $n) + $this->assertEqual($want, $choice->format($string, $n)); + } + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/I18N/CultureInfoTest.php b/tests/simple_unit/I18N/CultureInfoTest.php index 840d8f17..7df7deeb 100644 --- a/tests/simple_unit/I18N/CultureInfoTest.php +++ b/tests/simple_unit/I18N/CultureInfoTest.php @@ -1,13 +1,13 @@ -<?php
-
-Prado::using('System.I18N.core.*');
-class CultureInfoTest extends UnitTestCase
-{
- function test_missing_english_names_returns_culture_code()
- {
- $culture = new CultureInfo('iw');
- $this->assertEqual($culture->getEnglishName(), 'iw');
- }
-}
-
+<?php + +Prado::using('System.I18N.core.*'); +class CultureInfoTest extends UnitTestCase +{ + function test_missing_english_names_returns_culture_code() + { + $culture = new CultureInfo('iw'); + $this->assertEqual($culture->getEnglishName(), 'iw'); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/I18N/MysqlMessageSourceTestCase.php b/tests/simple_unit/I18N/MysqlMessageSourceTestCase.php index 2fc96163..80e9c1fd 100644 --- a/tests/simple_unit/I18N/MysqlMessageSourceTestCase.php +++ b/tests/simple_unit/I18N/MysqlMessageSourceTestCase.php @@ -1,45 +1,45 @@ -<?php
-
-Prado::using('System.I18N.core.MessageSource_MySQL');
-Prado::using('System.I18N.core.MessageFormat');
-
-class MysqlMessageSourceTestCase extends UnitTestCase
-{
- private $_source;
-
- function get_source()
- {
- if($this->_source===null)
- {
- $this->_source = new MessageSource_MySQL('mysq://prado:prado@localhost/i18n_test');
- $this->_source->setCulture('en_AU');
- }
- return $this->_source;
- }
-
-/*
- function test_source()
- {
- $source = $this->get_source();
- $this->assertEqual(3, count($source->catalogues()));
- }
-
- function test_load_source()
- {
- $source = $this->get_source();
- $this->assertTrue($source->load());
- }
-
- function test_message_format()
- {
- $formatter = new MessageFormat($this->get_source());
- var_dump($formatter->format('Hello'));
- var_dump($formatter->format('Goodbye'));
- //$this->assertEqual($formatter->format('Hello'),'G\'day Mate!');
-
- //$this->assertEqual($formatter->format('Goodbye'), 'Goodbye');
- }
-*/
-}
-
+<?php + +Prado::using('System.I18N.core.MessageSource_MySQL'); +Prado::using('System.I18N.core.MessageFormat'); + +class MysqlMessageSourceTestCase extends UnitTestCase +{ + private $_source; + + function get_source() + { + if($this->_source===null) + { + $this->_source = new MessageSource_MySQL('mysq://prado:prado@localhost/i18n_test'); + $this->_source->setCulture('en_AU'); + } + return $this->_source; + } + +/* + function test_source() + { + $source = $this->get_source(); + $this->assertEqual(3, count($source->catalogues())); + } + + function test_load_source() + { + $source = $this->get_source(); + $this->assertTrue($source->load()); + } + + function test_message_format() + { + $formatter = new MessageFormat($this->get_source()); + var_dump($formatter->format('Hello')); + var_dump($formatter->format('Goodbye')); + //$this->assertEqual($formatter->format('Hello'),'G\'day Mate!'); + + //$this->assertEqual($formatter->format('Goodbye'), 'Goodbye'); + } +*/ +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/Soap/ContactManager.php b/tests/simple_unit/Soap/ContactManager.php index 8bf3d756..290063b3 100644 --- a/tests/simple_unit/Soap/ContactManager.php +++ b/tests/simple_unit/Soap/ContactManager.php @@ -1,157 +1,157 @@ -<?php
-
-/**
- * Keeps track of the people in our Contact list.
- *
- * Starts with a standard Contact list and can add
- * new people to our list or change existing Contacts.
- * This class is for example purposes only, just to
- * show how to create a webservice
- */
-class ContactManager{
-
- /**
- * Gets the current Contact list.
- * @return Contact[]
- * @soapmethod
- */
- public function getContacts() {
- $Contact = new Contact();
- $Contact->address = new Address();
- $Contact->address->city ="sesamcity";
- $Contact->address->street ="sesamstreet";
- $Contact->email = "me@you.com";
- $Contact->id = 1;
- $Contact->name ="me";
-
- $ret[] = $Contact;
- //debugObject("Contacten: ",$ret);
- return $ret;
- }
-
- /**
- * Gets the Contact with the given id.
- * @param int $id The id
- * @return Contact
- * @soapmethod
- */
- public function getContact($id) {
- //get Contact from db
- //might wanna throw an exception when it does not exists
- throw new Exception("Contact '$id' not found");
- }
- /**
- * Generates an new, empty Contact template
- * @return Contact
- * @soapmethod
- */
- public function newContact() {
- return new Contact();
- }
-
- /**
- * Saves a given Contact
- * @param Contact $Contact
- * @return boolean
- * @soapmethod
- */
- public function saveContact(Contact $Contact) {
- //error_log(var_export($Contact,true));
- //$Contact->save();
- return true;
- }
-
- /**
- * @return mixed
- * @soapmethod
- */
- public function getList()
- {
- return array(array(1,2), array("12", 1.2));
- }
-
- /**
- * @return array
- * @soapmethod
- */
- public function getEmptyArray()
- {
- return array();
- }
-
-}
-
-
-/**
- * The Contact details for a person
- *
- * Stores the person's name, address and e-mail
- * This class is for example purposes only, just to
- * show how to create a webservice
- *
- */
-class Contact{
-
- /**
- * @var int $id
- * @soapproperty
- */
- public $id;
-
- /**
- * @var string $name
- * @soapproperty
- */
- public $name;
-
- /** @var Address $address
- * @soapproperty
- */
- public $address;
-
- /** @var string $email
- * @soapproperty
- */
- public $email;
-
- /**
- * saves a Contact
- *
- * @return void
- */
- public function save() {
- //save Contact 2 db
- }
-}
-
-/**
- * Stores an address
- *
- * An address consists of a street, number, zipcode and city.
- * This class is for example purposes only, just to
- * show how to create a webservice
- *
- */
-class Address{
- /** @var string $street
- * @soapproperty
- */
- public $street;
-
- /** @var string $nr
- * @soapproperty
- */
- public $nr;
-
- /** @var string $zipcode
- * @soapproperty
- */
- public $zipcode;
-
- /** @var string $city
- * @soapproperty
- */
- public $city;
-}
-
+<?php + +/** + * Keeps track of the people in our Contact list. + * + * Starts with a standard Contact list and can add + * new people to our list or change existing Contacts. + * This class is for example purposes only, just to + * show how to create a webservice + */ +class ContactManager{ + + /** + * Gets the current Contact list. + * @return Contact[] + * @soapmethod + */ + public function getContacts() { + $Contact = new Contact(); + $Contact->address = new Address(); + $Contact->address->city ="sesamcity"; + $Contact->address->street ="sesamstreet"; + $Contact->email = "me@you.com"; + $Contact->id = 1; + $Contact->name ="me"; + + $ret[] = $Contact; + //debugObject("Contacten: ",$ret); + return $ret; + } + + /** + * Gets the Contact with the given id. + * @param int $id The id + * @return Contact + * @soapmethod + */ + public function getContact($id) { + //get Contact from db + //might wanna throw an exception when it does not exists + throw new Exception("Contact '$id' not found"); + } + /** + * Generates an new, empty Contact template + * @return Contact + * @soapmethod + */ + public function newContact() { + return new Contact(); + } + + /** + * Saves a given Contact + * @param Contact $Contact + * @return boolean + * @soapmethod + */ + public function saveContact(Contact $Contact) { + //error_log(var_export($Contact,true)); + //$Contact->save(); + return true; + } + + /** + * @return mixed + * @soapmethod + */ + public function getList() + { + return array(array(1,2), array("12", 1.2)); + } + + /** + * @return array + * @soapmethod + */ + public function getEmptyArray() + { + return array(); + } + +} + + +/** + * The Contact details for a person + * + * Stores the person's name, address and e-mail + * This class is for example purposes only, just to + * show how to create a webservice + * + */ +class Contact{ + + /** + * @var int $id + * @soapproperty + */ + public $id; + + /** + * @var string $name + * @soapproperty + */ + public $name; + + /** @var Address $address + * @soapproperty + */ + public $address; + + /** @var string $email + * @soapproperty + */ + public $email; + + /** + * saves a Contact + * + * @return void + */ + public function save() { + //save Contact 2 db + } +} + +/** + * Stores an address + * + * An address consists of a street, number, zipcode and city. + * This class is for example purposes only, just to + * show how to create a webservice + * + */ +class Address{ + /** @var string $street + * @soapproperty + */ + public $street; + + /** @var string $nr + * @soapproperty + */ + public $nr; + + /** @var string $zipcode + * @soapproperty + */ + public $zipcode; + + /** @var string $city + * @soapproperty + */ + public $city; +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/Soap/SoapTestCase.php b/tests/simple_unit/Soap/SoapTestCase.php index d297ce41..fe151b04 100644 --- a/tests/simple_unit/Soap/SoapTestCase.php +++ b/tests/simple_unit/Soap/SoapTestCase.php @@ -1,91 +1,91 @@ -<?php
-
-ini_set("soap.wsdl_cache_enabled",0);
-
-require_once(dirname(__FILE__).'/ContactManager.php');
-
-class SoapTestCase extends UnitTestCase
-{
- function getWsdlUri()
- {
- $script = str_replace('unit.php', 'ws.php',$_SERVER['SCRIPT_NAME']);
- return "http://".$_SERVER['HTTP_HOST'].$script.'?soap=contacts.wsdl';
- }
-
- function getClient()
- {
- return new SoapClient($this->getWsdlUri());
- }
-
- function testContactArray()
- {
- $result = $this->getClient()->getContacts();
- $this->assertEqual(count($result), 1);
- $obj = $result->Contact;
- $this->assertEqual($obj->name, "me");
- $this->assertEqual($obj->id, 1);
- $this->assertEqual($obj->address->street, "sesamstreet");
- $this->assertNull($obj->address->nr);
- $this->assertNull($obj->address->zipcode);
- $this->assertEqual($obj->address->city, "sesamcity");
- $this->assertEqual($obj->email, "me@you.com");
- }
-
- function testGetContactThrowsException()
- {
- try
- {
- $result = $this->getClient()->getContact(1);
- $this->fail();
- }
- catch (SoapFault $f)
- {
- $this->pass();
- }
- }
-
- function testGetNewContact()
- {
- $obj = $this->getClient()->newContact();
- $this->assertNull($obj->name);
- $this->assertNull($obj->id);
- $this->assertNull($obj->address);
- $this->assertNull($obj->email);
- }
-
- function testSaveContactReturnsTrue()
- {
- $c = new Contact;
- $result = $this->getClient()->saveContact($c);
- $this->assertTrue($result);
- }
-
- function getMixedArray()
- {
- $result = $this->getClient()>getList();
- $expected = array(array(1,2), array("12", 1.2));
- $this->assertEqual($result, $expected);
- }
-
- function testEmptyArray()
- {
- $result = $this->getClient()->getEmptyArray();
- $this->assertTrue(is_array($result));
- $this->assertEqual(count($result), 0);
- }
-
- function testUnknownFunctionThrowsException()
- {
- try
- {
- $this->getClient()->test();
- $this->fail();
- }
- catch (SoapFault $f)
- {
- $this->pass();
- }
- }
-}
-
-?>
+<?php + +ini_set("soap.wsdl_cache_enabled",0); + +require_once(dirname(__FILE__).'/ContactManager.php'); + +class SoapTestCase extends UnitTestCase +{ + function getWsdlUri() + { + $script = str_replace('unit.php', 'ws.php',$_SERVER['SCRIPT_NAME']); + return "http://".$_SERVER['HTTP_HOST'].$script.'?soap=contacts.wsdl'; + } + + function getClient() + { + return new SoapClient($this->getWsdlUri()); + } + + function testContactArray() + { + $result = $this->getClient()->getContacts(); + $this->assertEqual(count($result), 1); + $obj = $result->Contact; + $this->assertEqual($obj->name, "me"); + $this->assertEqual($obj->id, 1); + $this->assertEqual($obj->address->street, "sesamstreet"); + $this->assertNull($obj->address->nr); + $this->assertNull($obj->address->zipcode); + $this->assertEqual($obj->address->city, "sesamcity"); + $this->assertEqual($obj->email, "me@you.com"); + } + + function testGetContactThrowsException() + { + try + { + $result = $this->getClient()->getContact(1); + $this->fail(); + } + catch (SoapFault $f) + { + $this->pass(); + } + } + + function testGetNewContact() + { + $obj = $this->getClient()->newContact(); + $this->assertNull($obj->name); + $this->assertNull($obj->id); + $this->assertNull($obj->address); + $this->assertNull($obj->email); + } + + function testSaveContactReturnsTrue() + { + $c = new Contact; + $result = $this->getClient()->saveContact($c); + $this->assertTrue($result); + } + + function getMixedArray() + { + $result = $this->getClient()>getList(); + $expected = array(array(1,2), array("12", 1.2)); + $this->assertEqual($result, $expected); + } + + function testEmptyArray() + { + $result = $this->getClient()->getEmptyArray(); + $this->assertTrue(is_array($result)); + $this->assertEqual(count($result), 0); + } + + function testUnknownFunctionThrowsException() + { + try + { + $this->getClient()->test(); + $this->fail(); + } + catch (SoapFault $f) + { + $this->pass(); + } + } +} + +?> diff --git a/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php b/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php index cc276a25..b3cde511 100644 --- a/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php +++ b/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php @@ -1,87 +1,87 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-Prado::using('System.Data.ActiveRecord.TActiveRecord');
-
-class ActiveAccount extends TActiveRecord
-{
- public $Account_Id;
- public $Account_FirstName;
- public $Account_LastName;
- public $Account_Email;
-
- public $Account_Banner_Option;
- public $Account_Cart_Option;
-
- const TABLE='Accounts';
-
- public static function finder($className=__CLASS__)
- {
- return parent::finder($className);
- }
-}
-
-class ActiveRecordSqlMapTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- TActiveRecordManager::getInstance()->setDbConnection($this->getConnection());
-
- //$this->initScript('account-init.sql');
- }
-
- function testLoadWithSqlMap()
- {
- $records = $this->sqlmap->queryForList('GetActiveRecordAccounts');
- $registry=TActiveRecordManager::getInstance()->getObjectStateRegistry();
- foreach($records as $record)
- {
- $this->assertEqual(get_class($record), 'ActiveAccount');
- $this->assertTrue($registry->isCleanObject($record));
- }
- }
-
- function testLoadWithActiveRecord()
- {
- $records = ActiveAccount::finder()->findAll();
- $registry=TActiveRecordManager::getInstance()->getObjectStateRegistry();
- foreach($records as $record)
- {
- $this->assertEqual(get_class($record), 'ActiveAccount');
- //$this->assertTrue($registry->isCleanObject($record)); //? not clean anymore?
- }
- }
-
- function testLoadWithSqlMap_SaveWithActiveRecord()
- {
- $record = $this->sqlmap->queryForObject('GetActiveRecordAccounts');
- $registry=TActiveRecordManager::getInstance()->getObjectStateRegistry();
- $record->Account_FirstName = "Testing 123";
- $this->assertTrue($registry->isDirtyObject($record));
-
- $this->assertTrue($record->save());
-
- $check1 = $this->sqlmap->queryForObject('GetActiveRecordAccounts');
- $finder = ActiveAccount::finder();
- $check2 = $finder->findByAccount_FirstName($record->Account_FirstName);
-
-
- $this->assertSameAccount($record,$check1);
- $this->assertSameAccount($record,$check2);
-
- $this->initScript('account-init.sql');
- }
-
- function assertSameAccount($account1,$account2)
- {
- $props = array('Account_Id', 'Account_FirstName', 'Account_LastName',
- 'Account_Email', 'Account_Banner_Option', 'Account_Cart_Option');
- foreach($props as $prop)
- $this->assertEqual($account1->{$prop}, $account2->{$prop});
- }
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseCase.php'); + +Prado::using('System.Data.ActiveRecord.TActiveRecord'); + +class ActiveAccount extends TActiveRecord +{ + public $Account_Id; + public $Account_FirstName; + public $Account_LastName; + public $Account_Email; + + public $Account_Banner_Option; + public $Account_Cart_Option; + + const TABLE='Accounts'; + + public static function finder($className=__CLASS__) + { + return parent::finder($className); + } +} + +class ActiveRecordSqlMapTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + TActiveRecordManager::getInstance()->setDbConnection($this->getConnection()); + + //$this->initScript('account-init.sql'); + } + + function testLoadWithSqlMap() + { + $records = $this->sqlmap->queryForList('GetActiveRecordAccounts'); + $registry=TActiveRecordManager::getInstance()->getObjectStateRegistry(); + foreach($records as $record) + { + $this->assertEqual(get_class($record), 'ActiveAccount'); + $this->assertTrue($registry->isCleanObject($record)); + } + } + + function testLoadWithActiveRecord() + { + $records = ActiveAccount::finder()->findAll(); + $registry=TActiveRecordManager::getInstance()->getObjectStateRegistry(); + foreach($records as $record) + { + $this->assertEqual(get_class($record), 'ActiveAccount'); + //$this->assertTrue($registry->isCleanObject($record)); //? not clean anymore? + } + } + + function testLoadWithSqlMap_SaveWithActiveRecord() + { + $record = $this->sqlmap->queryForObject('GetActiveRecordAccounts'); + $registry=TActiveRecordManager::getInstance()->getObjectStateRegistry(); + $record->Account_FirstName = "Testing 123"; + $this->assertTrue($registry->isDirtyObject($record)); + + $this->assertTrue($record->save()); + + $check1 = $this->sqlmap->queryForObject('GetActiveRecordAccounts'); + $finder = ActiveAccount::finder(); + $check2 = $finder->findByAccount_FirstName($record->Account_FirstName); + + + $this->assertSameAccount($record,$check1); + $this->assertSameAccount($record,$check2); + + $this->initScript('account-init.sql'); + } + + function assertSameAccount($account1,$account2) + { + $props = array('Account_Id', 'Account_FirstName', 'Account_LastName', + 'Account_Email', 'Account_Banner_Option', 'Account_Cart_Option'); + foreach($props as $prop) + $this->assertEqual($account1->{$prop}, $account2->{$prop}); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/BaseCase.php b/tests/simple_unit/SqlMap/BaseCase.php index e311302d..b0961b5b 100644 --- a/tests/simple_unit/SqlMap/BaseCase.php +++ b/tests/simple_unit/SqlMap/BaseCase.php @@ -1,262 +1,262 @@ -<?php
-
-require_once(dirname(__FILE__).'/common.php');
-Prado::using('System.Data.SqlMap.TSqlMapManager');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class BaseCase extends UnitTestCase
-{
- protected $sqlmap;
- protected $connection;
- private $mapper;
- private $config;
- protected $ScriptDirectory;
-
- public function testCase1()
- {
- $this->assertTrue(true);
- }
-
- public function testCase2()
- {
- $this->assertTrue(true);
- }
-
- public function __construct()
- {
- parent::__construct();
- $this->config = BaseTestConfig::createConfigInstance();
- $this->ScriptDirectory = $this->config->getScriptDir();
- }
-
- public function hasSupportFor($feature)
- {
- return $this->config->hasFeature($feature);
- }
-
- public function __destruct()
- {
- if(!is_null($this->mapper))
- $this->mapper->cacheConfiguration();
- }
-
- function getConnection()
- {
- if(is_null($this->connection))
- $this->connection = $this->config->getConnection();
- $this->connection->setActive(true);
- return $this->connection;
- }
-
- /**
- * Initialize an sqlMap
- */
- protected function initSqlMap()
- {
- $manager = new TSqlMapManager($this->config->getConnection());
- $manager->configureXml($this->config->getSqlMapConfigFile());
- $this->sqlmap = $manager->getSqlMapGateway();
- $manager->TypeHandlers->registerTypeHandler(new TDateTimeHandler);
- }
-
- /**
- * Run a sql batch for the datasource.
- */
- protected function initScript($script)
- {
- $runner = $this->config->getScriptRunner();
- $runner->runScript($this->getConnection(), $this->ScriptDirectory.$script);
- }
-
- /**
- * Create a new account with id = 6
- */
- protected function NewAccount6()
- {
- $account = new Account();
- $account->setID(6);
- $account->setFirstName('Calamity');
- $account->setLastName('Jane');
- $account->setEmailAddress('no_email@provided.com');
- return $account;
- }
-
- /**
- * Verify that the input account is equal to the account(id=1).
- */
- protected function assertAccount1(Account $account)
- {
- $this->assertIdentical($account->getID(), 1);
- $this->assertIdentical($account->getFirstName(), 'Joe');
- $this->assertIdentical($account->getEmailAddress(), 'Joe.Dalton@somewhere.com');
- }
-
- /**
- * Verify that the input account is equal to the account(id=6).
- */
- protected function assertAccount6(Account $account)
- {
- $this->assertIdentical($account->getID(), 6);
- $this->assertIdentical($account->getFirstName(), 'Calamity');
- $this->assertIdentical($account->getLastName(), 'Jane');
- $this->assertNull($account->getEmailAddress());
- }
-
- /**
- * Verify that the input order is equal to the order(id=1).
- */
- protected function assertOrder1(Order $order)
- {
- $date = @mktime(8,15,0,2,15,2003);
-
- $this->assertIdentical((int)$order->getID(), 1);
- if($order->getDate() instanceof TDateTime)
- $this->assertIdentical($order->getDate()->getTimestamp(), $date);
- else
- $this->fail();
- $this->assertIdentical($order->getCardType(), 'VISA');
- $this->assertIdentical($order->getCardNumber(), '999999999999');
- $this->assertIdentical($order->getCardExpiry(), '05/03');
- $this->assertIdentical($order->getStreet(), '11 This Street');
- $this->assertIdentical($order->getProvince(), 'BC');
- $this->assertIdentical($order->getPostalCode(), 'C4B 4F4');
- }
-
- function assertAccount1AsHashArray($account)
- {
- $this->assertIdentical(1, (int)$account["Id"]);
- $this->assertIdentical("Joe", $account["FirstName"]);
- $this->assertIdentical("Dalton", $account["LastName"]);
- $this->assertIdentical("Joe.Dalton@somewhere.com", $account["EmailAddress"]);
- }
-
- function AssertOrder1AsHashArray($order)
- {
- $date = @mktime(8,15,0,2,15,2003);
-
- $this->assertIdentical(1, $order["Id"]);
- if($order['Date'] instanceof TDateTime)
- $this->assertIdentical($date, $order["Date"]->getTimestamp());
- else
- $this->fail();
- $this->assertIdentical("VISA", $order["CardType"]);
- $this->assertIdentical("999999999999", $order["CardNumber"]);
- $this->assertIdentical("05/03", $order["CardExpiry"]);
- $this->assertIdentical("11 This Street", $order["Street"]);
- $this->assertIdentical("Victoria", $order["City"]);
- $this->assertIdentical("BC", $order["Province"]);
- $this->assertIdentical("C4B 4F4", $order["PostalCode"]);
- }
-
-}
-
-class HundredsBool extends TSqlMapTypeHandler
-{
- public function getResult($string)
- {
- $value = intval($string);
- if($value == 100)
- return true;
- if($value == 200)
- return false;
- //throw new Exception('unexpected value '.$value);
- }
-
- public function getParameter($parameter)
- {
- if($parameter)
- return 100;
- else
- return 200;
- }
-
- public function createNewInstance($data=null)
- {
- throw new TDataMapperException('can not create');
- }
-}
-
-class OuiNonBool extends TSqlMapTypeHandler
-{
- const YES = "Oui";
- const NO = "Non";
-
- public function getResult($string)
- {
- if($string === self::YES)
- return true;
- if($string === self::NO)
- return false;
- //throw new Exception('unexpected value '.$string);
- }
-
- public function getParameter($parameter)
- {
- if($parameter)
- return self::YES;
- else
- return self::NO;
- }
-
- public function createNewInstance($data=null)
- {
- throw new TDataMapperException('can not create');
- }
-}
-
-class TDateTimeHandler extends TSqlMapTypeHandler
-{
- public function getType()
- {
- return 'date';
- }
-
- public function getResult($string)
- {
- $time = new TDateTime($string);
- return $time;
- }
-
- public function getParameter($parameter)
- {
- if($parameter instanceof TDateTime)
- return $parameter->getTimestamp();
- else
- return $parameter;
- }
-
- public function createNewInstance($data=null)
- {
- return new TDateTime;
- }
-}
-
-class TDateTime
-{
- private $_datetime;
-
- public function __construct($datetime=null)
- {
- if(!is_null($datetime))
- $this->setDatetime($datetime);
- }
-
- public function getTimestamp()
- {
- return strtotime($this->getDatetime());
- }
-
- public function getDateTime()
- {
- return $this->_datetime;
- }
-
- public function setDateTime($value)
- {
- $this->_datetime = $value;
- }
-}
-
+<?php + +require_once(dirname(__FILE__).'/common.php'); +Prado::using('System.Data.SqlMap.TSqlMapManager'); + +/** + * @package System.DataAccess.SQLMap + */ +class BaseCase extends UnitTestCase +{ + protected $sqlmap; + protected $connection; + private $mapper; + private $config; + protected $ScriptDirectory; + + public function testCase1() + { + $this->assertTrue(true); + } + + public function testCase2() + { + $this->assertTrue(true); + } + + public function __construct() + { + parent::__construct(); + $this->config = BaseTestConfig::createConfigInstance(); + $this->ScriptDirectory = $this->config->getScriptDir(); + } + + public function hasSupportFor($feature) + { + return $this->config->hasFeature($feature); + } + + public function __destruct() + { + if(!is_null($this->mapper)) + $this->mapper->cacheConfiguration(); + } + + function getConnection() + { + if(is_null($this->connection)) + $this->connection = $this->config->getConnection(); + $this->connection->setActive(true); + return $this->connection; + } + + /** + * Initialize an sqlMap + */ + protected function initSqlMap() + { + $manager = new TSqlMapManager($this->config->getConnection()); + $manager->configureXml($this->config->getSqlMapConfigFile()); + $this->sqlmap = $manager->getSqlMapGateway(); + $manager->TypeHandlers->registerTypeHandler(new TDateTimeHandler); + } + + /** + * Run a sql batch for the datasource. + */ + protected function initScript($script) + { + $runner = $this->config->getScriptRunner(); + $runner->runScript($this->getConnection(), $this->ScriptDirectory.$script); + } + + /** + * Create a new account with id = 6 + */ + protected function NewAccount6() + { + $account = new Account(); + $account->setID(6); + $account->setFirstName('Calamity'); + $account->setLastName('Jane'); + $account->setEmailAddress('no_email@provided.com'); + return $account; + } + + /** + * Verify that the input account is equal to the account(id=1). + */ + protected function assertAccount1(Account $account) + { + $this->assertIdentical($account->getID(), 1); + $this->assertIdentical($account->getFirstName(), 'Joe'); + $this->assertIdentical($account->getEmailAddress(), 'Joe.Dalton@somewhere.com'); + } + + /** + * Verify that the input account is equal to the account(id=6). + */ + protected function assertAccount6(Account $account) + { + $this->assertIdentical($account->getID(), 6); + $this->assertIdentical($account->getFirstName(), 'Calamity'); + $this->assertIdentical($account->getLastName(), 'Jane'); + $this->assertNull($account->getEmailAddress()); + } + + /** + * Verify that the input order is equal to the order(id=1). + */ + protected function assertOrder1(Order $order) + { + $date = @mktime(8,15,0,2,15,2003); + + $this->assertIdentical((int)$order->getID(), 1); + if($order->getDate() instanceof TDateTime) + $this->assertIdentical($order->getDate()->getTimestamp(), $date); + else + $this->fail(); + $this->assertIdentical($order->getCardType(), 'VISA'); + $this->assertIdentical($order->getCardNumber(), '999999999999'); + $this->assertIdentical($order->getCardExpiry(), '05/03'); + $this->assertIdentical($order->getStreet(), '11 This Street'); + $this->assertIdentical($order->getProvince(), 'BC'); + $this->assertIdentical($order->getPostalCode(), 'C4B 4F4'); + } + + function assertAccount1AsHashArray($account) + { + $this->assertIdentical(1, (int)$account["Id"]); + $this->assertIdentical("Joe", $account["FirstName"]); + $this->assertIdentical("Dalton", $account["LastName"]); + $this->assertIdentical("Joe.Dalton@somewhere.com", $account["EmailAddress"]); + } + + function AssertOrder1AsHashArray($order) + { + $date = @mktime(8,15,0,2,15,2003); + + $this->assertIdentical(1, $order["Id"]); + if($order['Date'] instanceof TDateTime) + $this->assertIdentical($date, $order["Date"]->getTimestamp()); + else + $this->fail(); + $this->assertIdentical("VISA", $order["CardType"]); + $this->assertIdentical("999999999999", $order["CardNumber"]); + $this->assertIdentical("05/03", $order["CardExpiry"]); + $this->assertIdentical("11 This Street", $order["Street"]); + $this->assertIdentical("Victoria", $order["City"]); + $this->assertIdentical("BC", $order["Province"]); + $this->assertIdentical("C4B 4F4", $order["PostalCode"]); + } + +} + +class HundredsBool extends TSqlMapTypeHandler +{ + public function getResult($string) + { + $value = intval($string); + if($value == 100) + return true; + if($value == 200) + return false; + //throw new Exception('unexpected value '.$value); + } + + public function getParameter($parameter) + { + if($parameter) + return 100; + else + return 200; + } + + public function createNewInstance($data=null) + { + throw new TDataMapperException('can not create'); + } +} + +class OuiNonBool extends TSqlMapTypeHandler +{ + const YES = "Oui"; + const NO = "Non"; + + public function getResult($string) + { + if($string === self::YES) + return true; + if($string === self::NO) + return false; + //throw new Exception('unexpected value '.$string); + } + + public function getParameter($parameter) + { + if($parameter) + return self::YES; + else + return self::NO; + } + + public function createNewInstance($data=null) + { + throw new TDataMapperException('can not create'); + } +} + +class TDateTimeHandler extends TSqlMapTypeHandler +{ + public function getType() + { + return 'date'; + } + + public function getResult($string) + { + $time = new TDateTime($string); + return $time; + } + + public function getParameter($parameter) + { + if($parameter instanceof TDateTime) + return $parameter->getTimestamp(); + else + return $parameter; + } + + public function createNewInstance($data=null) + { + return new TDateTime; + } +} + +class TDateTime +{ + private $_datetime; + + public function __construct($datetime=null) + { + if(!is_null($datetime)) + $this->setDatetime($datetime); + } + + public function getTimestamp() + { + return strtotime($this->getDatetime()); + } + + public function getDateTime() + { + return $this->_datetime; + } + + public function setDateTime($value) + { + $this->_datetime = $value; + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/CacheTest.php b/tests/simple_unit/SqlMap/CacheTest.php index 04475cdb..131ddfbb 100644 --- a/tests/simple_unit/SqlMap/CacheTest.php +++ b/tests/simple_unit/SqlMap/CacheTest.php @@ -1,164 +1,164 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class CacheTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
-
- $this->initSqlMap();
-
- //force autoload
- new Account;
- }
-
- function resetDatabase()
- {
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test for JIRA 29
- */
- function testJIRA28()
- {
- $account = $this->sqlmap->queryForObject("GetNoAccountWithCache",-99);
- $this->assertNull($account);
- }
-
- /**
- * Test Cache query
- */
- function testQueryWithCache()
- {
- $this->resetDatabase();
-
- $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 === $list2);
-
- $account = $list1[1];
- $account->setEmailAddress("somebody@cache.com");
-
- //this will cause the cache to flush
- $this->sqlmap->update("UpdateAccountViaInlineParameters", $account);
-
- $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 !== $list3);
-
- $this->resetDatabase();
- }
-
-
- /**
- * Test flush Cache
- */
- function testFlushDataCache()
- {
- $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
- $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 === $list2);
- $this->sqlmap->flushCaches();
-
- $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 !== $list3);
- }
-
- /**
- *
- */
- function testFlushDataCacheOnExecute()
- {
- $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 === $list2);
- $this->sqlmap->update("UpdateAccountViaInlineParameters", $list1[0]);
-
- $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 !== $list3);
- }
-
- /**
- */
- protected function getCacheModel()
- {
- $cache = new TSqlMapCacheModel();
- // $cache->setFlushInterval(5*60);
- $cache->setImplementation('LRU');
- $cache->initialize();
- return $cache;
- }
-
- /**
- * Test CacheHit
- */
- function testCacheHit()
- {
- $cache = $this->getCacheModel();
- $key = new TSqlMapCacheKey('testkey');
- $cache->set($key, 'a');
-
- $returnedObject = $cache->get($key);
-
- $this->assertIdentical('a', $returnedObject);
-
- $this->assertIdentical(1, $cache->getHitRatio());
- }
-
-
-
- /**
- * Test CacheMiss
- */
- function testCacheMiss()
- {
- $cache = $this->getCacheModel();
- $key = new TSqlMapCacheKey('testKey');
- $value = 'testValue';
- $cache->set($key, $value);
-
- $wrongKey = new TSqlMapCacheKey('wrongKey');
-
- $returnedObject = $cache->get($wrongKey);
- $this->assertNotEqual($value, $returnedObject);
- $this->assertNull($returnedObject) ;
- $this->assertIdentical(0, $cache->getHitRatio());
- }
-
- /**
- * Test CacheHitMiss
- */
- function testCacheHitMiss()
- {
- $cache = $this->getCacheModel();
- $key = new TSqlMapCacheKey('testKey');
-
- $value = "testValue";
- $cache->set($key, $value);
-
- $returnedObject = $cache->get($key);
- $this->assertIdentical($value, $returnedObject);
-
- $wrongKey = new TSqlMapCacheKey('wrongKey');
-
- $returnedObject = $cache->get($wrongKey);
- $this->assertNotEqual($value, $returnedObject);
- $this->assertNull($returnedObject) ;
- $this->assertIdentical(0.5, $cache->getHitRatio());
- }
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class CacheTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + + $this->initSqlMap(); + + //force autoload + new Account; + } + + function resetDatabase() + { + $this->initScript('account-init.sql'); + } + + /** + * Test for JIRA 29 + */ + function testJIRA28() + { + $account = $this->sqlmap->queryForObject("GetNoAccountWithCache",-99); + $this->assertNull($account); + } + + /** + * Test Cache query + */ + function testQueryWithCache() + { + $this->resetDatabase(); + + $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 === $list2); + + $account = $list1[1]; + $account->setEmailAddress("somebody@cache.com"); + + //this will cause the cache to flush + $this->sqlmap->update("UpdateAccountViaInlineParameters", $account); + + $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 !== $list3); + + $this->resetDatabase(); + } + + + /** + * Test flush Cache + */ + function testFlushDataCache() + { + $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 === $list2); + $this->sqlmap->flushCaches(); + + $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 !== $list3); + } + + /** + * + */ + function testFlushDataCacheOnExecute() + { + $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 === $list2); + $this->sqlmap->update("UpdateAccountViaInlineParameters", $list1[0]); + + $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 !== $list3); + } + + /** + */ + protected function getCacheModel() + { + $cache = new TSqlMapCacheModel(); + // $cache->setFlushInterval(5*60); + $cache->setImplementation('LRU'); + $cache->initialize(); + return $cache; + } + + /** + * Test CacheHit + */ + function testCacheHit() + { + $cache = $this->getCacheModel(); + $key = new TSqlMapCacheKey('testkey'); + $cache->set($key, 'a'); + + $returnedObject = $cache->get($key); + + $this->assertIdentical('a', $returnedObject); + + $this->assertIdentical(1, $cache->getHitRatio()); + } + + + + /** + * Test CacheMiss + */ + function testCacheMiss() + { + $cache = $this->getCacheModel(); + $key = new TSqlMapCacheKey('testKey'); + $value = 'testValue'; + $cache->set($key, $value); + + $wrongKey = new TSqlMapCacheKey('wrongKey'); + + $returnedObject = $cache->get($wrongKey); + $this->assertNotEqual($value, $returnedObject); + $this->assertNull($returnedObject) ; + $this->assertIdentical(0, $cache->getHitRatio()); + } + + /** + * Test CacheHitMiss + */ + function testCacheHitMiss() + { + $cache = $this->getCacheModel(); + $key = new TSqlMapCacheKey('testKey'); + + $value = "testValue"; + $cache->set($key, $value); + + $returnedObject = $cache->get($key); + $this->assertIdentical($value, $returnedObject); + + $wrongKey = new TSqlMapCacheKey('wrongKey'); + + $returnedObject = $cache->get($wrongKey); + $this->assertNotEqual($value, $returnedObject); + $this->assertNull($returnedObject) ; + $this->assertIdentical(0.5, $cache->getHitRatio()); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/DelegateTest.php b/tests/simple_unit/SqlMap/DelegateTest.php index 32c47fd1..800e4240 100644 --- a/tests/simple_unit/SqlMap/DelegateTest.php +++ b/tests/simple_unit/SqlMap/DelegateTest.php @@ -1,64 +1,64 @@ -<?php
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class DelegateTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- }
-
- function testListDelegate()
- {
- $list = $this->sqlmap->queryWithRowDelegate(
- "GetAllAccountsViaResultMap", array($this, 'listHandler'));
-
- $this->assertIdentical(5, count($list));
- $this->assertAccount1($list[0]);
- $this->assertIdentical(1, $list[0]->getID());
- $this->assertIdentical(2, $list[1]->getID());
- $this->assertIdentical(3, $list[2]->getID());
- $this->assertIdentical(4, $list[3]->getID());
- $this->assertIdentical(5, $list[4]->getID());
- }
-
- /**
- * Test ExecuteQueryForMap : Hashtable.
- */
- function testExecuteQueryForMap()
- {
- $map = $this->sqlmap->QueryForMapWithRowDelegate(
- "GetAllAccountsViaResultClass", array($this, 'mapHandler'), null, "FirstName");
-
- $this->assertIdentical(5, count($map));
- $this->assertAccount1($map["Joe"]);
-
- $this->assertIdentical(1, $map["Joe"]->getID());
- $this->assertIdentical(2, $map["Averel"]->getID());
- $this->assertIdentical(3, $map["William"]->getID());
- $this->assertIdentical(4, $map["Jack"]->getID());
- $this->assertIdentical(5, $map["Gilles"]->getID());
- }
-
- public function listHandler($sender, $param)
- {
- $list = &$param->getList();
- $list[] = $param->result;
- $this->assertTrue($param->result instanceof Account);
- }
-
- public function mapHandler($sender, $param)
- {
- $map = &$param->getMap();
- $map[$param->getKey()] = $param->getValue();
- $this->assertTrue($param->getValue() instanceof Account);
- }
-}
-
-
-
+<?php +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class DelegateTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + } + + function testListDelegate() + { + $list = $this->sqlmap->queryWithRowDelegate( + "GetAllAccountsViaResultMap", array($this, 'listHandler')); + + $this->assertIdentical(5, count($list)); + $this->assertAccount1($list[0]); + $this->assertIdentical(1, $list[0]->getID()); + $this->assertIdentical(2, $list[1]->getID()); + $this->assertIdentical(3, $list[2]->getID()); + $this->assertIdentical(4, $list[3]->getID()); + $this->assertIdentical(5, $list[4]->getID()); + } + + /** + * Test ExecuteQueryForMap : Hashtable. + */ + function testExecuteQueryForMap() + { + $map = $this->sqlmap->QueryForMapWithRowDelegate( + "GetAllAccountsViaResultClass", array($this, 'mapHandler'), null, "FirstName"); + + $this->assertIdentical(5, count($map)); + $this->assertAccount1($map["Joe"]); + + $this->assertIdentical(1, $map["Joe"]->getID()); + $this->assertIdentical(2, $map["Averel"]->getID()); + $this->assertIdentical(3, $map["William"]->getID()); + $this->assertIdentical(4, $map["Jack"]->getID()); + $this->assertIdentical(5, $map["Gilles"]->getID()); + } + + public function listHandler($sender, $param) + { + $list = &$param->getList(); + $list[] = $param->result; + $this->assertTrue($param->result instanceof Account); + } + + public function mapHandler($sender, $param) + { + $map = &$param->getMap(); + $map[$param->getKey()] = $param->getValue(); + $this->assertTrue($param->getValue() instanceof Account); + } +} + + + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/Dynamic/DynamicTest.php b/tests/simple_unit/SqlMap/Dynamic/DynamicTest.php index ce58327b..436cd49e 100644 --- a/tests/simple_unit/SqlMap/Dynamic/DynamicTest.php +++ b/tests/simple_unit/SqlMap/Dynamic/DynamicTest.php @@ -1,11 +1,11 @@ -<?php
-
-class DynamicTest extends UnitTestCase
-{
- function testConditional()
- {
-
- }
-}
-
+<?php + +class DynamicTest extends UnitTestCase +{ + function testConditional() + { + + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/GroupByTest.php b/tests/simple_unit/SqlMap/GroupByTest.php index 5f6782e5..11bd86bb 100644 --- a/tests/simple_unit/SqlMap/GroupByTest.php +++ b/tests/simple_unit/SqlMap/GroupByTest.php @@ -1,43 +1,43 @@ -<?php
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-class AccountWithOrders extends Account
-{
- private $_orders = array();
-
- public function setOrders($orders)
- {
- $this->_orders = $orders;
- }
-
- public function getOrders()
- {
- return $this->_orders;
- }
-}
-
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class GroupByTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- }
-
- function testAccountWithOrders()
- {
- $this->initScript('account-init.sql');
- $accounts = $this->sqlmap->queryForList("getAccountWithOrders");
- $this->assertIdentical(5, count($accounts));
- foreach($accounts as $account)
- $this->assertIdentical(2, count($account->getOrders()));
- }
-
-/**/
-}
-
+<?php +require_once(dirname(__FILE__).'/BaseCase.php'); + +class AccountWithOrders extends Account +{ + private $_orders = array(); + + public function setOrders($orders) + { + $this->_orders = $orders; + } + + public function getOrders() + { + return $this->_orders; + } +} + + +/** + * @package System.DataAccess.SQLMap + */ +class GroupByTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + } + + function testAccountWithOrders() + { + $this->initScript('account-init.sql'); + $accounts = $this->sqlmap->queryForList("getAccountWithOrders"); + $this->assertIdentical(5, count($accounts)); + foreach($accounts as $account) + $this->assertIdentical(2, count($account->getOrders())); + } + +/**/ +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/InheritanceTest.php b/tests/simple_unit/SqlMap/InheritanceTest.php index b0dd2dc9..82f86af3 100644 --- a/tests/simple_unit/SqlMap/InheritanceTest.php +++ b/tests/simple_unit/SqlMap/InheritanceTest.php @@ -1,145 +1,145 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class InheritanceTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
-
- $this->initSqlMap();
- $this->initScript('documents-init.sql');
- }
-
- /// Test All document with no formula
- function testGetAllDocument()
- {
- $list = $this->sqlmap->queryForList("GetAllDocument");
-
- $this->assertEqual(6, count($list));
- $book = $list[0];
- $this->assertBook($book, 1, "The World of Null-A", 55);
-
- $book = $list[1];
- $this->assertBook($book, 3, "Lord of the Rings", 3587);
-
- $document = $list[2];
- $this->assertDocument($document, 5, "Le Monde");
-
- $document = $list[3];
- $this->assertDocument($document, 6, "Foundation");
-
- $news = $list[4];
- $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
-
- $document = $list[5];
- $this->assertDocument($document, 4, "Le Canard enchaine");
- }
-
- /// Test All document in a typed collection
- function testGetTypedCollection()
- {
- $list = $this->sqlmap->queryForList("GetTypedCollection");
-
- $this->assertEqual(6, $list->getCount());
-
- $book = $list[0];
- $this->assertBook($book, 1, "The World of Null-A", 55);
-
- $book = $list[1];
- $this->assertBook($book, 3, "Lord of the Rings", 3587);
-
- $document = $list[2];
- $this->assertDocument($document, 5, "Le Monde");
-
- $document = $list[3];
- $this->assertDocument($document, 6, "Foundation");
-
- $news = $list[4];
- $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
-
- $document = $list[5];
- $this->assertDocument($document, 4, "Le Canard enchaine");
- }
-
- /// Test All document with Custom Type Handler
- function testGetAllDocumentWithCustomTypeHandler()
- {
-
- //register the custom inheritance type handler
- $this->sqlmap->registerTypeHandler(new CustomInheritance);
-
- $list = $this->sqlmap->queryForList("GetAllDocumentWithCustomTypeHandler");
-
- $this->assertEqual(6, count($list));
- $book = $list[0];
- $this->assertBook($book, 1, "The World of Null-A", 55);
-
- $book = $list[1];
- $this->assertBook($book, 3, "Lord of the Rings", 3587);
-
- $news = $list[2];
- $this->assertNewspaper($news, 5, "Le Monde", "Paris");
-
- $book = $list[3];
- $this->assertBook($book, 6, "Foundation", 557);
-
- $news = $list[4];
- $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
-
- $news = $list[5];
- $this->assertNewspaper($news, 4, "Le Canard enchaine", "Paris");
- }
-
- function AssertDocument(Document $document, $id, $title)
- {
- $this->assertEqual($id, $document->getID());
- $this->assertEqual($title, $document->getTitle());
- }
-
- function AssertBook(Book $book, $id, $title, $pageNumber)
- {
- $this->assertEqual($id, $book->getId());
- $this->assertEqual($title, $book->getTitle());
- $this->assertEqual($pageNumber, (int)$book->getPageNumber());
- }
-
- function AssertNewspaper(Newspaper $news, $id, $title, $city)
- {
- $this->assertEqual($id, $news->getId());
- $this->assertEqual($title, $news->getTitle());
- $this->assertEqual($city, $news->getCity());
- }
-}
-
-
-class CustomInheritance extends TSqlMapTypeHandler
-{
- public function getResult($type)
- {
- switch ($type)
- {
- case 'Monograph': case 'Book':
- return 'Book';
- case 'Tabloid': case 'Broadsheet': case 'Newspaper':
- return 'Newspaper';
- default:
- return 'Document';
- }
- }
-
- public function getParameter($parameter)
- {
- throw new TDataMapperException('not implemented');
- }
-
- public function createNewInstance($data=null)
- {
- throw new TDataMapperException('can not create');
- }
-}
+<?php + +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class InheritanceTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + + $this->initSqlMap(); + $this->initScript('documents-init.sql'); + } + + /// Test All document with no formula + function testGetAllDocument() + { + $list = $this->sqlmap->queryForList("GetAllDocument"); + + $this->assertEqual(6, count($list)); + $book = $list[0]; + $this->assertBook($book, 1, "The World of Null-A", 55); + + $book = $list[1]; + $this->assertBook($book, 3, "Lord of the Rings", 3587); + + $document = $list[2]; + $this->assertDocument($document, 5, "Le Monde"); + + $document = $list[3]; + $this->assertDocument($document, 6, "Foundation"); + + $news = $list[4]; + $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon"); + + $document = $list[5]; + $this->assertDocument($document, 4, "Le Canard enchaine"); + } + + /// Test All document in a typed collection + function testGetTypedCollection() + { + $list = $this->sqlmap->queryForList("GetTypedCollection"); + + $this->assertEqual(6, $list->getCount()); + + $book = $list[0]; + $this->assertBook($book, 1, "The World of Null-A", 55); + + $book = $list[1]; + $this->assertBook($book, 3, "Lord of the Rings", 3587); + + $document = $list[2]; + $this->assertDocument($document, 5, "Le Monde"); + + $document = $list[3]; + $this->assertDocument($document, 6, "Foundation"); + + $news = $list[4]; + $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon"); + + $document = $list[5]; + $this->assertDocument($document, 4, "Le Canard enchaine"); + } + + /// Test All document with Custom Type Handler + function testGetAllDocumentWithCustomTypeHandler() + { + + //register the custom inheritance type handler + $this->sqlmap->registerTypeHandler(new CustomInheritance); + + $list = $this->sqlmap->queryForList("GetAllDocumentWithCustomTypeHandler"); + + $this->assertEqual(6, count($list)); + $book = $list[0]; + $this->assertBook($book, 1, "The World of Null-A", 55); + + $book = $list[1]; + $this->assertBook($book, 3, "Lord of the Rings", 3587); + + $news = $list[2]; + $this->assertNewspaper($news, 5, "Le Monde", "Paris"); + + $book = $list[3]; + $this->assertBook($book, 6, "Foundation", 557); + + $news = $list[4]; + $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon"); + + $news = $list[5]; + $this->assertNewspaper($news, 4, "Le Canard enchaine", "Paris"); + } + + function AssertDocument(Document $document, $id, $title) + { + $this->assertEqual($id, $document->getID()); + $this->assertEqual($title, $document->getTitle()); + } + + function AssertBook(Book $book, $id, $title, $pageNumber) + { + $this->assertEqual($id, $book->getId()); + $this->assertEqual($title, $book->getTitle()); + $this->assertEqual($pageNumber, (int)$book->getPageNumber()); + } + + function AssertNewspaper(Newspaper $news, $id, $title, $city) + { + $this->assertEqual($id, $news->getId()); + $this->assertEqual($title, $news->getTitle()); + $this->assertEqual($city, $news->getCity()); + } +} + + +class CustomInheritance extends TSqlMapTypeHandler +{ + public function getResult($type) + { + switch ($type) + { + case 'Monograph': case 'Book': + return 'Book'; + case 'Tabloid': case 'Broadsheet': case 'Newspaper': + return 'Newspaper'; + default: + return 'Document'; + } + } + + public function getParameter($parameter) + { + throw new TDataMapperException('not implemented'); + } + + public function createNewInstance($data=null) + { + throw new TDataMapperException('can not create'); + } +} ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/ParameterMapTest.php b/tests/simple_unit/SqlMap/ParameterMapTest.php index 7ace082f..fb29c162 100644 --- a/tests/simple_unit/SqlMap/ParameterMapTest.php +++ b/tests/simple_unit/SqlMap/ParameterMapTest.php @@ -1,249 +1,249 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class ParameterMapTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- }
-
- function setup()
- {
- $this->initScript('account-init.sql');
-// $this->initScript('account-procedure.sql');
- $this->initScript('order-init.sql');
-// $this->initScript('line-item-init.sql');
- $this->initScript('category-init.sql');
- }
-
- /// Test null replacement in ParameterMap property
- function testNullValueReplacement()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
-
- $this->assertNull($account->getEmailAddress(), 'no_email@provided.com');
-
- $this->assertAccount6($account);
- }
-
- /// Test Test Null Value Replacement Inline
- function testNullValueReplacementInline()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaInlineParameters", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
- $this->assertNull($account->getEmailAddress());
-
- $this->assertAccount6($account);
- }
-
- /// Test Test Null Value Replacement Inline
- function testSpecifiedType()
- {
- $account = $this->newAccount6();
- $account->setEmailAddress(null);
- $this->sqlmap->insert("InsertAccountNullableEmail", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
- $this->assertAccount6($account);
- }
-
-
- /// Test Test Null Value Replacement Inline
- function testUnknownParameterClass()
- {
- $account = $this->newAccount6();
- $account->setEmailAddress(null);
- $this->sqlmap->insert("InsertAccountUknownParameterClass", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
- $this->assertAccount6($account);
- }
-
-
- /// Test null replacement in ParameterMap property
- /// for System.DateTime.MinValue
- function testNullValueReplacementForDateTimeMinValue()
- {
- $account = $this->newAccount6();
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate(null);
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
-
- $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99);
-
- $this->assertIdentical($order->getCity(), $orderTest->getCity());
- }
-
- /// Test null replacement in ParameterMap/Hahstable property
- /// for System.DateTime.MinValue
- function testNullValueReplacementForDateTimeWithHashtable()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate('0001-01-01 00:00:00'); //<-- null replacement
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
-
- $orderTest = $this->sqlmap->queryForObject("GetOrderByHashTable", 99);
-
- $this->assertIdentical($orderTest["Date"], '0001-01-01 00:00:00');
- }
-
- /// Test null replacement in ParameterMap property
- /// for Guid
- function testNullValueReplacementForGuidValue()
- {
- if($this->hasSupportFor('last_insert_id'))
- {
- $category = new Category();
- $category->setName("Totoasdasd");
- $category->setGuidString('00000000-0000-0000-0000-000000000000');
-
- $key = $this->sqlmap->insert("InsertCategoryNull", $category);
-
- $categoryRead = $this->sqlmap->queryForObject("GetCategory", $key);
-
- $this->assertIdentical($category->getName(), $categoryRead->getName());
- $this->assertIdentical('', $categoryRead->getGuidString());
- }
- }
-
-
-
-/// Test complex mapping Via hasTable
- /// <example>
- ///
- /// map.Add("Item", Item);
- /// map.Add("Order", Order);
- ///
- /// <statement>
- /// ... #Item.prop1#...#Order.prop2#
- /// </statement>
- ///
- /// </example>
- function testComplexMappingViaHasTable()
- {
- $a = new Account();
- $a->setFirstName("Joe");
-
- $param["Account"] = $a;
-
- $o = new Order();
- $o->setCity("Dalton");
- $param["Order"] = $o;
-
- $accountTest = $this->sqlmap->queryForObject("GetAccountComplexMapping", $param);
-
- $this->assertAccount1($accountTest);
- }
-
-/*
- /// Test ByteArrayTypeHandler via Picture Property
- function testByteArrayTypeHandler()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate(0);
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
-
- $item = new LineItem();
- $item->setId(99);
- $item->setCode("test");
- $item->setPrice(-99.99);
- $item->setQuantity(99);
- $item->setOrder($order);
- $item->setPicture(null);
-
- // Check insert
- $this->sqlmap->insert("InsertLineItemWithPicture", $item);
-
- // select
- $item = null;
-
- $param["LineItem_ID"] = 99;
- $param["Order_ID"] = 99;
-
- $item = $this->sqlmap->queryForObject("GetSpecificLineItemWithPicture", $param);
-
- $this->assertNotNull($item->getId());
-// $this->assertNotNull($item->getPicture());
-// $this->assertIdentical( GetSize(item.Picture), this.GetSize( this.GetPicture() ));
- }
-*/
-
- /// Test extend parameter map capacity
- /// (Support Requests 1043181)
- function testInsertOrderViaExtendParameterMap()
- {
- $this->sqlmap->getSqlMapManager()->getTypeHandlers()->registerTypeHandler(new HundredsBool());
-
- $account = $this->newAccount6();
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate(null); //<-- null replacement
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaExtendParameterMap", $order);
-
- $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99);
-
- $this->assertIdentical($order->getCity(), $orderTest->getCity());
- }
-/**/
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class ParameterMapTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + } + + function setup() + { + $this->initScript('account-init.sql'); +// $this->initScript('account-procedure.sql'); + $this->initScript('order-init.sql'); +// $this->initScript('line-item-init.sql'); + $this->initScript('category-init.sql'); + } + + /// Test null replacement in ParameterMap property + function testNullValueReplacement() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + + $this->assertNull($account->getEmailAddress(), 'no_email@provided.com'); + + $this->assertAccount6($account); + } + + /// Test Test Null Value Replacement Inline + function testNullValueReplacementInline() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaInlineParameters", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + $this->assertNull($account->getEmailAddress()); + + $this->assertAccount6($account); + } + + /// Test Test Null Value Replacement Inline + function testSpecifiedType() + { + $account = $this->newAccount6(); + $account->setEmailAddress(null); + $this->sqlmap->insert("InsertAccountNullableEmail", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + $this->assertAccount6($account); + } + + + /// Test Test Null Value Replacement Inline + function testUnknownParameterClass() + { + $account = $this->newAccount6(); + $account->setEmailAddress(null); + $this->sqlmap->insert("InsertAccountUknownParameterClass", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + $this->assertAccount6($account); + } + + + /// Test null replacement in ParameterMap property + /// for System.DateTime.MinValue + function testNullValueReplacementForDateTimeMinValue() + { + $account = $this->newAccount6(); + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate(null); + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaParameterMap", $order); + + $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99); + + $this->assertIdentical($order->getCity(), $orderTest->getCity()); + } + + /// Test null replacement in ParameterMap/Hahstable property + /// for System.DateTime.MinValue + function testNullValueReplacementForDateTimeWithHashtable() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate('0001-01-01 00:00:00'); //<-- null replacement + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaParameterMap", $order); + + $orderTest = $this->sqlmap->queryForObject("GetOrderByHashTable", 99); + + $this->assertIdentical($orderTest["Date"], '0001-01-01 00:00:00'); + } + + /// Test null replacement in ParameterMap property + /// for Guid + function testNullValueReplacementForGuidValue() + { + if($this->hasSupportFor('last_insert_id')) + { + $category = new Category(); + $category->setName("Totoasdasd"); + $category->setGuidString('00000000-0000-0000-0000-000000000000'); + + $key = $this->sqlmap->insert("InsertCategoryNull", $category); + + $categoryRead = $this->sqlmap->queryForObject("GetCategory", $key); + + $this->assertIdentical($category->getName(), $categoryRead->getName()); + $this->assertIdentical('', $categoryRead->getGuidString()); + } + } + + + +/// Test complex mapping Via hasTable + /// <example> + /// + /// map.Add("Item", Item); + /// map.Add("Order", Order); + /// + /// <statement> + /// ... #Item.prop1#...#Order.prop2# + /// </statement> + /// + /// </example> + function testComplexMappingViaHasTable() + { + $a = new Account(); + $a->setFirstName("Joe"); + + $param["Account"] = $a; + + $o = new Order(); + $o->setCity("Dalton"); + $param["Order"] = $o; + + $accountTest = $this->sqlmap->queryForObject("GetAccountComplexMapping", $param); + + $this->assertAccount1($accountTest); + } + +/* + /// Test ByteArrayTypeHandler via Picture Property + function testByteArrayTypeHandler() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate(0); + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaParameterMap", $order); + + $item = new LineItem(); + $item->setId(99); + $item->setCode("test"); + $item->setPrice(-99.99); + $item->setQuantity(99); + $item->setOrder($order); + $item->setPicture(null); + + // Check insert + $this->sqlmap->insert("InsertLineItemWithPicture", $item); + + // select + $item = null; + + $param["LineItem_ID"] = 99; + $param["Order_ID"] = 99; + + $item = $this->sqlmap->queryForObject("GetSpecificLineItemWithPicture", $param); + + $this->assertNotNull($item->getId()); +// $this->assertNotNull($item->getPicture()); +// $this->assertIdentical( GetSize(item.Picture), this.GetSize( this.GetPicture() )); + } +*/ + + /// Test extend parameter map capacity + /// (Support Requests 1043181) + function testInsertOrderViaExtendParameterMap() + { + $this->sqlmap->getSqlMapManager()->getTypeHandlers()->registerTypeHandler(new HundredsBool()); + + $account = $this->newAccount6(); + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate(null); //<-- null replacement + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaExtendParameterMap", $order); + + $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99); + + $this->assertIdentical($order->getCity(), $orderTest->getCity()); + } +/**/ +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/PropertyAccessTest.php b/tests/simple_unit/SqlMap/PropertyAccessTest.php index 38573f4e..d580f965 100644 --- a/tests/simple_unit/SqlMap/PropertyAccessTest.php +++ b/tests/simple_unit/SqlMap/PropertyAccessTest.php @@ -1,77 +1,77 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class PropertyAccessTest extends BaseCase
-{
- function testGetPublicProperty()
- {
- $account = new AccountBis();
-
- $account->Id = 10;
- $account->FirstName = "Luky";
- $account->LastName = "Luke";
- $account->EmailAddress = "luly.luke@somewhere.com";
-
- $two = new AccountBis();
- $two->Id = 12;
- $two->FirstName = "Mini Me!";
- $account->More = $two;
-
- $account6 = $this->NewAccount6();
- $two->More = $account6;
-
- $this->assertIdentical(10, TPropertyAccess::get($account, 'Id'));
- $this->assertIdentical(12, TPropertyAccess::get($account, 'More.Id'));
- $this->assertIdentical(6, TPropertyAccess::get($account, 'More.More.Id'));
- }
-
- function testSetPublicProperty()
- {
- $account = new AccountBis();
-
- $account->Id = 10;
- $account->FirstName = "Luky";
- $account->LastName = "Luke";
- $account->EmailAddress = "luly.luke@somewhere.com";
-
- $two = new AccountBis();
- $two->Id = 12;
- $two->FirstName = "Mini Me!";
- TPropertyAccess::set($account, 'More', $two);
-
- $account6 = $this->NewAccount6();
- TPropertyAccess::set($account, 'More.More', $account6);
-
- TPropertyAccess::set($account, 'More.More.EmailAddress', 'hahaha');
-
- $this->assertIdentical(10, TPropertyAccess::get($account, 'Id'));
- $this->assertIdentical(12, TPropertyAccess::get($account, 'More.Id'));
- $this->assertIdentical(6, TPropertyAccess::get($account, 'More.More.Id'));
-
- $this->assertIdentical('hahaha',
- TPropertyAccess::get($account, 'More.More.EmailAddress'));
- }
-
- function testArrayAccessProperty()
- {
- $account = new AccountBis();
- $things['more'] = 1;
- $things['accounts'] = $this->NewAccount6();
- $account->More = $things;
-
- $this->assertIdentical(6, TPropertyAccess::get($account, 'More.accounts.ID'));
-
- TPropertyAccess::set($account, 'More.accounts.EmailAddress', 'adssd');
- $this->assertIdentical('adssd', TPropertyAccess::get($account, 'More.accounts.EmailAddress'));
-
- $this->assertIdentical(1, TPropertyAccess::get($things, 'more'));
- }
-
-}
-
-
+<?php + +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class PropertyAccessTest extends BaseCase +{ + function testGetPublicProperty() + { + $account = new AccountBis(); + + $account->Id = 10; + $account->FirstName = "Luky"; + $account->LastName = "Luke"; + $account->EmailAddress = "luly.luke@somewhere.com"; + + $two = new AccountBis(); + $two->Id = 12; + $two->FirstName = "Mini Me!"; + $account->More = $two; + + $account6 = $this->NewAccount6(); + $two->More = $account6; + + $this->assertIdentical(10, TPropertyAccess::get($account, 'Id')); + $this->assertIdentical(12, TPropertyAccess::get($account, 'More.Id')); + $this->assertIdentical(6, TPropertyAccess::get($account, 'More.More.Id')); + } + + function testSetPublicProperty() + { + $account = new AccountBis(); + + $account->Id = 10; + $account->FirstName = "Luky"; + $account->LastName = "Luke"; + $account->EmailAddress = "luly.luke@somewhere.com"; + + $two = new AccountBis(); + $two->Id = 12; + $two->FirstName = "Mini Me!"; + TPropertyAccess::set($account, 'More', $two); + + $account6 = $this->NewAccount6(); + TPropertyAccess::set($account, 'More.More', $account6); + + TPropertyAccess::set($account, 'More.More.EmailAddress', 'hahaha'); + + $this->assertIdentical(10, TPropertyAccess::get($account, 'Id')); + $this->assertIdentical(12, TPropertyAccess::get($account, 'More.Id')); + $this->assertIdentical(6, TPropertyAccess::get($account, 'More.More.Id')); + + $this->assertIdentical('hahaha', + TPropertyAccess::get($account, 'More.More.EmailAddress')); + } + + function testArrayAccessProperty() + { + $account = new AccountBis(); + $things['more'] = 1; + $things['accounts'] = $this->NewAccount6(); + $account->More = $things; + + $this->assertIdentical(6, TPropertyAccess::get($account, 'More.accounts.ID')); + + TPropertyAccess::set($account, 'More.accounts.EmailAddress', 'adssd'); + $this->assertIdentical('adssd', TPropertyAccess::get($account, 'More.accounts.EmailAddress')); + + $this->assertIdentical(1, TPropertyAccess::get($things, 'more')); + } + +} + + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/ResultClassTest.php b/tests/simple_unit/SqlMap/ResultClassTest.php index a2b81925..041c124e 100644 --- a/tests/simple_unit/SqlMap/ResultClassTest.php +++ b/tests/simple_unit/SqlMap/ResultClassTest.php @@ -1,249 +1,249 @@ -<?php
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class ResultClassTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- }
-
- /**
- * Test a boolean resultClass
- */
- function testBoolean()
- {
- $bit = $this->sqlmap->queryForObject("GetBoolean", 1);
- $this->assertIdentical(true, $bit);
- }
-
- /**
- * Test a boolean implicit resultClass
- */
- function testBooleanWithoutResultClass()
- {
- $bit = (boolean)$this->sqlmap->queryForObject("GetBooleanWithoutResultClass", 1);
- $this->assertIdentical(true, $bit);
- }
-
- /**
- * Test a byte resultClass
- */
- function testByte()
- {
- $letter = $this->sqlmap->queryForObject("GetByte", 1);
- $this->assertIdentical(155, (int)$letter);
- }
-
- /**
- * Test a byte implicit resultClass
- */
- function testByteWithoutResultClass()
- {
- $letter = $this->sqlmap->queryForObject("GetByteWithoutResultClass", 1);
- $this->assertIdentical(155, (int)$letter);
- }
-
- /**
- * Test a char resultClass
- */
- function testChar()
- {
- $letter = $this->sqlmap->queryForObject("GetChar", 1);
- $this->assertIdentical('a', trim($letter));
- }
-
- /**
- * Test a char implicit resultClass
- */
- function testCharWithoutResultClass()
- {
- $letter = $this->sqlmap->queryForObject("GetCharWithoutResultClass", 1);
- $this->assertIdentical('a', trim($letter));
- }
-
- /**
- * Test a DateTime resultClass
- */
- function testDateTime()
- {
- $orderDate = $this->sqlmap->queryForObject("GetDate", 1);
- $date = @mktime(8, 15, 00, 2, 15, 2003);
- $this->assertIdentical($date, $orderDate->getTimeStamp());
- }
-
- /**
- * Test a DateTime implicit resultClass
- */
- function testDateTimeWithoutResultClass()
- {
- $date = $this->sqlmap->queryForObject("GetDateWithoutResultClass", 1);
- $orderDate = new TDateTime;
- $orderDate->setDateTime($date);
- $date = @mktime(8, 15, 00, 2, 15, 2003);
-
- $this->assertIdentical($date, $orderDate->getTimeStamp());
- }
-
- /**
- * Test a decimal resultClass
- */
- function testDecimal()
- {
- $price = $this->sqlmap->queryForObject("GetDecimal", 1);
- $this->assertIdentical(1.56, $price);
- }
-
- /**
- * Test a decimal implicit resultClass
- */
- function testDecimalWithoutResultClass()
- {
- $price = $this->sqlmap->queryForObject("GetDecimalWithoutResultClass", 1);
- $this->assertIdentical(1.56, (float)$price);
- }
-
- /**
- * Test a double resultClass
- */
- function testDouble()
- {
- $price = $this->sqlmap->queryForObject("GetDouble", 1);
- $this->assertIdentical(99.5, $price);
- }
-
- /**
- * Test a double implicit resultClass
- */
- function testDoubleWithoutResultClass()
- {
- $price = $this->sqlmap->queryForObject("GetDoubleWithoutResultClass", 1);
- $this->assertIdentical(99.5, (float)$price);
- }
-
- /**
- * IBATISNET-25 Error applying ResultMap when using 'Guid' in resultClass
- */
-/* function testGuid()
- {
- Guid newGuid = new Guid("CD5ABF17-4BBC-4C86-92F1-257735414CF4");
-
- Guid guid = (Guid) $this->sqlmap->queryForObject("GetGuid", 1);
-
- $this->assertIdentical(newGuid, guid);
- }
-*/
-
- /**
- * Test a Guid implicit resultClass
- */
-/* function testGuidWithoutResultClass()
- {
- Guid newGuid = new Guid("CD5ABF17-4BBC-4C86-92F1-257735414CF4");
-
- string guidString = Convert.ToString($this->sqlmap->queryForObject("GetGuidWithoutResultClass", 1));
-
- Guid guid = new Guid(guidString);
-
- $this->assertIdentical(newGuid, guid);
- }
-*/
- /**
- * Test a int16 resultClass (integer in PHP)
- */
- function testInt16()
- {
- $integer = $this->sqlmap->queryForObject("GetInt16", 1);
-
- $this->assertIdentical(32111, $integer);
- }
-
- /**
- * Test a int16 implicit resultClass (integer in PHP)
- */
- function testInt16WithoutResultClass()
- {
- $integer = $this->sqlmap->queryForObject("GetInt16WithoutResultClass", 1);
- $this->assertIdentical(32111, (int)$integer);
- }
-
- /**
- * Test a int 32 resultClass (integer in PHP)
- */
- function testInt32()
- {
- $integer = $this->sqlmap->queryForObject("GetInt32", 1);
- $this->assertIdentical(999999, $integer);
- }
-
- /**
- * Test a int 32 implicit resultClass (integer in PHP)
- */
- function testInt32WithoutResultClass()
- {
- $integer = $this->sqlmap->queryForObject("GetInt32WithoutResultClass", 1);
- $this->assertIdentical(999999, (int)$integer);
- }
-
- /**
- * Test a int64 resultClass (float in PHP)
- */
- function testInt64()
- {
- $bigInt = $this->sqlmap->queryForObject("GetInt64", 1);
- $this->assertIdentical(9223372036854775800, $bigInt);
- }
-
- /**
- * Test a int64 implicit resultClass (float in PHP)
- */
- function testInt64WithoutResultClass()
- {
- $bigInt = $this->sqlmap->queryForObject("GetInt64WithoutResultClass", 1);
- $this->assertIdentical(9223372036854775800, (double)$bigInt);
- }
-
- /**
- * Test a single/float resultClass
- */
- function testSingle()
- {
- $price = (float)$this->sqlmap->queryForObject("GetSingle", 1);
- $this->assertIdentical(92233.5, $price);
- }
-
- /**
- * Test a single/float implicit resultClass
- */
- function testSingleWithoutResultClass()
- {
- $price = $this->sqlmap->queryForObject("GetSingleWithoutResultClass", 1);
- $this->assertIdentical(92233.5, (float)$price);
- }
-
- /**
- * Test a string resultClass
- */
- function testString()
- {
- $cardType = $this->sqlmap->queryForObject("GetString", 1);
- $this->assertIdentical("VISA", $cardType);
- }
-
- /**
- * Test a string implicit resultClass
- */
- function testStringWithoutResultClass()
- {
- $cardType = $this->sqlmap->queryForObject("GetStringWithoutResultClass", 1);
- $this->assertIdentical("VISA", $cardType);
- }
-/**/
-
-}
-
+<?php +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class ResultClassTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + } + + /** + * Test a boolean resultClass + */ + function testBoolean() + { + $bit = $this->sqlmap->queryForObject("GetBoolean", 1); + $this->assertIdentical(true, $bit); + } + + /** + * Test a boolean implicit resultClass + */ + function testBooleanWithoutResultClass() + { + $bit = (boolean)$this->sqlmap->queryForObject("GetBooleanWithoutResultClass", 1); + $this->assertIdentical(true, $bit); + } + + /** + * Test a byte resultClass + */ + function testByte() + { + $letter = $this->sqlmap->queryForObject("GetByte", 1); + $this->assertIdentical(155, (int)$letter); + } + + /** + * Test a byte implicit resultClass + */ + function testByteWithoutResultClass() + { + $letter = $this->sqlmap->queryForObject("GetByteWithoutResultClass", 1); + $this->assertIdentical(155, (int)$letter); + } + + /** + * Test a char resultClass + */ + function testChar() + { + $letter = $this->sqlmap->queryForObject("GetChar", 1); + $this->assertIdentical('a', trim($letter)); + } + + /** + * Test a char implicit resultClass + */ + function testCharWithoutResultClass() + { + $letter = $this->sqlmap->queryForObject("GetCharWithoutResultClass", 1); + $this->assertIdentical('a', trim($letter)); + } + + /** + * Test a DateTime resultClass + */ + function testDateTime() + { + $orderDate = $this->sqlmap->queryForObject("GetDate", 1); + $date = @mktime(8, 15, 00, 2, 15, 2003); + $this->assertIdentical($date, $orderDate->getTimeStamp()); + } + + /** + * Test a DateTime implicit resultClass + */ + function testDateTimeWithoutResultClass() + { + $date = $this->sqlmap->queryForObject("GetDateWithoutResultClass", 1); + $orderDate = new TDateTime; + $orderDate->setDateTime($date); + $date = @mktime(8, 15, 00, 2, 15, 2003); + + $this->assertIdentical($date, $orderDate->getTimeStamp()); + } + + /** + * Test a decimal resultClass + */ + function testDecimal() + { + $price = $this->sqlmap->queryForObject("GetDecimal", 1); + $this->assertIdentical(1.56, $price); + } + + /** + * Test a decimal implicit resultClass + */ + function testDecimalWithoutResultClass() + { + $price = $this->sqlmap->queryForObject("GetDecimalWithoutResultClass", 1); + $this->assertIdentical(1.56, (float)$price); + } + + /** + * Test a double resultClass + */ + function testDouble() + { + $price = $this->sqlmap->queryForObject("GetDouble", 1); + $this->assertIdentical(99.5, $price); + } + + /** + * Test a double implicit resultClass + */ + function testDoubleWithoutResultClass() + { + $price = $this->sqlmap->queryForObject("GetDoubleWithoutResultClass", 1); + $this->assertIdentical(99.5, (float)$price); + } + + /** + * IBATISNET-25 Error applying ResultMap when using 'Guid' in resultClass + */ +/* function testGuid() + { + Guid newGuid = new Guid("CD5ABF17-4BBC-4C86-92F1-257735414CF4"); + + Guid guid = (Guid) $this->sqlmap->queryForObject("GetGuid", 1); + + $this->assertIdentical(newGuid, guid); + } +*/ + + /** + * Test a Guid implicit resultClass + */ +/* function testGuidWithoutResultClass() + { + Guid newGuid = new Guid("CD5ABF17-4BBC-4C86-92F1-257735414CF4"); + + string guidString = Convert.ToString($this->sqlmap->queryForObject("GetGuidWithoutResultClass", 1)); + + Guid guid = new Guid(guidString); + + $this->assertIdentical(newGuid, guid); + } +*/ + /** + * Test a int16 resultClass (integer in PHP) + */ + function testInt16() + { + $integer = $this->sqlmap->queryForObject("GetInt16", 1); + + $this->assertIdentical(32111, $integer); + } + + /** + * Test a int16 implicit resultClass (integer in PHP) + */ + function testInt16WithoutResultClass() + { + $integer = $this->sqlmap->queryForObject("GetInt16WithoutResultClass", 1); + $this->assertIdentical(32111, (int)$integer); + } + + /** + * Test a int 32 resultClass (integer in PHP) + */ + function testInt32() + { + $integer = $this->sqlmap->queryForObject("GetInt32", 1); + $this->assertIdentical(999999, $integer); + } + + /** + * Test a int 32 implicit resultClass (integer in PHP) + */ + function testInt32WithoutResultClass() + { + $integer = $this->sqlmap->queryForObject("GetInt32WithoutResultClass", 1); + $this->assertIdentical(999999, (int)$integer); + } + + /** + * Test a int64 resultClass (float in PHP) + */ + function testInt64() + { + $bigInt = $this->sqlmap->queryForObject("GetInt64", 1); + $this->assertIdentical(9223372036854775800, $bigInt); + } + + /** + * Test a int64 implicit resultClass (float in PHP) + */ + function testInt64WithoutResultClass() + { + $bigInt = $this->sqlmap->queryForObject("GetInt64WithoutResultClass", 1); + $this->assertIdentical(9223372036854775800, (double)$bigInt); + } + + /** + * Test a single/float resultClass + */ + function testSingle() + { + $price = (float)$this->sqlmap->queryForObject("GetSingle", 1); + $this->assertIdentical(92233.5, $price); + } + + /** + * Test a single/float implicit resultClass + */ + function testSingleWithoutResultClass() + { + $price = $this->sqlmap->queryForObject("GetSingleWithoutResultClass", 1); + $this->assertIdentical(92233.5, (float)$price); + } + + /** + * Test a string resultClass + */ + function testString() + { + $cardType = $this->sqlmap->queryForObject("GetString", 1); + $this->assertIdentical("VISA", $cardType); + } + + /** + * Test a string implicit resultClass + */ + function testStringWithoutResultClass() + { + $cardType = $this->sqlmap->queryForObject("GetStringWithoutResultClass", 1); + $this->assertIdentical("VISA", $cardType); + } +/**/ + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/ResultMapTest.php b/tests/simple_unit/SqlMap/ResultMapTest.php index 41fb5931..d545b65e 100644 --- a/tests/simple_unit/SqlMap/ResultMapTest.php +++ b/tests/simple_unit/SqlMap/ResultMapTest.php @@ -1,273 +1,273 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class ResultMapTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- new Order;
- new LineItemCollection;
- new Account;
- }
-
- function resetDatabase()
- {
- $this->initScript('account-init.sql');
- $this->initScript('order-init.sql');
- $this->initScript('line-item-init.sql');
-// $this->initScript('enumeration-init.sql');
- }
-
- function testColumnsByName()
- {
- $order = $this->sqlmap->QueryForObject('GetOrderLiteByColumnName', 1);
- $this->assertOrder1($order);
- }
-
- function testColumnsByIndex()
- {
- $order = $this->sqlmap->QueryForObject("GetOrderLiteByColumnIndex", 1);
- $this->assertOrder1($order);
- }
-
- function testExtendedResultMap()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItemsNoLazyLoad", 1);
- $this->assertOrder1($order);
- $this->assertTrue($order->getLineItemsList() instanceof TList);
- $this->assertIdentical(2, $order->getLineItemsList()->getCount());
- }
-
-
- function testLazyLoad()
- {
- $order = $this->sqlmap->QueryForObject("GetOrderWithLineItems", 1);
- $this->assertOrder1($order);
- $this->assertNotNull($order->getLineItemsList());
- $this->assertFalse($order->getLineItemsList() instanceof TList);
- $this->assertIdentical(2, $order->getLineItemsList()->getCount());
-
- // After a call to a method from a proxy object,
- // the proxy object is replaced by the real object.
- $this->assertTrue($order->getLineItemsList() instanceof TList);
- $this->assertIdentical(2, $order->getLineItemsList()->getCount());
- }
-
- function testLazyWithTypedCollectionMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItemCollection", 1);
- $this->assertOrder1($order);
- $this->assertNotNull($order->getLineItems());
- $this->assertFalse($order->getLineItemsList() instanceof LineItemCollection);
-
- $this->assertIdentical(2, $order->getLineItems()->getCount());
-
- // After a call to a method from a proxy object,
- // the proxy object is replaced by the real object.
- $this->assertTrue($order->getLineItems() instanceof LineItemCollection);
- foreach($order->getLineItems() as $item)
- {
- $this->assertNotNull($item);
- $this->assertTrue($item instanceof LineItem);
- }
- }
-
- function testNullValueReplacementOnString()
- {
- $account = $this->sqlmap->queryForObject("GetAccountViaColumnName", 5);
- $this->assertIdentical("no_email@provided.com", $account->getEmailAddress());
- }
-
- function testTypeSpecified()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithTypes", 1);
- $this->assertOrder1($order);
- }
-
- function testComplexObjectMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithAccount", 1);
- $this->assertOrder1($order);
- $this->assertAccount1($order->getAccount());
- }
-
- function testCollectionMappingAndExtends()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItemsCollection", 1);
- $this->assertOrder1($order);
-
- // Check strongly typed collection
- $this->assertNotNull($order->getLineItems());
- $this->assertIdentical(2, $order->getLineItems()->getCount());
- }
-
- function testListMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItems", 1);
- $this->assertOrder1($order);
-
- // Check TList collection
- $this->assertNotNull($order->getLineItemsList());
- $this->assertIdentical(2, $order->getLineItemsList()->getCount());
- }
-
- function testArrayMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItemArray", 1);
- $this->assertOrder1($order);
- $this->assertNotNull($order->getLineItemsArray());
- $this->assertTrue(is_array($order->getLineItemsArray()));
- $this->assertIdentical(2, count($order->getLineItemsArray()));
- }
-
- function testTypedCollectionMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItemCollectionNoLazy", 1);
- $this->assertOrder1($order);
- $this->assertNotNull($order->getLineItems());
- $this->assertTrue($order->getLineItems() instanceof LineItemCollection);
- $this->assertIdentical(2, $order->getLineItems()->getCount());
- foreach($order->getLineItems() as $item)
- {
- $this->assertNotNull($item);
- $this->assertTrue($item instanceof LineItem);
- }
- }
-
- function testHashArrayMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderAsHastable", 1);
- $this->assertOrder1AsHashArray($order);
- }
-
- function testNestedObjects()
- {
- $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite", 1);
-
- $this->assertOrder1($order);
- $this->assertNotNull($order->getFavouriteLineItem());
- $this->assertIdentical(2, (int)$order->getFavouriteLineItem()->getID());
- $this->assertIdentical("ESM-23", $order->getFavouriteLineItem()->getCode());
-
- }
-
-
- function testNestedObjects2()
- {
- $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite2", 1);
- $this->assertOrder1($order);
-
- $this->assertNotNull($order->getFavouriteLineItem());
- $this->assertIdentical(2, (int)$order->getFavouriteLineItem()->getID());
- $this->assertIdentical("ESM-23", $order->getFavouriteLineItem()->getCode());
- }
-
- function testImplicitResultMaps()
- {
- $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite3", 1);
-
- // *** force date to timestamp since data type can't be
- // *** explicity known without mapping
- $order->setDate(new TDateTime($order->getDate()));
-
- $this->assertOrder1($order);
-
- $this->assertNotNull($order->getFavouriteLineItem());
- $this->assertIdentical(2, $order->getFavouriteLineItem()->getID());
- $this->assertIdentical("ESM-23", $order->getFavouriteLineItem()->getCode());
- }
-
- function testCompositeKeyMapping()
- {
- $this->resetDatabase();
-
- $order1 = $this->sqlmap->queryForObject("GetOrderWithFavouriteLineItem", 1);
- $order2 = $this->sqlmap->queryForObject("GetOrderWithFavouriteLineItem", 2);
-
- $this->assertNotNull($order1);
- $this->assertNotNull($order1->getFavouriteLineItem());
- $this->assertIdentical(2, $order1->getFavouriteLineItem()->getID());
-
- $this->assertNotNull($order2);
- $this->assertNotNull($order2->getFavouriteLineItem());
- $this->assertIdentical(1, $order2->getFavouriteLineItem()->getID());
- }
-
-
- function testSimpleTypeMapping()
- {
- $this->resetDatabase();
-
- $list = $this->sqlmap->QueryForList("GetAllCreditCardNumbersFromOrders", null);
-
- $this->assertIdentical(5, count($list));
- $this->assertIdentical("555555555555", $list[0]);
- }
-
- function testDecimalTypeMapping()
- {
- $this->resetDatabase();
-
- $param["LineItem_ID"] = 1;
- $param["Order_ID"] = 10;
- $price = $this->sqlmap->queryForObject("GetLineItemPrice", $param);
- $this->assertIdentical(gettype($price), 'double');
- $this->assertIdentical(45.43, $price);
- }
-
-//todo
-/*
- function testNullValueReplacementOnEnum()
- {
- $enum['Id'] = 99;
- $enum['Day'] = 'Days.Thu';
- $enum['Color'] = 'Colors.Blue';
- $enum['Month'] = 'Months.All';
-
- $this->sqlmap->insert("InsertEnumViaParameterMap", $enum);
-
- $enumClass = $this->sqlmap->queryForObject("GetEnumerationNullValue", 99);
-
- $this->assertIdentical($enumClass['Day'], 'Days.Thu');
- $this->asserEquals($enumClass['Color'], 'Colors.Blue');
- $this->assertIdentical($enumClass['Month'], 'Months.All');
- }
-
-
- function testByteArrayMapping()
- {
- }
-
- function testNullValueReplacementOnDecimal()
- {
- }
-
- function testNullValueReplacementOnDateTime()
- {
- }
-*/
-
-//future work
-
-/*
- //requires dynamic SQL
- function testDynamiqueCompositeKeyMapping()
- {
- $order1 = $this->sqlmap->queryForObject("GetOrderWithDynFavouriteLineItem", 1);
-
- $this->assertNotNull($order1);
- $this->assertNotNull($order1->getFavouriteLineItem());
- var_dump($order1);
- $this->assertIdentical(2, $order1->getFavouriteLineItem()->getID());
- }
-*/
-
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class ResultMapTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + new Order; + new LineItemCollection; + new Account; + } + + function resetDatabase() + { + $this->initScript('account-init.sql'); + $this->initScript('order-init.sql'); + $this->initScript('line-item-init.sql'); +// $this->initScript('enumeration-init.sql'); + } + + function testColumnsByName() + { + $order = $this->sqlmap->QueryForObject('GetOrderLiteByColumnName', 1); + $this->assertOrder1($order); + } + + function testColumnsByIndex() + { + $order = $this->sqlmap->QueryForObject("GetOrderLiteByColumnIndex", 1); + $this->assertOrder1($order); + } + + function testExtendedResultMap() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItemsNoLazyLoad", 1); + $this->assertOrder1($order); + $this->assertTrue($order->getLineItemsList() instanceof TList); + $this->assertIdentical(2, $order->getLineItemsList()->getCount()); + } + + + function testLazyLoad() + { + $order = $this->sqlmap->QueryForObject("GetOrderWithLineItems", 1); + $this->assertOrder1($order); + $this->assertNotNull($order->getLineItemsList()); + $this->assertFalse($order->getLineItemsList() instanceof TList); + $this->assertIdentical(2, $order->getLineItemsList()->getCount()); + + // After a call to a method from a proxy object, + // the proxy object is replaced by the real object. + $this->assertTrue($order->getLineItemsList() instanceof TList); + $this->assertIdentical(2, $order->getLineItemsList()->getCount()); + } + + function testLazyWithTypedCollectionMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItemCollection", 1); + $this->assertOrder1($order); + $this->assertNotNull($order->getLineItems()); + $this->assertFalse($order->getLineItemsList() instanceof LineItemCollection); + + $this->assertIdentical(2, $order->getLineItems()->getCount()); + + // After a call to a method from a proxy object, + // the proxy object is replaced by the real object. + $this->assertTrue($order->getLineItems() instanceof LineItemCollection); + foreach($order->getLineItems() as $item) + { + $this->assertNotNull($item); + $this->assertTrue($item instanceof LineItem); + } + } + + function testNullValueReplacementOnString() + { + $account = $this->sqlmap->queryForObject("GetAccountViaColumnName", 5); + $this->assertIdentical("no_email@provided.com", $account->getEmailAddress()); + } + + function testTypeSpecified() + { + $order = $this->sqlmap->queryForObject("GetOrderWithTypes", 1); + $this->assertOrder1($order); + } + + function testComplexObjectMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderWithAccount", 1); + $this->assertOrder1($order); + $this->assertAccount1($order->getAccount()); + } + + function testCollectionMappingAndExtends() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItemsCollection", 1); + $this->assertOrder1($order); + + // Check strongly typed collection + $this->assertNotNull($order->getLineItems()); + $this->assertIdentical(2, $order->getLineItems()->getCount()); + } + + function testListMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItems", 1); + $this->assertOrder1($order); + + // Check TList collection + $this->assertNotNull($order->getLineItemsList()); + $this->assertIdentical(2, $order->getLineItemsList()->getCount()); + } + + function testArrayMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItemArray", 1); + $this->assertOrder1($order); + $this->assertNotNull($order->getLineItemsArray()); + $this->assertTrue(is_array($order->getLineItemsArray())); + $this->assertIdentical(2, count($order->getLineItemsArray())); + } + + function testTypedCollectionMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItemCollectionNoLazy", 1); + $this->assertOrder1($order); + $this->assertNotNull($order->getLineItems()); + $this->assertTrue($order->getLineItems() instanceof LineItemCollection); + $this->assertIdentical(2, $order->getLineItems()->getCount()); + foreach($order->getLineItems() as $item) + { + $this->assertNotNull($item); + $this->assertTrue($item instanceof LineItem); + } + } + + function testHashArrayMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderAsHastable", 1); + $this->assertOrder1AsHashArray($order); + } + + function testNestedObjects() + { + $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite", 1); + + $this->assertOrder1($order); + $this->assertNotNull($order->getFavouriteLineItem()); + $this->assertIdentical(2, (int)$order->getFavouriteLineItem()->getID()); + $this->assertIdentical("ESM-23", $order->getFavouriteLineItem()->getCode()); + + } + + + function testNestedObjects2() + { + $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite2", 1); + $this->assertOrder1($order); + + $this->assertNotNull($order->getFavouriteLineItem()); + $this->assertIdentical(2, (int)$order->getFavouriteLineItem()->getID()); + $this->assertIdentical("ESM-23", $order->getFavouriteLineItem()->getCode()); + } + + function testImplicitResultMaps() + { + $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite3", 1); + + // *** force date to timestamp since data type can't be + // *** explicity known without mapping + $order->setDate(new TDateTime($order->getDate())); + + $this->assertOrder1($order); + + $this->assertNotNull($order->getFavouriteLineItem()); + $this->assertIdentical(2, $order->getFavouriteLineItem()->getID()); + $this->assertIdentical("ESM-23", $order->getFavouriteLineItem()->getCode()); + } + + function testCompositeKeyMapping() + { + $this->resetDatabase(); + + $order1 = $this->sqlmap->queryForObject("GetOrderWithFavouriteLineItem", 1); + $order2 = $this->sqlmap->queryForObject("GetOrderWithFavouriteLineItem", 2); + + $this->assertNotNull($order1); + $this->assertNotNull($order1->getFavouriteLineItem()); + $this->assertIdentical(2, $order1->getFavouriteLineItem()->getID()); + + $this->assertNotNull($order2); + $this->assertNotNull($order2->getFavouriteLineItem()); + $this->assertIdentical(1, $order2->getFavouriteLineItem()->getID()); + } + + + function testSimpleTypeMapping() + { + $this->resetDatabase(); + + $list = $this->sqlmap->QueryForList("GetAllCreditCardNumbersFromOrders", null); + + $this->assertIdentical(5, count($list)); + $this->assertIdentical("555555555555", $list[0]); + } + + function testDecimalTypeMapping() + { + $this->resetDatabase(); + + $param["LineItem_ID"] = 1; + $param["Order_ID"] = 10; + $price = $this->sqlmap->queryForObject("GetLineItemPrice", $param); + $this->assertIdentical(gettype($price), 'double'); + $this->assertIdentical(45.43, $price); + } + +//todo +/* + function testNullValueReplacementOnEnum() + { + $enum['Id'] = 99; + $enum['Day'] = 'Days.Thu'; + $enum['Color'] = 'Colors.Blue'; + $enum['Month'] = 'Months.All'; + + $this->sqlmap->insert("InsertEnumViaParameterMap", $enum); + + $enumClass = $this->sqlmap->queryForObject("GetEnumerationNullValue", 99); + + $this->assertIdentical($enumClass['Day'], 'Days.Thu'); + $this->asserEquals($enumClass['Color'], 'Colors.Blue'); + $this->assertIdentical($enumClass['Month'], 'Months.All'); + } + + + function testByteArrayMapping() + { + } + + function testNullValueReplacementOnDecimal() + { + } + + function testNullValueReplacementOnDateTime() + { + } +*/ + +//future work + +/* + //requires dynamic SQL + function testDynamiqueCompositeKeyMapping() + { + $order1 = $this->sqlmap->queryForObject("GetOrderWithDynFavouriteLineItem", 1); + + $this->assertNotNull($order1); + $this->assertNotNull($order1->getFavouriteLineItem()); + var_dump($order1); + $this->assertIdentical(2, $order1->getFavouriteLineItem()->getID()); + } +*/ + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/SelectKeyTest.php b/tests/simple_unit/SqlMap/SelectKeyTest.php index dd1d58df..a1efa640 100644 --- a/tests/simple_unit/SqlMap/SelectKeyTest.php +++ b/tests/simple_unit/SqlMap/SelectKeyTest.php @@ -1,120 +1,120 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class SelectKeyTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
-
- //force autoload
- new Account;
- new Order;
- new LineItem;
- new LineItemCollection;
- new A; new B; new C; new D; new E; new F;
- }
-
- /**
- * Test Insert with post GeneratedKey
- */
- function testInsertPostKey()
- {
- $this->initScript('line-item-init.sql');
-
- $item = new LineItem();
-
- $item->setId(10);
- $item->setCode("blah");
- $item->setOrder(new Order());
- $item->getOrder()->setId(9);
- $item->setPrice(44.00);
- $item->setQuantity(1);
-
- $key = $this->sqlmap->Insert("InsertLineItemPostKey", $item);
-
- $this->assertIdentical(99, $key);
- $this->assertIdentical(99, $item->getId());
-
- $param["Order_ID"] = 9;
- $param["LineItem_ID"] =10;
- $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
-
- $this->assertNotNull($testItem);
- $this->assertIdentical(10, $testItem->getId());
-
- $this->initScript('line-item-init.sql');
- }
-
- /**
- * Test Insert pre GeneratedKey
- */
- function testInsertPreKey()
- {
- $this->initScript('line-item-init.sql');
-
- $item = new LineItem();
-
- $item->setId(10);
- $item->setCode("blah");
- $item->setOrder(new Order());
- $item->getOrder()->setId(9);
- $item->setPrice(44.00);
- $item->setQuantity(1);
-
- $key = $this->sqlmap->Insert("InsertLineItemPreKey", $item);
-
- $this->assertIdentical(99, $key);
- $this->assertIdentical(99, $item->getId());
-
- $param["Order_ID"] = 9;
- $param["LineItem_ID"] = 99;
-
- $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
-
- $this->assertNotNull($testItem);
- $this->assertIdentical(99, $testItem->getId());
-
- $this->initScript('line-item-init.sql');
- }
-
- /**
- * Test Test Insert No Key
- */
- function testInsertNoKey()
- {
- $this->initScript('line-item-init.sql');
-
- $item = new LineItem();
-
- $item->setId(100);
- $item->setCode("blah");
- $item->setOrder(new Order());
- $item->getOrder()->setId(9);
- $item->setPrice(44.00);
- $item->setQuantity(1);
-
-
- $key = $this->sqlmap->Insert("InsertLineItemNoKey", $item);
-
- $this->assertNull($key);
- $this->assertIdentical(100, $item->getId());
-
- $param["Order_ID"] = 9;
- $param["LineItem_ID"] = 100;
-
- $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
-
- $this->assertNotNull($testItem);
- $this->assertIdentical(100, $testItem->getId());
-
- $this->initScript('line-item-init.sql');
- }
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class SelectKeyTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + + //force autoload + new Account; + new Order; + new LineItem; + new LineItemCollection; + new A; new B; new C; new D; new E; new F; + } + + /** + * Test Insert with post GeneratedKey + */ + function testInsertPostKey() + { + $this->initScript('line-item-init.sql'); + + $item = new LineItem(); + + $item->setId(10); + $item->setCode("blah"); + $item->setOrder(new Order()); + $item->getOrder()->setId(9); + $item->setPrice(44.00); + $item->setQuantity(1); + + $key = $this->sqlmap->Insert("InsertLineItemPostKey", $item); + + $this->assertIdentical(99, $key); + $this->assertIdentical(99, $item->getId()); + + $param["Order_ID"] = 9; + $param["LineItem_ID"] =10; + $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param); + + $this->assertNotNull($testItem); + $this->assertIdentical(10, $testItem->getId()); + + $this->initScript('line-item-init.sql'); + } + + /** + * Test Insert pre GeneratedKey + */ + function testInsertPreKey() + { + $this->initScript('line-item-init.sql'); + + $item = new LineItem(); + + $item->setId(10); + $item->setCode("blah"); + $item->setOrder(new Order()); + $item->getOrder()->setId(9); + $item->setPrice(44.00); + $item->setQuantity(1); + + $key = $this->sqlmap->Insert("InsertLineItemPreKey", $item); + + $this->assertIdentical(99, $key); + $this->assertIdentical(99, $item->getId()); + + $param["Order_ID"] = 9; + $param["LineItem_ID"] = 99; + + $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param); + + $this->assertNotNull($testItem); + $this->assertIdentical(99, $testItem->getId()); + + $this->initScript('line-item-init.sql'); + } + + /** + * Test Test Insert No Key + */ + function testInsertNoKey() + { + $this->initScript('line-item-init.sql'); + + $item = new LineItem(); + + $item->setId(100); + $item->setCode("blah"); + $item->setOrder(new Order()); + $item->getOrder()->setId(9); + $item->setPrice(44.00); + $item->setQuantity(1); + + + $key = $this->sqlmap->Insert("InsertLineItemNoKey", $item); + + $this->assertNull($key); + $this->assertIdentical(100, $item->getId()); + + $param["Order_ID"] = 9; + $param["LineItem_ID"] = 100; + + $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param); + + $this->assertNotNull($testItem); + $this->assertIdentical(100, $testItem->getId()); + + $this->initScript('line-item-init.sql'); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/SqlMapCacheTest.php b/tests/simple_unit/SqlMap/SqlMapCacheTest.php index af392fb3..1bb9b8d4 100644 --- a/tests/simple_unit/SqlMap/SqlMapCacheTest.php +++ b/tests/simple_unit/SqlMap/SqlMapCacheTest.php @@ -1,77 +1,77 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class SqlMapCacheTest extends UnitTestCase
-{
- function testFIFOCache()
- {
- $fifo = new TSqlMapFifoCache(2);
- $object1 = new TSqlMapManager;
- $object2 = new TComponent;
- $object3 = new TSqlMapGateway(null);
-
- $key1 = 'key1';
- $key2 = 'key2';
- $key3 = 'key3';
-
- $fifo->set($key1, $object1);
- $fifo->set($key2, $object2);
-
- $this->assertTrue($object1 === $fifo->get($key1));
- $this->assertTrue($object2 === $fifo->get($key2));
-
- //object 1 should be removed
- $fifo->set($key3, $object3);
-
- $this->assertNull($fifo->get($key1));
- $this->assertTrue($object2 === $fifo->get($key2));
- $this->assertTrue($object3 === $fifo->get($key3));
-
- //object 2 should be removed
- $fifo->set($key1, $object1);
-
- $this->assertNull($fifo->get($key2));
- $this->assertTrue($object3 === $fifo->get($key3));
- $this->assertTrue($object1 === $fifo->get($key1));
- }
-
- function testLruCache()
- {
- $lru = new TSqlMapLruCache(2);
-
- $object1 = new TSqlMapManager;
- $object2 = new TComponent;
- $object3 = new TSqlMapGateway(null);
-
- $key1 = 'key1';
- $key2 = 'key2';
- $key3 = 'key3';
-
- $lru->set($key1, $object1);
- $lru->set($key2, $object2);
-
- $this->assertTrue($object2 === $lru->get($key2));
- $this->assertTrue($object1 === $lru->get($key1));
-
- //object 2 should be removed, i.e. least recently used
- $lru->set($key3, $object3);
-
- $this->assertNull($lru->get($key2));
- $this->assertTrue($object1 === $lru->get($key1));
- $this->assertTrue($object3 === $lru->get($key3));
-
- //object 1 will be removed
- $lru->set($key2, $object2);
-
- $this->assertNull($lru->get($key1));
- $this->assertTrue($object2 === $lru->get($key2));
- $this->assertTrue($object3 === $lru->get($key3));
- }
-}
-
-
+<?php + +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class SqlMapCacheTest extends UnitTestCase +{ + function testFIFOCache() + { + $fifo = new TSqlMapFifoCache(2); + $object1 = new TSqlMapManager; + $object2 = new TComponent; + $object3 = new TSqlMapGateway(null); + + $key1 = 'key1'; + $key2 = 'key2'; + $key3 = 'key3'; + + $fifo->set($key1, $object1); + $fifo->set($key2, $object2); + + $this->assertTrue($object1 === $fifo->get($key1)); + $this->assertTrue($object2 === $fifo->get($key2)); + + //object 1 should be removed + $fifo->set($key3, $object3); + + $this->assertNull($fifo->get($key1)); + $this->assertTrue($object2 === $fifo->get($key2)); + $this->assertTrue($object3 === $fifo->get($key3)); + + //object 2 should be removed + $fifo->set($key1, $object1); + + $this->assertNull($fifo->get($key2)); + $this->assertTrue($object3 === $fifo->get($key3)); + $this->assertTrue($object1 === $fifo->get($key1)); + } + + function testLruCache() + { + $lru = new TSqlMapLruCache(2); + + $object1 = new TSqlMapManager; + $object2 = new TComponent; + $object3 = new TSqlMapGateway(null); + + $key1 = 'key1'; + $key2 = 'key2'; + $key3 = 'key3'; + + $lru->set($key1, $object1); + $lru->set($key2, $object2); + + $this->assertTrue($object2 === $lru->get($key2)); + $this->assertTrue($object1 === $lru->get($key1)); + + //object 2 should be removed, i.e. least recently used + $lru->set($key3, $object3); + + $this->assertNull($lru->get($key2)); + $this->assertTrue($object1 === $lru->get($key1)); + $this->assertTrue($object3 === $lru->get($key3)); + + //object 1 will be removed + $lru->set($key2, $object2); + + $this->assertNull($lru->get($key1)); + $this->assertTrue($object2 === $lru->get($key2)); + $this->assertTrue($object3 === $lru->get($key3)); + } +} + + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/StatementExtendsTest.php b/tests/simple_unit/SqlMap/StatementExtendsTest.php index 4d87ca58..f496f154 100644 --- a/tests/simple_unit/SqlMap/StatementExtendsTest.php +++ b/tests/simple_unit/SqlMap/StatementExtendsTest.php @@ -1,29 +1,29 @@ -<?php
-
-Prado::using('System.Data.SqlMap.TSqlMapConfig');
-class StatementExtendsTest extends UnitTestCase
-{
- protected $sqlmap;
-
- function setup()
- {
- $config = new TSqlMapConfig();
- $config->ConfigFile = dirname(__FILE__).'/maps/tests.xml';
- $this->sqlmap = $config->getClient();
- }
-
- function test_extends1()
- {
- $manager = $this->sqlmap->SqlMapManager;
- $sql = $manager->getMappedStatement('test')->getSqlString();
-
- $this->assertPattern('/img_request/', $sql);
- $this->assertNoPattern('/img_progress/', $sql);
-
- $sql2 = $manager->getMappedStatement('GetAllProgress')->getSqlString();
- $this->assertPattern('/img_request/', $sql2);
- $this->assertPattern('/img_progress/', $sql2);
- }
-}
-
+<?php + +Prado::using('System.Data.SqlMap.TSqlMapConfig'); +class StatementExtendsTest extends UnitTestCase +{ + protected $sqlmap; + + function setup() + { + $config = new TSqlMapConfig(); + $config->ConfigFile = dirname(__FILE__).'/maps/tests.xml'; + $this->sqlmap = $config->getClient(); + } + + function test_extends1() + { + $manager = $this->sqlmap->SqlMapManager; + $sql = $manager->getMappedStatement('test')->getSqlString(); + + $this->assertPattern('/img_request/', $sql); + $this->assertNoPattern('/img_progress/', $sql); + + $sql2 = $manager->getMappedStatement('GetAllProgress')->getSqlString(); + $this->assertPattern('/img_request/', $sql2); + $this->assertPattern('/img_progress/', $sql2); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/StatementTest.php b/tests/simple_unit/SqlMap/StatementTest.php index 3ac0a3ab..f9c3fb13 100644 --- a/tests/simple_unit/SqlMap/StatementTest.php +++ b/tests/simple_unit/SqlMap/StatementTest.php @@ -1,1135 +1,1135 @@ -<?php
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class StatementTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
-
- //force autoload
- new Account;
- new Order;
- new LineItem;
- new LineItemCollection;
- new A; new B; new C; new D; new E; new F;
- }
-
- public function setup()
- {
-
- }
-
- function resetDatabase()
- {
- $this->initScript('account-init.sql');
- $this->initScript('order-init.sql');
- $this->initScript('line-item-init.sql');
-// $this->initScript('enumeration-init.sql');
- $this->initScript('other-init.sql');
- }
-
-
- #region Object Query tests
-
- /**
- * Test Open connection with a connection string
- */
- function testOpenConnection()
- {
- $conn = $this->sqlmap->getDbConnection();
- $conn->setActive(true);
- $account= $this->sqlmap->QueryForObject("SelectWithProperty");
- $conn->setActive(false);
- $this->assertAccount1($account);
- }
-
- /**
- * Test use a statement with property subtitution
- * (JIRA 22)
- */
- function testSelectWithProperty()
- {
- $account= $this->sqlmap->QueryForObject("SelectWithProperty");
- $this->assertAccount1($account);
- }
-
- /**
- * Test ExecuteQueryForObject Via ColumnName
- */
- function testExecuteQueryForObjectViaColumnName()
- {
- $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
- $this->assertAccount1($account);
- }
-
- /**
- * Test ExecuteQueryForObject Via ColumnIndex
- */
- function testExecuteQueryForObjectViaColumnIndex()
- {
- $account= $this->sqlmap->QueryForObject("GetAccountViaColumnIndex", 1);
- $this->assertAccount1($account);
- }
-
- /**
- * Test ExecuteQueryForObject Via ResultClass
- */
- function testExecuteQueryForObjectViaResultClass()
- {
- $account= $this->sqlmap->QueryForObject("GetAccountViaResultClass", 1);
- $this->assertAccount1($account);
- }
-
- /**
- * Test ExecuteQueryForObject With simple ResultClass : string
- */
- function testExecuteQueryForObjectWithSimpleResultClass()
- {
- $email = $this->sqlmap->QueryForObject("GetEmailAddressViaResultClass", 1);
- $this->assertIdentical("Joe.Dalton@somewhere.com", $email);
- }
-
- /**
- * Test ExecuteQueryForObject With simple ResultMap : string
- */
- function testExecuteQueryForObjectWithSimpleResultMap()
- {
- $email = $this->sqlmap->QueryForObject("GetEmailAddressViaResultMap", 1);
- $this->assertIdentical("Joe.Dalton@somewhere.com", $email);
- }
-
- /**
- * Test Primitive ReturnValue : TDateTime
- */
- function testPrimitiveReturnValue()
- {
- $CardExpiry = $this->sqlmap->QueryForObject("GetOrderCardExpiryViaResultClass", 1);
- $date = @mktime(8, 15, 00, 2, 15, 2003);
- $this->assertIdentical($date, $CardExpiry->getTimeStamp());
- }
-
- /**
- * Test ExecuteQueryForObject with result object : Account
- */
- function testExecuteQueryForObjectWithResultObject()
- {
- $account= new Account();
- $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1, $account);
- $this->assertAccount1($account);
- $this->assertTrue($account == $testAccount);
- }
-
- /**
- * Test ExecuteQueryForObject as array
- */
- function testExecuteQueryForObjectAsHashArray()
- {
- $account = $this->sqlmap->QueryForObject("GetAccountAsHashtable", 1);
- $this->assertAccount1AsHashArray($account);
- }
-
- /**
- * Test ExecuteQueryForObject as Hashtable ResultClass
- */
- function testExecuteQueryForObjectAsHashtableResultClass()
- {
- $account = $this->sqlmap->QueryForObject("GetAccountAsHashtableResultClass", 1);
- $this->assertAccount1AsHashArray($account);
- }
-
- /**
- * Test ExecuteQueryForObject via Hashtable
- */
- function testExecuteQueryForObjectViaHashtable()
- {
- $param["LineItem_ID"] = 2;
- $param["Order_ID"] = 9;
-
- $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
-
- $this->assertNotNull($testItem);
- $this->assertIdentical("TSM-12", $testItem->getCode());
- }
- /**/
-
- //TODO: Test Query Dynamic Sql Element
- function testQueryDynamicSqlElement()
- {
- //$list = $this->sqlmap->QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_ID");
-
- //$this->assertIdentical("Joe.Dalton@somewhere.com", $list[0]);
-
- //list = $this->sqlmap->QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_FirstName");
-
- //$this->assertIdentical("Averel.Dalton@somewhere.com", $list[0]);
-
- }
-
- // TODO: Test Execute QueryForList With ResultMap With Dynamic Element
- function testExecuteQueryForListWithResultMapWithDynamicElement()
- {
- //$list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "LIKE");
-
- //$this->assertAccount1$list[0]);
- //$this->assertIdentical(3, $list->getCount());
- //$this->assertIdentical(1, $list[0]->getID());
- //$this->assertIdentical(2, $list[1]->getID());
- //$this->assertIdentical(4, $list[2]->getID());
-
- //list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "=");
-
- //$this->assertIdentical(0, $list->getCount());
- }
-
-
-
- /**
- * Test Get Account Via Inline Parameters
- */
- function testExecuteQueryForObjectViaInlineParameters()
- {
- $account= new Account();
- $account->setID(1);
-
- $testAccount = $this->sqlmap->QueryForObject("GetAccountViaInlineParameters", $account);
-
- $this->assertAccount1($testAccount);
- }
- /**/
-
- // TODO: Test ExecuteQuery For Object With Enum property
-
- function testExecuteQueryForObjectWithEnum()
- {
- //$enumClass = $this->sqlmap->QueryForObject("GetEnumeration", 1);
-
- //$this->assertIdentical(enumClass.Day, Days.Sat);
- //$this->assertIdentical(enumClass.Color, Colors.Red);
- //$this->assertIdentical(enumClass.Month, Months.August);
-
- //enumClass = $this->sqlmap->QueryForObject("GetEnumeration", 3) as Enumeration;
-
- //$this->assertIdentical(enumClass.Day, Days.Mon);
- //$this->assertIdentical(enumClass.Color, Colors.Blue);
- //$this->assertIdentical(enumClass.Month, Months.September);*/
- }
-
- #endregion
-
- #region List Query tests
-
- /**
- * Test QueryForList with Hashtable ResultMap
- */
- function testQueryForListWithHashtableResultMap()
- {
- $this->initScript('account-init.sql');
- $list = $this->sqlmap->QueryForList("GetAllAccountsAsHashMapViaResultMap");
-
- $this->assertAccount1AsHashArray($list[0]);
- $this->assertIdentical(5, count($list));
-
- $this->assertIdentical(1, (int)$list[0]["Id"]);
- $this->assertIdentical(2, (int)$list[1]["Id"]);
- $this->assertIdentical(3, (int)$list[2]["Id"]);
- $this->assertIdentical(4, (int)$list[3]["Id"]);
- $this->assertIdentical(5, (int)$list[4]["Id"]);
- }
-
- /**
- * Test QueryForList with Hashtable ResultClass
- */
- function testQueryForListWithHashtableResultClass()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsAsHashtableViaResultClass");
-
- $this->assertAccount1AsHashArray($list[0]);
- $this->assertIdentical(5, count($list));
-
- $this->assertIdentical(1, (int)$list[0]["Id"]);
- $this->assertIdentical(2, (int)$list[1]["Id"]);
- $this->assertIdentical(3, (int)$list[2]["Id"]);
- $this->assertIdentical(4, (int)$list[3]["Id"]);
- $this->assertIdentical(5, (int)$list[4]["Id"]);
- }
-
- /**
- * Test QueryForList with IList ResultClass
- */
- function testQueryForListWithIListResultClass()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsAsArrayListViaResultClass");
-
- $listAccount = $list[0];
-
- $this->assertIdentical(1,(int)$listAccount[0]);
- $this->assertIdentical("Joe",$listAccount[1]);
- $this->assertIdentical("Dalton",$listAccount[2]);
- $this->assertIdentical("Joe.Dalton@somewhere.com",$listAccount[3]);
-
- $this->assertIdentical(5, count($list));
-
- $listAccount = $list[0];
- $this->assertIdentical(1, (int)$listAccount[0]);
- $listAccount = $list[1];
- $this->assertIdentical(2, (int)$listAccount[0]);
- $listAccount = $list[2];
- $this->assertIdentical(3, (int)$listAccount[0]);
- $listAccount = $list[3];
- $this->assertIdentical(4, (int)$listAccount[0]);
- $listAccount = $list[4];
- $this->assertIdentical(5, (int)$listAccount[0]);
- }
-
- /**
- * Test QueryForList With ResultMap, result collection as ArrayList
- */
- function testQueryForListWithResultMap()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMap");
-
- $this->assertAccount1($list[0]);
- $this->assertIdentical(5, count($list));
- $this->assertIdentical(1, $list[0]->getID());
- $this->assertIdentical(2, $list[1]->getID());
- $this->assertIdentical(3, $list[2]->getID());
- $this->assertIdentical(4, $list[3]->getID());
- $this->assertIdentical(5, $list[4]->getID());
- }
-
- /**
- * Test ExecuteQueryForPaginatedList
- */
- function testExecuteQueryForPaginatedList()
- {
- // Get List of all 5
- $list = $this->sqlmap->QueryForPagedList("GetAllAccountsViaResultMap", null, 2);
-
- // Test initial state (page 0)
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertAccount1($list[0]);
- $this->assertIdentical(2, $list->getCount());
- $this->assertIdentical(1, $list[0]->getID());
- $this->assertIdentical(2, $list[1]->getID());
-
- // Test illegal previous page (no effect, state should be same)
- $list->PreviousPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertAccount1($list[0]);
- $this->assertIdentical(2, $list->getCount());
- $this->assertIdentical(1, $list[0]->getID());
- $this->assertIdentical(2, $list[1]->getID());
-
- // Test next (page 1)
- $list->NextPage();
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertIdentical(2, $list->getCount());
- $this->assertIdentical(3, $list[0]->getID());
- $this->assertIdentical(4, $list[1]->getID());
-
- // Test next (page 2 -last)
- $list->NextPage();
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(1, $list->getCount());
- $this->assertIdentical(5, $list[0]->getID());
-
- // Test previous (page 1)
- $list->PreviousPage();
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertIdentical(2, $list->getCount());
- $this->assertIdentical(3, $list[0]->getID());
- $this->assertIdentical(4, $list[1]->getID());
-
- // Test previous (page 0 -first)
- $list->PreviousPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertAccount1($list[0]);
- $this->assertIdentical(2, $list->getCount());
- $this->assertIdentical(1, $list[0]->getID());
- $this->assertIdentical(2, $list[1]->getID());
-
- // Test goto (page 0)
- $list->GotoPage(0);
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertIdentical(2, $list->getCount());
- $this->assertIdentical(1, $list[0]->getID());
- $this->assertIdentical(2, $list[1]->getID());
-
- // Test goto (page 1)
- $list->GotoPage(1);
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertIdentical(2, $list->getCount());
- $this->assertIdentical(3, $list[0]->getID());
- $this->assertIdentical(4, $list[1]->getID());
-
- // Test goto (page 2)
- $list->GotoPage(2);
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(1, $list->getCount());
- $this->assertIdentical(5, $list[0]->getID());
-
- // Test illegal goto (page 0)
- $list->GotoPage(3);
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(0, $list->getCount());
-
- $list = $this->sqlmap->QueryForPagedList("GetNoAccountsViaResultMap", null, 2);
-
- // Test empty list
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(0, $list->getCount());
-
- // Test next
- $list->NextPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(0, $list->getCount());
-
- // Test previous
- $list->PreviousPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(0, $list->getCount());
-
- // Test previous
- $list->GotoPage(0);
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(0, $list->getCount());
- $list = $this->sqlmap->QueryForPagedList("GetFewAccountsViaResultMap", null, 2);
-
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(1, $list->getCount());
-
- // Test next
- $list->NextPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(1, $list->getCount());
- // Test previous
- $list->PreviousPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(1, $list->getCount());
-
- // Test previous
- $list->GotoPage(0);
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertIdentical(1, $list->getCount());
-
-
- $list = $this->sqlmap->QueryForPagedList("GetAllAccountsViaResultMap", null, 5);
-
- $this->assertIdentical(5, $list->getCount());
-
- $list->NextPage();
- $this->assertIdentical(5, $list->getCount());
-
- $b = $list->getIsPreviousPageAvailable();
- $list->PreviousPage();
- $this->assertIdentical(5, $list->getCount());
- }
-
- /**
- * Test QueryForList with ResultObject :
- * AccountCollection strongly typed collection
- */
- function testQueryForListWithResultObject()
- {
- $accounts = new AccountCollection();
-
- $this->sqlmap->QueryForList("GetAllAccountsViaResultMap", null, $accounts);
- $this->assertAccount1($accounts[0]);
- $this->assertIdentical(5, $accounts->getCount());
- $this->assertIdentical(1, $accounts[0]->getID());
- $this->assertIdentical(2, $accounts[1]->getID());
- $this->assertIdentical(3, $accounts[2]->getID());
- $this->assertIdentical(4, $accounts[3]->getID());
- $this->assertIdentical(5, $accounts[4]->GetId());
- }
-
- /**
- * Test QueryForList with ListClass : LineItemCollection
- */
- function testQueryForListWithListClass()
- {
- $linesItem = $this->sqlmap->QueryForList("GetLineItemsForOrderWithListClass", 10);
-
- $this->assertNotNull($linesItem);
- $this->assertIdentical(2, $linesItem->getCount());
- $this->assertIdentical("ESM-34", $linesItem[0]->getCode());
- $this->assertIdentical("QSM-98", $linesItem[1]->getCode());
- }
-
- /**
- * Test QueryForList with no result.
- */
- function testQueryForListWithNoResult()
- {
- $list = $this->sqlmap->QueryForList("GetNoAccountsViaResultMap");
-
- $this->assertIdentical(0, count($list));
- }
-
- /**
- * Test QueryForList with ResultClass : Account.
- */
- function testQueryForListResultClass()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultClass");
-
- $this->assertAccount1($list[0]);
- $this->assertIdentical(5, count($list));
- $this->assertIdentical(1, $list[0]->getID());
- $this->assertIdentical(2, $list[1]->getID());
- $this->assertIdentical(3, $list[2]->getID());
- $this->assertIdentical(4, $list[3]->getID());
- $this->assertIdentical(5, $list[4]->getID());
- }
-
- /**
- * Test QueryForList with simple resultClass : string
- */
- function testQueryForListWithSimpleResultClass()
- {
- $list = $this->sqlmap->QueryForList("GetAllEmailAddressesViaResultClass");
-
- $this->assertIdentical("Joe.Dalton@somewhere.com", $list[0]);
- $this->assertIdentical("Averel.Dalton@somewhere.com", $list[1]);
- $this->assertIdentical('', $list[2]);
- $this->assertIdentical("Jack.Dalton@somewhere.com", $list[3]);
- $this->assertIdentical('', $list[4]);
- }
-
- /**
- * Test QueryForList with simple ResultMap : string
- */
- function testQueryForListWithSimpleResultMap()
- {
- $list = $this->sqlmap->QueryForList("GetAllEmailAddressesViaResultMap");
-
- $this->assertIdentical("Joe.Dalton@somewhere.com", $list[0]);
- $this->assertIdentical("Averel.Dalton@somewhere.com", $list[1]);
- $this->assertIdentical('', $list[2]);
- $this->assertIdentical("Jack.Dalton@somewhere.com", $list[3]);
- $this->assertIdentical('', $list[4]);
- }
-
- /**
- * Test QueryForListWithSkipAndMax
- */
- function testQueryForListWithSkipAndMax()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMap", null, null, 2, 2);
-
- $this->assertIdentical(2, count($list));
- $this->assertIdentical(3, $list[0]->getID());
- $this->assertIdentical(4, $list[1]->getID());
- }
-
-
- /**
- * Test row delegate
- */
- function testQueryWithRowDelegate()
- {
- //$handler = new SqlMapper.RowDelegate(this.RowHandler);
-
- //$list = $this->sqlmap->QueryWithRowDelegate("GetAllAccountsViaResultMap", null, handler);
-
- //$this->assertIdentical(5, _index);
- //$this->assertIdentical(5, $list->getCount());
- //$this->assertAccount1$list[0]);
- //$this->assertIdentical(1, $list[0]->getID());
- //$this->assertIdentical(2, $list[1]->getID());
- //$this->assertIdentical(3, $list[2]->getID());
- //$this->assertIdentical(4, $list[3]->getID());
- //$this->assertIdentical(5, $list[4]->getID());
- }
-
- #endregion
-
- #region Map Tests
-
- /**
- * Test ExecuteQueryForMap : Hashtable.
- */
- function testExecuteQueryForMap()
- {
- $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, "FirstName");
-
- $this->assertIdentical(5, count($map));
- $this->assertAccount1($map["Joe"]);
-
- $this->assertIdentical(1, $map["Joe"]->getID());
- $this->assertIdentical(2, $map["Averel"]->getID());
- $this->assertIdentical(3, $map["William"]->getID());
- $this->assertIdentical(4, $map["Jack"]->getID());
- $this->assertIdentical(5, $map["Gilles"]->getID());
- }
-
- /**
- * Test ExecuteQueryForMap : Hashtable.
- *
- * If the keyProperty is an integer, you must acces the map
- * by map[integer] and not by map["integer"]
- */
- function testExecuteQueryForMap2()
- {
- $map = $this->sqlmap->QueryForMap("GetAllOrderWithLineItems", null, "PostalCode");
-
- $this->assertIdentical(11, count($map));
- $order = $map["T4H 9G4"];
-
- $this->assertIdentical(2, $order->getLineItemsList()->getCount());
- }
-
- /**
- * Test ExecuteQueryForMap with value property :
- * "FirstName" as key, "EmailAddress" as value
- */
- function testExecuteQueryForMapWithValueProperty()
- {
- $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null,
- "FirstName", "EmailAddress");
-
- $this->assertIdentical(5, count($map));
-
- $this->assertIdentical("Joe.Dalton@somewhere.com", $map["Joe"]);
- $this->assertIdentical("Averel.Dalton@somewhere.com", $map["Averel"]);
- $this->assertNull($map["William"]);
- $this->assertIdentical("Jack.Dalton@somewhere.com", $map["Jack"]);
- $this->assertNull($map["Gilles"]);
- }
-
- /**
- * Test ExecuteQueryForWithJoined
- */
- function testExecuteQueryForWithJoined()
- {
- $order = $this->sqlmap->QueryForObject("GetOrderJoinWithAccount",10);
-
- $this->assertNotNull($order->getAccount());
-
- $order = $this->sqlmap->QueryForObject("GetOrderJoinWithAccount",11);
-
- $this->assertNull($order->getAccount());
- }
-
- /**
- * Test ExecuteQueryFor With Complex Joined
- *
- * A->B->C
- * ->E
- * ->F
- */
- function testExecuteQueryForWithComplexJoined()
- {
- $a = $this->sqlmap->QueryForObject("SelectComplexJoined");
- $this->assertNotNull($a);
- $this->assertNotNull($a->getB());
- $this->assertNotNull($a->getB()->getC());
- $this->assertNull($a->getB()->getD());
- $this->assertNotNull($a->getE());
- $this->assertNull($a->getF());
- }
- #endregion
-
- #region Extends statement
-
- /**
- * Test base Extends statement
- */
- function testExtendsGetAllAccounts()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccounts");
-
- $this->assertAccount1($list[0]);
- $this->assertIdentical(5, count($list));
- $this->assertIdentical(1, $list[0]->getID());
- $this->assertIdentical(2, $list[1]->getID());
- $this->assertIdentical(3, $list[2]->getID());
- $this->assertIdentical(4, $list[3]->getID());
- $this->assertIdentical(5, $list[4]->getID());
- }
-
- /**
- * Test Extends statement GetAllAccountsOrderByName extends GetAllAccounts
- */
- function testExtendsGetAllAccountsOrderByName()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsOrderByName");
-
- $this->assertAccount1($list[3]);
- $this->assertIdentical(5, count($list));
-
- $this->assertIdentical(2, $list[0]->getID());
- $this->assertIdentical(5, $list[1]->getID());
- $this->assertIdentical(4, $list[2]->getID());
- $this->assertIdentical(1, $list[3]->getID());
- $this->assertIdentical(3, $list[4]->getID());
- }
-
- /**
- * Test Extends statement GetOneAccount extends GetAllAccounts
- */
- function testExtendsGetOneAccount()
- {
- $account= $this->sqlmap->QueryForObject("GetOneAccount", 1);
- $this->assertAccount1($account);
- }
-
- /**
- * Test Extends statement GetSomeAccount extends GetAllAccounts
- */
- function testExtendsGetSomeAccount()
- {
- $param["lowID"] = 2;
- $param["hightID"] = 4;
-
- $list = $this->sqlmap->QueryForList("GetSomeAccount", $param);
-
- $this->assertIdentical(3, count($list));
-
- $this->assertIdentical(2, $list[0]->getID());
- $this->assertIdentical(3, $list[1]->getID());
- $this->assertIdentical(4, $list[2]->getID());
- }
-
- #endregion
-
- #region Update tests
-
-
- /**
- * Test Insert account via public fields
- */
- function testInsertAccountViaPublicFields()
- {
- $this->initScript('account-init.sql');
-
- $account = new AccountBis();
-
- $account->Id = 10;
- $account->FirstName = "Luky";
- $account->LastName = "Luke";
- $account->EmailAddress = "luly.luke@somewhere.com";
-
- $this->sqlmap->Insert("InsertAccountViaPublicFields", $account);
-
- $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 10);
-
- $this->assertNotNull($testAccount);
-
- $this->assertIdentical(10, $testAccount->getID());
-
- $this->initScript('account-init.sql');
- }
-
- /**
- *
- */
- function testInsertOrderViaProperties()
- {
- $this->initScript('account-init.sql');
- $this->initScript('order-init.sql');
- $account= $this->NewAccount6();
-
- $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate('2005-05-20');
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->Insert("InsertOrderViaPublicFields", $order);
-
- $this->initScript('account-init.sql');
- $this->initScript('order-init.sql');
- }
-
-
- /**
- * Test Insert account via inline parameters
- */
- function testInsertAccountViaInlineParameters()
- {
- $this->initScript('account-init.sql');
- $account= new Account();
-
- $account->setId(10);
- $account->setFirstName("Luky");
- $account->setLastName("Luke");
- $account->setEmailAddress("luly.luke@somewhere.com");
-
- $this->sqlmap->Insert("InsertAccountViaInlineParameters", $account);
-
- $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnIndex", 10);
-
- $this->assertNotNull($testAccount);
- $this->assertIdentical(10, $testAccount->getId());
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Insert account via parameterMap
- */
- function testInsertAccountViaParameterMap()
- {
- $this->initScript('account-init.sql');
- $account= $this->NewAccount6();
- $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
-
- $account = $this->sqlmap->QueryForObject("GetAccountNullableEmail", 6);
- $this->AssertAccount6($account);
-
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Update via parameterMap
- */
- function testUpdateViaParameterMap()
- {
- $this->initScript('account-init.sql');
- $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $account->setEmailAddress("new@somewhere.com");
- $this->sqlmap->Update("UpdateAccountViaParameterMap", $account);
-
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $this->assertIdentical("new@somewhere.com", $account->getEmailAddress());
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Update via parameterMap V2
- */
- function testUpdateViaParameterMap2()
- {
- $this->initScript('account-init.sql');
- $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $account->setEmailAddress("new@somewhere.com");
- $this->sqlmap->Update("UpdateAccountViaParameterMap2", $account);
-
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $this->assertIdentical("new@somewhere.com", $account->getEmailAddress());
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Update with inline parameters
- */
- function testUpdateWithInlineParameters()
- {
- $this->initScript('account-init.sql');
- $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $account->setEmailAddress("new@somewhere.com");
- $this->sqlmap->Update("UpdateAccountViaInlineParameters", $account);
-
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $this->assertIdentical("new@somewhere.com", $account->getEmailAddress());
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Execute Update With Parameter Class
- */
- function testExecuteUpdateWithParameterClass()
- {
- $this->initScript('account-init.sql');
- $account= $this->NewAccount6();
-
- $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
-
- $noRowsDeleted = $this->sqlmap->Update("DeleteAccount", null);
-
- $this->sqlmap->Update("DeleteAccount", $account);
-
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6);
-
- $this->assertNull($account);
- $this->assertIdentical(0, $noRowsDeleted);
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Execute Delete
- */
- function testExecuteDelete()
- {
- $this->initScript('account-init.sql');
- $account= $this->NewAccount6();
-
- $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
-
- $account = null;
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6);
-
- $this->assertTrue($account->getId() == 6);
-
- $rowNumber = $this->sqlmap->Delete("DeleteAccount", $account);
- $this->assertTrue($rowNumber == 1);
-
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6);
-
- $this->assertNull($account);
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Execute Delete
- */
- function testDeleteWithComments()
- {
- $this->initScript('line-item-init.sql');
- $rowNumber = $this->sqlmap->Delete("DeleteWithComments");
-
- $this->assertIdentical($rowNumber, 2);
- $this->initScript('line-item-init.sql');
- }
-
-
-
- #endregion
-
- #region Row delegate
-
- private $_index = 0;
-
- function RowHandler($sender, $paramterObject, $list)
- {
- //_index++;
- //$this->assertIdentical(_index, (($account) obj).Id);
- //$list->Add(obj);
- }
-
- #endregion
-
- #region JIRA Tests
-
- /**
- * Test JIRA 30 (repeating property)
- */
- function testJIRA30()
- {
- $account= new Account();
- $account->setId(1);
- $account->setFirstName("Joe");
- $account->setLastName("Dalton");
- $account->setEmailAddress("Joe.Dalton@somewhere.com");
-
- $result = $this->sqlmap->QueryForObject("GetAccountWithRepeatingProperty", $account);
-
- $this->assertAccount1($result);
- }
-
- /**
- * Test Bit column
- */
- function testJIRA42()
- {
- $other = new Other();
-
- $other->setInt(100);
- $other->setBool(true);
- $other->setLong(789456321);
-
- $this->sqlmap->Insert("InsertBool", $other);
- }
-
- /**
- * Test for access a result map in a different namespace
- */
- function testJIRA45()
- {
- $account= $this->sqlmap->QueryForObject("GetAccountJIRA45", 1);
- $this->assertAccount1($account);
- }
-
- /**
- * Test : Whitespace is not maintained properly when CDATA tags are used
- */
- function testJIRA110()
- {
- $account= $this->sqlmap->QueryForObject("Get1Account");
- $this->assertAccount1($account);
- }
-
- /**
- * Test : Whitespace is not maintained properly when CDATA tags are used
- */
- function testJIRA110Bis()
- {
- $list = $this->sqlmap->QueryForList("GetAccounts");
-
- $this->assertAccount1($list[0]);
- $this->assertIdentical(5, count($list));
- }
-
- /**
- * Test for cache stats only being calculated on CachingStatments
- */
- function testJIRA113()
- {
- // $this->sqlmap->FlushCaches();
-
- // taken from TestFlushDataCache()
- // first query is not cached, second query is: 50% cache hit
- /*$list = $this->sqlmap->QueryForList("GetCachedAccountsViaResultMap");
- $firstId = HashCodeProvider.GetIdentityHashCode(list);
- list = $this->sqlmap->QueryForList("GetCachedAccountsViaResultMap");
- int secondId = HashCodeProvider.GetIdentityHashCode(list);
- $this->assertIdentical(firstId, secondId);
-
- string cacheStats = $this->sqlmap->GetDataCacheStats();
-
- $this->assertNotNull(cacheStats);*/
- }
-
- #endregion
-
- #region CustomTypeHandler tests
-
- /**
- * Test CustomTypeHandler
- */
- function testExecuteQueryWithCustomTypeHandler()
- {
- $this->sqlmap->registerTypeHandler(new HundredsBool());
- $this->sqlmap->registerTypeHandler(new OuiNonBool());
-
- $list = $this->sqlmap->QueryForList("GetAllAccountsViaCustomTypeHandler");
-
- $this->assertAccount1($list[0]);
- $this->assertIdentical(5, count($list));
- $this->assertIdentical(1, $list[0]->getID());
- $this->assertIdentical(2, $list[1]->getID());
- $this->assertIdentical(3, $list[2]->getID());
- $this->assertIdentical(4, $list[3]->getID());
- $this->assertIdentical(5, $list[4]->getID());
-
- $this->assertFalse($list[0]->getCartOptions());
- $this->assertFalse($list[1]->getCartOptions());
- $this->assertTrue($list[2]->getCartOptions());
- $this->assertTrue($list[3]->getCartOptions());
- $this->assertTrue($list[4]->getCartOptions());
-
- $this->assertTrue($list[0]->getBannerOptions());
- $this->assertTrue($list[1]->getBannerOptions());
- $this->assertFalse($list[2]->getBannerOptions());
- $this->assertFalse($list[3]->getBannerOptions());
- $this->assertTrue($list[4]->getBannerOptions());
- }
-
- /**
- * Test CustomTypeHandler Oui/Non
- */
- function testCustomTypeHandler()
- {
- $this->initScript('other-init.sql');
- $this->initScript('account-init.sql');
-
- $this->sqlmap->registerTypeHandler(new OuiNonBool());
-
- $other = new Other();
- $other->setInt(99);
- $other->setLong(1966);
- $other->setBool(true);
- $other->setBool2(false);
- $this->sqlmap->Insert("InsertCustomTypeHandler", $other);
-
- $anOther = $this->sqlmap->QueryForObject("SelectByInt", 99);
- $this->assertNotNull( $anOther );
- $this->assertIdentical(99, (int)$anOther->getInt());
- $this->assertIdentical(1966, (int)$anOther->getLong());
- $this->assertIdentical(true, (boolean)$anOther->getBool());
- $this->assertIdentical(false, (boolean)$anOther->getBool2());
-
- }
-
- /**
- * Test CustomTypeHandler Oui/Non
- */
- function testInsertInlineCustomTypeHandlerV1()
- {
- $this->initScript('other-init.sql');
- $this->initScript('account-init.sql');
-
- $other = new Other();
- $other->setInt(99);
- $other->setLong(1966);
- $other->setBool(true);
- $other->setBool2(false);
-
- $this->sqlmap->Insert("InsertInlineCustomTypeHandlerV1", $other);
-
- $anOther = $this->sqlmap->QueryForObject("SelectByIntV1", 99);
-
- $this->assertNotNull( $anOther );
- $this->assertIdentical(99, (int)$anOther->getInt());
- $this->assertIdentical(1966, (int)$anOther->getLong());
- $this->assertIdentical(true, (boolean)$anOther->getBool());
- $this->assertIdentical(false, (boolean)$anOther->getBool2());
-
- }
-
- /**
- * Test CustomTypeHandler Oui/Non
- */
- function testInsertInlineCustomTypeHandlerV2()
- {
- $this->initScript('other-init.sql');
- $this->initScript('account-init.sql');
-
- $other = new Other();
- $other->setInt(99);
- $other->setLong(1966);
- $other->setBool(true);
- $other->setBool2(false);
-
- $this->sqlmap->Insert("InsertInlineCustomTypeHandlerV2", $other);
-
- $anOther = $this->sqlmap->QueryForObject("SelectByInt", 99);
-
- $this->assertNotNull( $anOther );
- $this->assertIdentical(99, (int)$anOther->getInt());
- $this->assertIdentical(1966, (int)$anOther->getLong());
- $this->assertIdentical(true, (boolean)$anOther->getBool());
- $this->assertIdentical(false, (boolean)$anOther->getBool2());
- }
- #endregion
- /**/
-}
-
+<?php +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class StatementTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + + //force autoload + new Account; + new Order; + new LineItem; + new LineItemCollection; + new A; new B; new C; new D; new E; new F; + } + + public function setup() + { + + } + + function resetDatabase() + { + $this->initScript('account-init.sql'); + $this->initScript('order-init.sql'); + $this->initScript('line-item-init.sql'); +// $this->initScript('enumeration-init.sql'); + $this->initScript('other-init.sql'); + } + + + #region Object Query tests + + /** + * Test Open connection with a connection string + */ + function testOpenConnection() + { + $conn = $this->sqlmap->getDbConnection(); + $conn->setActive(true); + $account= $this->sqlmap->QueryForObject("SelectWithProperty"); + $conn->setActive(false); + $this->assertAccount1($account); + } + + /** + * Test use a statement with property subtitution + * (JIRA 22) + */ + function testSelectWithProperty() + { + $account= $this->sqlmap->QueryForObject("SelectWithProperty"); + $this->assertAccount1($account); + } + + /** + * Test ExecuteQueryForObject Via ColumnName + */ + function testExecuteQueryForObjectViaColumnName() + { + $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + $this->assertAccount1($account); + } + + /** + * Test ExecuteQueryForObject Via ColumnIndex + */ + function testExecuteQueryForObjectViaColumnIndex() + { + $account= $this->sqlmap->QueryForObject("GetAccountViaColumnIndex", 1); + $this->assertAccount1($account); + } + + /** + * Test ExecuteQueryForObject Via ResultClass + */ + function testExecuteQueryForObjectViaResultClass() + { + $account= $this->sqlmap->QueryForObject("GetAccountViaResultClass", 1); + $this->assertAccount1($account); + } + + /** + * Test ExecuteQueryForObject With simple ResultClass : string + */ + function testExecuteQueryForObjectWithSimpleResultClass() + { + $email = $this->sqlmap->QueryForObject("GetEmailAddressViaResultClass", 1); + $this->assertIdentical("Joe.Dalton@somewhere.com", $email); + } + + /** + * Test ExecuteQueryForObject With simple ResultMap : string + */ + function testExecuteQueryForObjectWithSimpleResultMap() + { + $email = $this->sqlmap->QueryForObject("GetEmailAddressViaResultMap", 1); + $this->assertIdentical("Joe.Dalton@somewhere.com", $email); + } + + /** + * Test Primitive ReturnValue : TDateTime + */ + function testPrimitiveReturnValue() + { + $CardExpiry = $this->sqlmap->QueryForObject("GetOrderCardExpiryViaResultClass", 1); + $date = @mktime(8, 15, 00, 2, 15, 2003); + $this->assertIdentical($date, $CardExpiry->getTimeStamp()); + } + + /** + * Test ExecuteQueryForObject with result object : Account + */ + function testExecuteQueryForObjectWithResultObject() + { + $account= new Account(); + $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1, $account); + $this->assertAccount1($account); + $this->assertTrue($account == $testAccount); + } + + /** + * Test ExecuteQueryForObject as array + */ + function testExecuteQueryForObjectAsHashArray() + { + $account = $this->sqlmap->QueryForObject("GetAccountAsHashtable", 1); + $this->assertAccount1AsHashArray($account); + } + + /** + * Test ExecuteQueryForObject as Hashtable ResultClass + */ + function testExecuteQueryForObjectAsHashtableResultClass() + { + $account = $this->sqlmap->QueryForObject("GetAccountAsHashtableResultClass", 1); + $this->assertAccount1AsHashArray($account); + } + + /** + * Test ExecuteQueryForObject via Hashtable + */ + function testExecuteQueryForObjectViaHashtable() + { + $param["LineItem_ID"] = 2; + $param["Order_ID"] = 9; + + $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param); + + $this->assertNotNull($testItem); + $this->assertIdentical("TSM-12", $testItem->getCode()); + } + /**/ + + //TODO: Test Query Dynamic Sql Element + function testQueryDynamicSqlElement() + { + //$list = $this->sqlmap->QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_ID"); + + //$this->assertIdentical("Joe.Dalton@somewhere.com", $list[0]); + + //list = $this->sqlmap->QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_FirstName"); + + //$this->assertIdentical("Averel.Dalton@somewhere.com", $list[0]); + + } + + // TODO: Test Execute QueryForList With ResultMap With Dynamic Element + function testExecuteQueryForListWithResultMapWithDynamicElement() + { + //$list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "LIKE"); + + //$this->assertAccount1$list[0]); + //$this->assertIdentical(3, $list->getCount()); + //$this->assertIdentical(1, $list[0]->getID()); + //$this->assertIdentical(2, $list[1]->getID()); + //$this->assertIdentical(4, $list[2]->getID()); + + //list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "="); + + //$this->assertIdentical(0, $list->getCount()); + } + + + + /** + * Test Get Account Via Inline Parameters + */ + function testExecuteQueryForObjectViaInlineParameters() + { + $account= new Account(); + $account->setID(1); + + $testAccount = $this->sqlmap->QueryForObject("GetAccountViaInlineParameters", $account); + + $this->assertAccount1($testAccount); + } + /**/ + + // TODO: Test ExecuteQuery For Object With Enum property + + function testExecuteQueryForObjectWithEnum() + { + //$enumClass = $this->sqlmap->QueryForObject("GetEnumeration", 1); + + //$this->assertIdentical(enumClass.Day, Days.Sat); + //$this->assertIdentical(enumClass.Color, Colors.Red); + //$this->assertIdentical(enumClass.Month, Months.August); + + //enumClass = $this->sqlmap->QueryForObject("GetEnumeration", 3) as Enumeration; + + //$this->assertIdentical(enumClass.Day, Days.Mon); + //$this->assertIdentical(enumClass.Color, Colors.Blue); + //$this->assertIdentical(enumClass.Month, Months.September);*/ + } + + #endregion + + #region List Query tests + + /** + * Test QueryForList with Hashtable ResultMap + */ + function testQueryForListWithHashtableResultMap() + { + $this->initScript('account-init.sql'); + $list = $this->sqlmap->QueryForList("GetAllAccountsAsHashMapViaResultMap"); + + $this->assertAccount1AsHashArray($list[0]); + $this->assertIdentical(5, count($list)); + + $this->assertIdentical(1, (int)$list[0]["Id"]); + $this->assertIdentical(2, (int)$list[1]["Id"]); + $this->assertIdentical(3, (int)$list[2]["Id"]); + $this->assertIdentical(4, (int)$list[3]["Id"]); + $this->assertIdentical(5, (int)$list[4]["Id"]); + } + + /** + * Test QueryForList with Hashtable ResultClass + */ + function testQueryForListWithHashtableResultClass() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsAsHashtableViaResultClass"); + + $this->assertAccount1AsHashArray($list[0]); + $this->assertIdentical(5, count($list)); + + $this->assertIdentical(1, (int)$list[0]["Id"]); + $this->assertIdentical(2, (int)$list[1]["Id"]); + $this->assertIdentical(3, (int)$list[2]["Id"]); + $this->assertIdentical(4, (int)$list[3]["Id"]); + $this->assertIdentical(5, (int)$list[4]["Id"]); + } + + /** + * Test QueryForList with IList ResultClass + */ + function testQueryForListWithIListResultClass() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsAsArrayListViaResultClass"); + + $listAccount = $list[0]; + + $this->assertIdentical(1,(int)$listAccount[0]); + $this->assertIdentical("Joe",$listAccount[1]); + $this->assertIdentical("Dalton",$listAccount[2]); + $this->assertIdentical("Joe.Dalton@somewhere.com",$listAccount[3]); + + $this->assertIdentical(5, count($list)); + + $listAccount = $list[0]; + $this->assertIdentical(1, (int)$listAccount[0]); + $listAccount = $list[1]; + $this->assertIdentical(2, (int)$listAccount[0]); + $listAccount = $list[2]; + $this->assertIdentical(3, (int)$listAccount[0]); + $listAccount = $list[3]; + $this->assertIdentical(4, (int)$listAccount[0]); + $listAccount = $list[4]; + $this->assertIdentical(5, (int)$listAccount[0]); + } + + /** + * Test QueryForList With ResultMap, result collection as ArrayList + */ + function testQueryForListWithResultMap() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMap"); + + $this->assertAccount1($list[0]); + $this->assertIdentical(5, count($list)); + $this->assertIdentical(1, $list[0]->getID()); + $this->assertIdentical(2, $list[1]->getID()); + $this->assertIdentical(3, $list[2]->getID()); + $this->assertIdentical(4, $list[3]->getID()); + $this->assertIdentical(5, $list[4]->getID()); + } + + /** + * Test ExecuteQueryForPaginatedList + */ + function testExecuteQueryForPaginatedList() + { + // Get List of all 5 + $list = $this->sqlmap->QueryForPagedList("GetAllAccountsViaResultMap", null, 2); + + // Test initial state (page 0) + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertAccount1($list[0]); + $this->assertIdentical(2, $list->getCount()); + $this->assertIdentical(1, $list[0]->getID()); + $this->assertIdentical(2, $list[1]->getID()); + + // Test illegal previous page (no effect, state should be same) + $list->PreviousPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertAccount1($list[0]); + $this->assertIdentical(2, $list->getCount()); + $this->assertIdentical(1, $list[0]->getID()); + $this->assertIdentical(2, $list[1]->getID()); + + // Test next (page 1) + $list->NextPage(); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertIdentical(2, $list->getCount()); + $this->assertIdentical(3, $list[0]->getID()); + $this->assertIdentical(4, $list[1]->getID()); + + // Test next (page 2 -last) + $list->NextPage(); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(1, $list->getCount()); + $this->assertIdentical(5, $list[0]->getID()); + + // Test previous (page 1) + $list->PreviousPage(); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertIdentical(2, $list->getCount()); + $this->assertIdentical(3, $list[0]->getID()); + $this->assertIdentical(4, $list[1]->getID()); + + // Test previous (page 0 -first) + $list->PreviousPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertAccount1($list[0]); + $this->assertIdentical(2, $list->getCount()); + $this->assertIdentical(1, $list[0]->getID()); + $this->assertIdentical(2, $list[1]->getID()); + + // Test goto (page 0) + $list->GotoPage(0); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertIdentical(2, $list->getCount()); + $this->assertIdentical(1, $list[0]->getID()); + $this->assertIdentical(2, $list[1]->getID()); + + // Test goto (page 1) + $list->GotoPage(1); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertIdentical(2, $list->getCount()); + $this->assertIdentical(3, $list[0]->getID()); + $this->assertIdentical(4, $list[1]->getID()); + + // Test goto (page 2) + $list->GotoPage(2); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(1, $list->getCount()); + $this->assertIdentical(5, $list[0]->getID()); + + // Test illegal goto (page 0) + $list->GotoPage(3); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(0, $list->getCount()); + + $list = $this->sqlmap->QueryForPagedList("GetNoAccountsViaResultMap", null, 2); + + // Test empty list + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(0, $list->getCount()); + + // Test next + $list->NextPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(0, $list->getCount()); + + // Test previous + $list->PreviousPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(0, $list->getCount()); + + // Test previous + $list->GotoPage(0); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(0, $list->getCount()); + $list = $this->sqlmap->QueryForPagedList("GetFewAccountsViaResultMap", null, 2); + + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(1, $list->getCount()); + + // Test next + $list->NextPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(1, $list->getCount()); + // Test previous + $list->PreviousPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(1, $list->getCount()); + + // Test previous + $list->GotoPage(0); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertIdentical(1, $list->getCount()); + + + $list = $this->sqlmap->QueryForPagedList("GetAllAccountsViaResultMap", null, 5); + + $this->assertIdentical(5, $list->getCount()); + + $list->NextPage(); + $this->assertIdentical(5, $list->getCount()); + + $b = $list->getIsPreviousPageAvailable(); + $list->PreviousPage(); + $this->assertIdentical(5, $list->getCount()); + } + + /** + * Test QueryForList with ResultObject : + * AccountCollection strongly typed collection + */ + function testQueryForListWithResultObject() + { + $accounts = new AccountCollection(); + + $this->sqlmap->QueryForList("GetAllAccountsViaResultMap", null, $accounts); + $this->assertAccount1($accounts[0]); + $this->assertIdentical(5, $accounts->getCount()); + $this->assertIdentical(1, $accounts[0]->getID()); + $this->assertIdentical(2, $accounts[1]->getID()); + $this->assertIdentical(3, $accounts[2]->getID()); + $this->assertIdentical(4, $accounts[3]->getID()); + $this->assertIdentical(5, $accounts[4]->GetId()); + } + + /** + * Test QueryForList with ListClass : LineItemCollection + */ + function testQueryForListWithListClass() + { + $linesItem = $this->sqlmap->QueryForList("GetLineItemsForOrderWithListClass", 10); + + $this->assertNotNull($linesItem); + $this->assertIdentical(2, $linesItem->getCount()); + $this->assertIdentical("ESM-34", $linesItem[0]->getCode()); + $this->assertIdentical("QSM-98", $linesItem[1]->getCode()); + } + + /** + * Test QueryForList with no result. + */ + function testQueryForListWithNoResult() + { + $list = $this->sqlmap->QueryForList("GetNoAccountsViaResultMap"); + + $this->assertIdentical(0, count($list)); + } + + /** + * Test QueryForList with ResultClass : Account. + */ + function testQueryForListResultClass() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultClass"); + + $this->assertAccount1($list[0]); + $this->assertIdentical(5, count($list)); + $this->assertIdentical(1, $list[0]->getID()); + $this->assertIdentical(2, $list[1]->getID()); + $this->assertIdentical(3, $list[2]->getID()); + $this->assertIdentical(4, $list[3]->getID()); + $this->assertIdentical(5, $list[4]->getID()); + } + + /** + * Test QueryForList with simple resultClass : string + */ + function testQueryForListWithSimpleResultClass() + { + $list = $this->sqlmap->QueryForList("GetAllEmailAddressesViaResultClass"); + + $this->assertIdentical("Joe.Dalton@somewhere.com", $list[0]); + $this->assertIdentical("Averel.Dalton@somewhere.com", $list[1]); + $this->assertIdentical('', $list[2]); + $this->assertIdentical("Jack.Dalton@somewhere.com", $list[3]); + $this->assertIdentical('', $list[4]); + } + + /** + * Test QueryForList with simple ResultMap : string + */ + function testQueryForListWithSimpleResultMap() + { + $list = $this->sqlmap->QueryForList("GetAllEmailAddressesViaResultMap"); + + $this->assertIdentical("Joe.Dalton@somewhere.com", $list[0]); + $this->assertIdentical("Averel.Dalton@somewhere.com", $list[1]); + $this->assertIdentical('', $list[2]); + $this->assertIdentical("Jack.Dalton@somewhere.com", $list[3]); + $this->assertIdentical('', $list[4]); + } + + /** + * Test QueryForListWithSkipAndMax + */ + function testQueryForListWithSkipAndMax() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMap", null, null, 2, 2); + + $this->assertIdentical(2, count($list)); + $this->assertIdentical(3, $list[0]->getID()); + $this->assertIdentical(4, $list[1]->getID()); + } + + + /** + * Test row delegate + */ + function testQueryWithRowDelegate() + { + //$handler = new SqlMapper.RowDelegate(this.RowHandler); + + //$list = $this->sqlmap->QueryWithRowDelegate("GetAllAccountsViaResultMap", null, handler); + + //$this->assertIdentical(5, _index); + //$this->assertIdentical(5, $list->getCount()); + //$this->assertAccount1$list[0]); + //$this->assertIdentical(1, $list[0]->getID()); + //$this->assertIdentical(2, $list[1]->getID()); + //$this->assertIdentical(3, $list[2]->getID()); + //$this->assertIdentical(4, $list[3]->getID()); + //$this->assertIdentical(5, $list[4]->getID()); + } + + #endregion + + #region Map Tests + + /** + * Test ExecuteQueryForMap : Hashtable. + */ + function testExecuteQueryForMap() + { + $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, "FirstName"); + + $this->assertIdentical(5, count($map)); + $this->assertAccount1($map["Joe"]); + + $this->assertIdentical(1, $map["Joe"]->getID()); + $this->assertIdentical(2, $map["Averel"]->getID()); + $this->assertIdentical(3, $map["William"]->getID()); + $this->assertIdentical(4, $map["Jack"]->getID()); + $this->assertIdentical(5, $map["Gilles"]->getID()); + } + + /** + * Test ExecuteQueryForMap : Hashtable. + * + * If the keyProperty is an integer, you must acces the map + * by map[integer] and not by map["integer"] + */ + function testExecuteQueryForMap2() + { + $map = $this->sqlmap->QueryForMap("GetAllOrderWithLineItems", null, "PostalCode"); + + $this->assertIdentical(11, count($map)); + $order = $map["T4H 9G4"]; + + $this->assertIdentical(2, $order->getLineItemsList()->getCount()); + } + + /** + * Test ExecuteQueryForMap with value property : + * "FirstName" as key, "EmailAddress" as value + */ + function testExecuteQueryForMapWithValueProperty() + { + $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, + "FirstName", "EmailAddress"); + + $this->assertIdentical(5, count($map)); + + $this->assertIdentical("Joe.Dalton@somewhere.com", $map["Joe"]); + $this->assertIdentical("Averel.Dalton@somewhere.com", $map["Averel"]); + $this->assertNull($map["William"]); + $this->assertIdentical("Jack.Dalton@somewhere.com", $map["Jack"]); + $this->assertNull($map["Gilles"]); + } + + /** + * Test ExecuteQueryForWithJoined + */ + function testExecuteQueryForWithJoined() + { + $order = $this->sqlmap->QueryForObject("GetOrderJoinWithAccount",10); + + $this->assertNotNull($order->getAccount()); + + $order = $this->sqlmap->QueryForObject("GetOrderJoinWithAccount",11); + + $this->assertNull($order->getAccount()); + } + + /** + * Test ExecuteQueryFor With Complex Joined + * + * A->B->C + * ->E + * ->F + */ + function testExecuteQueryForWithComplexJoined() + { + $a = $this->sqlmap->QueryForObject("SelectComplexJoined"); + $this->assertNotNull($a); + $this->assertNotNull($a->getB()); + $this->assertNotNull($a->getB()->getC()); + $this->assertNull($a->getB()->getD()); + $this->assertNotNull($a->getE()); + $this->assertNull($a->getF()); + } + #endregion + + #region Extends statement + + /** + * Test base Extends statement + */ + function testExtendsGetAllAccounts() + { + $list = $this->sqlmap->QueryForList("GetAllAccounts"); + + $this->assertAccount1($list[0]); + $this->assertIdentical(5, count($list)); + $this->assertIdentical(1, $list[0]->getID()); + $this->assertIdentical(2, $list[1]->getID()); + $this->assertIdentical(3, $list[2]->getID()); + $this->assertIdentical(4, $list[3]->getID()); + $this->assertIdentical(5, $list[4]->getID()); + } + + /** + * Test Extends statement GetAllAccountsOrderByName extends GetAllAccounts + */ + function testExtendsGetAllAccountsOrderByName() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsOrderByName"); + + $this->assertAccount1($list[3]); + $this->assertIdentical(5, count($list)); + + $this->assertIdentical(2, $list[0]->getID()); + $this->assertIdentical(5, $list[1]->getID()); + $this->assertIdentical(4, $list[2]->getID()); + $this->assertIdentical(1, $list[3]->getID()); + $this->assertIdentical(3, $list[4]->getID()); + } + + /** + * Test Extends statement GetOneAccount extends GetAllAccounts + */ + function testExtendsGetOneAccount() + { + $account= $this->sqlmap->QueryForObject("GetOneAccount", 1); + $this->assertAccount1($account); + } + + /** + * Test Extends statement GetSomeAccount extends GetAllAccounts + */ + function testExtendsGetSomeAccount() + { + $param["lowID"] = 2; + $param["hightID"] = 4; + + $list = $this->sqlmap->QueryForList("GetSomeAccount", $param); + + $this->assertIdentical(3, count($list)); + + $this->assertIdentical(2, $list[0]->getID()); + $this->assertIdentical(3, $list[1]->getID()); + $this->assertIdentical(4, $list[2]->getID()); + } + + #endregion + + #region Update tests + + + /** + * Test Insert account via public fields + */ + function testInsertAccountViaPublicFields() + { + $this->initScript('account-init.sql'); + + $account = new AccountBis(); + + $account->Id = 10; + $account->FirstName = "Luky"; + $account->LastName = "Luke"; + $account->EmailAddress = "luly.luke@somewhere.com"; + + $this->sqlmap->Insert("InsertAccountViaPublicFields", $account); + + $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 10); + + $this->assertNotNull($testAccount); + + $this->assertIdentical(10, $testAccount->getID()); + + $this->initScript('account-init.sql'); + } + + /** + * + */ + function testInsertOrderViaProperties() + { + $this->initScript('account-init.sql'); + $this->initScript('order-init.sql'); + $account= $this->NewAccount6(); + + $this->sqlmap->Insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate('2005-05-20'); + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->Insert("InsertOrderViaPublicFields", $order); + + $this->initScript('account-init.sql'); + $this->initScript('order-init.sql'); + } + + + /** + * Test Insert account via inline parameters + */ + function testInsertAccountViaInlineParameters() + { + $this->initScript('account-init.sql'); + $account= new Account(); + + $account->setId(10); + $account->setFirstName("Luky"); + $account->setLastName("Luke"); + $account->setEmailAddress("luly.luke@somewhere.com"); + + $this->sqlmap->Insert("InsertAccountViaInlineParameters", $account); + + $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnIndex", 10); + + $this->assertNotNull($testAccount); + $this->assertIdentical(10, $testAccount->getId()); + $this->initScript('account-init.sql'); + } + + /** + * Test Insert account via parameterMap + */ + function testInsertAccountViaParameterMap() + { + $this->initScript('account-init.sql'); + $account= $this->NewAccount6(); + $this->sqlmap->Insert("InsertAccountViaParameterMap", $account); + + $account = $this->sqlmap->QueryForObject("GetAccountNullableEmail", 6); + $this->AssertAccount6($account); + + $this->initScript('account-init.sql'); + } + + /** + * Test Update via parameterMap + */ + function testUpdateViaParameterMap() + { + $this->initScript('account-init.sql'); + $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $account->setEmailAddress("new@somewhere.com"); + $this->sqlmap->Update("UpdateAccountViaParameterMap", $account); + + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $this->assertIdentical("new@somewhere.com", $account->getEmailAddress()); + $this->initScript('account-init.sql'); + } + + /** + * Test Update via parameterMap V2 + */ + function testUpdateViaParameterMap2() + { + $this->initScript('account-init.sql'); + $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $account->setEmailAddress("new@somewhere.com"); + $this->sqlmap->Update("UpdateAccountViaParameterMap2", $account); + + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $this->assertIdentical("new@somewhere.com", $account->getEmailAddress()); + $this->initScript('account-init.sql'); + } + + /** + * Test Update with inline parameters + */ + function testUpdateWithInlineParameters() + { + $this->initScript('account-init.sql'); + $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $account->setEmailAddress("new@somewhere.com"); + $this->sqlmap->Update("UpdateAccountViaInlineParameters", $account); + + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $this->assertIdentical("new@somewhere.com", $account->getEmailAddress()); + $this->initScript('account-init.sql'); + } + + /** + * Test Execute Update With Parameter Class + */ + function testExecuteUpdateWithParameterClass() + { + $this->initScript('account-init.sql'); + $account= $this->NewAccount6(); + + $this->sqlmap->Insert("InsertAccountViaParameterMap", $account); + + $noRowsDeleted = $this->sqlmap->Update("DeleteAccount", null); + + $this->sqlmap->Update("DeleteAccount", $account); + + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6); + + $this->assertNull($account); + $this->assertIdentical(0, $noRowsDeleted); + $this->initScript('account-init.sql'); + } + + /** + * Test Execute Delete + */ + function testExecuteDelete() + { + $this->initScript('account-init.sql'); + $account= $this->NewAccount6(); + + $this->sqlmap->Insert("InsertAccountViaParameterMap", $account); + + $account = null; + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6); + + $this->assertTrue($account->getId() == 6); + + $rowNumber = $this->sqlmap->Delete("DeleteAccount", $account); + $this->assertTrue($rowNumber == 1); + + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6); + + $this->assertNull($account); + $this->initScript('account-init.sql'); + } + + /** + * Test Execute Delete + */ + function testDeleteWithComments() + { + $this->initScript('line-item-init.sql'); + $rowNumber = $this->sqlmap->Delete("DeleteWithComments"); + + $this->assertIdentical($rowNumber, 2); + $this->initScript('line-item-init.sql'); + } + + + + #endregion + + #region Row delegate + + private $_index = 0; + + function RowHandler($sender, $paramterObject, $list) + { + //_index++; + //$this->assertIdentical(_index, (($account) obj).Id); + //$list->Add(obj); + } + + #endregion + + #region JIRA Tests + + /** + * Test JIRA 30 (repeating property) + */ + function testJIRA30() + { + $account= new Account(); + $account->setId(1); + $account->setFirstName("Joe"); + $account->setLastName("Dalton"); + $account->setEmailAddress("Joe.Dalton@somewhere.com"); + + $result = $this->sqlmap->QueryForObject("GetAccountWithRepeatingProperty", $account); + + $this->assertAccount1($result); + } + + /** + * Test Bit column + */ + function testJIRA42() + { + $other = new Other(); + + $other->setInt(100); + $other->setBool(true); + $other->setLong(789456321); + + $this->sqlmap->Insert("InsertBool", $other); + } + + /** + * Test for access a result map in a different namespace + */ + function testJIRA45() + { + $account= $this->sqlmap->QueryForObject("GetAccountJIRA45", 1); + $this->assertAccount1($account); + } + + /** + * Test : Whitespace is not maintained properly when CDATA tags are used + */ + function testJIRA110() + { + $account= $this->sqlmap->QueryForObject("Get1Account"); + $this->assertAccount1($account); + } + + /** + * Test : Whitespace is not maintained properly when CDATA tags are used + */ + function testJIRA110Bis() + { + $list = $this->sqlmap->QueryForList("GetAccounts"); + + $this->assertAccount1($list[0]); + $this->assertIdentical(5, count($list)); + } + + /** + * Test for cache stats only being calculated on CachingStatments + */ + function testJIRA113() + { + // $this->sqlmap->FlushCaches(); + + // taken from TestFlushDataCache() + // first query is not cached, second query is: 50% cache hit + /*$list = $this->sqlmap->QueryForList("GetCachedAccountsViaResultMap"); + $firstId = HashCodeProvider.GetIdentityHashCode(list); + list = $this->sqlmap->QueryForList("GetCachedAccountsViaResultMap"); + int secondId = HashCodeProvider.GetIdentityHashCode(list); + $this->assertIdentical(firstId, secondId); + + string cacheStats = $this->sqlmap->GetDataCacheStats(); + + $this->assertNotNull(cacheStats);*/ + } + + #endregion + + #region CustomTypeHandler tests + + /** + * Test CustomTypeHandler + */ + function testExecuteQueryWithCustomTypeHandler() + { + $this->sqlmap->registerTypeHandler(new HundredsBool()); + $this->sqlmap->registerTypeHandler(new OuiNonBool()); + + $list = $this->sqlmap->QueryForList("GetAllAccountsViaCustomTypeHandler"); + + $this->assertAccount1($list[0]); + $this->assertIdentical(5, count($list)); + $this->assertIdentical(1, $list[0]->getID()); + $this->assertIdentical(2, $list[1]->getID()); + $this->assertIdentical(3, $list[2]->getID()); + $this->assertIdentical(4, $list[3]->getID()); + $this->assertIdentical(5, $list[4]->getID()); + + $this->assertFalse($list[0]->getCartOptions()); + $this->assertFalse($list[1]->getCartOptions()); + $this->assertTrue($list[2]->getCartOptions()); + $this->assertTrue($list[3]->getCartOptions()); + $this->assertTrue($list[4]->getCartOptions()); + + $this->assertTrue($list[0]->getBannerOptions()); + $this->assertTrue($list[1]->getBannerOptions()); + $this->assertFalse($list[2]->getBannerOptions()); + $this->assertFalse($list[3]->getBannerOptions()); + $this->assertTrue($list[4]->getBannerOptions()); + } + + /** + * Test CustomTypeHandler Oui/Non + */ + function testCustomTypeHandler() + { + $this->initScript('other-init.sql'); + $this->initScript('account-init.sql'); + + $this->sqlmap->registerTypeHandler(new OuiNonBool()); + + $other = new Other(); + $other->setInt(99); + $other->setLong(1966); + $other->setBool(true); + $other->setBool2(false); + $this->sqlmap->Insert("InsertCustomTypeHandler", $other); + + $anOther = $this->sqlmap->QueryForObject("SelectByInt", 99); + $this->assertNotNull( $anOther ); + $this->assertIdentical(99, (int)$anOther->getInt()); + $this->assertIdentical(1966, (int)$anOther->getLong()); + $this->assertIdentical(true, (boolean)$anOther->getBool()); + $this->assertIdentical(false, (boolean)$anOther->getBool2()); + + } + + /** + * Test CustomTypeHandler Oui/Non + */ + function testInsertInlineCustomTypeHandlerV1() + { + $this->initScript('other-init.sql'); + $this->initScript('account-init.sql'); + + $other = new Other(); + $other->setInt(99); + $other->setLong(1966); + $other->setBool(true); + $other->setBool2(false); + + $this->sqlmap->Insert("InsertInlineCustomTypeHandlerV1", $other); + + $anOther = $this->sqlmap->QueryForObject("SelectByIntV1", 99); + + $this->assertNotNull( $anOther ); + $this->assertIdentical(99, (int)$anOther->getInt()); + $this->assertIdentical(1966, (int)$anOther->getLong()); + $this->assertIdentical(true, (boolean)$anOther->getBool()); + $this->assertIdentical(false, (boolean)$anOther->getBool2()); + + } + + /** + * Test CustomTypeHandler Oui/Non + */ + function testInsertInlineCustomTypeHandlerV2() + { + $this->initScript('other-init.sql'); + $this->initScript('account-init.sql'); + + $other = new Other(); + $other->setInt(99); + $other->setLong(1966); + $other->setBool(true); + $other->setBool2(false); + + $this->sqlmap->Insert("InsertInlineCustomTypeHandlerV2", $other); + + $anOther = $this->sqlmap->QueryForObject("SelectByInt", 99); + + $this->assertNotNull( $anOther ); + $this->assertIdentical(99, (int)$anOther->getInt()); + $this->assertIdentical(1966, (int)$anOther->getLong()); + $this->assertIdentical(true, (boolean)$anOther->getBool()); + $this->assertIdentical(false, (boolean)$anOther->getBool2()); + } + #endregion + /**/ +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/TestQueryForMap.php b/tests/simple_unit/SqlMap/TestQueryForMap.php index 25ef2f4d..89676469 100644 --- a/tests/simple_unit/SqlMap/TestQueryForMap.php +++ b/tests/simple_unit/SqlMap/TestQueryForMap.php @@ -1,43 +1,43 @@ -<?php
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-class TestQueryForMap extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- }
-
- /**
- * Test ExecuteQueryForMap : Hashtable.
- */
- function testExecuteQueryForMap()
- {
- $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, "FirstName",null,0,2);
- $this->assertIdentical(2, count($map));
- $this->assertAccount1($map["Joe"]);
-
- $this->assertIdentical(1, $map["Joe"]->getID());
- $this->assertIdentical(2, $map["Averel"]->getID());
- }
-
- /**
- * Test ExecuteQueryForMap with value property :
- * "FirstName" as key, "EmailAddress" as value
- */
- function testExecuteQueryForMapWithValueProperty()
- {
- $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null,
- "FirstName", "EmailAddress",1,3);
-
- $this->assertIdentical(3, count($map));
-
- $this->assertIdentical("Averel.Dalton@somewhere.com", $map["Averel"]);
- $this->assertNull($map["William"]);
- $this->assertIdentical("Jack.Dalton@somewhere.com", $map["Jack"]);
- }
-
-}
-
+<?php +require_once(dirname(__FILE__).'/BaseCase.php'); + +class TestQueryForMap extends BaseCase +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + } + + /** + * Test ExecuteQueryForMap : Hashtable. + */ + function testExecuteQueryForMap() + { + $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, "FirstName",null,0,2); + $this->assertIdentical(2, count($map)); + $this->assertAccount1($map["Joe"]); + + $this->assertIdentical(1, $map["Joe"]->getID()); + $this->assertIdentical(2, $map["Averel"]->getID()); + } + + /** + * Test ExecuteQueryForMap with value property : + * "FirstName" as key, "EmailAddress" as value + */ + function testExecuteQueryForMapWithValueProperty() + { + $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, + "FirstName", "EmailAddress",1,3); + + $this->assertIdentical(3, count($map)); + + $this->assertIdentical("Averel.Dalton@somewhere.com", $map["Averel"]); + $this->assertNull($map["William"]); + $this->assertIdentical("Jack.Dalton@somewhere.com", $map["Jack"]); + } + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/common.php b/tests/simple_unit/SqlMap/common.php index aaba8c80..5146d123 100644 --- a/tests/simple_unit/SqlMap/common.php +++ b/tests/simple_unit/SqlMap/common.php @@ -1,155 +1,155 @@ -<?php
-
-Prado::using('System.Data.TDbConnection');
-
-if(!defined('SQLMAP_TESTS'))
- define('SQLMAP_TESTS', realpath(dirname(__FILE__)));
-
-if(!class_exists('Account', false))
-{
- include(SQLMAP_TESTS.'/domain/A.php');
- include(SQLMAP_TESTS.'/domain/Account.php');
- include(SQLMAP_TESTS.'/domain/AccountBis.php');
- include(SQLMAP_TESTS.'/domain/AccountCollection.php');
- include(SQLMAP_TESTS.'/domain/B.php');
- include(SQLMAP_TESTS.'/domain/Document.php');
- include(SQLMAP_TESTS.'/domain/Book.php');
- include(SQLMAP_TESTS.'/domain/C.php');
- include(SQLMAP_TESTS.'/domain/Category.php');
- include(SQLMAP_TESTS.'/domain/Complex.php');
- include(SQLMAP_TESTS.'/domain/D.php');
- include(SQLMAP_TESTS.'/domain/DocumentCollection.php');
- include(SQLMAP_TESTS.'/domain/E.php');
- include(SQLMAP_TESTS.'/domain/F.php');
- include(SQLMAP_TESTS.'/domain/LineItem.php');
- include(SQLMAP_TESTS.'/domain/LineItemCollection.php');
- include(SQLMAP_TESTS.'/domain/Newspaper.php');
- include(SQLMAP_TESTS.'/domain/Order.php');
- include(SQLMAP_TESTS.'/domain/Other.php');
- include(SQLMAP_TESTS.'/domain/Sample.php');
- include(SQLMAP_TESTS.'/domain/Search.php');
- include(SQLMAP_TESTS.'/domain/User.php');
-}
-
-class DefaultScriptRunner
-{
- function runScript($connection, $script)
- {
- $sql = file_get_contents($script);
- $lines = explode(';', $sql);
- foreach($lines as $line)
- {
- $line = trim($line);
- if(strlen($line) > 0)
- $connection->createCommand($line)->execute();
- }
- }
-}
-
-class CopyFileScriptRunner
-{
- protected $baseFile;
- protected $targetFile;
-
- public function __construct($base, $target)
- {
- $this->baseFile = $base;
- $this->targetFile = $target;
- }
-
- function runScript($connection, $script)
- {
- copy($this->baseFile, $this->targetFile);
- }
-}
-
-class SQLiteBaseTestConfig extends BaseTestConfig
-{
- protected $baseFile;
- protected $targetFile;
-
- public function __construct()
- {
- $this->_sqlmapConfigFile = SQLMAP_TESTS.'/sqlite.xml';
- $this->_scriptDir = SQLMAP_TESTS.'/scripts/sqlite/';
-
- $this->targetFile = realpath(SQLMAP_TESTS.'/sqlite/tests.db');
- $this->baseFile = realpath(SQLMAP_TESTS.'/sqlite/backup.db');
- $file = realpath($this->targetFile);
- $this->_connection = new TDbConnection("sqlite:{$file}");
- }
-
- public function getScriptRunner()
- {
- return new CopyFileScriptRunner($this->baseFile, $this->targetFile);
- }
-}
-
-class MySQLBaseTestConfig extends BaseTestConfig
-{
- public function __construct()
- {
- $this->_sqlmapConfigFile = SQLMAP_TESTS.'/mysql.xml';
- $this->_scriptDir = SQLMAP_TESTS.'/scripts/mysql/';
- $this->_features = array('insert_id');
- $dsn = 'mysql:host=localhost;dbname=sqlmap_test;port=3307';
- $this->_connection = new TDbConnection($dsn, 'test5', 'test5');
- }
-}
-
-class MSSQLBaseTestConfig extends BaseTestConfig
-{
- public function __construct()
- {
- $this->_sqlmap = SQLMAP_TESTS.'/mssql.xml';
- $this->_connectionString = 'odbc_mssql://sqlmap_tests';
- $this->_scriptDir = SQLMAP_TESTS.'/scripts/mssql/';
- $this->_features = array('insert_id');
- }
-}
-
-class BaseTestConfig
-{
- protected $_scriptDir;
- protected $_connection;
- protected $_sqlmapConfigFile;
-
- public function hasFeature($type)
- {
- return false;
- }
-
- public function getScriptDir()
- {
- return $this->_scriptDir;
- }
-
- public function getConnection()
- {
- return $this->_connection;
- }
-
- public function getSqlMapConfigFile()
- {
- return $this->_sqlmapConfigFile;
- }
-
- public function getScriptRunner()
- {
- return new DefaultScriptRunner();
- }
-
- public static function createConfigInstance()
- {
- //change this to connection to a different database
-
- //return new MySQLBaseTestConfig();
-
- return new SQLiteBaseTestConfig();
-
- //return new MSSQLBaseTestConfig();
- }
-}
-
-
+<?php + +Prado::using('System.Data.TDbConnection'); + +if(!defined('SQLMAP_TESTS')) + define('SQLMAP_TESTS', realpath(dirname(__FILE__))); + +if(!class_exists('Account', false)) +{ + include(SQLMAP_TESTS.'/domain/A.php'); + include(SQLMAP_TESTS.'/domain/Account.php'); + include(SQLMAP_TESTS.'/domain/AccountBis.php'); + include(SQLMAP_TESTS.'/domain/AccountCollection.php'); + include(SQLMAP_TESTS.'/domain/B.php'); + include(SQLMAP_TESTS.'/domain/Document.php'); + include(SQLMAP_TESTS.'/domain/Book.php'); + include(SQLMAP_TESTS.'/domain/C.php'); + include(SQLMAP_TESTS.'/domain/Category.php'); + include(SQLMAP_TESTS.'/domain/Complex.php'); + include(SQLMAP_TESTS.'/domain/D.php'); + include(SQLMAP_TESTS.'/domain/DocumentCollection.php'); + include(SQLMAP_TESTS.'/domain/E.php'); + include(SQLMAP_TESTS.'/domain/F.php'); + include(SQLMAP_TESTS.'/domain/LineItem.php'); + include(SQLMAP_TESTS.'/domain/LineItemCollection.php'); + include(SQLMAP_TESTS.'/domain/Newspaper.php'); + include(SQLMAP_TESTS.'/domain/Order.php'); + include(SQLMAP_TESTS.'/domain/Other.php'); + include(SQLMAP_TESTS.'/domain/Sample.php'); + include(SQLMAP_TESTS.'/domain/Search.php'); + include(SQLMAP_TESTS.'/domain/User.php'); +} + +class DefaultScriptRunner +{ + function runScript($connection, $script) + { + $sql = file_get_contents($script); + $lines = explode(';', $sql); + foreach($lines as $line) + { + $line = trim($line); + if(strlen($line) > 0) + $connection->createCommand($line)->execute(); + } + } +} + +class CopyFileScriptRunner +{ + protected $baseFile; + protected $targetFile; + + public function __construct($base, $target) + { + $this->baseFile = $base; + $this->targetFile = $target; + } + + function runScript($connection, $script) + { + copy($this->baseFile, $this->targetFile); + } +} + +class SQLiteBaseTestConfig extends BaseTestConfig +{ + protected $baseFile; + protected $targetFile; + + public function __construct() + { + $this->_sqlmapConfigFile = SQLMAP_TESTS.'/sqlite.xml'; + $this->_scriptDir = SQLMAP_TESTS.'/scripts/sqlite/'; + + $this->targetFile = realpath(SQLMAP_TESTS.'/sqlite/tests.db'); + $this->baseFile = realpath(SQLMAP_TESTS.'/sqlite/backup.db'); + $file = realpath($this->targetFile); + $this->_connection = new TDbConnection("sqlite:{$file}"); + } + + public function getScriptRunner() + { + return new CopyFileScriptRunner($this->baseFile, $this->targetFile); + } +} + +class MySQLBaseTestConfig extends BaseTestConfig +{ + public function __construct() + { + $this->_sqlmapConfigFile = SQLMAP_TESTS.'/mysql.xml'; + $this->_scriptDir = SQLMAP_TESTS.'/scripts/mysql/'; + $this->_features = array('insert_id'); + $dsn = 'mysql:host=localhost;dbname=sqlmap_test;port=3307'; + $this->_connection = new TDbConnection($dsn, 'test5', 'test5'); + } +} + +class MSSQLBaseTestConfig extends BaseTestConfig +{ + public function __construct() + { + $this->_sqlmap = SQLMAP_TESTS.'/mssql.xml'; + $this->_connectionString = 'odbc_mssql://sqlmap_tests'; + $this->_scriptDir = SQLMAP_TESTS.'/scripts/mssql/'; + $this->_features = array('insert_id'); + } +} + +class BaseTestConfig +{ + protected $_scriptDir; + protected $_connection; + protected $_sqlmapConfigFile; + + public function hasFeature($type) + { + return false; + } + + public function getScriptDir() + { + return $this->_scriptDir; + } + + public function getConnection() + { + return $this->_connection; + } + + public function getSqlMapConfigFile() + { + return $this->_sqlmapConfigFile; + } + + public function getScriptRunner() + { + return new DefaultScriptRunner(); + } + + public static function createConfigInstance() + { + //change this to connection to a different database + + //return new MySQLBaseTestConfig(); + + return new SQLiteBaseTestConfig(); + + //return new MSSQLBaseTestConfig(); + } +} + + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/A.php b/tests/simple_unit/SqlMap/domain/A.php index 6830ea4d..af1f925d 100644 --- a/tests/simple_unit/SqlMap/domain/A.php +++ b/tests/simple_unit/SqlMap/domain/A.php @@ -1,27 +1,27 @@ -<?php
-
-class A
-{
- private $_ID='';
- private $_Libelle='';
- private $_B='';
- private $_E='';
- private $_F='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-
- public function getB(){ return $this->_B; }
- public function setB($value){ $this->_B = $value; }
-
- public function getE(){ return $this->_E; }
- public function setE($value){ $this->_E = $value; }
-
- public function getF(){ return $this->_F; }
- public function setF($value){ $this->_F = $value; }
-}
-
+<?php + +class A +{ + private $_ID=''; + private $_Libelle=''; + private $_B=''; + private $_E=''; + private $_F=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } + + public function getB(){ return $this->_B; } + public function setB($value){ $this->_B = $value; } + + public function getE(){ return $this->_E; } + public function setE($value){ $this->_E = $value; } + + public function getF(){ return $this->_F; } + public function setF($value){ $this->_F = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/Account.php b/tests/simple_unit/SqlMap/domain/Account.php index f01726ba..9502eb85 100644 --- a/tests/simple_unit/SqlMap/domain/Account.php +++ b/tests/simple_unit/SqlMap/domain/Account.php @@ -1,36 +1,36 @@ -<?php
-
-class Account
-{
- private $_ID=0;
- private $_FirstName='';
- private $_LastName='';
- private $_EmailAddress=null;
- private $_IDS='';
- private $_BannerOptions=0;
- private $_CartOptions=0;
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = intval($value); }
-
- public function getFirstName(){ return $this->_FirstName; }
- public function setFirstName($value){ $this->_FirstName = $value; }
-
- public function getLastName(){ return $this->_LastName; }
- public function setLastName($value){ $this->_LastName = $value; }
-
- public function getEmailAddress(){ return $this->_EmailAddress; }
- public function setEmailAddress($value){ $this->_EmailAddress = $value; }
-
- public function getIDS(){ return $this->_IDS; }
- public function setIDS($value){ $this->_IDS = $value; }
-
- public function getBannerOptions(){ return $this->_BannerOptions; }
- public function setBannerOptions($value){ $this->_BannerOptions = $value; }
-
- public function getCartOptions(){ return $this->_CartOptions; }
- public function setCartOptions($value){ $this->_CartOptions = $value; }
-
-}
-
+<?php + +class Account +{ + private $_ID=0; + private $_FirstName=''; + private $_LastName=''; + private $_EmailAddress=null; + private $_IDS=''; + private $_BannerOptions=0; + private $_CartOptions=0; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = intval($value); } + + public function getFirstName(){ return $this->_FirstName; } + public function setFirstName($value){ $this->_FirstName = $value; } + + public function getLastName(){ return $this->_LastName; } + public function setLastName($value){ $this->_LastName = $value; } + + public function getEmailAddress(){ return $this->_EmailAddress; } + public function setEmailAddress($value){ $this->_EmailAddress = $value; } + + public function getIDS(){ return $this->_IDS; } + public function setIDS($value){ $this->_IDS = $value; } + + public function getBannerOptions(){ return $this->_BannerOptions; } + public function setBannerOptions($value){ $this->_BannerOptions = $value; } + + public function getCartOptions(){ return $this->_CartOptions; } + public function setCartOptions($value){ $this->_CartOptions = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/AccountBis.php b/tests/simple_unit/SqlMap/domain/AccountBis.php index 8c96d8e4..d454f2a8 100644 --- a/tests/simple_unit/SqlMap/domain/AccountBis.php +++ b/tests/simple_unit/SqlMap/domain/AccountBis.php @@ -1,13 +1,13 @@ -<?php
-
-class AccountBis
-{
- public $Id;
- public $FirstName;
- public $LastName;
- public $EmailAddress;
- public $More;
-}
-
-
+<?php + +class AccountBis +{ + public $Id; + public $FirstName; + public $LastName; + public $EmailAddress; + public $More; +} + + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/AccountCollection.php b/tests/simple_unit/SqlMap/domain/AccountCollection.php index 9fc8edb7..b14ece5e 100644 --- a/tests/simple_unit/SqlMap/domain/AccountCollection.php +++ b/tests/simple_unit/SqlMap/domain/AccountCollection.php @@ -1,17 +1,17 @@ -<?php
-
-class AccountCollection extends TList
-{
- public function addRange($accounts)
- {
- foreach($accounts as $account)
- $this->add($account);
- }
-
- public function copyTo(TList $array)
- {
- $array->copyFrom($this);
- }
-}
-
+<?php + +class AccountCollection extends TList +{ + public function addRange($accounts) + { + foreach($accounts as $account) + $this->add($account); + } + + public function copyTo(TList $array) + { + $array->copyFrom($this); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/B.php b/tests/simple_unit/SqlMap/domain/B.php index a05e21d4..788b804e 100644 --- a/tests/simple_unit/SqlMap/domain/B.php +++ b/tests/simple_unit/SqlMap/domain/B.php @@ -1,23 +1,23 @@ -<?php
-
-class B
-{
- private $_C='';
- private $_D='';
- private $_ID='';
- private $_Libelle='';
-
- public function getC(){ return $this->_C; }
- public function setC($value){ $this->_C = $value; }
-
- public function getD(){ return $this->_D; }
- public function setD($value){ $this->_D = $value; }
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-}
-
+<?php + +class B +{ + private $_C=''; + private $_D=''; + private $_ID=''; + private $_Libelle=''; + + public function getC(){ return $this->_C; } + public function setC($value){ $this->_C = $value; } + + public function getD(){ return $this->_D; } + public function setD($value){ $this->_D = $value; } + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/Book.php b/tests/simple_unit/SqlMap/domain/Book.php index cc12c30e..80877112 100644 --- a/tests/simple_unit/SqlMap/domain/Book.php +++ b/tests/simple_unit/SqlMap/domain/Book.php @@ -1,11 +1,11 @@ -<?php
-
-class Book extends Document
-{
- private $_PageNumber='';
-
- public function getPageNumber(){ return $this->_PageNumber; }
- public function setPageNumber($value){ $this->_PageNumber = $value; }
-}
-
+<?php + +class Book extends Document +{ + private $_PageNumber=''; + + public function getPageNumber(){ return $this->_PageNumber; } + public function setPageNumber($value){ $this->_PageNumber = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/C.php b/tests/simple_unit/SqlMap/domain/C.php index 09fb456a..47118d44 100644 --- a/tests/simple_unit/SqlMap/domain/C.php +++ b/tests/simple_unit/SqlMap/domain/C.php @@ -1,15 +1,15 @@ -<?php
-
-class C
-{
- private $_ID='';
- private $_Libelle='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-}
-
+<?php + +class C +{ + private $_ID=''; + private $_Libelle=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/Category.php b/tests/simple_unit/SqlMap/domain/Category.php index 83fecc7e..db76edb4 100644 --- a/tests/simple_unit/SqlMap/domain/Category.php +++ b/tests/simple_unit/SqlMap/domain/Category.php @@ -1,19 +1,19 @@ -<?php
-
-class Category
-{
- private $_ID=-1;
- private $_Name='';
- private $_Guid='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getName(){ return $this->_Name; }
- public function setName($value){ $this->_Name = $value; }
-
- public function getGuidString(){ return $this->_Guid; }
- public function setGuidString($value){ $this->_Guid = $value; }
-}
-
+<?php + +class Category +{ + private $_ID=-1; + private $_Name=''; + private $_Guid=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getName(){ return $this->_Name; } + public function setName($value){ $this->_Name = $value; } + + public function getGuidString(){ return $this->_Guid; } + public function setGuidString($value){ $this->_Guid = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/Complex.php b/tests/simple_unit/SqlMap/domain/Complex.php index 92b500f4..99cb04b8 100644 --- a/tests/simple_unit/SqlMap/domain/Complex.php +++ b/tests/simple_unit/SqlMap/domain/Complex.php @@ -1,11 +1,11 @@ -<?php
-
-class Complex
-{
- private $_map;
-
- public function getMap(){ return $this->_map; }
- public function setMap(TMap $map){ $this->_map = $map; }
-}
-
+<?php + +class Complex +{ + private $_map; + + public function getMap(){ return $this->_map; } + public function setMap(TMap $map){ $this->_map = $map; } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/D.php b/tests/simple_unit/SqlMap/domain/D.php index 5d1baabd..2cbd2883 100644 --- a/tests/simple_unit/SqlMap/domain/D.php +++ b/tests/simple_unit/SqlMap/domain/D.php @@ -1,16 +1,16 @@ -<?php
-
-class D
-{
- private $_ID='';
- private $_Libelle='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-
-}
-
+<?php + +class D +{ + private $_ID=''; + private $_Libelle=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/Document.php b/tests/simple_unit/SqlMap/domain/Document.php index 63bcfd33..682f8eb3 100644 --- a/tests/simple_unit/SqlMap/domain/Document.php +++ b/tests/simple_unit/SqlMap/domain/Document.php @@ -1,16 +1,16 @@ -<?php
-
-class Document
-{
- private $_ID='';
- private $_Title='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getTitle(){ return $this->_Title; }
- public function setTitle($value){ $this->_Title = $value; }
-
-}
-
+<?php + +class Document +{ + private $_ID=''; + private $_Title=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getTitle(){ return $this->_Title; } + public function setTitle($value){ $this->_Title = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/DocumentCollection.php b/tests/simple_unit/SqlMap/domain/DocumentCollection.php index c15b6f7d..c130db56 100644 --- a/tests/simple_unit/SqlMap/domain/DocumentCollection.php +++ b/tests/simple_unit/SqlMap/domain/DocumentCollection.php @@ -1,8 +1,8 @@ -<?php
-
-class DocumentCollection extends TList
-{
-
-}
-
+<?php + +class DocumentCollection extends TList +{ + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/E.php b/tests/simple_unit/SqlMap/domain/E.php index 2c80bb46..8473c156 100644 --- a/tests/simple_unit/SqlMap/domain/E.php +++ b/tests/simple_unit/SqlMap/domain/E.php @@ -1,16 +1,16 @@ -<?php
-
-class E
-{
- private $_ID='';
- private $_Libelle='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-
-}
-
+<?php + +class E +{ + private $_ID=''; + private $_Libelle=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/F.php b/tests/simple_unit/SqlMap/domain/F.php index b1090cc6..2bbbb2fb 100644 --- a/tests/simple_unit/SqlMap/domain/F.php +++ b/tests/simple_unit/SqlMap/domain/F.php @@ -1,16 +1,16 @@ -<?php
-
-class F
-{
- private $_ID='';
- private $_Libelle='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-
-}
-
+<?php + +class F +{ + private $_ID=''; + private $_Libelle=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/LineItem.php b/tests/simple_unit/SqlMap/domain/LineItem.php index d851da6c..f6908bbd 100644 --- a/tests/simple_unit/SqlMap/domain/LineItem.php +++ b/tests/simple_unit/SqlMap/domain/LineItem.php @@ -1,32 +1,32 @@ -<?php
-
-class LineItem
-{
- private $_ID=-1;
- private $_Order='';
- private $_Code='';
- private $_Quantity=-1;
- private $_Price=0.0;
- private $_PictureData='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getOrder(){ return $this->_Order; }
- public function setOrder($value){ $this->_Order = $value; }
-
- public function getCode(){ return $this->_Code; }
- public function setCode($value){ $this->_Code = $value; }
-
- public function getQuantity(){ return $this->_Quantity; }
- public function setQuantity($value){ $this->_Quantity = $value; }
-
- public function getPrice(){ return $this->_Price; }
- public function setPrice($value){ $this->_Price = $value; }
-
- public function getPictureData(){ return $this->_PictureData; }
- public function setPictureData($value){ $this->_PictureData = $value; }
-
-}
-
+<?php + +class LineItem +{ + private $_ID=-1; + private $_Order=''; + private $_Code=''; + private $_Quantity=-1; + private $_Price=0.0; + private $_PictureData=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getOrder(){ return $this->_Order; } + public function setOrder($value){ $this->_Order = $value; } + + public function getCode(){ return $this->_Code; } + public function setCode($value){ $this->_Code = $value; } + + public function getQuantity(){ return $this->_Quantity; } + public function setQuantity($value){ $this->_Quantity = $value; } + + public function getPrice(){ return $this->_Price; } + public function setPrice($value){ $this->_Price = $value; } + + public function getPictureData(){ return $this->_PictureData; } + public function setPictureData($value){ $this->_PictureData = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/LineItemCollection.php b/tests/simple_unit/SqlMap/domain/LineItemCollection.php index f177487c..8bc95622 100644 --- a/tests/simple_unit/SqlMap/domain/LineItemCollection.php +++ b/tests/simple_unit/SqlMap/domain/LineItemCollection.php @@ -1,8 +1,8 @@ -<?php
-
-class LineItemCollection extends TList
-{
-
-}
-
+<?php + +class LineItemCollection extends TList +{ + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/Newspaper.php b/tests/simple_unit/SqlMap/domain/Newspaper.php index 4eb56aa2..08716c6d 100644 --- a/tests/simple_unit/SqlMap/domain/Newspaper.php +++ b/tests/simple_unit/SqlMap/domain/Newspaper.php @@ -1,12 +1,12 @@ -<?php
-
-class Newspaper extends Document
-{
- private $_City='';
-
- public function getCity(){ return $this->_City; }
- public function setCity($value){ $this->_City = $value; }
-
-}
-
+<?php + +class Newspaper extends Document +{ + private $_City=''; + + public function getCity(){ return $this->_City; } + public function setCity($value){ $this->_City = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/Order.php b/tests/simple_unit/SqlMap/domain/Order.php index 65d18b13..312626fe 100644 --- a/tests/simple_unit/SqlMap/domain/Order.php +++ b/tests/simple_unit/SqlMap/domain/Order.php @@ -1,71 +1,71 @@ -<?php
-
-class Order
-{
- private $_ID=-1;
- private $_Account='';
- private $_Date='';
- private $_CardType='';
- private $_CardExpiry='';
- private $_CardNumber='';
- private $_Street='';
- private $_City='';
- private $_Province='';
- private $_PostalCode='';
- private $_LineItemsList='';
- private $_LineItems=null;
- private $_LineItemsArray=array();
- private $_FavouriteLineItem=null;
-
- public function __construct()
- {
- $this->_LineItemsList = new TList;
- $this->_LineItems = new TList;
- $this->_FavouriteLineItem = new LineItem;
- }
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getAccount(){ return $this->_Account; }
- public function setAccount($value){ $this->_Account = $value; }
-
- public function getDate(){ return $this->_Date; }
- public function setDate($value){ $this->_Date = $value; }
-
- public function getCardType(){ return $this->_CardType; }
- public function setCardType($value){ $this->_CardType = $value; }
-
- public function getCardExpiry(){ return $this->_CardExpiry; }
- public function setCardExpiry($value){ $this->_CardExpiry = $value; }
-
- public function getCardNumber(){ return $this->_CardNumber; }
- public function setCardNumber($value){ $this->_CardNumber = $value; }
-
- public function getStreet(){ return $this->_Street; }
- public function setStreet($value){ $this->_Street = $value; }
-
- public function getCity(){ return $this->_City; }
- public function setCity($value){ $this->_City = $value; }
-
- public function getProvince(){ return $this->_Province; }
- public function setProvince($value){ $this->_Province = $value; }
-
- public function getPostalCode(){ return $this->_PostalCode; }
- public function setPostalCode($value){ $this->_PostalCode = $value; }
-
- public function getLineItemsList(){ return $this->_LineItemsList; }
- public function setLineItemsList($value){ $this->_LineItemsList = $value; }
-
- public function getLineItems(){ return $this->_LineItems; }
- public function setLineItems($value){ $this->_LineItems = $value; }
-
- public function getLineItemsArray(){ return $this->_LineItemsArray; }
- public function setLineItemsArray($value){ $this->_LineItemsArray = $value; }
-
- public function getFavouriteLineItem(){ return $this->_FavouriteLineItem; }
- public function setFavouriteLineItem($value){ $this->_FavouriteLineItem = $value; }
-
-}
-
+<?php + +class Order +{ + private $_ID=-1; + private $_Account=''; + private $_Date=''; + private $_CardType=''; + private $_CardExpiry=''; + private $_CardNumber=''; + private $_Street=''; + private $_City=''; + private $_Province=''; + private $_PostalCode=''; + private $_LineItemsList=''; + private $_LineItems=null; + private $_LineItemsArray=array(); + private $_FavouriteLineItem=null; + + public function __construct() + { + $this->_LineItemsList = new TList; + $this->_LineItems = new TList; + $this->_FavouriteLineItem = new LineItem; + } + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getAccount(){ return $this->_Account; } + public function setAccount($value){ $this->_Account = $value; } + + public function getDate(){ return $this->_Date; } + public function setDate($value){ $this->_Date = $value; } + + public function getCardType(){ return $this->_CardType; } + public function setCardType($value){ $this->_CardType = $value; } + + public function getCardExpiry(){ return $this->_CardExpiry; } + public function setCardExpiry($value){ $this->_CardExpiry = $value; } + + public function getCardNumber(){ return $this->_CardNumber; } + public function setCardNumber($value){ $this->_CardNumber = $value; } + + public function getStreet(){ return $this->_Street; } + public function setStreet($value){ $this->_Street = $value; } + + public function getCity(){ return $this->_City; } + public function setCity($value){ $this->_City = $value; } + + public function getProvince(){ return $this->_Province; } + public function setProvince($value){ $this->_Province = $value; } + + public function getPostalCode(){ return $this->_PostalCode; } + public function setPostalCode($value){ $this->_PostalCode = $value; } + + public function getLineItemsList(){ return $this->_LineItemsList; } + public function setLineItemsList($value){ $this->_LineItemsList = $value; } + + public function getLineItems(){ return $this->_LineItems; } + public function setLineItems($value){ $this->_LineItems = $value; } + + public function getLineItemsArray(){ return $this->_LineItemsArray; } + public function setLineItemsArray($value){ $this->_LineItemsArray = $value; } + + public function getFavouriteLineItem(){ return $this->_FavouriteLineItem; } + public function setFavouriteLineItem($value){ $this->_FavouriteLineItem = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/Other.php b/tests/simple_unit/SqlMap/domain/Other.php index 32d85e90..9e78ab97 100644 --- a/tests/simple_unit/SqlMap/domain/Other.php +++ b/tests/simple_unit/SqlMap/domain/Other.php @@ -1,23 +1,23 @@ -<?php
-
-class Other
-{
- private $_Int=-1;
- private $_Long=-1;
- private $_Bool=false;
- private $_Bool2=false;
-
- public function getBool2(){ return $this->_Bool2; }
- public function setBool2($value){ $this->_Bool2 = $value; }
-
- public function getBool(){ return $this->_Bool; }
- public function setBool($value){ $this->_Bool = $value; }
-
- public function getInt(){ return $this->_Int; }
- public function setInt($value){ $this->_Int = $value; }
-
- public function getLong(){ return $this->_Long; }
- public function setLong($value){ $this->_Long = $value; }
-}
-
+<?php + +class Other +{ + private $_Int=-1; + private $_Long=-1; + private $_Bool=false; + private $_Bool2=false; + + public function getBool2(){ return $this->_Bool2; } + public function setBool2($value){ $this->_Bool2 = $value; } + + public function getBool(){ return $this->_Bool; } + public function setBool($value){ $this->_Bool = $value; } + + public function getInt(){ return $this->_Int; } + public function setInt($value){ $this->_Int = $value; } + + public function getLong(){ return $this->_Long; } + public function setLong($value){ $this->_Long = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/Sample.php b/tests/simple_unit/SqlMap/domain/Sample.php index c9a34601..e03be2df 100644 --- a/tests/simple_unit/SqlMap/domain/Sample.php +++ b/tests/simple_unit/SqlMap/domain/Sample.php @@ -1,55 +1,55 @@ -<?php
-
-class Sample
-{
- private $_FirstID='';
- private $_SecondID='';
- private $_ThirdID='';
- private $_FourthID='';
- private $_FifthID='';
- private $_SequenceID='';
- private $_DistributedID='';
- private $_SampleChar='';
- private $_SampleDecimal='';
- private $_SampleMoney='';
- private $_SampleDate='';
- private $_SequenceDate='';
-
- public function getFirstID(){ return $this->_FirstID; }
- public function setFirstID($value){ $this->_FirstID = $value; }
-
- public function getSecondID(){ return $this->_SecondID; }
- public function setSecondID($value){ $this->_SecondID = $value; }
-
- public function getThirdID(){ return $this->_ThirdID; }
- public function setThirdID($value){ $this->_ThirdID = $value; }
-
- public function getFourthID(){ return $this->_FourthID; }
- public function setFourthID($value){ $this->_FourthID = $value; }
-
- public function getFifthID(){ return $this->_FifthID; }
- public function setFifthID($value){ $this->_FifthID = $value; }
-
- public function getSequenceID(){ return $this->_SequenceID; }
- public function setSequenceID($value){ $this->_SequenceID = $value; }
-
- public function getDistributedID(){ return $this->_DistributedID; }
- public function setDistributedID($value){ $this->_DistributedID = $value; }
-
- public function getSampleChar(){ return $this->_SampleChar; }
- public function setSampleChar($value){ $this->_SampleChar = $value; }
-
- public function getSampleDecimal(){ return $this->_SampleDecimal; }
- public function setSampleDecimal($value){ $this->_SampleDecimal = $value; }
-
- public function getSampleMoney(){ return $this->_SampleMoney; }
- public function setSampleMoney($value){ $this->_SampleMoney = $value; }
-
- public function getSampleDate(){ return $this->_SampleDate; }
- public function setSampleDate($value){ $this->_SampleDate = $value; }
-
- public function getSequenceDate(){ return $this->_SequenceDate; }
- public function setSequenceDate($value){ $this->_SequenceDate = $value; }
-}
-
+<?php + +class Sample +{ + private $_FirstID=''; + private $_SecondID=''; + private $_ThirdID=''; + private $_FourthID=''; + private $_FifthID=''; + private $_SequenceID=''; + private $_DistributedID=''; + private $_SampleChar=''; + private $_SampleDecimal=''; + private $_SampleMoney=''; + private $_SampleDate=''; + private $_SequenceDate=''; + + public function getFirstID(){ return $this->_FirstID; } + public function setFirstID($value){ $this->_FirstID = $value; } + + public function getSecondID(){ return $this->_SecondID; } + public function setSecondID($value){ $this->_SecondID = $value; } + + public function getThirdID(){ return $this->_ThirdID; } + public function setThirdID($value){ $this->_ThirdID = $value; } + + public function getFourthID(){ return $this->_FourthID; } + public function setFourthID($value){ $this->_FourthID = $value; } + + public function getFifthID(){ return $this->_FifthID; } + public function setFifthID($value){ $this->_FifthID = $value; } + + public function getSequenceID(){ return $this->_SequenceID; } + public function setSequenceID($value){ $this->_SequenceID = $value; } + + public function getDistributedID(){ return $this->_DistributedID; } + public function setDistributedID($value){ $this->_DistributedID = $value; } + + public function getSampleChar(){ return $this->_SampleChar; } + public function setSampleChar($value){ $this->_SampleChar = $value; } + + public function getSampleDecimal(){ return $this->_SampleDecimal; } + public function setSampleDecimal($value){ $this->_SampleDecimal = $value; } + + public function getSampleMoney(){ return $this->_SampleMoney; } + public function setSampleMoney($value){ $this->_SampleMoney = $value; } + + public function getSampleDate(){ return $this->_SampleDate; } + public function setSampleDate($value){ $this->_SampleDate = $value; } + + public function getSequenceDate(){ return $this->_SequenceDate; } + public function setSequenceDate($value){ $this->_SequenceDate = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/Search.php b/tests/simple_unit/SqlMap/domain/Search.php index a09ca6e6..c01891a9 100644 --- a/tests/simple_unit/SqlMap/domain/Search.php +++ b/tests/simple_unit/SqlMap/domain/Search.php @@ -1,23 +1,23 @@ -<?php
-
-class Search
-{
- private $_NumberSearch='';
- private $_StartDate='';
- private $_Operande='';
- private $_StartDateAnd='';
-
- public function getNumberSearch(){ return $this->_NumberSearch; }
- public function setNumberSearch($value){ $this->_NumberSearch = $value; }
-
- public function getStartDate(){ return $this->_StartDate; }
- public function setStartDate($value){ $this->_StartDate = $value; }
-
- public function getOperande(){ return $this->_Operande; }
- public function setOperande($value){ $this->_Operande = $value; }
-
- public function getStartDateAnd(){ return $this->_StartDateAnd; }
- public function setStartDateAnd($value){ $this->_StartDateAnd = $value; }
-}
-
+<?php + +class Search +{ + private $_NumberSearch=''; + private $_StartDate=''; + private $_Operande=''; + private $_StartDateAnd=''; + + public function getNumberSearch(){ return $this->_NumberSearch; } + public function setNumberSearch($value){ $this->_NumberSearch = $value; } + + public function getStartDate(){ return $this->_StartDate; } + public function setStartDate($value){ $this->_StartDate = $value; } + + public function getOperande(){ return $this->_Operande; } + public function setOperande($value){ $this->_Operande = $value; } + + public function getStartDateAnd(){ return $this->_StartDateAnd; } + public function setStartDateAnd($value){ $this->_StartDateAnd = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/domain/User.php b/tests/simple_unit/SqlMap/domain/User.php index 0c3a547f..b21712a3 100644 --- a/tests/simple_unit/SqlMap/domain/User.php +++ b/tests/simple_unit/SqlMap/domain/User.php @@ -1,27 +1,27 @@ -<?php
-
-class User
-{
- private $_ID='';
- private $_UserName='';
- private $_Password='';
- private $_EmailAddress='';
- private $_LastLogon='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getUserName(){ return $this->_UserName; }
- public function setUserName($value){ $this->_UserName = $value; }
-
- public function getPassword(){ return $this->_Password; }
- public function setPassword($value){ $this->_Password = $value; }
-
- public function getEmailAddress(){ return $this->_EmailAddress; }
- public function setEmailAddress($value){ $this->_EmailAddress = $value; }
-
- public function getLastLogon(){ return $this->_LastLogon; }
- public function setLastLogon($value){ $this->_LastLogon = $value; }
-}
-
+<?php + +class User +{ + private $_ID=''; + private $_UserName=''; + private $_Password=''; + private $_EmailAddress=''; + private $_LastLogon=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getUserName(){ return $this->_UserName; } + public function setUserName($value){ $this->_UserName = $value; } + + public function getPassword(){ return $this->_Password; } + public function setPassword($value){ $this->_Password = $value; } + + public function getEmailAddress(){ return $this->_EmailAddress; } + public function setEmailAddress($value){ $this->_EmailAddress = $value; } + + public function getLastLogon(){ return $this->_LastLogon; } + public function setLastLogon($value){ $this->_LastLogon = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/gen.php b/tests/simple_unit/SqlMap/gen.php index b7c42271..855172ba 100644 --- a/tests/simple_unit/SqlMap/gen.php +++ b/tests/simple_unit/SqlMap/gen.php @@ -1,33 +1,33 @@ -<?php
-
-$props = <<<EOD
-_prepend
-_property
-_compareProperty
-_compareValue
-EOD;
-
-print_vars($props);
-echo "\n";
-print_funcs($props);
-
-function print_vars($props)
-{
- foreach(explode("\n", $props) as $prop)
- {
- echo "\tprivate \${$prop};\n";
- }
-}
-
-function print_funcs($props)
-{
- foreach(explode("\n", $props) as $prop)
- {
- $name = ucfirst(str_replace('_', '', $prop));
- $getter = "\tpublic function get{$name}(){ return \$this->{$prop}; }\n";
- $setter = "\tpublic function set{$name}(\$value){ \$this->{$prop} = \$value; }\n";
- echo $getter.$setter."\n";
- }
-}
-
+<?php + +$props = <<<EOD +_prepend +_property +_compareProperty +_compareValue +EOD; + +print_vars($props); +echo "\n"; +print_funcs($props); + +function print_vars($props) +{ + foreach(explode("\n", $props) as $prop) + { + echo "\tprivate \${$prop};\n"; + } +} + +function print_funcs($props) +{ + foreach(explode("\n", $props) as $prop) + { + $name = ucfirst(str_replace('_', '', $prop)); + $getter = "\tpublic function get{$name}(){ return \$this->{$prop}; }\n"; + $setter = "\tpublic function set{$name}(\$value){ \$this->{$prop} = \$value; }\n"; + echo $getter.$setter."\n"; + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/SqlMap/queryForListLimitTest.php b/tests/simple_unit/SqlMap/queryForListLimitTest.php index 3937474a..349314a5 100644 --- a/tests/simple_unit/SqlMap/queryForListLimitTest.php +++ b/tests/simple_unit/SqlMap/queryForListLimitTest.php @@ -1,40 +1,40 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseCase.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class queryForListLimitTest extends BaseCase
-{
- function __construct()
- {
- parent::__construct();
-
- $this->initSqlMap();
-
- //force autoload
- new Account;
- }
-
- function resetDatabase()
- {
- $this->initScript('account-init.sql');
- }
-
- function test_accounts_limit_2()
- {
- $list1 = $this->sqlmap->queryForList('GetAllAccountsAsArrayListViaResultClass',null,null,1,2);
- $this->assertEqual(count($list1),2);
-
- $this->assertEqual($list1[0][0],'2');
- $this->assertEqual($list1[0][1],'Averel');
- $this->assertEqual($list1[0][2],'Dalton');
-
- $this->assertEqual($list1[1][0],'3');
- $this->assertEqual($list1[1][1],'William');
- $this->assertEqual($list1[1][2],'Dalton');
- }
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseCase.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class queryForListLimitTest extends BaseCase +{ + function __construct() + { + parent::__construct(); + + $this->initSqlMap(); + + //force autoload + new Account; + } + + function resetDatabase() + { + $this->initScript('account-init.sql'); + } + + function test_accounts_limit_2() + { + $list1 = $this->sqlmap->queryForList('GetAllAccountsAsArrayListViaResultClass',null,null,1,2); + $this->assertEqual(count($list1),2); + + $this->assertEqual($list1[0][0],'2'); + $this->assertEqual($list1[0][1],'Averel'); + $this->assertEqual($list1[0][2],'Dalton'); + + $this->assertEqual($list1[1][0],'3'); + $this->assertEqual($list1[1][1],'William'); + $this->assertEqual($list1[1][2],'Dalton'); + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/TableGateway/BaseGatewayTest.php b/tests/simple_unit/TableGateway/BaseGatewayTest.php index ff7a58b0..98b236ee 100644 --- a/tests/simple_unit/TableGateway/BaseGatewayTest.php +++ b/tests/simple_unit/TableGateway/BaseGatewayTest.php @@ -1,94 +1,94 @@ <?php -Prado::using('System.Data.*');
-Prado::using('System.Data.DataGateway.TTableGateway');
-
-class BaseGatewayTest extends UnitTestCase
-{
- protected $gateway1;
- protected $gateway2;
-
- /**
- * @return TTableGateway
- */
- function getGateway()
- {
- if($this->gateway1===null)
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- $this->gateway1 = new TTableGateway('address', $conn);
- }
- return $this->gateway1;
- }
-
- /**
- * @return TTableGateway
- */
- function getGateway2()
- {
- if($this->gateway2===null)
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- $this->gateway2 = new TTableGateway('department_sections', $conn);
- }
- return $this->gateway2;
- }
-
- function setup()
- {
- $this->delete_all();
- }
-
- function add_record1()
- {
- $result = $this->getGateway()->insert($this->get_record1());
- $this->assertTrue(intval($result) > 0);
- }
- function add_record2()
- {
- $result = $this->getGateway()->insert($this->get_record2());
- $this->assertTrue(intval($result) > 0);
- }
- function get_record1()
- {
- return array(
- 'username' => 'Username',
- 'phone' => 121987,
- 'field1_boolean' => true,
- 'field2_date' => '2007-12-25',
- 'field3_double' => 121.1,
- 'field4_integer' => 3,
- 'field5_text' => 'asdasd',
- 'field6_time' => '12:40:00',
- 'field7_timestamp' => 'NOW',
- 'field8_money' => '$121.12',
- 'field9_numeric' => 98.2232,
- 'int_fk1'=>1,
- 'int_fk2'=>1,
- );
- }
-
-
- function get_record2()
- {
- return array(
- 'username' => 'record2',
- 'phone' => 45233,
- 'field1_boolean' => false,
- 'field2_date' => '2004-10-05',
- 'field3_double' => 1221.1,
- 'field4_integer' => 2,
- 'field5_text' => 'hello world',
- 'field6_time' => '22:40:00',
- 'field7_timestamp' => 'NOW',
- 'field8_money' => '$1121.12',
- 'field9_numeric' => 8.2213,
- 'int_fk1'=>1,
- 'int_fk2'=>1,
- );
- }
- function delete_all()
- {
- $this->getGateway()->deleteAll('1=1');
- }
+Prado::using('System.Data.*'); +Prado::using('System.Data.DataGateway.TTableGateway'); + +class BaseGatewayTest extends UnitTestCase +{ + protected $gateway1; + protected $gateway2; + + /** + * @return TTableGateway + */ + function getGateway() + { + if($this->gateway1===null) + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + $this->gateway1 = new TTableGateway('address', $conn); + } + return $this->gateway1; + } + + /** + * @return TTableGateway + */ + function getGateway2() + { + if($this->gateway2===null) + { + $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test'); + $this->gateway2 = new TTableGateway('department_sections', $conn); + } + return $this->gateway2; + } + + function setup() + { + $this->delete_all(); + } + + function add_record1() + { + $result = $this->getGateway()->insert($this->get_record1()); + $this->assertTrue(intval($result) > 0); + } + function add_record2() + { + $result = $this->getGateway()->insert($this->get_record2()); + $this->assertTrue(intval($result) > 0); + } + function get_record1() + { + return array( + 'username' => 'Username', + 'phone' => 121987, + 'field1_boolean' => true, + 'field2_date' => '2007-12-25', + 'field3_double' => 121.1, + 'field4_integer' => 3, + 'field5_text' => 'asdasd', + 'field6_time' => '12:40:00', + 'field7_timestamp' => 'NOW', + 'field8_money' => '$121.12', + 'field9_numeric' => 98.2232, + 'int_fk1'=>1, + 'int_fk2'=>1, + ); + } + + + function get_record2() + { + return array( + 'username' => 'record2', + 'phone' => 45233, + 'field1_boolean' => false, + 'field2_date' => '2004-10-05', + 'field3_double' => 1221.1, + 'field4_integer' => 2, + 'field5_text' => 'hello world', + 'field6_time' => '22:40:00', + 'field7_timestamp' => 'NOW', + 'field8_money' => '$1121.12', + 'field9_numeric' => 8.2213, + 'int_fk1'=>1, + 'int_fk2'=>1, + ); + } + function delete_all() + { + $this->getGateway()->deleteAll('1=1'); + } } ?>
\ No newline at end of file diff --git a/tests/simple_unit/TableGateway/CountTest.php b/tests/simple_unit/TableGateway/CountTest.php index 56ffb19b..0e159ab0 100644 --- a/tests/simple_unit/TableGateway/CountTest.php +++ b/tests/simple_unit/TableGateway/CountTest.php @@ -1,16 +1,16 @@ <?php -
-require_once(dirname(__FILE__).'/BaseGatewayTest.php');
-
-class CountTest extends BaseGatewayTest
-{
- function test_simple_count()
- {
- $result = $this->getGateway2()->count();
- $this->assertEqual(44,$result);
-
- $result = $this->getGateway2()->count('department_id = ?', 1);
- $this->assertEqual(4, $result);
- }
+ +require_once(dirname(__FILE__).'/BaseGatewayTest.php'); + +class CountTest extends BaseGatewayTest +{ + function test_simple_count() + { + $result = $this->getGateway2()->count(); + $this->assertEqual(44,$result); + + $result = $this->getGateway2()->count('department_id = ?', 1); + $this->assertEqual(4, $result); + } } ?>
\ No newline at end of file diff --git a/tests/simple_unit/TableGateway/DeleteByPkTest.php b/tests/simple_unit/TableGateway/DeleteByPkTest.php index 120b63e9..57d9dd31 100644 --- a/tests/simple_unit/TableGateway/DeleteByPkTest.php +++ b/tests/simple_unit/TableGateway/DeleteByPkTest.php @@ -1,52 +1,52 @@ <?php -
-require_once(dirname(__FILE__).'/BaseGatewayTest.php');
-
-class DeleteByPkTest extends BaseGatewayTest
-{
- function test_delete_by_1_pk()
- {
- $this->add_record1();
- $id = $this->getGateway()->getLastInsertId();
- $deleted = $this->getGateway()->deleteByPk($id);
-
- $this->assertEqual(1, $deleted);
- }
-
- function test_delete_by_multiple_pk()
- {
- $this->add_record1();
- $id1 = $this->getGateway()->getLastInsertId();
- $this->add_record2();
- $id2 = $this->getGateway()->getLastInsertId();
-
- $deleted = $this->getGateway()->deleteByPk($id1, $id2);
-
- $this->assertEqual(2, $deleted);
- }
-
- function test_delete_by_multiple_pk2()
- {
- $this->add_record1();
- $id1 = $this->getGateway()->getLastInsertId();
- $this->add_record2();
- $id2 = $this->getGateway()->getLastInsertId();
-
- $deleted = $this->getGateway()->deleteByPk(array($id1, $id2));
-
- $this->assertEqual(2, $deleted);
- }
-
- function test_delete_by_multiple_pk3()
- {
- $this->add_record1();
- $id1 = $this->getGateway()->getLastInsertId();
- $this->add_record2();
- $id2 = $this->getGateway()->getLastInsertId();
-
- $deleted = $this->getGateway()->deleteByPk(array(array($id1), array($id2)));
-
- $this->assertEqual(2, $deleted);
- }
+ +require_once(dirname(__FILE__).'/BaseGatewayTest.php'); + +class DeleteByPkTest extends BaseGatewayTest +{ + function test_delete_by_1_pk() + { + $this->add_record1(); + $id = $this->getGateway()->getLastInsertId(); + $deleted = $this->getGateway()->deleteByPk($id); + + $this->assertEqual(1, $deleted); + } + + function test_delete_by_multiple_pk() + { + $this->add_record1(); + $id1 = $this->getGateway()->getLastInsertId(); + $this->add_record2(); + $id2 = $this->getGateway()->getLastInsertId(); + + $deleted = $this->getGateway()->deleteByPk($id1, $id2); + + $this->assertEqual(2, $deleted); + } + + function test_delete_by_multiple_pk2() + { + $this->add_record1(); + $id1 = $this->getGateway()->getLastInsertId(); + $this->add_record2(); + $id2 = $this->getGateway()->getLastInsertId(); + + $deleted = $this->getGateway()->deleteByPk(array($id1, $id2)); + + $this->assertEqual(2, $deleted); + } + + function test_delete_by_multiple_pk3() + { + $this->add_record1(); + $id1 = $this->getGateway()->getLastInsertId(); + $this->add_record2(); + $id2 = $this->getGateway()->getLastInsertId(); + + $deleted = $this->getGateway()->deleteByPk(array(array($id1), array($id2))); + + $this->assertEqual(2, $deleted); + } } ?>
\ No newline at end of file diff --git a/tests/simple_unit/TableGateway/MagicCallTest.php b/tests/simple_unit/TableGateway/MagicCallTest.php index c0df313d..8d42fba8 100644 --- a/tests/simple_unit/TableGateway/MagicCallTest.php +++ b/tests/simple_unit/TableGateway/MagicCallTest.php @@ -1,31 +1,31 @@ <?php -
-require_once(dirname(__FILE__).'/BaseGatewayTest.php');
-
-class MagicCallTest extends BaseGatewayTest
-{
- function test_magic_call()
- {
- $this->add_record1(); $this->add_record2();
-
- $result = $this->getGateway()->findByUsername("record2");
- $this->assertEqual($result['username'], 'record2');
- }
-
- function test_combined_and_or()
- {
- $this->add_record1(); $this->add_record2();
-
- $result = $this->getGateway()->findAllByUsername_OR_phone('Username', '45233')->readAll();
- $this->assertEqual(2, count($result));
- }
-
- function test_no_result()
- {
- $this->add_record1(); $this->add_record2();
- $result = $this->getGateway()->findAllByUsername_and_phone('Username', '45233')->readAll();
-
- $this->assertEqual(0, count($result));
- }
+ +require_once(dirname(__FILE__).'/BaseGatewayTest.php'); + +class MagicCallTest extends BaseGatewayTest +{ + function test_magic_call() + { + $this->add_record1(); $this->add_record2(); + + $result = $this->getGateway()->findByUsername("record2"); + $this->assertEqual($result['username'], 'record2'); + } + + function test_combined_and_or() + { + $this->add_record1(); $this->add_record2(); + + $result = $this->getGateway()->findAllByUsername_OR_phone('Username', '45233')->readAll(); + $this->assertEqual(2, count($result)); + } + + function test_no_result() + { + $this->add_record1(); $this->add_record2(); + $result = $this->getGateway()->findAllByUsername_and_phone('Username', '45233')->readAll(); + + $this->assertEqual(0, count($result)); + } } ?>
\ No newline at end of file diff --git a/tests/simple_unit/TableGateway/TableGatewayPgsqlTest.php b/tests/simple_unit/TableGateway/TableGatewayPgsqlTest.php index 4d1077f7..f34dcefc 100644 --- a/tests/simple_unit/TableGateway/TableGatewayPgsqlTest.php +++ b/tests/simple_unit/TableGateway/TableGatewayPgsqlTest.php @@ -1,56 +1,56 @@ <?php -require_once(dirname(__FILE__).'/BaseGatewayTest.php');
-
-class TableGatewayPgsqlTest extends BaseGatewayTest
-{
-
- function test_update()
- {
- $this->add_record1();
- $address = array('username' => 'tester 1', 'field5_text'=>null);
- $result = $this->getGateway()->update($address, 'username = ?', 'Username');
- $this->assertTrue($result);
-
- $test = $this->getGateway()->find('username = ?', 'tester 1');
- unset($test['id']);
- $expect = $this->get_record1();
- $expect['username'] = 'tester 1';
- $expect['field5_text'] = null;
- unset($expect['field7_timestamp']); unset($test['field7_timestamp']);
- $this->assertEqual($expect, $test);
-
- $this->assertTrue($this->getGateway()->deleteAll('username = ?', 'tester 1'));
- }
-
- function test_update_named()
- {
- $this->add_record1();
- $address = array('username' => 'tester 1', 'field5_text'=>null);
- $result = $this->getGateway()->update($address, 'username = :name', array(':name'=>'Username'));
- $this->assertTrue($result);
-
- $test = $this->getGateway()->find('username = :name', array(':name'=>'tester 1'));
- unset($test['id']);
- $expect = $this->get_record1();
- $expect['username'] = 'tester 1';
- $expect['field5_text'] = null;
- unset($expect['field7_timestamp']); unset($test['field7_timestamp']);
- $this->assertEqual($expect, $test);
-
- $this->assertTrue($this->getGateway()->deleteAll('username = :name', array(':name'=>'tester 1')));
- }
-
- function test_find_all()
- {
- $this->add_record1();
- $this->add_record2();
-
- $results = $this->getGateway()->findAll('true')->readAll();
- $this->assertEqual(count($results), 2);
-
- $result = $this->getGateway()->findAllBySql('SELECT username FROM address WHERE phone = ?', '45233')->read();
- $this->assertEqual($result['username'], 'record2');
- }
-
+require_once(dirname(__FILE__).'/BaseGatewayTest.php'); + +class TableGatewayPgsqlTest extends BaseGatewayTest +{ + + function test_update() + { + $this->add_record1(); + $address = array('username' => 'tester 1', 'field5_text'=>null); + $result = $this->getGateway()->update($address, 'username = ?', 'Username'); + $this->assertTrue($result); + + $test = $this->getGateway()->find('username = ?', 'tester 1'); + unset($test['id']); + $expect = $this->get_record1(); + $expect['username'] = 'tester 1'; + $expect['field5_text'] = null; + unset($expect['field7_timestamp']); unset($test['field7_timestamp']); + $this->assertEqual($expect, $test); + + $this->assertTrue($this->getGateway()->deleteAll('username = ?', 'tester 1')); + } + + function test_update_named() + { + $this->add_record1(); + $address = array('username' => 'tester 1', 'field5_text'=>null); + $result = $this->getGateway()->update($address, 'username = :name', array(':name'=>'Username')); + $this->assertTrue($result); + + $test = $this->getGateway()->find('username = :name', array(':name'=>'tester 1')); + unset($test['id']); + $expect = $this->get_record1(); + $expect['username'] = 'tester 1'; + $expect['field5_text'] = null; + unset($expect['field7_timestamp']); unset($test['field7_timestamp']); + $this->assertEqual($expect, $test); + + $this->assertTrue($this->getGateway()->deleteAll('username = :name', array(':name'=>'tester 1'))); + } + + function test_find_all() + { + $this->add_record1(); + $this->add_record2(); + + $results = $this->getGateway()->findAll('true')->readAll(); + $this->assertEqual(count($results), 2); + + $result = $this->getGateway()->findAllBySql('SELECT username FROM address WHERE phone = ?', '45233')->read(); + $this->assertEqual($result['username'], 'record2'); + } + } ?>
\ No newline at end of file diff --git a/tests/simple_unit/TableGateway/TableInfoGatewayTest.php b/tests/simple_unit/TableGateway/TableInfoGatewayTest.php index 2be848c5..51af7634 100644 --- a/tests/simple_unit/TableGateway/TableInfoGatewayTest.php +++ b/tests/simple_unit/TableGateway/TableInfoGatewayTest.php @@ -1,17 +1,17 @@ <?php -
-require_once(dirname(__FILE__).'/BaseGatewayTest.php');
-
-class TableInfoGatewayTest extends BaseGatewayTest
-{
- function test_table_info()
- {
- $conn = $this->getGateway()->getDbConnection();
- $this->add_record1();
- $this->add_record2();
- $info = TDbMetaData::getInstance($conn)->getTableInfo('address');
- $table = new TTableGateway($info, $conn);
- $this->assertEqual(count($table->findAll()->readAll()), 2);
- }
+ +require_once(dirname(__FILE__).'/BaseGatewayTest.php'); + +class TableInfoGatewayTest extends BaseGatewayTest +{ + function test_table_info() + { + $conn = $this->getGateway()->getDbConnection(); + $this->add_record1(); + $this->add_record2(); + $info = TDbMetaData::getInstance($conn)->getTableInfo('address'); + $table = new TTableGateway($info, $conn); + $this->assertEqual(count($table->findAll()->readAll()), 2); + } } ?>
\ No newline at end of file diff --git a/tests/simple_unit/TableGateway/TestFindByPk.php b/tests/simple_unit/TableGateway/TestFindByPk.php index b9a25edf..5a7a081c 100644 --- a/tests/simple_unit/TableGateway/TestFindByPk.php +++ b/tests/simple_unit/TableGateway/TestFindByPk.php @@ -1,48 +1,48 @@ <?php -
-require_once(dirname(__FILE__).'/BaseGatewayTest.php');
-
-class TestFindByPk extends BaseGatewayTest
-{
- function test_one_key()
- {
- $this->add_record1();
- $id = $this->getGateway()->getLastInsertId();
- $result = $this->getGateway()->findByPk($id);
-
- $record1 = $this->get_record1();
-
- //clean and ignore some fields
- unset($result['id']);
- unset($result['field7_timestamp']);
- unset($record1['field7_timestamp']);
- $result['phone'] = intval($result['phone']);
- $result['field9_numeric'] = floatval($result['field9_numeric']);
-
- $this->assertEqual($record1, $result);
- }
-
- function test_composite_key()
- {
- $gateway = $this->getGateway2();
-
- $result = $gateway->findByPk(1,1);
- $expect = array("department_id" => 1, "section_id" => 1, "order" => 0);
- $this->assertEqual($expect, $result);
- }
-
- function test_find_all_keys()
- {
- $gateway = $this->getGateway2();
-
- $result = $gateway->findAllByPks(array(1,1), array(3,13))->readAll();
-
- $expect = array(
- array("department_id" => 1, "section_id" => 1, "order" => 0),
- array("department_id" => 3, "section_id" => 13, "order" => 0));
-
- $this->assertEqual($expect, $result);
-
- }
+ +require_once(dirname(__FILE__).'/BaseGatewayTest.php'); + +class TestFindByPk extends BaseGatewayTest +{ + function test_one_key() + { + $this->add_record1(); + $id = $this->getGateway()->getLastInsertId(); + $result = $this->getGateway()->findByPk($id); + + $record1 = $this->get_record1(); + + //clean and ignore some fields + unset($result['id']); + unset($result['field7_timestamp']); + unset($record1['field7_timestamp']); + $result['phone'] = intval($result['phone']); + $result['field9_numeric'] = floatval($result['field9_numeric']); + + $this->assertEqual($record1, $result); + } + + function test_composite_key() + { + $gateway = $this->getGateway2(); + + $result = $gateway->findByPk(1,1); + $expect = array("department_id" => 1, "section_id" => 1, "order" => 0); + $this->assertEqual($expect, $result); + } + + function test_find_all_keys() + { + $gateway = $this->getGateway2(); + + $result = $gateway->findAllByPks(array(1,1), array(3,13))->readAll(); + + $expect = array( + array("department_id" => 1, "section_id" => 1, "order" => 0), + array("department_id" => 3, "section_id" => 13, "order" => 0)); + + $this->assertEqual($expect, $result); + + } } ?>
\ No newline at end of file diff --git a/tests/simple_unit/Tickets/Ticket589Test.php b/tests/simple_unit/Tickets/Ticket589Test.php index 26f4f7ed..2fedda6f 100644 --- a/tests/simple_unit/Tickets/Ticket589Test.php +++ b/tests/simple_unit/Tickets/Ticket589Test.php @@ -1,22 +1,22 @@ -<?php
-
-Prado::using('System.Data.SqlMap.TSqlMapManager');
-
-class Ticket589Test extends UnitTestCase
-{
- function test()
- {
- $manager = new TSqlMapManager();
- try
- {
- $manager->configureXml(dirname(__FILE__).'/sqlmap.xml');
- $this->fail();
- }catch(TSqlMapConfigurationException $e)
- {
- $expect = 'Invalid property \'parametrClass\' for class \'TSqlMapStatement\' for tag \'<statement id="findNotVisitedWatchedTopicList"';
- $this->assertEqual(strpos($e->getMessage(),$expect),0);
- }
- }
-}
-
+<?php + +Prado::using('System.Data.SqlMap.TSqlMapManager'); + +class Ticket589Test extends UnitTestCase +{ + function test() + { + $manager = new TSqlMapManager(); + try + { + $manager->configureXml(dirname(__FILE__).'/sqlmap.xml'); + $this->fail(); + }catch(TSqlMapConfigurationException $e) + { + $expect = 'Invalid property \'parametrClass\' for class \'TSqlMapStatement\' for tag \'<statement id="findNotVisitedWatchedTopicList"'; + $this->assertEqual(strpos($e->getMessage(),$expect),0); + } + } +} + ?>
\ No newline at end of file diff --git a/tests/simple_unit/unit.php b/tests/simple_unit/unit.php index 7e86e925..63910f68 100644 --- a/tests/simple_unit/unit.php +++ b/tests/simple_unit/unit.php @@ -1,9 +1,9 @@ -<?php
-
-include_once '../test_tools/unit_tests.php';
-$test_cases = dirname(__FILE__)."/";
-
-$tester = new PradoUnitTester($test_cases);
-$tester->run(new HtmlReporter());
-
+<?php + +include_once '../test_tools/unit_tests.php'; +$test_cases = dirname(__FILE__)."/"; + +$tester = new PradoUnitTester($test_cases); +$tester->run(new HtmlReporter()); + ?>
\ No newline at end of file diff --git a/tests/simple_unit/ws.php b/tests/simple_unit/ws.php index 97e21cad..703235d1 100644 --- a/tests/simple_unit/ws.php +++ b/tests/simple_unit/ws.php @@ -1,9 +1,9 @@ -<?php
-
-include_once '../../framework/prado.php';
-include_once './Soap/ContactManager.php';
-
-$app = new TApplication('.');
-$app->run();
-
+<?php + +include_once '../../framework/prado.php'; +include_once './Soap/ContactManager.php'; + +$app = new TApplication('.'); +$app->run(); + ?>
\ No newline at end of file diff --git a/tests/test_tools/selenium/core/lib/cssQuery/cssQuery-p.js b/tests/test_tools/selenium/core/lib/cssQuery/cssQuery-p.js index 4a7eb88a..00e43a42 100644 --- a/tests/test_tools/selenium/core/lib/cssQuery/cssQuery-p.js +++ b/tests/test_tools/selenium/core/lib/cssQuery/cssQuery-p.js @@ -1,6 +1,6 @@ -/*
- cssQuery, version 2.0.2 (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Z(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(e){H(e&&(e=e.2U)&&!M(e))28;5 e};7 G=6(e){H(e&&(e=e.2T)&&!M(e))28;5 e};7 1r=6(e){5 M(e.27)||G(e.27)};7 1P=6(e){5 M(e.26)||16(e.26)};7 1o=6(e){7 c=[];e=1r(e);H(e){c.z(e);e=G(e)}5 c};7 U=K;7 1h=6(e){7 d=Q(e);5(2S d.25=="2R")?/\\.1J$/i.l(d.2Q):2P(d.25=="2O 2N")};7 Q=6(e){5 e.2M||e.1g};7 X=6(e,t){5(t=="*"&&e.1B)?e.1B:e.X(t)};7 17=6(e,t,n){8(t=="*")5 M(e);8(!14(e,n))5 L;8(!1h(e))t=t.2L();5 e.1f==t};7 14=6(e,n){5!n||(n=="*")||(e.2K==n)};7 1e=6(e){5 e.1G};6 24(r,f,B){7 m,i,j;9(i=0;i<f.y;i++){8(m=f[i].1B.2J(B)){8(m.B==B)r.z(m);1A 8(m.y!=23){9(j=0;j<m.y;j++){8(m[j].B==B)r.z(m[j])}}}}5 r};8(![].z)22.2I.z=6(){9(7 i=0;i<1z.y;i++){o[o.y]=1z[i]}5 o.y};7 N=/\\|/;6 21(A,t,f,a){8(N.l(f)){f=f.1l(N);a=f[0];f=f[1]}7 r=[];8(D[t]){D[t](r,A,f,a)}5 r};7 S=/^[^\\s>+~]/;7 20=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 1y(s){8(S.l(s))s=" "+s;5 s.P(20)||[]};7 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;7 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;7 18=6(s){5 s.O(W,"$1").O(I,"$1*$2")};7 1u={1Z:6(){5"\'"},P:/^(\'[^\']*\')|("[^"]*")$/,l:6(s){5 o.P.l(s)},1S:6(s){5 o.l(s)?s:o+s+o},1Y:6(s){5 o.l(s)?s.Z(1,-1):s}};7 1s=6(t){5 1u.1Y(t)};7 E=/([\\/()[\\]?{}|*+-])/g;6 R(s){5 s.O(E,"\\\\$1")};x.15("1j-2H",6(){D[">"]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=1o(f[i]);9(j=0;(e=s[j]);j++)8(17(e,t,n))r.z(e)}};D["+"]=6(r,f,t,n){9(7 i=0;i<f.y;i++){7 e=G(f[i]);8(e&&17(e,t,n))r.z(e)}};D["@"]=6(r,f,a){7 t=T[a].l;7 e,i;9(i=0;(e=f[i]);i++)8(t(e))r.z(e)};h["2G-10"]=6(e){5!16(e)};h["1x"]=6(e,c){c=12 1t("^"+c,"i");H(e&&!e.13("1x"))e=e.1n;5 e&&c.l(e.13("1x"))};q.1X=/\\\\:/g;q.1w="@";q.J={};q.O=6(m,a,n,c,v){7 k=o.1w+m;8(!T[k]){a=o.1W(a,c||"",v||"");T[k]=a;T.z(a)}5 T[k].B};q.1Q=6(s){s=s.O(o.1X,"|");7 m;H(m=s.P(o.P)){7 r=o.O(m[0],m[1],m[2],m[3],m[4]);s=s.O(o.P,r)}5 s};q.1W=6(p,t,v){7 a={};a.B=o.1w+T.y;a.2F=p;t=o.J[t];t=t?t(o.13(p),1s(v)):L;a.l=12 2E("e","5 "+t);5 a};q.13=6(n){1d(n.2D()){F"B":5"e.B";F"2C":5"e.1V";F"9":5"e.2B";F"1T":8(U){5"1U((e.2A.P(/1T=\\\\1v?([^\\\\s\\\\1v]*)\\\\1v?/)||[])[1]||\'\')"}}5"e.13(\'"+n.O(N,":")+"\')"};q.J[""]=6(a){5 a};q.J["="]=6(a,v){5 a+"=="+1u.1S(v)};q.J["~="]=6(a,v){5"/(^| )"+R(v)+"( |$)/.l("+a+")"};q.J["|="]=6(a,v){5"/^"+R(v)+"(-|$)/.l("+a+")"};7 1R=18;18=6(s){5 1R(q.1Q(s))}});x.15("1j-2z",6(){D["~"]=6(r,f,t,n){7 e,i;9(i=0;(e=f[i]);i++){H(e=G(e)){8(17(e,t,n))r.z(e)}}};h["2y"]=6(e,t){t=12 1t(R(1s(t)));5 t.l(1e(e))};h["2x"]=6(e){5 e==Q(e).1H};h["2w"]=6(e){7 n,i;9(i=0;(n=e.1F[i]);i++){8(M(n)||n.1c==3)5 L}5 K};h["1N-10"]=6(e){5!G(e)};h["2v-10"]=6(e){e=e.1n;5 1r(e)==1P(e)};h["2u"]=6(e,s){7 n=x(s,Q(e));9(7 i=0;i<n.y;i++){8(n[i]==e)5 L}5 K};h["1O-10"]=6(e,a){5 1p(e,a,16)};h["1O-1N-10"]=6(e,a){5 1p(e,a,G)};h["2t"]=6(e){5 e.B==2s.2r.Z(1)};h["1M"]=6(e){5 e.1M};h["2q"]=6(e){5 e.1q===L};h["1q"]=6(e){5 e.1q};h["1L"]=6(e){5 e.1L};q.J["^="]=6(a,v){5"/^"+R(v)+"/.l("+a+")"};q.J["$="]=6(a,v){5"/"+R(v)+"$/.l("+a+")"};q.J["*="]=6(a,v){5"/"+R(v)+"/.l("+a+")"};6 1p(e,a,t){1d(a){F"n":5 K;F"2p":a="2n";1a;F"2o":a="2n+1"}7 1m=1o(e.1n);6 1k(i){7 i=(t==G)?1m.y-i:i-1;5 1m[i]==e};8(!Y(a))5 1k(a);a=a.1l("n");7 m=1K(a[0]);7 s=1K(a[1]);8((Y(m)||m==1)&&s==0)5 K;8(m==0&&!Y(s))5 1k(s);8(Y(s))s=0;7 c=1;H(e=t(e))c++;8(Y(m)||m==1)5(t==G)?(c<=s):(s>=c);5(c%m)==s}});x.15("1j-2m",6(){U=1i("L;/*@2l@8(@\\2k)U=K@2j@*/");8(!U){X=6(e,t,n){5 n?e.2i("*",t):e.X(t)};14=6(e,n){5!n||(n=="*")||(e.2h==n)};1h=1g.1I?6(e){5/1J/i.l(Q(e).1I)}:6(e){5 Q(e).1H.1f!="2g"};1e=6(e){5 e.2f||e.1G||1b(e)};6 1b(e){7 t="",n,i;9(i=0;(n=e.1F[i]);i++){1d(n.1c){F 11:F 1:t+=1b(n);1a;F 3:t+=n.2e;1a}}5 t}}});19=K;5 x}();',62,190,'|||||return|function|var|if|for||||||||pseudoClasses||||test|||this||AttributeSelector|||||||cssQuery|length|push|fr|id||selectors||case|nextElementSibling|while||tests|true|false|thisElement||replace|match|getDocument|regEscape||attributeSelectors|isMSIE|cache||getElementsByTagName|isNaN|slice|child||new|getAttribute|compareNamespace|addModule|previousElementSibling|compareTagName|parseSelector|loaded|break|_0|nodeType|switch|getTextContent|tagName|document|isXML|eval|css|_1|split|ch|parentNode|childElements|nthChild|disabled|firstElementChild|getText|RegExp|Quote|x22|PREFIX|lang|_2|arguments|else|all|links|version|se|childNodes|innerText|documentElement|contentType|xml|parseInt|indeterminate|checked|last|nth|lastElementChild|parse|_3|add|href|String|className|create|NS_IE|remove|toString|ST|select|Array|null|_4|mimeType|lastChild|firstChild|continue|modules|delete|join|caching|error|nodeValue|textContent|HTML|prefix|getElementsByTagNameNS|end|x5fwin32|cc_on|standard||odd|even|enabled|hash|location|target|not|only|empty|root|contains|level3|outerHTML|htmlFor|class|toLowerCase|Function|name|first|level2|prototype|item|scopeName|toUpperCase|ownerDocument|Document|XML|Boolean|URL|unknown|typeof|nextSibling|previousSibling|visited|link|valueOf|clearCache|catch|concat|constructor|callee|try'.split('|'),0,{}))
+/* + cssQuery, version 2.0.2 (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ +eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 x=6(){7 1D="2.0.2";7 C=/\\s*,\\s*/;7 x=6(s,A){33{7 m=[];7 u=1z.32.2c&&!A;7 b=(A)?(A.31==22)?A:[A]:[1g];7 1E=18(s).1l(C),i;9(i=0;i<1E.y;i++){s=1y(1E[i]);8(U&&s.Z(0,3).2b("")==" *#"){s=s.Z(2);A=24([],b,s[1])}1A A=b;7 j=0,t,f,a,c="";H(j<s.y){t=s[j++];f=s[j++];c+=t+f;a="";8(s[j]=="("){H(s[j++]!=")")a+=s[j];a=a.Z(0,-1);c+="("+a+")"}A=(u&&V[c])?V[c]:21(A,t,f,a);8(u)V[c]=A}m=m.30(A)}2a x.2d;5 m}2Z(e){x.2d=e;5[]}};x.1Z=6(){5"6 x() {\\n [1D "+1D+"]\\n}"};7 V={};x.2c=L;x.2Y=6(s){8(s){s=1y(s).2b("");2a V[s]}1A V={}};7 29={};7 19=L;x.15=6(n,s){8(19)1i("s="+1U(s));29[n]=12 s()};x.2X=6(c){5 c?1i(c):o};7 D={};7 h={};7 q={P:/\\[([\\w-]+(\\|[\\w-]+)?)\\s*(\\W?=)?\\s*([^\\]]*)\\]/};7 T=[];D[" "]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=X(f[i],t,n);9(j=0;(e=s[j]);j++){8(M(e)&&14(e,n))r.z(e)}}};D["#"]=6(r,f,i){7 e,j;9(j=0;(e=f[j]);j++)8(e.B==i)r.z(e)};D["."]=6(r,f,c){c=12 1t("(^|\\\\s)"+c+"(\\\\s|$)");7 e,i;9(i=0;(e=f[i]);i++)8(c.l(e.1V))r.z(e)};D[":"]=6(r,f,p,a){7 t=h[p],e,i;8(t)9(i=0;(e=f[i]);i++)8(t(e,a))r.z(e)};h["2W"]=6(e){7 d=Q(e);8(d.1C)9(7 i=0;i<d.1C.y;i++){8(d.1C[i]==e)5 K}};h["2V"]=6(e){};7 M=6(e){5(e&&e.1c==1&&e.1f!="!")?e:23};7 16=6(e){H(e&&(e=e.2U)&&!M(e))28;5 e};7 G=6(e){H(e&&(e=e.2T)&&!M(e))28;5 e};7 1r=6(e){5 M(e.27)||G(e.27)};7 1P=6(e){5 M(e.26)||16(e.26)};7 1o=6(e){7 c=[];e=1r(e);H(e){c.z(e);e=G(e)}5 c};7 U=K;7 1h=6(e){7 d=Q(e);5(2S d.25=="2R")?/\\.1J$/i.l(d.2Q):2P(d.25=="2O 2N")};7 Q=6(e){5 e.2M||e.1g};7 X=6(e,t){5(t=="*"&&e.1B)?e.1B:e.X(t)};7 17=6(e,t,n){8(t=="*")5 M(e);8(!14(e,n))5 L;8(!1h(e))t=t.2L();5 e.1f==t};7 14=6(e,n){5!n||(n=="*")||(e.2K==n)};7 1e=6(e){5 e.1G};6 24(r,f,B){7 m,i,j;9(i=0;i<f.y;i++){8(m=f[i].1B.2J(B)){8(m.B==B)r.z(m);1A 8(m.y!=23){9(j=0;j<m.y;j++){8(m[j].B==B)r.z(m[j])}}}}5 r};8(![].z)22.2I.z=6(){9(7 i=0;i<1z.y;i++){o[o.y]=1z[i]}5 o.y};7 N=/\\|/;6 21(A,t,f,a){8(N.l(f)){f=f.1l(N);a=f[0];f=f[1]}7 r=[];8(D[t]){D[t](r,A,f,a)}5 r};7 S=/^[^\\s>+~]/;7 20=/[\\s#.:>+~()@]|[^\\s#.:>+~()@]+/g;6 1y(s){8(S.l(s))s=" "+s;5 s.P(20)||[]};7 W=/\\s*([\\s>+~(),]|^|$)\\s*/g;7 I=/([\\s>+~,]|[^(]\\+|^)([#.:@])/g;7 18=6(s){5 s.O(W,"$1").O(I,"$1*$2")};7 1u={1Z:6(){5"\'"},P:/^(\'[^\']*\')|("[^"]*")$/,l:6(s){5 o.P.l(s)},1S:6(s){5 o.l(s)?s:o+s+o},1Y:6(s){5 o.l(s)?s.Z(1,-1):s}};7 1s=6(t){5 1u.1Y(t)};7 E=/([\\/()[\\]?{}|*+-])/g;6 R(s){5 s.O(E,"\\\\$1")};x.15("1j-2H",6(){D[">"]=6(r,f,t,n){7 e,i,j;9(i=0;i<f.y;i++){7 s=1o(f[i]);9(j=0;(e=s[j]);j++)8(17(e,t,n))r.z(e)}};D["+"]=6(r,f,t,n){9(7 i=0;i<f.y;i++){7 e=G(f[i]);8(e&&17(e,t,n))r.z(e)}};D["@"]=6(r,f,a){7 t=T[a].l;7 e,i;9(i=0;(e=f[i]);i++)8(t(e))r.z(e)};h["2G-10"]=6(e){5!16(e)};h["1x"]=6(e,c){c=12 1t("^"+c,"i");H(e&&!e.13("1x"))e=e.1n;5 e&&c.l(e.13("1x"))};q.1X=/\\\\:/g;q.1w="@";q.J={};q.O=6(m,a,n,c,v){7 k=o.1w+m;8(!T[k]){a=o.1W(a,c||"",v||"");T[k]=a;T.z(a)}5 T[k].B};q.1Q=6(s){s=s.O(o.1X,"|");7 m;H(m=s.P(o.P)){7 r=o.O(m[0],m[1],m[2],m[3],m[4]);s=s.O(o.P,r)}5 s};q.1W=6(p,t,v){7 a={};a.B=o.1w+T.y;a.2F=p;t=o.J[t];t=t?t(o.13(p),1s(v)):L;a.l=12 2E("e","5 "+t);5 a};q.13=6(n){1d(n.2D()){F"B":5"e.B";F"2C":5"e.1V";F"9":5"e.2B";F"1T":8(U){5"1U((e.2A.P(/1T=\\\\1v?([^\\\\s\\\\1v]*)\\\\1v?/)||[])[1]||\'\')"}}5"e.13(\'"+n.O(N,":")+"\')"};q.J[""]=6(a){5 a};q.J["="]=6(a,v){5 a+"=="+1u.1S(v)};q.J["~="]=6(a,v){5"/(^| )"+R(v)+"( |$)/.l("+a+")"};q.J["|="]=6(a,v){5"/^"+R(v)+"(-|$)/.l("+a+")"};7 1R=18;18=6(s){5 1R(q.1Q(s))}});x.15("1j-2z",6(){D["~"]=6(r,f,t,n){7 e,i;9(i=0;(e=f[i]);i++){H(e=G(e)){8(17(e,t,n))r.z(e)}}};h["2y"]=6(e,t){t=12 1t(R(1s(t)));5 t.l(1e(e))};h["2x"]=6(e){5 e==Q(e).1H};h["2w"]=6(e){7 n,i;9(i=0;(n=e.1F[i]);i++){8(M(n)||n.1c==3)5 L}5 K};h["1N-10"]=6(e){5!G(e)};h["2v-10"]=6(e){e=e.1n;5 1r(e)==1P(e)};h["2u"]=6(e,s){7 n=x(s,Q(e));9(7 i=0;i<n.y;i++){8(n[i]==e)5 L}5 K};h["1O-10"]=6(e,a){5 1p(e,a,16)};h["1O-1N-10"]=6(e,a){5 1p(e,a,G)};h["2t"]=6(e){5 e.B==2s.2r.Z(1)};h["1M"]=6(e){5 e.1M};h["2q"]=6(e){5 e.1q===L};h["1q"]=6(e){5 e.1q};h["1L"]=6(e){5 e.1L};q.J["^="]=6(a,v){5"/^"+R(v)+"/.l("+a+")"};q.J["$="]=6(a,v){5"/"+R(v)+"$/.l("+a+")"};q.J["*="]=6(a,v){5"/"+R(v)+"/.l("+a+")"};6 1p(e,a,t){1d(a){F"n":5 K;F"2p":a="2n";1a;F"2o":a="2n+1"}7 1m=1o(e.1n);6 1k(i){7 i=(t==G)?1m.y-i:i-1;5 1m[i]==e};8(!Y(a))5 1k(a);a=a.1l("n");7 m=1K(a[0]);7 s=1K(a[1]);8((Y(m)||m==1)&&s==0)5 K;8(m==0&&!Y(s))5 1k(s);8(Y(s))s=0;7 c=1;H(e=t(e))c++;8(Y(m)||m==1)5(t==G)?(c<=s):(s>=c);5(c%m)==s}});x.15("1j-2m",6(){U=1i("L;/*@2l@8(@\\2k)U=K@2j@*/");8(!U){X=6(e,t,n){5 n?e.2i("*",t):e.X(t)};14=6(e,n){5!n||(n=="*")||(e.2h==n)};1h=1g.1I?6(e){5/1J/i.l(Q(e).1I)}:6(e){5 Q(e).1H.1f!="2g"};1e=6(e){5 e.2f||e.1G||1b(e)};6 1b(e){7 t="",n,i;9(i=0;(n=e.1F[i]);i++){1d(n.1c){F 11:F 1:t+=1b(n);1a;F 3:t+=n.2e;1a}}5 t}}});19=K;5 x}();',62,190,'|||||return|function|var|if|for||||||||pseudoClasses||||test|||this||AttributeSelector|||||||cssQuery|length|push|fr|id||selectors||case|nextElementSibling|while||tests|true|false|thisElement||replace|match|getDocument|regEscape||attributeSelectors|isMSIE|cache||getElementsByTagName|isNaN|slice|child||new|getAttribute|compareNamespace|addModule|previousElementSibling|compareTagName|parseSelector|loaded|break|_0|nodeType|switch|getTextContent|tagName|document|isXML|eval|css|_1|split|ch|parentNode|childElements|nthChild|disabled|firstElementChild|getText|RegExp|Quote|x22|PREFIX|lang|_2|arguments|else|all|links|version|se|childNodes|innerText|documentElement|contentType|xml|parseInt|indeterminate|checked|last|nth|lastElementChild|parse|_3|add|href|String|className|create|NS_IE|remove|toString|ST|select|Array|null|_4|mimeType|lastChild|firstChild|continue|modules|delete|join|caching|error|nodeValue|textContent|HTML|prefix|getElementsByTagNameNS|end|x5fwin32|cc_on|standard||odd|even|enabled|hash|location|target|not|only|empty|root|contains|level3|outerHTML|htmlFor|class|toLowerCase|Function|name|first|level2|prototype|item|scopeName|toUpperCase|ownerDocument|Document|XML|Boolean|URL|unknown|typeof|nextSibling|previousSibling|visited|link|valueOf|clearCache|catch|concat|constructor|callee|try'.split('|'),0,{})) diff --git a/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-level2.js b/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-level2.js index 02dd0e5f..2987b15b 100644 --- a/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-level2.js +++ b/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-level2.js @@ -1,142 +1,142 @@ -/*
- cssQuery, version 2.0.2 (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-
-cssQuery.addModule("css-level2", function() {
-
-// -----------------------------------------------------------------------
-// selectors
-// -----------------------------------------------------------------------
-
-// child selector
-selectors[">"] = function($results, $from, $tagName, $namespace) {
- var $element, i, j;
- for (i = 0; i < $from.length; i++) {
- var $subset = childElements($from[i]);
- for (j = 0; ($element = $subset[j]); j++)
- if (compareTagName($element, $tagName, $namespace))
- $results.push($element);
- }
-};
-
-// sibling selector
-selectors["+"] = function($results, $from, $tagName, $namespace) {
- for (var i = 0; i < $from.length; i++) {
- var $element = nextElementSibling($from[i]);
- if ($element && compareTagName($element, $tagName, $namespace))
- $results.push($element);
- }
-};
-
-// attribute selector
-selectors["@"] = function($results, $from, $attributeSelectorID) {
- var $test = attributeSelectors[$attributeSelectorID].test;
- var $element, i;
- for (i = 0; ($element = $from[i]); i++)
- if ($test($element)) $results.push($element);
-};
-
-// -----------------------------------------------------------------------
-// pseudo-classes
-// -----------------------------------------------------------------------
-
-pseudoClasses["first-child"] = function($element) {
- return !previousElementSibling($element);
-};
-
-pseudoClasses["lang"] = function($element, $code) {
- $code = new RegExp("^" + $code, "i");
- while ($element && !$element.getAttribute("lang")) $element = $element.parentNode;
- return $element && $code.test($element.getAttribute("lang"));
-};
-
-// -----------------------------------------------------------------------
-// attribute selectors
-// -----------------------------------------------------------------------
-
-// constants
-AttributeSelector.NS_IE = /\\:/g;
-AttributeSelector.PREFIX = "@";
-// properties
-AttributeSelector.tests = {};
-// methods
-AttributeSelector.replace = function($match, $attribute, $namespace, $compare, $value) {
- var $key = this.PREFIX + $match;
- if (!attributeSelectors[$key]) {
- $attribute = this.create($attribute, $compare || "", $value || "");
- // store the selector
- attributeSelectors[$key] = $attribute;
- attributeSelectors.push($attribute);
- }
- return attributeSelectors[$key].id;
-};
-AttributeSelector.parse = function($selector) {
- $selector = $selector.replace(this.NS_IE, "|");
- var $match;
- while ($match = $selector.match(this.match)) {
- var $replace = this.replace($match[0], $match[1], $match[2], $match[3], $match[4]);
- $selector = $selector.replace(this.match, $replace);
- }
- return $selector;
-};
-AttributeSelector.create = function($propertyName, $test, $value) {
- var $attributeSelector = {};
- $attributeSelector.id = this.PREFIX + attributeSelectors.length;
- $attributeSelector.name = $propertyName;
- $test = this.tests[$test];
- $test = $test ? $test(this.getAttribute($propertyName), getText($value)) : false;
- $attributeSelector.test = new Function("e", "return " + $test);
- return $attributeSelector;
-};
-AttributeSelector.getAttribute = function($name) {
- switch ($name.toLowerCase()) {
- case "id":
- return "e.id";
- case "class":
- return "e.className";
- case "for":
- return "e.htmlFor";
- case "href":
- if (isMSIE) {
- // IE always returns the full path not the fragment in the href attribute
- // so we RegExp it out of outerHTML. Opera does the same thing but there
- // is no way to get the original attribute.
- return "String((e.outerHTML.match(/href=\\x22?([^\\s\\x22]*)\\x22?/)||[])[1]||'')";
- }
- }
- return "e.getAttribute('" + $name.replace($NAMESPACE, ":") + "')";
-};
-
-// -----------------------------------------------------------------------
-// attribute selector tests
-// -----------------------------------------------------------------------
-
-AttributeSelector.tests[""] = function($attribute) {
- return $attribute;
-};
-
-AttributeSelector.tests["="] = function($attribute, $value) {
- return $attribute + "==" + Quote.add($value);
-};
-
-AttributeSelector.tests["~="] = function($attribute, $value) {
- return "/(^| )" + regEscape($value) + "( |$)/.test(" + $attribute + ")";
-};
-
-AttributeSelector.tests["|="] = function($attribute, $value) {
- return "/^" + regEscape($value) + "(-|$)/.test(" + $attribute + ")";
-};
-
-// -----------------------------------------------------------------------
-// parsing
-// -----------------------------------------------------------------------
-
-// override parseSelector to parse out attribute selectors
-var _parseSelector = parseSelector;
-parseSelector = function($selector) {
- return _parseSelector(AttributeSelector.parse($selector));
-};
-
-}); // addModule
+/* + cssQuery, version 2.0.2 (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ + +cssQuery.addModule("css-level2", function() { + +// ----------------------------------------------------------------------- +// selectors +// ----------------------------------------------------------------------- + +// child selector +selectors[">"] = function($results, $from, $tagName, $namespace) { + var $element, i, j; + for (i = 0; i < $from.length; i++) { + var $subset = childElements($from[i]); + for (j = 0; ($element = $subset[j]); j++) + if (compareTagName($element, $tagName, $namespace)) + $results.push($element); + } +}; + +// sibling selector +selectors["+"] = function($results, $from, $tagName, $namespace) { + for (var i = 0; i < $from.length; i++) { + var $element = nextElementSibling($from[i]); + if ($element && compareTagName($element, $tagName, $namespace)) + $results.push($element); + } +}; + +// attribute selector +selectors["@"] = function($results, $from, $attributeSelectorID) { + var $test = attributeSelectors[$attributeSelectorID].test; + var $element, i; + for (i = 0; ($element = $from[i]); i++) + if ($test($element)) $results.push($element); +}; + +// ----------------------------------------------------------------------- +// pseudo-classes +// ----------------------------------------------------------------------- + +pseudoClasses["first-child"] = function($element) { + return !previousElementSibling($element); +}; + +pseudoClasses["lang"] = function($element, $code) { + $code = new RegExp("^" + $code, "i"); + while ($element && !$element.getAttribute("lang")) $element = $element.parentNode; + return $element && $code.test($element.getAttribute("lang")); +}; + +// ----------------------------------------------------------------------- +// attribute selectors +// ----------------------------------------------------------------------- + +// constants +AttributeSelector.NS_IE = /\\:/g; +AttributeSelector.PREFIX = "@"; +// properties +AttributeSelector.tests = {}; +// methods +AttributeSelector.replace = function($match, $attribute, $namespace, $compare, $value) { + var $key = this.PREFIX + $match; + if (!attributeSelectors[$key]) { + $attribute = this.create($attribute, $compare || "", $value || ""); + // store the selector + attributeSelectors[$key] = $attribute; + attributeSelectors.push($attribute); + } + return attributeSelectors[$key].id; +}; +AttributeSelector.parse = function($selector) { + $selector = $selector.replace(this.NS_IE, "|"); + var $match; + while ($match = $selector.match(this.match)) { + var $replace = this.replace($match[0], $match[1], $match[2], $match[3], $match[4]); + $selector = $selector.replace(this.match, $replace); + } + return $selector; +}; +AttributeSelector.create = function($propertyName, $test, $value) { + var $attributeSelector = {}; + $attributeSelector.id = this.PREFIX + attributeSelectors.length; + $attributeSelector.name = $propertyName; + $test = this.tests[$test]; + $test = $test ? $test(this.getAttribute($propertyName), getText($value)) : false; + $attributeSelector.test = new Function("e", "return " + $test); + return $attributeSelector; +}; +AttributeSelector.getAttribute = function($name) { + switch ($name.toLowerCase()) { + case "id": + return "e.id"; + case "class": + return "e.className"; + case "for": + return "e.htmlFor"; + case "href": + if (isMSIE) { + // IE always returns the full path not the fragment in the href attribute + // so we RegExp it out of outerHTML. Opera does the same thing but there + // is no way to get the original attribute. + return "String((e.outerHTML.match(/href=\\x22?([^\\s\\x22]*)\\x22?/)||[])[1]||'')"; + } + } + return "e.getAttribute('" + $name.replace($NAMESPACE, ":") + "')"; +}; + +// ----------------------------------------------------------------------- +// attribute selector tests +// ----------------------------------------------------------------------- + +AttributeSelector.tests[""] = function($attribute) { + return $attribute; +}; + +AttributeSelector.tests["="] = function($attribute, $value) { + return $attribute + "==" + Quote.add($value); +}; + +AttributeSelector.tests["~="] = function($attribute, $value) { + return "/(^| )" + regEscape($value) + "( |$)/.test(" + $attribute + ")"; +}; + +AttributeSelector.tests["|="] = function($attribute, $value) { + return "/^" + regEscape($value) + "(-|$)/.test(" + $attribute + ")"; +}; + +// ----------------------------------------------------------------------- +// parsing +// ----------------------------------------------------------------------- + +// override parseSelector to parse out attribute selectors +var _parseSelector = parseSelector; +parseSelector = function($selector) { + return _parseSelector(AttributeSelector.parse($selector)); +}; + +}); // addModule diff --git a/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-level3.js b/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-level3.js index 11d19664..4dce4651 100644 --- a/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-level3.js +++ b/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-level3.js @@ -1,150 +1,150 @@ -/*
- cssQuery, version 2.0.2 (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-
-/* Thanks to Bill Edney */
-
-cssQuery.addModule("css-level3", function() {
-
-// -----------------------------------------------------------------------
-// selectors
-// -----------------------------------------------------------------------
-
-// indirect sibling selector
-selectors["~"] = function($results, $from, $tagName, $namespace) {
- var $element, i;
- for (i = 0; ($element = $from[i]); i++) {
- while ($element = nextElementSibling($element)) {
- if (compareTagName($element, $tagName, $namespace))
- $results.push($element);
- }
- }
-};
-
-// -----------------------------------------------------------------------
-// pseudo-classes
-// -----------------------------------------------------------------------
-
-// I'm hoping these pseudo-classes are pretty readable. Let me know if
-// any need explanation.
-
-pseudoClasses["contains"] = function($element, $text) {
- $text = new RegExp(regEscape(getText($text)));
- return $text.test(getTextContent($element));
-};
-
-pseudoClasses["root"] = function($element) {
- return $element == getDocument($element).documentElement;
-};
-
-pseudoClasses["empty"] = function($element) {
- var $node, i;
- for (i = 0; ($node = $element.childNodes[i]); i++) {
- if (thisElement($node) || $node.nodeType == 3) return false;
- }
- return true;
-};
-
-pseudoClasses["last-child"] = function($element) {
- return !nextElementSibling($element);
-};
-
-pseudoClasses["only-child"] = function($element) {
- $element = $element.parentNode;
- return firstElementChild($element) == lastElementChild($element);
-};
-
-pseudoClasses["not"] = function($element, $selector) {
- var $negated = cssQuery($selector, getDocument($element));
- for (var i = 0; i < $negated.length; i++) {
- if ($negated[i] == $element) return false;
- }
- return true;
-};
-
-pseudoClasses["nth-child"] = function($element, $arguments) {
- return nthChild($element, $arguments, previousElementSibling);
-};
-
-pseudoClasses["nth-last-child"] = function($element, $arguments) {
- return nthChild($element, $arguments, nextElementSibling);
-};
-
-pseudoClasses["target"] = function($element) {
- return $element.id == location.hash.slice(1);
-};
-
-// UI element states
-
-pseudoClasses["checked"] = function($element) {
- return $element.checked;
-};
-
-pseudoClasses["enabled"] = function($element) {
- return $element.disabled === false;
-};
-
-pseudoClasses["disabled"] = function($element) {
- return $element.disabled;
-};
-
-pseudoClasses["indeterminate"] = function($element) {
- return $element.indeterminate;
-};
-
-// -----------------------------------------------------------------------
-// attribute selector tests
-// -----------------------------------------------------------------------
-
-AttributeSelector.tests["^="] = function($attribute, $value) {
- return "/^" + regEscape($value) + "/.test(" + $attribute + ")";
-};
-
-AttributeSelector.tests["$="] = function($attribute, $value) {
- return "/" + regEscape($value) + "$/.test(" + $attribute + ")";
-};
-
-AttributeSelector.tests["*="] = function($attribute, $value) {
- return "/" + regEscape($value) + "/.test(" + $attribute + ")";
-};
-
-// -----------------------------------------------------------------------
-// nth child support (Bill Edney)
-// -----------------------------------------------------------------------
-
-function nthChild($element, $arguments, $traverse) {
- switch ($arguments) {
- case "n": return true;
- case "even": $arguments = "2n"; break;
- case "odd": $arguments = "2n+1";
- }
-
- var $$children = childElements($element.parentNode);
- function _checkIndex($index) {
- var $index = ($traverse == nextElementSibling) ? $$children.length - $index : $index - 1;
- return $$children[$index] == $element;
- };
-
- // it was just a number (no "n")
- if (!isNaN($arguments)) return _checkIndex($arguments);
-
- $arguments = $arguments.split("n");
- var $multiplier = parseInt($arguments[0]);
- var $step = parseInt($arguments[1]);
-
- if ((isNaN($multiplier) || $multiplier == 1) && $step == 0) return true;
- if ($multiplier == 0 && !isNaN($step)) return _checkIndex($step);
- if (isNaN($step)) $step = 0;
-
- var $count = 1;
- while ($element = $traverse($element)) $count++;
-
- if (isNaN($multiplier) || $multiplier == 1)
- return ($traverse == nextElementSibling) ? ($count <= $step) : ($step >= $count);
-
- return ($count % $multiplier) == $step;
-};
-
-}); // addModule
+/* + cssQuery, version 2.0.2 (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ + +/* Thanks to Bill Edney */ + +cssQuery.addModule("css-level3", function() { + +// ----------------------------------------------------------------------- +// selectors +// ----------------------------------------------------------------------- + +// indirect sibling selector +selectors["~"] = function($results, $from, $tagName, $namespace) { + var $element, i; + for (i = 0; ($element = $from[i]); i++) { + while ($element = nextElementSibling($element)) { + if (compareTagName($element, $tagName, $namespace)) + $results.push($element); + } + } +}; + +// ----------------------------------------------------------------------- +// pseudo-classes +// ----------------------------------------------------------------------- + +// I'm hoping these pseudo-classes are pretty readable. Let me know if +// any need explanation. + +pseudoClasses["contains"] = function($element, $text) { + $text = new RegExp(regEscape(getText($text))); + return $text.test(getTextContent($element)); +}; + +pseudoClasses["root"] = function($element) { + return $element == getDocument($element).documentElement; +}; + +pseudoClasses["empty"] = function($element) { + var $node, i; + for (i = 0; ($node = $element.childNodes[i]); i++) { + if (thisElement($node) || $node.nodeType == 3) return false; + } + return true; +}; + +pseudoClasses["last-child"] = function($element) { + return !nextElementSibling($element); +}; + +pseudoClasses["only-child"] = function($element) { + $element = $element.parentNode; + return firstElementChild($element) == lastElementChild($element); +}; + +pseudoClasses["not"] = function($element, $selector) { + var $negated = cssQuery($selector, getDocument($element)); + for (var i = 0; i < $negated.length; i++) { + if ($negated[i] == $element) return false; + } + return true; +}; + +pseudoClasses["nth-child"] = function($element, $arguments) { + return nthChild($element, $arguments, previousElementSibling); +}; + +pseudoClasses["nth-last-child"] = function($element, $arguments) { + return nthChild($element, $arguments, nextElementSibling); +}; + +pseudoClasses["target"] = function($element) { + return $element.id == location.hash.slice(1); +}; + +// UI element states + +pseudoClasses["checked"] = function($element) { + return $element.checked; +}; + +pseudoClasses["enabled"] = function($element) { + return $element.disabled === false; +}; + +pseudoClasses["disabled"] = function($element) { + return $element.disabled; +}; + +pseudoClasses["indeterminate"] = function($element) { + return $element.indeterminate; +}; + +// ----------------------------------------------------------------------- +// attribute selector tests +// ----------------------------------------------------------------------- + +AttributeSelector.tests["^="] = function($attribute, $value) { + return "/^" + regEscape($value) + "/.test(" + $attribute + ")"; +}; + +AttributeSelector.tests["$="] = function($attribute, $value) { + return "/" + regEscape($value) + "$/.test(" + $attribute + ")"; +}; + +AttributeSelector.tests["*="] = function($attribute, $value) { + return "/" + regEscape($value) + "/.test(" + $attribute + ")"; +}; + +// ----------------------------------------------------------------------- +// nth child support (Bill Edney) +// ----------------------------------------------------------------------- + +function nthChild($element, $arguments, $traverse) { + switch ($arguments) { + case "n": return true; + case "even": $arguments = "2n"; break; + case "odd": $arguments = "2n+1"; + } + + var $$children = childElements($element.parentNode); + function _checkIndex($index) { + var $index = ($traverse == nextElementSibling) ? $$children.length - $index : $index - 1; + return $$children[$index] == $element; + }; + + // it was just a number (no "n") + if (!isNaN($arguments)) return _checkIndex($arguments); + + $arguments = $arguments.split("n"); + var $multiplier = parseInt($arguments[0]); + var $step = parseInt($arguments[1]); + + if ((isNaN($multiplier) || $multiplier == 1) && $step == 0) return true; + if ($multiplier == 0 && !isNaN($step)) return _checkIndex($step); + if (isNaN($step)) $step = 0; + + var $count = 1; + while ($element = $traverse($element)) $count++; + + if (isNaN($multiplier) || $multiplier == 1) + return ($traverse == nextElementSibling) ? ($count <= $step) : ($step >= $count); + + return ($count % $multiplier) == $step; +}; + +}); // addModule diff --git a/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-standard.js b/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-standard.js index 77314b86..309184d5 100644 --- a/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-standard.js +++ b/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-standard.js @@ -1,53 +1,53 @@ -/*
- cssQuery, version 2.0.2 (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-
-cssQuery.addModule("css-standard", function() { // override IE optimisation
-
-// cssQuery was originally written as the CSS engine for IE7. It is
-// optimised (in terms of size not speed) for IE so this module is
-// provided separately to provide cross-browser support.
-
-// -----------------------------------------------------------------------
-// browser compatibility
-// -----------------------------------------------------------------------
-
-// sniff for Win32 Explorer
-isMSIE = eval("false;/*@cc_on@if(@\x5fwin32)isMSIE=true@end@*/");
-
-if (!isMSIE) {
- getElementsByTagName = function($element, $tagName, $namespace) {
- return $namespace ? $element.getElementsByTagNameNS("*", $tagName) :
- $element.getElementsByTagName($tagName);
- };
-
- compareNamespace = function($element, $namespace) {
- return !$namespace || ($namespace == "*") || ($element.prefix == $namespace);
- };
-
- isXML = document.contentType ? function($element) {
- return /xml/i.test(getDocument($element).contentType);
- } : function($element) {
- return getDocument($element).documentElement.tagName != "HTML";
- };
-
- getTextContent = function($element) {
- // mozilla || opera || other
- return $element.textContent || $element.innerText || _getTextContent($element);
- };
-
- function _getTextContent($element) {
- var $textContent = "", $node, i;
- for (i = 0; ($node = $element.childNodes[i]); i++) {
- switch ($node.nodeType) {
- case 11: // document fragment
- case 1: $textContent += _getTextContent($node); break;
- case 3: $textContent += $node.nodeValue; break;
- }
- }
- return $textContent;
- };
-}
-}); // addModule
+/* + cssQuery, version 2.0.2 (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ + +cssQuery.addModule("css-standard", function() { // override IE optimisation + +// cssQuery was originally written as the CSS engine for IE7. It is +// optimised (in terms of size not speed) for IE so this module is +// provided separately to provide cross-browser support. + +// ----------------------------------------------------------------------- +// browser compatibility +// ----------------------------------------------------------------------- + +// sniff for Win32 Explorer +isMSIE = eval("false;/*@cc_on@if(@\x5fwin32)isMSIE=true@end@*/"); + +if (!isMSIE) { + getElementsByTagName = function($element, $tagName, $namespace) { + return $namespace ? $element.getElementsByTagNameNS("*", $tagName) : + $element.getElementsByTagName($tagName); + }; + + compareNamespace = function($element, $namespace) { + return !$namespace || ($namespace == "*") || ($element.prefix == $namespace); + }; + + isXML = document.contentType ? function($element) { + return /xml/i.test(getDocument($element).contentType); + } : function($element) { + return getDocument($element).documentElement.tagName != "HTML"; + }; + + getTextContent = function($element) { + // mozilla || opera || other + return $element.textContent || $element.innerText || _getTextContent($element); + }; + + function _getTextContent($element) { + var $textContent = "", $node, i; + for (i = 0; ($node = $element.childNodes[i]); i++) { + switch ($node.nodeType) { + case 11: // document fragment + case 1: $textContent += _getTextContent($node); break; + case 3: $textContent += $node.nodeValue; break; + } + } + return $textContent; + }; +} +}); // addModule diff --git a/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery.js b/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery.js index 1fcab4a1..7a6efee8 100644 --- a/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery.js +++ b/tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery.js @@ -1,356 +1,356 @@ -/*
- cssQuery, version 2.0.2 (2005-08-19)
- Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/)
- License: http://creativecommons.org/licenses/LGPL/2.1/
-*/
-
-// the following functions allow querying of the DOM using CSS selectors
-var cssQuery = function() {
-var version = "2.0.2";
-
-// -----------------------------------------------------------------------
-// main query function
-// -----------------------------------------------------------------------
-
-var $COMMA = /\s*,\s*/;
-var cssQuery = function($selector, $$from) {
-try {
- var $match = [];
- var $useCache = arguments.callee.caching && !$$from;
- var $base = ($$from) ? ($$from.constructor == Array) ? $$from : [$$from] : [document];
- // process comma separated selectors
- var $$selectors = parseSelector($selector).split($COMMA), i;
- for (i = 0; i < $$selectors.length; i++) {
- // convert the selector to a stream
- $selector = _toStream($$selectors[i]);
- // faster chop if it starts with id (MSIE only)
- if (isMSIE && $selector.slice(0, 3).join("") == " *#") {
- $selector = $selector.slice(2);
- $$from = _msie_selectById([], $base, $selector[1]);
- } else $$from = $base;
- // process the stream
- var j = 0, $token, $filter, $arguments, $cacheSelector = "";
- while (j < $selector.length) {
- $token = $selector[j++];
- $filter = $selector[j++];
- $cacheSelector += $token + $filter;
- // some pseudo-classes allow arguments to be passed
- // e.g. nth-child(even)
- $arguments = "";
- if ($selector[j] == "(") {
- while ($selector[j++] != ")" && j < $selector.length) {
- $arguments += $selector[j];
- }
- $arguments = $arguments.slice(0, -1);
- $cacheSelector += "(" + $arguments + ")";
- }
- // process a token/filter pair use cached results if possible
- $$from = ($useCache && cache[$cacheSelector]) ?
- cache[$cacheSelector] : select($$from, $token, $filter, $arguments);
- if ($useCache) cache[$cacheSelector] = $$from;
- }
- $match = $match.concat($$from);
- }
- delete cssQuery.error;
- return $match;
-} catch ($error) {
- cssQuery.error = $error;
- return [];
-}};
-
-// -----------------------------------------------------------------------
-// public interface
-// -----------------------------------------------------------------------
-
-cssQuery.toString = function() {
- return "function cssQuery() {\n [version " + version + "]\n}";
-};
-
-// caching
-var cache = {};
-cssQuery.caching = false;
-cssQuery.clearCache = function($selector) {
- if ($selector) {
- $selector = _toStream($selector).join("");
- delete cache[$selector];
- } else cache = {};
-};
-
-// allow extensions
-var modules = {};
-var loaded = false;
-cssQuery.addModule = function($name, $script) {
- if (loaded) eval("$script=" + String($script));
- modules[$name] = new $script();;
-};
-
-// hackery
-cssQuery.valueOf = function($code) {
- return $code ? eval($code) : this;
-};
-
-// -----------------------------------------------------------------------
-// declarations
-// -----------------------------------------------------------------------
-
-var selectors = {};
-var pseudoClasses = {};
-// a safari bug means that these have to be declared here
-var AttributeSelector = {match: /\[([\w-]+(\|[\w-]+)?)\s*(\W?=)?\s*([^\]]*)\]/};
-var attributeSelectors = [];
-
-// -----------------------------------------------------------------------
-// selectors
-// -----------------------------------------------------------------------
-
-// descendant selector
-selectors[" "] = function($results, $from, $tagName, $namespace) {
- // loop through current selection
- var $element, i, j;
- for (i = 0; i < $from.length; i++) {
- // get descendants
- var $subset = getElementsByTagName($from[i], $tagName, $namespace);
- // loop through descendants and add to results selection
- for (j = 0; ($element = $subset[j]); j++) {
- if (thisElement($element) && compareNamespace($element, $namespace))
- $results.push($element);
- }
- }
-};
-
-// ID selector
-selectors["#"] = function($results, $from, $id) {
- // loop through current selection and check ID
- var $element, j;
- for (j = 0; ($element = $from[j]); j++) if ($element.id == $id) $results.push($element);
-};
-
-// class selector
-selectors["."] = function($results, $from, $className) {
- // create a RegExp version of the class
- $className = new RegExp("(^|\\s)" + $className + "(\\s|$)");
- // loop through current selection and check class
- var $element, i;
- for (i = 0; ($element = $from[i]); i++)
- if ($className.test($element.className)) $results.push($element);
-};
-
-// pseudo-class selector
-selectors[":"] = function($results, $from, $pseudoClass, $arguments) {
- // retrieve the cssQuery pseudo-class function
- var $test = pseudoClasses[$pseudoClass], $element, i;
- // loop through current selection and apply pseudo-class filter
- if ($test) for (i = 0; ($element = $from[i]); i++)
- // if the cssQuery pseudo-class function returns "true" add the element
- if ($test($element, $arguments)) $results.push($element);
-};
-
-// -----------------------------------------------------------------------
-// pseudo-classes
-// -----------------------------------------------------------------------
-
-pseudoClasses["link"] = function($element) {
- var $document = getDocument($element);
- if ($document.links) for (var i = 0; i < $document.links.length; i++) {
- if ($document.links[i] == $element) return true;
- }
-};
-
-pseudoClasses["visited"] = function($element) {
- // can't do this without jiggery-pokery
-};
-
-// -----------------------------------------------------------------------
-// DOM traversal
-// -----------------------------------------------------------------------
-
-// IE5/6 includes comments (LOL) in it's elements collections.
-// so we have to check for this. the test is tagName != "!". LOL (again).
-var thisElement = function($element) {
- return ($element && $element.nodeType == 1 && $element.tagName != "!") ? $element : null;
-};
-
-// return the previous element to the supplied element
-// previousSibling is not good enough as it might return a text or comment node
-var previousElementSibling = function($element) {
- while ($element && ($element = $element.previousSibling) && !thisElement($element)) continue;
- return $element;
-};
-
-// return the next element to the supplied element
-var nextElementSibling = function($element) {
- while ($element && ($element = $element.nextSibling) && !thisElement($element)) continue;
- return $element;
-};
-
-// return the first child ELEMENT of an element
-// NOT the first child node (though they may be the same thing)
-var firstElementChild = function($element) {
- return thisElement($element.firstChild) || nextElementSibling($element.firstChild);
-};
-
-var lastElementChild = function($element) {
- return thisElement($element.lastChild) || previousElementSibling($element.lastChild);
-};
-
-// return child elements of an element (not child nodes)
-var childElements = function($element) {
- var $childElements = [];
- $element = firstElementChild($element);
- while ($element) {
- $childElements.push($element);
- $element = nextElementSibling($element);
- }
- return $childElements;
-};
-
-// -----------------------------------------------------------------------
-// browser compatibility
-// -----------------------------------------------------------------------
-
-// all of the functions in this section can be overwritten. the default
-// configuration is for IE. The functions below reflect this. standard
-// methods are included in a separate module. It would probably be better
-// the other way round of course but this makes it easier to keep IE7 trim.
-
-var isMSIE = true;
-
-var isXML = function($element) {
- var $document = getDocument($element);
- return (typeof $document.mimeType == "unknown") ?
- /\.xml$/i.test($document.URL) :
- Boolean($document.mimeType == "XML Document");
-};
-
-// return the element's containing document
-var getDocument = function($element) {
- return $element.ownerDocument || $element.document;
-};
-
-var getElementsByTagName = function($element, $tagName) {
- return ($tagName == "*" && $element.all) ? $element.all : $element.getElementsByTagName($tagName);
-};
-
-var compareTagName = function($element, $tagName, $namespace) {
- if ($tagName == "*") return thisElement($element);
- if (!compareNamespace($element, $namespace)) return false;
- if (!isXML($element)) $tagName = $tagName.toUpperCase();
- return $element.tagName == $tagName;
-};
-
-var compareNamespace = function($element, $namespace) {
- return !$namespace || ($namespace == "*") || ($element.scopeName == $namespace);
-};
-
-var getTextContent = function($element) {
- return $element.innerText;
-};
-
-function _msie_selectById($results, $from, id) {
- var $match, i, j;
- for (i = 0; i < $from.length; i++) {
- if ($match = $from[i].all.item(id)) {
- if ($match.id == id) $results.push($match);
- else if ($match.length != null) {
- for (j = 0; j < $match.length; j++) {
- if ($match[j].id == id) $results.push($match[j]);
- }
- }
- }
- }
- return $results;
-};
-
-// for IE5.0
-if (![].push) Array.prototype.push = function() {
- for (var i = 0; i < arguments.length; i++) {
- this[this.length] = arguments[i];
- }
- return this.length;
-};
-
-// -----------------------------------------------------------------------
-// query support
-// -----------------------------------------------------------------------
-
-// select a set of matching elements.
-// "from" is an array of elements.
-// "token" is a character representing the type of filter
-// e.g. ">" means child selector
-// "filter" represents the tag name, id or class name that is being selected
-// the function returns an array of matching elements
-var $NAMESPACE = /\|/;
-function select($$from, $token, $filter, $arguments) {
- if ($NAMESPACE.test($filter)) {
- $filter = $filter.split($NAMESPACE);
- $arguments = $filter[0];
- $filter = $filter[1];
- }
- var $results = [];
- if (selectors[$token]) {
- selectors[$token]($results, $$from, $filter, $arguments);
- }
- return $results;
-};
-
-// -----------------------------------------------------------------------
-// parsing
-// -----------------------------------------------------------------------
-
-// convert css selectors to a stream of tokens and filters
-// it's not a real stream. it's just an array of strings.
-var $STANDARD_SELECT = /^[^\s>+~]/;
-var $$STREAM = /[\s#.:>+~()@]|[^\s#.:>+~()@]+/g;
-function _toStream($selector) {
- if ($STANDARD_SELECT.test($selector)) $selector = " " + $selector;
- return $selector.match($$STREAM) || [];
-};
-
-var $WHITESPACE = /\s*([\s>+~(),]|^|$)\s*/g;
-var $IMPLIED_ALL = /([\s>+~,]|[^(]\+|^)([#.:@])/g;
-var parseSelector = function($selector) {
- return $selector
- // trim whitespace
- .replace($WHITESPACE, "$1")
- // e.g. ".class1" --> "*.class1"
- .replace($IMPLIED_ALL, "$1*$2");
-};
-
-var Quote = {
- toString: function() {return "'"},
- match: /^('[^']*')|("[^"]*")$/,
- test: function($string) {
- return this.match.test($string);
- },
- add: function($string) {
- return this.test($string) ? $string : this + $string + this;
- },
- remove: function($string) {
- return this.test($string) ? $string.slice(1, -1) : $string;
- }
-};
-
-var getText = function($text) {
- return Quote.remove($text);
-};
-
-var $ESCAPE = /([\/()[\]?{}|*+-])/g;
-function regEscape($string) {
- return $string.replace($ESCAPE, "\\$1");
-};
-
-// -----------------------------------------------------------------------
-// modules
-// -----------------------------------------------------------------------
-
-// -------- >> insert modules here for packaging << -------- \\
-
-loaded = true;
-
-// -----------------------------------------------------------------------
-// return the query function
-// -----------------------------------------------------------------------
-
-return cssQuery;
-
-}(); // cssQuery
+/* + cssQuery, version 2.0.2 (2005-08-19) + Copyright: 2004-2005, Dean Edwards (http://dean.edwards.name/) + License: http://creativecommons.org/licenses/LGPL/2.1/ +*/ + +// the following functions allow querying of the DOM using CSS selectors +var cssQuery = function() { +var version = "2.0.2"; + +// ----------------------------------------------------------------------- +// main query function +// ----------------------------------------------------------------------- + +var $COMMA = /\s*,\s*/; +var cssQuery = function($selector, $$from) { +try { + var $match = []; + var $useCache = arguments.callee.caching && !$$from; + var $base = ($$from) ? ($$from.constructor == Array) ? $$from : [$$from] : [document]; + // process comma separated selectors + var $$selectors = parseSelector($selector).split($COMMA), i; + for (i = 0; i < $$selectors.length; i++) { + // convert the selector to a stream + $selector = _toStream($$selectors[i]); + // faster chop if it starts with id (MSIE only) + if (isMSIE && $selector.slice(0, 3).join("") == " *#") { + $selector = $selector.slice(2); + $$from = _msie_selectById([], $base, $selector[1]); + } else $$from = $base; + // process the stream + var j = 0, $token, $filter, $arguments, $cacheSelector = ""; + while (j < $selector.length) { + $token = $selector[j++]; + $filter = $selector[j++]; + $cacheSelector += $token + $filter; + // some pseudo-classes allow arguments to be passed + // e.g. nth-child(even) + $arguments = ""; + if ($selector[j] == "(") { + while ($selector[j++] != ")" && j < $selector.length) { + $arguments += $selector[j]; + } + $arguments = $arguments.slice(0, -1); + $cacheSelector += "(" + $arguments + ")"; + } + // process a token/filter pair use cached results if possible + $$from = ($useCache && cache[$cacheSelector]) ? + cache[$cacheSelector] : select($$from, $token, $filter, $arguments); + if ($useCache) cache[$cacheSelector] = $$from; + } + $match = $match.concat($$from); + } + delete cssQuery.error; + return $match; +} catch ($error) { + cssQuery.error = $error; + return []; +}}; + +// ----------------------------------------------------------------------- +// public interface +// ----------------------------------------------------------------------- + +cssQuery.toString = function() { + return "function cssQuery() {\n [version " + version + "]\n}"; +}; + +// caching +var cache = {}; +cssQuery.caching = false; +cssQuery.clearCache = function($selector) { + if ($selector) { + $selector = _toStream($selector).join(""); + delete cache[$selector]; + } else cache = {}; +}; + +// allow extensions +var modules = {}; +var loaded = false; +cssQuery.addModule = function($name, $script) { + if (loaded) eval("$script=" + String($script)); + modules[$name] = new $script();; +}; + +// hackery +cssQuery.valueOf = function($code) { + return $code ? eval($code) : this; +}; + +// ----------------------------------------------------------------------- +// declarations +// ----------------------------------------------------------------------- + +var selectors = {}; +var pseudoClasses = {}; +// a safari bug means that these have to be declared here +var AttributeSelector = {match: /\[([\w-]+(\|[\w-]+)?)\s*(\W?=)?\s*([^\]]*)\]/}; +var attributeSelectors = []; + +// ----------------------------------------------------------------------- +// selectors +// ----------------------------------------------------------------------- + +// descendant selector +selectors[" "] = function($results, $from, $tagName, $namespace) { + // loop through current selection + var $element, i, j; + for (i = 0; i < $from.length; i++) { + // get descendants + var $subset = getElementsByTagName($from[i], $tagName, $namespace); + // loop through descendants and add to results selection + for (j = 0; ($element = $subset[j]); j++) { + if (thisElement($element) && compareNamespace($element, $namespace)) + $results.push($element); + } + } +}; + +// ID selector +selectors["#"] = function($results, $from, $id) { + // loop through current selection and check ID + var $element, j; + for (j = 0; ($element = $from[j]); j++) if ($element.id == $id) $results.push($element); +}; + +// class selector +selectors["."] = function($results, $from, $className) { + // create a RegExp version of the class + $className = new RegExp("(^|\\s)" + $className + "(\\s|$)"); + // loop through current selection and check class + var $element, i; + for (i = 0; ($element = $from[i]); i++) + if ($className.test($element.className)) $results.push($element); +}; + +// pseudo-class selector +selectors[":"] = function($results, $from, $pseudoClass, $arguments) { + // retrieve the cssQuery pseudo-class function + var $test = pseudoClasses[$pseudoClass], $element, i; + // loop through current selection and apply pseudo-class filter + if ($test) for (i = 0; ($element = $from[i]); i++) + // if the cssQuery pseudo-class function returns "true" add the element + if ($test($element, $arguments)) $results.push($element); +}; + +// ----------------------------------------------------------------------- +// pseudo-classes +// ----------------------------------------------------------------------- + +pseudoClasses["link"] = function($element) { + var $document = getDocument($element); + if ($document.links) for (var i = 0; i < $document.links.length; i++) { + if ($document.links[i] == $element) return true; + } +}; + +pseudoClasses["visited"] = function($element) { + // can't do this without jiggery-pokery +}; + +// ----------------------------------------------------------------------- +// DOM traversal +// ----------------------------------------------------------------------- + +// IE5/6 includes comments (LOL) in it's elements collections. +// so we have to check for this. the test is tagName != "!". LOL (again). +var thisElement = function($element) { + return ($element && $element.nodeType == 1 && $element.tagName != "!") ? $element : null; +}; + +// return the previous element to the supplied element +// previousSibling is not good enough as it might return a text or comment node +var previousElementSibling = function($element) { + while ($element && ($element = $element.previousSibling) && !thisElement($element)) continue; + return $element; +}; + +// return the next element to the supplied element +var nextElementSibling = function($element) { + while ($element && ($element = $element.nextSibling) && !thisElement($element)) continue; + return $element; +}; + +// return the first child ELEMENT of an element +// NOT the first child node (though they may be the same thing) +var firstElementChild = function($element) { + return thisElement($element.firstChild) || nextElementSibling($element.firstChild); +}; + +var lastElementChild = function($element) { + return thisElement($element.lastChild) || previousElementSibling($element.lastChild); +}; + +// return child elements of an element (not child nodes) +var childElements = function($element) { + var $childElements = []; + $element = firstElementChild($element); + while ($element) { + $childElements.push($element); + $element = nextElementSibling($element); + } + return $childElements; +}; + +// ----------------------------------------------------------------------- +// browser compatibility +// ----------------------------------------------------------------------- + +// all of the functions in this section can be overwritten. the default +// configuration is for IE. The functions below reflect this. standard +// methods are included in a separate module. It would probably be better +// the other way round of course but this makes it easier to keep IE7 trim. + +var isMSIE = true; + +var isXML = function($element) { + var $document = getDocument($element); + return (typeof $document.mimeType == "unknown") ? + /\.xml$/i.test($document.URL) : + Boolean($document.mimeType == "XML Document"); +}; + +// return the element's containing document +var getDocument = function($element) { + return $element.ownerDocument || $element.document; +}; + +var getElementsByTagName = function($element, $tagName) { + return ($tagName == "*" && $element.all) ? $element.all : $element.getElementsByTagName($tagName); +}; + +var compareTagName = function($element, $tagName, $namespace) { + if ($tagName == "*") return thisElement($element); + if (!compareNamespace($element, $namespace)) return false; + if (!isXML($element)) $tagName = $tagName.toUpperCase(); + return $element.tagName == $tagName; +}; + +var compareNamespace = function($element, $namespace) { + return !$namespace || ($namespace == "*") || ($element.scopeName == $namespace); +}; + +var getTextContent = function($element) { + return $element.innerText; +}; + +function _msie_selectById($results, $from, id) { + var $match, i, j; + for (i = 0; i < $from.length; i++) { + if ($match = $from[i].all.item(id)) { + if ($match.id == id) $results.push($match); + else if ($match.length != null) { + for (j = 0; j < $match.length; j++) { + if ($match[j].id == id) $results.push($match[j]); + } + } + } + } + return $results; +}; + +// for IE5.0 +if (![].push) Array.prototype.push = function() { + for (var i = 0; i < arguments.length; i++) { + this[this.length] = arguments[i]; + } + return this.length; +}; + +// ----------------------------------------------------------------------- +// query support +// ----------------------------------------------------------------------- + +// select a set of matching elements. +// "from" is an array of elements. +// "token" is a character representing the type of filter +// e.g. ">" means child selector +// "filter" represents the tag name, id or class name that is being selected +// the function returns an array of matching elements +var $NAMESPACE = /\|/; +function select($$from, $token, $filter, $arguments) { + if ($NAMESPACE.test($filter)) { + $filter = $filter.split($NAMESPACE); + $arguments = $filter[0]; + $filter = $filter[1]; + } + var $results = []; + if (selectors[$token]) { + selectors[$token]($results, $$from, $filter, $arguments); + } + return $results; +}; + +// ----------------------------------------------------------------------- +// parsing +// ----------------------------------------------------------------------- + +// convert css selectors to a stream of tokens and filters +// it's not a real stream. it's just an array of strings. +var $STANDARD_SELECT = /^[^\s>+~]/; +var $$STREAM = /[\s#.:>+~()@]|[^\s#.:>+~()@]+/g; +function _toStream($selector) { + if ($STANDARD_SELECT.test($selector)) $selector = " " + $selector; + return $selector.match($$STREAM) || []; +}; + +var $WHITESPACE = /\s*([\s>+~(),]|^|$)\s*/g; +var $IMPLIED_ALL = /([\s>+~,]|[^(]\+|^)([#.:@])/g; +var parseSelector = function($selector) { + return $selector + // trim whitespace + .replace($WHITESPACE, "$1") + // e.g. ".class1" --> "*.class1" + .replace($IMPLIED_ALL, "$1*$2"); +}; + +var Quote = { + toString: function() {return "'"}, + match: /^('[^']*')|("[^"]*")$/, + test: function($string) { + return this.match.test($string); + }, + add: function($string) { + return this.test($string) ? $string : this + $string + this; + }, + remove: function($string) { + return this.test($string) ? $string.slice(1, -1) : $string; + } +}; + +var getText = function($text) { + return Quote.remove($text); +}; + +var $ESCAPE = /([\/()[\]?{}|*+-])/g; +function regEscape($string) { + return $string.replace($ESCAPE, "\\$1"); +}; + +// ----------------------------------------------------------------------- +// modules +// ----------------------------------------------------------------------- + +// -------- >> insert modules here for packaging << -------- \\ + +loaded = true; + +// ----------------------------------------------------------------------- +// return the query function +// ----------------------------------------------------------------------- + +return cssQuery; + +}(); // cssQuery diff --git a/tests/test_tools/selenium/core/scripts/js2html.js b/tests/test_tools/selenium/core/scripts/js2html.js index a384dce3..407709df 100644 --- a/tests/test_tools/selenium/core/scripts/js2html.js +++ b/tests/test_tools/selenium/core/scripts/js2html.js @@ -1,70 +1,70 @@ -/*
-
-This is an experiment in using the Narcissus JavaScript engine
-to allow Selenium scripts to be written in plain JavaScript.
-
-The 'jsparse' function will compile each high level block into a Selenium table script.
-
-
-TODO:
-1) Test! (More browsers, more sample scripts)
-2) Stepping and walking lower levels of the parse tree
-3) Calling Selenium commands directly from JavaScript
-4) Do we want comments to appear in the TestRunner?
-5) Fix context so variables don't have to be global
- For now, variables defined with "var" won't be found
- if used later on in a script.
-6) Fix formatting
-*/
-
-
-function jsparse() {
- var script = document.getElementById('sejs')
- var fname = 'javascript script';
- parse_result = parse(script.text, fname, 0);
-
- var x2 = new ExecutionContext(GLOBAL_CODE);
- ExecutionContext.current = x2;
-
-
- var new_test_source = '';
- var new_line = '';
-
- for (i=0;i<parse_result.$length;i++){
- var the_start = parse_result[i].start;
- var the_end;
- if ( i == (parse_result.$length-1)) {
- the_end = parse_result.tokenizer.source.length;
- } else {
- the_end = parse_result[i+1].start;
- }
-
- var script_fragment = parse_result.tokenizer.source.slice(the_start,the_end)
-
- new_line = '<tr><td style="display:none;" class="js">getEval</td>' +
- '<td style="display:none;">currentTest.doNextCommand()</td>' +
- '<td style="white-space: pre;">' + script_fragment + '</td>' +
- '<td></td></tr>\n';
- new_test_source += new_line;
- //eval(script_fragment);
-
-
- };
-
-
-
- execute(parse_result,x2)
-
- // Create HTML Table
- body = document.body
- body.innerHTML += "<table class='selenium' id='se-js-table'>"+
- "<tbody>" +
- "<tr><td>// " + document.title + "</td></tr>" +
- new_test_source +
- "</tbody" +
- "</table>";
-
- //body.innerHTML = "<pre>" + parse_result + "</pre>"
-}
-
-
+/* + +This is an experiment in using the Narcissus JavaScript engine +to allow Selenium scripts to be written in plain JavaScript. + +The 'jsparse' function will compile each high level block into a Selenium table script. + + +TODO: +1) Test! (More browsers, more sample scripts) +2) Stepping and walking lower levels of the parse tree +3) Calling Selenium commands directly from JavaScript +4) Do we want comments to appear in the TestRunner? +5) Fix context so variables don't have to be global + For now, variables defined with "var" won't be found + if used later on in a script. +6) Fix formatting +*/ + + +function jsparse() { + var script = document.getElementById('sejs') + var fname = 'javascript script'; + parse_result = parse(script.text, fname, 0); + + var x2 = new ExecutionContext(GLOBAL_CODE); + ExecutionContext.current = x2; + + + var new_test_source = ''; + var new_line = ''; + + for (i=0;i<parse_result.$length;i++){ + var the_start = parse_result[i].start; + var the_end; + if ( i == (parse_result.$length-1)) { + the_end = parse_result.tokenizer.source.length; + } else { + the_end = parse_result[i+1].start; + } + + var script_fragment = parse_result.tokenizer.source.slice(the_start,the_end) + + new_line = '<tr><td style="display:none;" class="js">getEval</td>' + + '<td style="display:none;">currentTest.doNextCommand()</td>' + + '<td style="white-space: pre;">' + script_fragment + '</td>' + + '<td></td></tr>\n'; + new_test_source += new_line; + //eval(script_fragment); + + + }; + + + + execute(parse_result,x2) + + // Create HTML Table + body = document.body + body.innerHTML += "<table class='selenium' id='se-js-table'>"+ + "<tbody>" + + "<tr><td>// " + document.title + "</td></tr>" + + new_test_source + + "</tbody" + + "</table>"; + + //body.innerHTML = "<pre>" + parse_result + "</pre>" +} + + diff --git a/tests/test_tools/selenium/core/scripts/se2html.js b/tests/test_tools/selenium/core/scripts/se2html.js index 67054a49..4894d4b1 100644 --- a/tests/test_tools/selenium/core/scripts/se2html.js +++ b/tests/test_tools/selenium/core/scripts/se2html.js @@ -1,63 +1,63 @@ -/*
-
-This is an experiment in creating a "selenese" parser that drastically
-cuts down on the line noise associated with writing tests in HTML.
-
-The 'parse' function will accept the follow sample commands.
-
-test-cases:
- //comment
- command "param"
- command "param" // comment
- command "param" "param2"
- command "param" "param2" // this is a comment
-
-TODO:
-1) Deal with multiline parameters
-2) Escape quotes properly
-3) Determine whether this should/will become the "preferred" syntax
- for delivered Selenium self-test scripts
-*/
-
-
-function separse(doc) {
- // Get object
- script = doc.getElementById('testcase')
- // Split into lines
- lines = script.text.split('\n');
-
-
- var command_pattern = / *(\w+) *"([^"]*)" *(?:"([^"]*)"){0,1}(?: *(\/\/ *.+))*/i;
- var comment_pattern = /^ *(\/\/ *.+)/
-
- // Regex each line into selenium command and convert into table row.
- // eg. "<command> <quote> <quote> <comment>"
- var new_test_source = '';
- var new_line = '';
- for (var x=0; x < lines.length; x++) {
- result = lines[x].match(command_pattern);
- if (result != null) {
- new_line = "<tr><td>" + (result[1] || ' ') + "</td>" +
- "<td>" + (result[2] || ' ') + "</td>" +
- "<td>" + (result[3] || ' ') + "</td>" +
- "<td>" + (result[4] || ' ') + "</td></tr>\n";
- new_test_source += new_line;
- }
- result = lines[x].match(comment_pattern);
- if (result != null) {
- new_line = '<tr><td rowspan="1" colspan="4">' +
- (result[1] || ' ') +
- '</td></tr>';
- new_test_source += new_line;
- }
- }
-
- // Create HTML Table
- body = doc.body
- body.innerHTML += "<table class='selenium' id='testtable'>"+
- new_test_source +
- "</table>";
-
-}
-
-
+/* + +This is an experiment in creating a "selenese" parser that drastically +cuts down on the line noise associated with writing tests in HTML. + +The 'parse' function will accept the follow sample commands. + +test-cases: + //comment + command "param" + command "param" // comment + command "param" "param2" + command "param" "param2" // this is a comment + +TODO: +1) Deal with multiline parameters +2) Escape quotes properly +3) Determine whether this should/will become the "preferred" syntax + for delivered Selenium self-test scripts +*/ + + +function separse(doc) { + // Get object + script = doc.getElementById('testcase') + // Split into lines + lines = script.text.split('\n'); + + + var command_pattern = / *(\w+) *"([^"]*)" *(?:"([^"]*)"){0,1}(?: *(\/\/ *.+))*/i; + var comment_pattern = /^ *(\/\/ *.+)/ + + // Regex each line into selenium command and convert into table row. + // eg. "<command> <quote> <quote> <comment>" + var new_test_source = ''; + var new_line = ''; + for (var x=0; x < lines.length; x++) { + result = lines[x].match(command_pattern); + if (result != null) { + new_line = "<tr><td>" + (result[1] || ' ') + "</td>" + + "<td>" + (result[2] || ' ') + "</td>" + + "<td>" + (result[3] || ' ') + "</td>" + + "<td>" + (result[4] || ' ') + "</td></tr>\n"; + new_test_source += new_line; + } + result = lines[x].match(comment_pattern); + if (result != null) { + new_line = '<tr><td rowspan="1" colspan="4">' + + (result[1] || ' ') + + '</td></tr>'; + new_test_source += new_line; + } + } + + // Create HTML Table + body = doc.body + body.innerHTML += "<table class='selenium' id='testtable'>"+ + new_test_source + + "</table>"; + +} + + diff --git a/tests/test_tools/selenium/php/TestSuiteHeader.php b/tests/test_tools/selenium/php/TestSuiteHeader.php index 6fe2f6b6..d253740c 100644 --- a/tests/test_tools/selenium/php/TestSuiteHeader.php +++ b/tests/test_tools/selenium/php/TestSuiteHeader.php @@ -1,54 +1,54 @@ -<!--
-Copyright 2004 ThoughtWorks, Inc
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<html>
-<head>
-<meta content="text/html; charset=ISO-8859-1"
-http-equiv="content-type">
-<title>Test Suite</title>
-<link rel="stylesheet" type="text/css" href="<?php echo $base_dir; ?>core/selenium.css" />
-<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-browserdetect.js"></script>
-<script language="JavaScript" type="text/javascript">
- var DISABLED = true; // used to flag failing tests
-
- function filterTestsForBrowser() {
- var suiteTable = document.getElementById("suiteTable");
- var skippedTests = document.getElementById("skippedTests");
-
- for(rowNum = suiteTable.rows.length - 1; rowNum >= 0; rowNum--)
- {
- var row = suiteTable.rows[rowNum];
- var filterString = row.getAttribute("unless");
- if (filterString && eval(filterString))
- {
- var cellHTML = row.cells[0].innerHTML;
- suiteTable.deleteRow(rowNum);
-
- var newRow = skippedTests.insertRow(1);
- var newCell = newRow.insertCell(0)
- newCell.innerHTML = cellHTML;
- }
- }
- }
-</script>
-</head>
-
-<body onload="filterTestsForBrowser()">
-
- <table id="suiteTable" cellpadding="1"
- cellspacing="1"
- border="1"
- class="selenium">
- <tbody>
+<!-- +Copyright 2004 ThoughtWorks, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<html> +<head> +<meta content="text/html; charset=ISO-8859-1" +http-equiv="content-type"> +<title>Test Suite</title> +<link rel="stylesheet" type="text/css" href="<?php echo $base_dir; ?>core/selenium.css" /> +<script language="JavaScript" type="text/javascript" src="<?php echo $base_dir; ?>core/scripts/selenium-browserdetect.js"></script> +<script language="JavaScript" type="text/javascript"> + var DISABLED = true; // used to flag failing tests + + function filterTestsForBrowser() { + var suiteTable = document.getElementById("suiteTable"); + var skippedTests = document.getElementById("skippedTests"); + + for(rowNum = suiteTable.rows.length - 1; rowNum >= 0; rowNum--) + { + var row = suiteTable.rows[rowNum]; + var filterString = row.getAttribute("unless"); + if (filterString && eval(filterString)) + { + var cellHTML = row.cells[0].innerHTML; + suiteTable.deleteRow(rowNum); + + var newRow = skippedTests.insertRow(1); + var newCell = newRow.insertCell(0) + newCell.innerHTML = cellHTML; + } + } + } +</script> +</head> + +<body onload="filterTestsForBrowser()"> + + <table id="suiteTable" cellpadding="1" + cellspacing="1" + border="1" + class="selenium"> + <tbody> diff --git a/tests/unit/Data/SqlMap/AllTests.php b/tests/unit/Data/SqlMap/AllTests.php index 66f02608..2f820f83 100644 --- a/tests/unit/Data/SqlMap/AllTests.php +++ b/tests/unit/Data/SqlMap/AllTests.php @@ -1,30 +1,30 @@ -<?php
-require_once dirname(__FILE__).'/../../phpunit.php';
-
-if(!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'Data_SqlMap_AllTests::main');
-}
-
-require_once 'DynamicParameterTest.php';
-require_once 'DataMapper/AllTests.php';
-
-class Data_SqlMap_AllTests {
-
- public static function main() {
- PHPUnit_TextUI_TestRunner::run(self::suite());
- }
-
- public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite('System.Data.SqlMap');
-
- $suite->addTestSuite('DynamicParameterTest');
- $suite -> addTest( Data_SqlMap_DataMapper_AllTests::suite() );
-
- return $suite;
- }
-}
-
-if(PHPUnit_MAIN_METHOD == 'Data_SqlMap_AllTests::main') {
- Data_SqlMap_AllTests::main();
-}
-?>
+<?php +require_once dirname(__FILE__).'/../../phpunit.php'; + +if(!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Data_SqlMap_AllTests::main'); +} + +require_once 'DynamicParameterTest.php'; +require_once 'DataMapper/AllTests.php'; + +class Data_SqlMap_AllTests { + + public static function main() { + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + public static function suite() { + $suite = new PHPUnit_Framework_TestSuite('System.Data.SqlMap'); + + $suite->addTestSuite('DynamicParameterTest'); + $suite -> addTest( Data_SqlMap_DataMapper_AllTests::suite() ); + + return $suite; + } +} + +if(PHPUnit_MAIN_METHOD == 'Data_SqlMap_AllTests::main') { + Data_SqlMap_AllTests::main(); +} +?> diff --git a/tests/unit/Data/SqlMap/DynamicParameterTest.php b/tests/unit/Data/SqlMap/DynamicParameterTest.php index f9b39b96..0bd5334e 100644 --- a/tests/unit/Data/SqlMap/DynamicParameterTest.php +++ b/tests/unit/Data/SqlMap/DynamicParameterTest.php @@ -1,109 +1,109 @@ -<?php
-require_once dirname(__FILE__).'/../../phpunit.php';
-
-Prado::using('System.Data.*');
-Prado::using('System.Data.SqlMap.*');
-
-/**
- * @package System.Data.SqlMap
- */
-class DynamicParameterTest extends PHPUnit_Framework_TestCase
-{
-
- protected function getMysqlSqlMapManager()
- {
- static $conn;
- static $sqlMapManager;
-
- if(Prado::getApplication() === null)
- Prado::setApplication(new TApplication(dirname(__FILE__).'/app'));
-
- if($conn === null)
- $conn = new TDbConnection('mysql:host=localhost;dbname=prado_system_data_sqlmap', 'prado_unitest', 'prado_system_data_sqlmap_unitest');
-
- $conn->setActive(true);
-
- if($sqlMapManager === null)
- {
- $sqlMapManager = new TSqlMapManager($conn);
- $sqlMapManager->configureXml( dirname(__FILE__) . '/DynamicParameterTestMap.xml');
- }
-
- return $sqlMapManager;
- }
-
- public function testMysqlSelectStaticSql()
- {
- $mapper = $this->getMysqlSqlMapManager();
- $gateway = $mapper->getSqlmapGateway();
-
- $value = $gateway->queryForObject('SelectStaticSql1');
- self::assertEquals('staticsql1', $value);
-
- $value = $gateway->queryForObject('SelectStaticSql2');
- self::assertEquals('staticsql2', $value);
- }
-
- public function testMysqlSelectDynamicTable()
- {
- $mapper = $this->getMysqlSqlMapManager();
- $gateway = $mapper->getSqlmapGateway();
-
- $value = $gateway->queryForObject('SelectDynamicTable', 'dynamicparametertest1');
- self::assertEquals('dynamictableparametertest1', $value);
-
- $value = $gateway->queryForObject('SelectDynamicTable', 'dynamicparametertest2');
- self::assertEquals('dynamictableparametertest2', $value);
- }
-
- public function testMysqlSelectDynamicComplex()
- {
- $mapper = $this->getMysqlSqlMapManager();
- $gateway = $mapper->getSqlmapGateway();
-
- $aParams = array(
- 'tablename' => 'dynamicparametertest1',
- 'testname' => 'dynamictable'
- );
- $value = $gateway->queryForObject('SelectDynamicComplex', $aParams);
- self::assertEquals('#dynamictableparametertest1$', $value);
-
- $aParams = array(
- 'tablename' => 'dynamicparametertest2',
- 'testname' => 'dynamictable'
- );
- $value = $gateway->queryForObject('SelectDynamicComplex', $aParams);
- self::assertEquals('#dynamictableparametertest2$', $value);
- }
-
- public function testMysqlSelectNoDynamic()
- {
- $mapper = $this->getMysqlSqlMapManager();
- $gateway = $mapper->getSqlmapGateway();
-
- $value = $gateway->queryForObject('SelectNoDynamic', 'dynamictable');
- self::assertEquals('dynamictableparametertest1', $value);
-
- $value = $gateway->queryForObject('SelectNoDynamic', 'staticsql');
- self::assertEquals('staticsql1', $value);
- }
-
- /**
- * Issue#209 test
- */
- public function testMysqlInlineEscapeParam()
- {
- $mapper = $this->getMysqlSqlMapManager();
- $gateway = $mapper->getSqlmapGateway();
-
- $value = $gateway->queryForObject('SelectInlineEscapeParam', "'1234567*123$456789$012345' AS foobar");
- self::assertEquals('1234567*123$456789$012345', $value);
-
- $value = $gateway->queryForObject('SelectInlineEscapeParam', '"1234567*123$456789$012345" AS foobar');
- self::assertEquals('1234567*123$456789$012345', $value);
-
- }
-
-}
-
+<?php +require_once dirname(__FILE__).'/../../phpunit.php'; + +Prado::using('System.Data.*'); +Prado::using('System.Data.SqlMap.*'); + +/** + * @package System.Data.SqlMap + */ +class DynamicParameterTest extends PHPUnit_Framework_TestCase +{ + + protected function getMysqlSqlMapManager() + { + static $conn; + static $sqlMapManager; + + if(Prado::getApplication() === null) + Prado::setApplication(new TApplication(dirname(__FILE__).'/app')); + + if($conn === null) + $conn = new TDbConnection('mysql:host=localhost;dbname=prado_system_data_sqlmap', 'prado_unitest', 'prado_system_data_sqlmap_unitest'); + + $conn->setActive(true); + + if($sqlMapManager === null) + { + $sqlMapManager = new TSqlMapManager($conn); + $sqlMapManager->configureXml( dirname(__FILE__) . '/DynamicParameterTestMap.xml'); + } + + return $sqlMapManager; + } + + public function testMysqlSelectStaticSql() + { + $mapper = $this->getMysqlSqlMapManager(); + $gateway = $mapper->getSqlmapGateway(); + + $value = $gateway->queryForObject('SelectStaticSql1'); + self::assertEquals('staticsql1', $value); + + $value = $gateway->queryForObject('SelectStaticSql2'); + self::assertEquals('staticsql2', $value); + } + + public function testMysqlSelectDynamicTable() + { + $mapper = $this->getMysqlSqlMapManager(); + $gateway = $mapper->getSqlmapGateway(); + + $value = $gateway->queryForObject('SelectDynamicTable', 'dynamicparametertest1'); + self::assertEquals('dynamictableparametertest1', $value); + + $value = $gateway->queryForObject('SelectDynamicTable', 'dynamicparametertest2'); + self::assertEquals('dynamictableparametertest2', $value); + } + + public function testMysqlSelectDynamicComplex() + { + $mapper = $this->getMysqlSqlMapManager(); + $gateway = $mapper->getSqlmapGateway(); + + $aParams = array( + 'tablename' => 'dynamicparametertest1', + 'testname' => 'dynamictable' + ); + $value = $gateway->queryForObject('SelectDynamicComplex', $aParams); + self::assertEquals('#dynamictableparametertest1$', $value); + + $aParams = array( + 'tablename' => 'dynamicparametertest2', + 'testname' => 'dynamictable' + ); + $value = $gateway->queryForObject('SelectDynamicComplex', $aParams); + self::assertEquals('#dynamictableparametertest2$', $value); + } + + public function testMysqlSelectNoDynamic() + { + $mapper = $this->getMysqlSqlMapManager(); + $gateway = $mapper->getSqlmapGateway(); + + $value = $gateway->queryForObject('SelectNoDynamic', 'dynamictable'); + self::assertEquals('dynamictableparametertest1', $value); + + $value = $gateway->queryForObject('SelectNoDynamic', 'staticsql'); + self::assertEquals('staticsql1', $value); + } + + /** + * Issue#209 test + */ + public function testMysqlInlineEscapeParam() + { + $mapper = $this->getMysqlSqlMapManager(); + $gateway = $mapper->getSqlmapGateway(); + + $value = $gateway->queryForObject('SelectInlineEscapeParam', "'1234567*123$456789$012345' AS foobar"); + self::assertEquals('1234567*123$456789$012345', $value); + + $value = $gateway->queryForObject('SelectInlineEscapeParam', '"1234567*123$456789$012345" AS foobar'); + self::assertEquals('1234567*123$456789$012345', $value); + + } + +} + ?>
\ No newline at end of file diff --git a/tests/unit/Data/TDbDataReaderTest.php b/tests/unit/Data/TDbDataReaderTest.php index 68f9bfe8..9d61a330 100644 --- a/tests/unit/Data/TDbDataReaderTest.php +++ b/tests/unit/Data/TDbDataReaderTest.php @@ -1,179 +1,179 @@ -<?php
-
-require_once(dirname(__FILE__).'/../phpunit2.php');
-
-Prado::using('System.Data.*');
-
-define('TEST_DB_FILE',dirname(__FILE__).'/db/test.db');
-
-class FooRecord extends TComponent
-{
- public $id;
- private $_name;
- public $param;
-
- public function __construct($param)
- {
- $this->param=$param;
- }
-
- public function getName()
- {
- return $this->_name;
- }
-
- public function setName($value)
- {
- $this->_name=$value;
- }
-}
-
-/**
- * @package System.Data.PDO
- */
-class TDbDataReaderTest extends PHPUnit2_Framework_TestCase
-{
- private $_connection;
-
- public function setUp()
- {
- @unlink(TEST_DB_FILE);
- $this->_connection=new TDbConnection('sqlite:'.TEST_DB_FILE);
- $this->_connection->Active=true;
- $this->_connection->createCommand('CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(8))')->execute();
- $this->_connection->createCommand('INSERT INTO foo (name) VALUES (\'my name\')')->execute();
- $this->_connection->createCommand('INSERT INTO foo (name) VALUES (\'my name 2\')')->execute();
- }
-
- public function tearDown()
- {
- $this->_connection=null;
- }
-
- public function testRead()
- {
- $reader=$this->_connection->createCommand('SELECT * FROM foo')->query();
- $row=$reader->read();
- $this->assertTrue($row['id']==='1' && $row['name']==='my name');
- $row=$reader->read();
- $this->assertTrue($row['id']==='2' && $row['name']==='my name 2');
- $row=$reader->read();
- $this->assertFalse($row);
- }
-
- public function testReadColumn()
- {
- $reader=$this->_connection->createCommand('SELECT * FROM foo')->query();
- $this->assertEquals($reader->readColumn(0),'1');
- $this->assertEquals($reader->readColumn(1),'my name 2');
- $this->assertFalse($reader->readColumn(0));
- }
-
- public function testReadObject()
- {
- $reader=$this->_connection->createCommand('SELECT * FROM foo')->query();
- $object=$reader->readObject('FooRecord',array('object'));
- $this->assertEquals($object->id,'1');
- $this->assertEquals($object->Name,'my name');
- $this->assertEquals($object->param,'object');
- }
-
- public function testReadAll()
- {
- $reader=$this->_connection->createCommand('SELECT * FROM foo')->query();
- $rows=$reader->readAll();
- $this->assertEquals(count($rows),2);
- $row=$rows[0];
- $this->assertTrue($row['id']==='1' && $row['name']==='my name');
- $row=$rows[1];
- $this->assertTrue($row['id']==='2' && $row['name']==='my name 2');
-
- $reader=$this->_connection->createCommand('SELECT * FROM foo WHERE id=3')->query();
- $rows=$reader->readAll();
- $this->assertEquals($rows,array());
- }
-
- public function testClose()
- {
- $reader=$this->_connection->createCommand('SELECT * FROM foo')->query();
- $row=$reader->read();
- $this->assertFalse($reader->IsClosed);
- $reader->close();
- $this->assertTrue($reader->IsClosed);
- try
- {
- $reader->read();
- $this->fail('Expected exception is not raised');
- }
- catch(Exception $e)
- {
- }
- }
-
- public function testRowCount()
- {
- // unable to test because SQLite doesn't support row count
- }
-
- public function testColumnCount()
- {
- $reader=$this->_connection->createCommand('SELECT * FROM foo')->query();
- $this->assertEquals($reader->ColumnCount,2);
-
- $reader=$this->_connection->createCommand('SELECT * FROM foo WHERE id=11')->query();
- $this->assertEquals($reader->ColumnCount,2);
- }
-
- public function testForeach()
- {
- $ids=array();
- $reader=$this->_connection->createCommand('SELECT * FROM foo')->query();
- foreach($reader as $row)
- $ids[]=$row['id'];
- $this->assertEquals(count($ids),2);
- $this->assertTrue($ids[0]==='1' && $ids[1]==='2');
-
- try
- {
- foreach($reader as $row)
- $ids[]=$row['id'];
- $this->fail('Expected exception is not raised');
- }
- catch(TDbException $e)
- {
- }
- }
-
- public function testFetchMode()
- {
- $reader=$this->_connection->createCommand('SELECT * FROM foo')->query();
-
- $reader->FetchMode=PDO::FETCH_NUM;
- $row=$reader->read();
- $this->assertFalse(isset($row['id']));
- $this->assertTrue(isset($row[0]));
-
- $reader->FetchMode=PDO::FETCH_ASSOC;
- $row=$reader->read();
- $this->assertTrue(isset($row['id']));
- $this->assertFalse(isset($row[0]));
- }
-
- public function testBindColumn()
- {
- $reader=$this->_connection->createCommand('SELECT * FROM foo')->query();
- $reader->bindColumn(1,$id);
- $reader->bindColumn(2,$name);
- $reader->read();
- $this->assertEquals($id,'1');
- $this->assertEquals($name,'my name');
- $reader->read();
- $this->assertEquals($id,'2');
- $this->assertEquals($name,'my name 2');
- $reader->read();
- $this->assertEquals($id,'2');
- $this->assertEquals($name,'my name 2');
- }
-}
-
+<?php + +require_once(dirname(__FILE__).'/../phpunit2.php'); + +Prado::using('System.Data.*'); + +define('TEST_DB_FILE',dirname(__FILE__).'/db/test.db'); + +class FooRecord extends TComponent +{ + public $id; + private $_name; + public $param; + + public function __construct($param) + { + $this->param=$param; + } + + public function getName() + { + return $this->_name; + } + + public function setName($value) + { + $this->_name=$value; + } +} + +/** + * @package System.Data.PDO + */ +class TDbDataReaderTest extends PHPUnit2_Framework_TestCase +{ + private $_connection; + + public function setUp() + { + @unlink(TEST_DB_FILE); + $this->_connection=new TDbConnection('sqlite:'.TEST_DB_FILE); + $this->_connection->Active=true; + $this->_connection->createCommand('CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(8))')->execute(); + $this->_connection->createCommand('INSERT INTO foo (name) VALUES (\'my name\')')->execute(); + $this->_connection->createCommand('INSERT INTO foo (name) VALUES (\'my name 2\')')->execute(); + } + + public function tearDown() + { + $this->_connection=null; + } + + public function testRead() + { + $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); + $row=$reader->read(); + $this->assertTrue($row['id']==='1' && $row['name']==='my name'); + $row=$reader->read(); + $this->assertTrue($row['id']==='2' && $row['name']==='my name 2'); + $row=$reader->read(); + $this->assertFalse($row); + } + + public function testReadColumn() + { + $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); + $this->assertEquals($reader->readColumn(0),'1'); + $this->assertEquals($reader->readColumn(1),'my name 2'); + $this->assertFalse($reader->readColumn(0)); + } + + public function testReadObject() + { + $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); + $object=$reader->readObject('FooRecord',array('object')); + $this->assertEquals($object->id,'1'); + $this->assertEquals($object->Name,'my name'); + $this->assertEquals($object->param,'object'); + } + + public function testReadAll() + { + $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); + $rows=$reader->readAll(); + $this->assertEquals(count($rows),2); + $row=$rows[0]; + $this->assertTrue($row['id']==='1' && $row['name']==='my name'); + $row=$rows[1]; + $this->assertTrue($row['id']==='2' && $row['name']==='my name 2'); + + $reader=$this->_connection->createCommand('SELECT * FROM foo WHERE id=3')->query(); + $rows=$reader->readAll(); + $this->assertEquals($rows,array()); + } + + public function testClose() + { + $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); + $row=$reader->read(); + $this->assertFalse($reader->IsClosed); + $reader->close(); + $this->assertTrue($reader->IsClosed); + try + { + $reader->read(); + $this->fail('Expected exception is not raised'); + } + catch(Exception $e) + { + } + } + + public function testRowCount() + { + // unable to test because SQLite doesn't support row count + } + + public function testColumnCount() + { + $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); + $this->assertEquals($reader->ColumnCount,2); + + $reader=$this->_connection->createCommand('SELECT * FROM foo WHERE id=11')->query(); + $this->assertEquals($reader->ColumnCount,2); + } + + public function testForeach() + { + $ids=array(); + $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); + foreach($reader as $row) + $ids[]=$row['id']; + $this->assertEquals(count($ids),2); + $this->assertTrue($ids[0]==='1' && $ids[1]==='2'); + + try + { + foreach($reader as $row) + $ids[]=$row['id']; + $this->fail('Expected exception is not raised'); + } + catch(TDbException $e) + { + } + } + + public function testFetchMode() + { + $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); + + $reader->FetchMode=PDO::FETCH_NUM; + $row=$reader->read(); + $this->assertFalse(isset($row['id'])); + $this->assertTrue(isset($row[0])); + + $reader->FetchMode=PDO::FETCH_ASSOC; + $row=$reader->read(); + $this->assertTrue(isset($row['id'])); + $this->assertFalse(isset($row[0])); + } + + public function testBindColumn() + { + $reader=$this->_connection->createCommand('SELECT * FROM foo')->query(); + $reader->bindColumn(1,$id); + $reader->bindColumn(2,$name); + $reader->read(); + $this->assertEquals($id,'1'); + $this->assertEquals($name,'my name'); + $reader->read(); + $this->assertEquals($id,'2'); + $this->assertEquals($name,'my name 2'); + $reader->read(); + $this->assertEquals($id,'2'); + $this->assertEquals($name,'my name 2'); + } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/BaseTest.php b/tests/unit/SQLMap/BaseTest.php index 0f3ce1e2..047863ec 100644 --- a/tests/unit/SQLMap/BaseTest.php +++ b/tests/unit/SQLMap/BaseTest.php @@ -1,260 +1,260 @@ -<?php
-require_once dirname(__FILE__).'/../phpunit2.php';
-
-require_once(dirname(__FILE__).'/common.php');
-require_once(SQLMAP_DIR.'/TSqlMapClient.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class BaseTest extends PHPUnit2_Framework_TestCase
-{
- protected $sqlmap;
- protected $connection;
- private $mapper;
- private $config;
-
- public function testCase1()
- {
- $this->assertTrue(true);
- }
-
- public function testCase2()
- {
- $this->assertTrue(true);
- }
-
- public function __construct()
- {
- parent::__construct();
- $this->config = BaseTestConfig::createConfigInstance();
- $this->ScriptDirectory = $this->config->getScriptDir();
- }
-
- public function hasSupportFor($feature)
- {
- return $this->config->hasFeature($feature);
- }
-
- public function __destruct()
- {
- if(!is_null($this->mapper))
- $this->mapper->cacheConfiguration();
- }
-
- function getConnection()
- {
- if(is_null($this->connection))
- $this->connection = new TAdodbConnection($this->config->getConnectionString());
- $this->connection->open();
- return $this->connection;
- }
-
- protected static $ScriptDirectory;
-
- /**
- * Initialize an sqlMap
- */
- protected function initSqlMap()
- {
- $filename = $this->config->getSqlMapConfigFile();
- $this->mapper = new TSQLMapClient;
- $this->sqlmap = $this->mapper->configure($filename,true);
- $this->sqlmap->getTypeHandlerFactory()->register('date', new TDateTimeHandler);
- $this->sqlmap->getDataProvider()->setConnectionString($this->config->getConnectionString());
- }
-
- /**
- * Run a sql batch for the datasource.
- */
- protected function initScript($script)
- {
- $runner = $this->config->getScriptRunner();
- $runner->runScript($this->getConnection(), $this->ScriptDirectory.$script);
- }
-
- /**
- * Create a new account with id = 6
- */
- protected function NewAccount6()
- {
- $account = new Account();
- $account->setID(6);
- $account->setFirstName('Calamity');
- $account->setLastName('Jane');
- $account->setEmailAddress('no_email@provided.com');
- return $account;
- }
-
- /**
- * Verify that the input account is equal to the account(id=1).
- */
- protected function assertAccount1(Account $account)
- {
- $this->assertEquals($account->getID(), 1);
- $this->assertEquals($account->getFirstName(), 'Joe');
- $this->assertEquals($account->getEmailAddress(), 'Joe.Dalton@somewhere.com');
- }
-
- /**
- * Verify that the input account is equal to the account(id=6).
- */
- protected function assertAccount6(Account $account)
- {
- $this->assertEquals($account->getID(), 6);
- $this->assertEquals($account->getFirstName(), 'Calamity');
- $this->assertEquals($account->getLastName(), 'Jane');
- $this->assertNull($account->getEmailAddress());
- }
-
- /**
- * Verify that the input order is equal to the order(id=1).
- */
- protected function assertOrder1(Order $order)
- {
- $date = @mktime(8,15,0,2,15,2003);
-
- $this->assertEquals((int)$order->getID(), 1);
- if($order->getDate() instanceof TDateTime)
- $this->assertEquals($order->getDate()->getTimestamp(), $date);
- else
- $this->fail();
- $this->assertEquals($order->getCardType(), 'VISA');
- $this->assertEquals($order->getCardNumber(), '999999999999');
- $this->assertEquals($order->getCardExpiry(), '05/03');
- $this->assertEquals($order->getStreet(), '11 This Street');
- $this->assertEquals($order->getProvince(), 'BC');
- $this->assertEquals($order->getPostalCode(), 'C4B 4F4');
- }
-
- function assertAccount1AsHashArray($account)
- {
- $this->assertEquals(1, (int)$account["Id"]);
- $this->assertEquals("Joe", $account["FirstName"]);
- $this->assertEquals("Dalton", $account["LastName"]);
- $this->assertEquals("Joe.Dalton@somewhere.com", $account["EmailAddress"]);
- }
-
- function AssertOrder1AsHashArray($order)
- {
- $date = @mktime(8,15,0,2,15,2003);
-
- $this->assertEquals(1, $order["Id"]);
- if($order['Date'] instanceof TDateTime)
- $this->assertEquals($date, $order["Date"]->getTimestamp());
- else
- $this->fail();
- $this->assertEquals("VISA", $order["CardType"]);
- $this->assertEquals("999999999999", $order["CardNumber"]);
- $this->assertEquals("05/03", $order["CardExpiry"]);
- $this->assertEquals("11 This Street", $order["Street"]);
- $this->assertEquals("Victoria", $order["City"]);
- $this->assertEquals("BC", $order["Province"]);
- $this->assertEquals("C4B 4F4", $order["PostalCode"]);
- }
-
-}
-
-class HundredsBool implements ITypeHandlerCallback
-{
- public function getResult($string)
- {
- $value = intval($string);
- if($value == 100)
- return true;
- if($value == 200)
- return false;
- //throw new Exception('unexpected value '.$value);
- }
-
- public function getParameter($parameter)
- {
- if($parameter)
- return 100;
- else
- return 200;
- }
-
- public function createNewInstance($data=null)
- {
- throw new TDataMapperException('can not create');
- }
-}
-
-class OuiNonBool implements ITypeHandlerCallback
-{
- const YES = "Oui";
- const NO = "Non";
-
- public function getResult($string)
- {
- if($string === self::YES)
- return true;
- if($string === self::NO)
- return false;
- //throw new Exception('unexpected value '.$string);
- }
-
- public function getParameter($parameter)
- {
- if($parameter)
- return self::YES;
- else
- return self::NO;
- }
-
- public function createNewInstance($data=null)
- {
- throw new TDataMapperException('can not create');
- }
-}
-
-class TDateTimeHandler implements ITypeHandlerCallback
-{
- public function getResult($string)
- {
- $time = new TDateTime($string);
- return $time;
- }
-
- public function getParameter($parameter)
- {
- if($parameter instanceof TDateTime)
- return $parameter->getTimestamp();
- else
- return $parameter;
- }
-
- public function createNewInstance($data=null)
- {
- return new TDateTime;
- }
-}
-
-class TDateTime
-{
- private $_datetime;
-
- public function __construct($datetime=null)
- {
- if(!is_null($datetime))
- $this->setDatetime($datetime);
- }
-
- public function getTimestamp()
- {
- return strtotime($this->getDatetime());
- }
-
- public function getDateTime()
- {
- return $this->_datetime;
- }
-
- public function setDateTime($value)
- {
- $this->_datetime = $value;
- }
-}
-
+<?php +require_once dirname(__FILE__).'/../phpunit2.php'; + +require_once(dirname(__FILE__).'/common.php'); +require_once(SQLMAP_DIR.'/TSqlMapClient.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class BaseTest extends PHPUnit2_Framework_TestCase +{ + protected $sqlmap; + protected $connection; + private $mapper; + private $config; + + public function testCase1() + { + $this->assertTrue(true); + } + + public function testCase2() + { + $this->assertTrue(true); + } + + public function __construct() + { + parent::__construct(); + $this->config = BaseTestConfig::createConfigInstance(); + $this->ScriptDirectory = $this->config->getScriptDir(); + } + + public function hasSupportFor($feature) + { + return $this->config->hasFeature($feature); + } + + public function __destruct() + { + if(!is_null($this->mapper)) + $this->mapper->cacheConfiguration(); + } + + function getConnection() + { + if(is_null($this->connection)) + $this->connection = new TAdodbConnection($this->config->getConnectionString()); + $this->connection->open(); + return $this->connection; + } + + protected static $ScriptDirectory; + + /** + * Initialize an sqlMap + */ + protected function initSqlMap() + { + $filename = $this->config->getSqlMapConfigFile(); + $this->mapper = new TSQLMapClient; + $this->sqlmap = $this->mapper->configure($filename,true); + $this->sqlmap->getTypeHandlerFactory()->register('date', new TDateTimeHandler); + $this->sqlmap->getDataProvider()->setConnectionString($this->config->getConnectionString()); + } + + /** + * Run a sql batch for the datasource. + */ + protected function initScript($script) + { + $runner = $this->config->getScriptRunner(); + $runner->runScript($this->getConnection(), $this->ScriptDirectory.$script); + } + + /** + * Create a new account with id = 6 + */ + protected function NewAccount6() + { + $account = new Account(); + $account->setID(6); + $account->setFirstName('Calamity'); + $account->setLastName('Jane'); + $account->setEmailAddress('no_email@provided.com'); + return $account; + } + + /** + * Verify that the input account is equal to the account(id=1). + */ + protected function assertAccount1(Account $account) + { + $this->assertEquals($account->getID(), 1); + $this->assertEquals($account->getFirstName(), 'Joe'); + $this->assertEquals($account->getEmailAddress(), 'Joe.Dalton@somewhere.com'); + } + + /** + * Verify that the input account is equal to the account(id=6). + */ + protected function assertAccount6(Account $account) + { + $this->assertEquals($account->getID(), 6); + $this->assertEquals($account->getFirstName(), 'Calamity'); + $this->assertEquals($account->getLastName(), 'Jane'); + $this->assertNull($account->getEmailAddress()); + } + + /** + * Verify that the input order is equal to the order(id=1). + */ + protected function assertOrder1(Order $order) + { + $date = @mktime(8,15,0,2,15,2003); + + $this->assertEquals((int)$order->getID(), 1); + if($order->getDate() instanceof TDateTime) + $this->assertEquals($order->getDate()->getTimestamp(), $date); + else + $this->fail(); + $this->assertEquals($order->getCardType(), 'VISA'); + $this->assertEquals($order->getCardNumber(), '999999999999'); + $this->assertEquals($order->getCardExpiry(), '05/03'); + $this->assertEquals($order->getStreet(), '11 This Street'); + $this->assertEquals($order->getProvince(), 'BC'); + $this->assertEquals($order->getPostalCode(), 'C4B 4F4'); + } + + function assertAccount1AsHashArray($account) + { + $this->assertEquals(1, (int)$account["Id"]); + $this->assertEquals("Joe", $account["FirstName"]); + $this->assertEquals("Dalton", $account["LastName"]); + $this->assertEquals("Joe.Dalton@somewhere.com", $account["EmailAddress"]); + } + + function AssertOrder1AsHashArray($order) + { + $date = @mktime(8,15,0,2,15,2003); + + $this->assertEquals(1, $order["Id"]); + if($order['Date'] instanceof TDateTime) + $this->assertEquals($date, $order["Date"]->getTimestamp()); + else + $this->fail(); + $this->assertEquals("VISA", $order["CardType"]); + $this->assertEquals("999999999999", $order["CardNumber"]); + $this->assertEquals("05/03", $order["CardExpiry"]); + $this->assertEquals("11 This Street", $order["Street"]); + $this->assertEquals("Victoria", $order["City"]); + $this->assertEquals("BC", $order["Province"]); + $this->assertEquals("C4B 4F4", $order["PostalCode"]); + } + +} + +class HundredsBool implements ITypeHandlerCallback +{ + public function getResult($string) + { + $value = intval($string); + if($value == 100) + return true; + if($value == 200) + return false; + //throw new Exception('unexpected value '.$value); + } + + public function getParameter($parameter) + { + if($parameter) + return 100; + else + return 200; + } + + public function createNewInstance($data=null) + { + throw new TDataMapperException('can not create'); + } +} + +class OuiNonBool implements ITypeHandlerCallback +{ + const YES = "Oui"; + const NO = "Non"; + + public function getResult($string) + { + if($string === self::YES) + return true; + if($string === self::NO) + return false; + //throw new Exception('unexpected value '.$string); + } + + public function getParameter($parameter) + { + if($parameter) + return self::YES; + else + return self::NO; + } + + public function createNewInstance($data=null) + { + throw new TDataMapperException('can not create'); + } +} + +class TDateTimeHandler implements ITypeHandlerCallback +{ + public function getResult($string) + { + $time = new TDateTime($string); + return $time; + } + + public function getParameter($parameter) + { + if($parameter instanceof TDateTime) + return $parameter->getTimestamp(); + else + return $parameter; + } + + public function createNewInstance($data=null) + { + return new TDateTime; + } +} + +class TDateTime +{ + private $_datetime; + + public function __construct($datetime=null) + { + if(!is_null($datetime)) + $this->setDatetime($datetime); + } + + public function getTimestamp() + { + return strtotime($this->getDatetime()); + } + + public function getDateTime() + { + return $this->_datetime; + } + + public function setDateTime($value) + { + $this->_datetime = $value; + } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/CacheTest.php b/tests/unit/SQLMap/CacheTest.php index 4fd69916..c8a0aab7 100644 --- a/tests/unit/SQLMap/CacheTest.php +++ b/tests/unit/SQLMap/CacheTest.php @@ -1,164 +1,164 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class CacheTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
-
- $this->initSqlMap();
-
- //force autoload
- new Account;
- }
-
- function resetDatabase()
- {
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test for JIRA 29
- */
- function testJIRA28()
- {
- $account = $this->sqlmap->queryForObject("GetNoAccountWithCache",-99);
- $this->assertNull($account);
- }
-
- /**
- * Test Cache query
- */
- function testQueryWithCache()
- {
- $this->resetDatabase();
-
- $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 === $list2);
-
- $account = $list1[1];
- $account->setEmailAddress("somebody@cache.com");
-
- //this will cause the cache to flush
- $this->sqlmap->update("UpdateAccountViaInlineParameters", $account);
-
- $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 !== $list3);
-
- $this->resetDatabase();
- }
-
-
- /**
- * Test flush Cache
- */
- function testFlushDataCache()
- {
- $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
- $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 === $list2);
- $this->sqlmap->flushCaches();
-
- $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 !== $list3);
- }
-
- /**
- *
- */
- function testFlushDataCacheOnExecute()
- {
- $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 === $list2);
- $this->sqlmap->update("UpdateAccountViaInlineParameters", $list1[0]);
-
- $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap");
-
- $this->assertTrue($list1 !== $list3);
- }
-
- /**
- */
- protected function getCacheModel()
- {
- $cache = new TSqlMapCacheModel();
- // $cache->setFlushInterval(5*60);
- $cache->setImplementation('LRU');
- $cache->initialize($this->sqlmap);
- return $cache;
- }
-
- /**
- * Test CacheHit
- */
- function testCacheHit()
- {
- $cache = $this->getCacheModel();
- $key = new TSqlMapCacheKey('testkey');
- $cache->set($key, 'a');
-
- $returnedObject = $cache->get($key);
-
- $this->assertEquals('a', $returnedObject);
-
- $this->assertEquals(1, $cache->getHitRatio());
- }
-
-
-
- /**
- * Test CacheMiss
- */
- function testCacheMiss()
- {
- $cache = $this->getCacheModel();
- $key = new TSqlMapCacheKey('testKey');
- $value = 'testValue';
- $cache->set($key, $value);
-
- $wrongKey = new TSqlMapCacheKey('wrongKey');
-
- $returnedObject = $cache->get($wrongKey);
- $this->assertNotEquals($value, $returnedObject);
- $this->assertNull($returnedObject) ;
- $this->assertEquals(0, $cache->getHitRatio());
- }
-
- /**
- * Test CacheHitMiss
- */
- function testCacheHitMiss()
- {
- $cache = $this->getCacheModel();
- $key = new TSqlMapCacheKey('testKey');
-
- $value = "testValue";
- $cache->set($key, $value);
-
- $returnedObject = $cache->get($key);
- $this->assertEquals($value, $returnedObject);
-
- $wrongKey = new TSqlMapCacheKey('wrongKey');
-
- $returnedObject = $cache->get($wrongKey);
- $this->assertNotEquals($value, $returnedObject);
- $this->assertNull($returnedObject) ;
- $this->assertEquals(0.5, $cache->getHitRatio());
- }
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class CacheTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + + $this->initSqlMap(); + + //force autoload + new Account; + } + + function resetDatabase() + { + $this->initScript('account-init.sql'); + } + + /** + * Test for JIRA 29 + */ + function testJIRA28() + { + $account = $this->sqlmap->queryForObject("GetNoAccountWithCache",-99); + $this->assertNull($account); + } + + /** + * Test Cache query + */ + function testQueryWithCache() + { + $this->resetDatabase(); + + $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 === $list2); + + $account = $list1[1]; + $account->setEmailAddress("somebody@cache.com"); + + //this will cause the cache to flush + $this->sqlmap->update("UpdateAccountViaInlineParameters", $account); + + $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 !== $list3); + + $this->resetDatabase(); + } + + + /** + * Test flush Cache + */ + function testFlushDataCache() + { + $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 === $list2); + $this->sqlmap->flushCaches(); + + $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 !== $list3); + } + + /** + * + */ + function testFlushDataCacheOnExecute() + { + $list1 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $list2 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 === $list2); + $this->sqlmap->update("UpdateAccountViaInlineParameters", $list1[0]); + + $list3 = $this->sqlmap->queryForList("GetCachedAccountsViaResultMap"); + + $this->assertTrue($list1 !== $list3); + } + + /** + */ + protected function getCacheModel() + { + $cache = new TSqlMapCacheModel(); + // $cache->setFlushInterval(5*60); + $cache->setImplementation('LRU'); + $cache->initialize($this->sqlmap); + return $cache; + } + + /** + * Test CacheHit + */ + function testCacheHit() + { + $cache = $this->getCacheModel(); + $key = new TSqlMapCacheKey('testkey'); + $cache->set($key, 'a'); + + $returnedObject = $cache->get($key); + + $this->assertEquals('a', $returnedObject); + + $this->assertEquals(1, $cache->getHitRatio()); + } + + + + /** + * Test CacheMiss + */ + function testCacheMiss() + { + $cache = $this->getCacheModel(); + $key = new TSqlMapCacheKey('testKey'); + $value = 'testValue'; + $cache->set($key, $value); + + $wrongKey = new TSqlMapCacheKey('wrongKey'); + + $returnedObject = $cache->get($wrongKey); + $this->assertNotEquals($value, $returnedObject); + $this->assertNull($returnedObject) ; + $this->assertEquals(0, $cache->getHitRatio()); + } + + /** + * Test CacheHitMiss + */ + function testCacheHitMiss() + { + $cache = $this->getCacheModel(); + $key = new TSqlMapCacheKey('testKey'); + + $value = "testValue"; + $cache->set($key, $value); + + $returnedObject = $cache->get($key); + $this->assertEquals($value, $returnedObject); + + $wrongKey = new TSqlMapCacheKey('wrongKey'); + + $returnedObject = $cache->get($wrongKey); + $this->assertNotEquals($value, $returnedObject); + $this->assertNull($returnedObject) ; + $this->assertEquals(0.5, $cache->getHitRatio()); + } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/ConfigureTest.php b/tests/unit/SQLMap/ConfigureTest.php index ef2e5e31..84c77c0e 100644 --- a/tests/unit/SQLMap/ConfigureTest.php +++ b/tests/unit/SQLMap/ConfigureTest.php @@ -1,20 +1,20 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class ConfigureTest extends BaseTest
-{
-
- function testConfigureAbsolutePath()
- {
- $builder = new TDomSqlMapBuilder;
- $filename = realpath(dirname(__FILE__).'/resources/sqlmap.xml');
- $sqlmap = $builder->configure($filename);
- $this->assertNotNull($sqlmap);
- }
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class ConfigureTest extends BaseTest +{ + + function testConfigureAbsolutePath() + { + $builder = new TDomSqlMapBuilder; + $filename = realpath(dirname(__FILE__).'/resources/sqlmap.xml'); + $sqlmap = $builder->configure($filename); + $this->assertNotNull($sqlmap); + } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/ConnectionTest.php b/tests/unit/SQLMap/ConnectionTest.php index 138505fd..5ab1e7e7 100644 --- a/tests/unit/SQLMap/ConnectionTest.php +++ b/tests/unit/SQLMap/ConnectionTest.php @@ -1,26 +1,26 @@ -<?php
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class ConnectionTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlmap();
- }
-
- function testOpenConnection()
- {
- $conn = $this->sqlmap->openConnection();
- $this->assertFalse($conn->getIsClosed());
- $this->sqlmap->closeConnection();
- $this->assertTrue($conn->getIsClosed());
- $this->sqlmap->openConnection();
- $this->assertFalse($conn->getIsClosed());
- }
-}
-
+<?php +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class ConnectionTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + $this->initSqlmap(); + } + + function testOpenConnection() + { + $conn = $this->sqlmap->openConnection(); + $this->assertFalse($conn->getIsClosed()); + $this->sqlmap->closeConnection(); + $this->assertTrue($conn->getIsClosed()); + $this->sqlmap->openConnection(); + $this->assertFalse($conn->getIsClosed()); + } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/DelegateTest.php b/tests/unit/SQLMap/DelegateTest.php index e4c4d812..cd285d98 100644 --- a/tests/unit/SQLMap/DelegateTest.php +++ b/tests/unit/SQLMap/DelegateTest.php @@ -1,64 +1,64 @@ -<?php
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class DelegateTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- }
-
- function testListDelegate()
- {
- $list = $this->sqlmap->queryWithRowDelegate(
- "GetAllAccountsViaResultMap", array($this, 'listHandler'));
-
- $this->assertEquals(5, count($list));
- $this->assertAccount1($list[0]);
- $this->assertEquals(1, $list[0]->getID());
- $this->assertEquals(2, $list[1]->getID());
- $this->assertEquals(3, $list[2]->getID());
- $this->assertEquals(4, $list[3]->getID());
- $this->assertEquals(5, $list[4]->getID());
- }
-
- /**
- * Test ExecuteQueryForMap : Hashtable.
- */
- function testExecuteQueryForMap()
- {
- $map = $this->sqlmap->QueryForMapWithRowDelegate(
- "GetAllAccountsViaResultClass", array($this, 'mapHandler'), null, "FirstName");
-
- $this->assertEquals(5, count($map));
- $this->assertAccount1($map["Joe"]);
-
- $this->assertEquals(1, $map["Joe"]->getID());
- $this->assertEquals(2, $map["Averel"]->getID());
- $this->assertEquals(3, $map["William"]->getID());
- $this->assertEquals(4, $map["Jack"]->getID());
- $this->assertEquals(5, $map["Gilles"]->getID());
- }
-
- public function listHandler($sender, $param)
- {
- $list = &$param->getList();
- $list[] = $param->result;
- $this->assertTrue($param->result instanceof Account);
- }
-
- public function mapHandler($sender, $param)
- {
- $map = &$param->getMap();
- $map[$param->getKey()] = $param->getValue();
- $this->assertTrue($param->getValue() instanceof Account);
- }
-}
-
-
-
+<?php +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class DelegateTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + } + + function testListDelegate() + { + $list = $this->sqlmap->queryWithRowDelegate( + "GetAllAccountsViaResultMap", array($this, 'listHandler')); + + $this->assertEquals(5, count($list)); + $this->assertAccount1($list[0]); + $this->assertEquals(1, $list[0]->getID()); + $this->assertEquals(2, $list[1]->getID()); + $this->assertEquals(3, $list[2]->getID()); + $this->assertEquals(4, $list[3]->getID()); + $this->assertEquals(5, $list[4]->getID()); + } + + /** + * Test ExecuteQueryForMap : Hashtable. + */ + function testExecuteQueryForMap() + { + $map = $this->sqlmap->QueryForMapWithRowDelegate( + "GetAllAccountsViaResultClass", array($this, 'mapHandler'), null, "FirstName"); + + $this->assertEquals(5, count($map)); + $this->assertAccount1($map["Joe"]); + + $this->assertEquals(1, $map["Joe"]->getID()); + $this->assertEquals(2, $map["Averel"]->getID()); + $this->assertEquals(3, $map["William"]->getID()); + $this->assertEquals(4, $map["Jack"]->getID()); + $this->assertEquals(5, $map["Gilles"]->getID()); + } + + public function listHandler($sender, $param) + { + $list = &$param->getList(); + $list[] = $param->result; + $this->assertTrue($param->result instanceof Account); + } + + public function mapHandler($sender, $param) + { + $map = &$param->getMap(); + $map[$param->getKey()] = $param->getValue(); + $this->assertTrue($param->getValue() instanceof Account); + } +} + + + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/GroupByTest.php b/tests/unit/SQLMap/GroupByTest.php index a03a7305..eed714c9 100644 --- a/tests/unit/SQLMap/GroupByTest.php +++ b/tests/unit/SQLMap/GroupByTest.php @@ -1,43 +1,43 @@ -<?php
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-class AccountWithOrders extends Account
-{
- private $_orders = array();
-
- public function setOrders($orders)
- {
- $this->_orders = $orders;
- }
-
- public function getOrders()
- {
- return $this->_orders;
- }
-}
-
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class GroupByTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- }
-
- function testAccountWithOrders()
- {
- $this->initScript('account-init.sql');
- $accounts = $this->sqlmap->queryForList("getAccountWithOrders");
- $this->assertEquals(5, count($accounts));
- foreach($accounts as $account)
- $this->assertEquals(2, count($account->getOrders()));
- }
-
-/**/
-}
-
+<?php +require_once(dirname(__FILE__).'/BaseTest.php'); + +class AccountWithOrders extends Account +{ + private $_orders = array(); + + public function setOrders($orders) + { + $this->_orders = $orders; + } + + public function getOrders() + { + return $this->_orders; + } +} + + +/** + * @package System.DataAccess.SQLMap + */ +class GroupByTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + } + + function testAccountWithOrders() + { + $this->initScript('account-init.sql'); + $accounts = $this->sqlmap->queryForList("getAccountWithOrders"); + $this->assertEquals(5, count($accounts)); + foreach($accounts as $account) + $this->assertEquals(2, count($account->getOrders())); + } + +/**/ +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/InheritanceTest.php b/tests/unit/SQLMap/InheritanceTest.php index 9ace1c29..41a81ae1 100644 --- a/tests/unit/SQLMap/InheritanceTest.php +++ b/tests/unit/SQLMap/InheritanceTest.php @@ -1,146 +1,146 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class InheritanceTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
-
- $this->initSqlMap();
- $this->initScript('documents-init.sql');
- }
-
- /// Test All document with no formula
- function testGetAllDocument()
- {
- $list = $this->sqlmap->queryForList("GetAllDocument");
-
- $this->assertEquals(6, count($list));
- $book = $list[0];
- $this->assertBook($book, 1, "The World of Null-A", 55);
-
- $book = $list[1];
- $this->assertBook($book, 3, "Lord of the Rings", 3587);
-
- $document = $list[2];
- $this->assertDocument($document, 5, "Le Monde");
-
- $document = $list[3];
- $this->assertDocument($document, 6, "Foundation");
-
- $news = $list[4];
- $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
-
- $document = $list[5];
- $this->assertDocument($document, 4, "Le Canard enchaine");
- }
-
- /// Test All document in a typed collection
- function testGetTypedCollection()
- {
- $list = $this->sqlmap->queryForList("GetTypedCollection");
-
- $this->assertEquals(6, $list->getCount());
-
- $book = $list[0];
- $this->assertBook($book, 1, "The World of Null-A", 55);
-
- $book = $list[1];
- $this->assertBook($book, 3, "Lord of the Rings", 3587);
-
- $document = $list[2];
- $this->assertDocument($document, 5, "Le Monde");
-
- $document = $list[3];
- $this->assertDocument($document, 6, "Foundation");
-
- $news = $list[4];
- $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
-
- $document = $list[5];
- $this->assertDocument($document, 4, "Le Canard enchaine");
- }
-
- /// Test All document with Custom Type Handler
- function testGetAllDocumentWithCustomTypeHandler()
- {
-
- //register the custom inheritance type handler
- $this->sqlmap->getTypeHandlerFactory()->register(
- 'CustomInheritance', new CustomInheritance);
-
- $list = $this->sqlmap->queryForList("GetAllDocumentWithCustomTypeHandler");
-
- $this->assertEquals(6, count($list));
- $book = $list[0];
- $this->assertBook($book, 1, "The World of Null-A", 55);
-
- $book = $list[1];
- $this->assertBook($book, 3, "Lord of the Rings", 3587);
-
- $news = $list[2];
- $this->assertNewspaper($news, 5, "Le Monde", "Paris");
-
- $book = $list[3];
- $this->assertBook($book, 6, "Foundation", 557);
-
- $news = $list[4];
- $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon");
-
- $news = $list[5];
- $this->assertNewspaper($news, 4, "Le Canard enchaine", "Paris");
- }
-
- function AssertDocument(Document $document, $id, $title)
- {
- $this->assertEquals($id, $document->getID());
- $this->assertEquals($title, $document->getTitle());
- }
-
- function AssertBook(Book $book, $id, $title, $pageNumber)
- {
- $this->assertEquals($id, $book->getId());
- $this->assertEquals($title, $book->getTitle());
- $this->assertEquals($pageNumber, (int)$book->getPageNumber());
- }
-
- function AssertNewspaper(Newspaper $news, $id, $title, $city)
- {
- $this->assertEquals($id, $news->getId());
- $this->assertEquals($title, $news->getTitle());
- $this->assertEquals($city, $news->getCity());
- }
-}
-
-
-class CustomInheritance implements ITypeHandlerCallback
-{
- public function getResult($type)
- {
- switch ($type)
- {
- case 'Monograph': case 'Book':
- return 'Book';
- case 'Tabloid': case 'Broadsheet': case 'Newspaper':
- return 'Newspaper';
- default:
- return 'Document';
- }
- }
-
- public function getParameter($parameter)
- {
- throw new TDataMapperException('not implemented');
- }
-
- public function createNewInstance($data=null)
- {
- throw new TDataMapperException('can not create');
- }
-}
+<?php + +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class InheritanceTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + + $this->initSqlMap(); + $this->initScript('documents-init.sql'); + } + + /// Test All document with no formula + function testGetAllDocument() + { + $list = $this->sqlmap->queryForList("GetAllDocument"); + + $this->assertEquals(6, count($list)); + $book = $list[0]; + $this->assertBook($book, 1, "The World of Null-A", 55); + + $book = $list[1]; + $this->assertBook($book, 3, "Lord of the Rings", 3587); + + $document = $list[2]; + $this->assertDocument($document, 5, "Le Monde"); + + $document = $list[3]; + $this->assertDocument($document, 6, "Foundation"); + + $news = $list[4]; + $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon"); + + $document = $list[5]; + $this->assertDocument($document, 4, "Le Canard enchaine"); + } + + /// Test All document in a typed collection + function testGetTypedCollection() + { + $list = $this->sqlmap->queryForList("GetTypedCollection"); + + $this->assertEquals(6, $list->getCount()); + + $book = $list[0]; + $this->assertBook($book, 1, "The World of Null-A", 55); + + $book = $list[1]; + $this->assertBook($book, 3, "Lord of the Rings", 3587); + + $document = $list[2]; + $this->assertDocument($document, 5, "Le Monde"); + + $document = $list[3]; + $this->assertDocument($document, 6, "Foundation"); + + $news = $list[4]; + $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon"); + + $document = $list[5]; + $this->assertDocument($document, 4, "Le Canard enchaine"); + } + + /// Test All document with Custom Type Handler + function testGetAllDocumentWithCustomTypeHandler() + { + + //register the custom inheritance type handler + $this->sqlmap->getTypeHandlerFactory()->register( + 'CustomInheritance', new CustomInheritance); + + $list = $this->sqlmap->queryForList("GetAllDocumentWithCustomTypeHandler"); + + $this->assertEquals(6, count($list)); + $book = $list[0]; + $this->assertBook($book, 1, "The World of Null-A", 55); + + $book = $list[1]; + $this->assertBook($book, 3, "Lord of the Rings", 3587); + + $news = $list[2]; + $this->assertNewspaper($news, 5, "Le Monde", "Paris"); + + $book = $list[3]; + $this->assertBook($book, 6, "Foundation", 557); + + $news = $list[4]; + $this->assertNewspaper($news, 2, "Le Progres de Lyon", "Lyon"); + + $news = $list[5]; + $this->assertNewspaper($news, 4, "Le Canard enchaine", "Paris"); + } + + function AssertDocument(Document $document, $id, $title) + { + $this->assertEquals($id, $document->getID()); + $this->assertEquals($title, $document->getTitle()); + } + + function AssertBook(Book $book, $id, $title, $pageNumber) + { + $this->assertEquals($id, $book->getId()); + $this->assertEquals($title, $book->getTitle()); + $this->assertEquals($pageNumber, (int)$book->getPageNumber()); + } + + function AssertNewspaper(Newspaper $news, $id, $title, $city) + { + $this->assertEquals($id, $news->getId()); + $this->assertEquals($title, $news->getTitle()); + $this->assertEquals($city, $news->getCity()); + } +} + + +class CustomInheritance implements ITypeHandlerCallback +{ + public function getResult($type) + { + switch ($type) + { + case 'Monograph': case 'Book': + return 'Book'; + case 'Tabloid': case 'Broadsheet': case 'Newspaper': + return 'Newspaper'; + default: + return 'Document'; + } + } + + public function getParameter($parameter) + { + throw new TDataMapperException('not implemented'); + } + + public function createNewInstance($data=null) + { + throw new TDataMapperException('can not create'); + } +} ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/ParameterMapTest.php b/tests/unit/SQLMap/ParameterMapTest.php index 5b3c3006..130b1505 100644 --- a/tests/unit/SQLMap/ParameterMapTest.php +++ b/tests/unit/SQLMap/ParameterMapTest.php @@ -1,249 +1,249 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class ParameterMapTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- }
-
- function setup()
- {
- $this->initScript('account-init.sql');
-// $this->initScript('account-procedure.sql');
- $this->initScript('order-init.sql');
-// $this->initScript('line-item-init.sql');
- $this->initScript('category-init.sql');
- }
-
- /// Test null replacement in ParameterMap property
- function testNullValueReplacement()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
-
- $this->assertNull($account->getEmailAddress(), 'no_email@provided.com');
-
- $this->assertAccount6($account);
- }
-
- /// Test Test Null Value Replacement Inline
- function testNullValueReplacementInline()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaInlineParameters", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
- $this->assertNull($account->getEmailAddress());
-
- $this->assertAccount6($account);
- }
-
- /// Test Test Null Value Replacement Inline
- function testSpecifiedType()
- {
- $account = $this->newAccount6();
- $account->setEmailAddress(null);
- $this->sqlmap->insert("InsertAccountNullableEmail", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
- $this->assertAccount6($account);
- }
-
-
- /// Test Test Null Value Replacement Inline
- function testUnknownParameterClass()
- {
- $account = $this->newAccount6();
- $account->setEmailAddress(null);
- $this->sqlmap->insert("InsertAccountUknownParameterClass", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
- $this->assertAccount6($account);
- }
-
-
- /// Test null replacement in ParameterMap property
- /// for System.DateTime.MinValue
- function testNullValueReplacementForDateTimeMinValue()
- {
- $account = $this->newAccount6();
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate(null);
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
-
- $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99);
-
- $this->assertEquals($order->getCity(), $orderTest->getCity());
- }
-
- /// Test null replacement in ParameterMap/Hahstable property
- /// for System.DateTime.MinValue
- function testNullValueReplacementForDateTimeWithHashtable()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate('0001-01-01 00:00:00'); //<-- null replacement
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
-
- $orderTest = $this->sqlmap->queryForObject("GetOrderByHashTable", 99);
-
- $this->assertEquals($orderTest["Date"], '0001-01-01 00:00:00');
- }
-
- /// Test null replacement in ParameterMap property
- /// for Guid
- function testNullValueReplacementForGuidValue()
- {
- if($this->hasSupportFor('last_insert_id'))
- {
- $category = new Category();
- $category->setName("Totoasdasd");
- $category->setGuidString('00000000-0000-0000-0000-000000000000');
-
- $key = $this->sqlmap->insert("InsertCategoryNull", $category);
-
- $categoryRead = $this->sqlmap->queryForObject("GetCategory", $key);
-
- $this->assertEquals($category->getName(), $categoryRead->getName());
- $this->assertEquals('', $categoryRead->getGuidString());
- }
- }
-
-
-
-/// Test complex mapping Via hasTable
- /// <example>
- ///
- /// map.Add("Item", Item);
- /// map.Add("Order", Order);
- ///
- /// <statement>
- /// ... #Item.prop1#...#Order.prop2#
- /// </statement>
- ///
- /// </example>
- function testComplexMappingViaHasTable()
- {
- $a = new Account();
- $a->setFirstName("Joe");
-
- $param["Account"] = $a;
-
- $o = new Order();
- $o->setCity("Dalton");
- $param["Order"] = $o;
-
- $accountTest = $this->sqlmap->queryForObject("GetAccountComplexMapping", $param);
-
- $this->assertAccount1($accountTest);
- }
-
-/*
- /// Test ByteArrayTypeHandler via Picture Property
- function testByteArrayTypeHandler()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate(0);
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
-
- $item = new LineItem();
- $item->setId(99);
- $item->setCode("test");
- $item->setPrice(-99.99);
- $item->setQuantity(99);
- $item->setOrder($order);
- $item->setPicture(null);
-
- // Check insert
- $this->sqlmap->insert("InsertLineItemWithPicture", $item);
-
- // select
- $item = null;
-
- $param["LineItem_ID"] = 99;
- $param["Order_ID"] = 99;
-
- $item = $this->sqlmap->queryForObject("GetSpecificLineItemWithPicture", $param);
-
- $this->assertNotNull($item->getId());
-// $this->assertNotNull($item->getPicture());
-// $this->assertEquals( GetSize(item.Picture), this.GetSize( this.GetPicture() ));
- }
-*/
-
- /// Test extend parameter map capacity
- /// (Support Requests 1043181)
- function testInsertOrderViaExtendParameterMap()
- {
- $this->sqlmap->getTypeHandlerFactory()->register('HundredsBool', new HundredsBool());
-
- $account = $this->newAccount6();
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate(null); //<-- null replacement
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaExtendParameterMap", $order);
-
- $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99);
-
- $this->assertEquals($order->getCity(), $orderTest->getCity());
- }
-/**/
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class ParameterMapTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + } + + function setup() + { + $this->initScript('account-init.sql'); +// $this->initScript('account-procedure.sql'); + $this->initScript('order-init.sql'); +// $this->initScript('line-item-init.sql'); + $this->initScript('category-init.sql'); + } + + /// Test null replacement in ParameterMap property + function testNullValueReplacement() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + + $this->assertNull($account->getEmailAddress(), 'no_email@provided.com'); + + $this->assertAccount6($account); + } + + /// Test Test Null Value Replacement Inline + function testNullValueReplacementInline() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaInlineParameters", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + $this->assertNull($account->getEmailAddress()); + + $this->assertAccount6($account); + } + + /// Test Test Null Value Replacement Inline + function testSpecifiedType() + { + $account = $this->newAccount6(); + $account->setEmailAddress(null); + $this->sqlmap->insert("InsertAccountNullableEmail", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + $this->assertAccount6($account); + } + + + /// Test Test Null Value Replacement Inline + function testUnknownParameterClass() + { + $account = $this->newAccount6(); + $account->setEmailAddress(null); + $this->sqlmap->insert("InsertAccountUknownParameterClass", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + $this->assertAccount6($account); + } + + + /// Test null replacement in ParameterMap property + /// for System.DateTime.MinValue + function testNullValueReplacementForDateTimeMinValue() + { + $account = $this->newAccount6(); + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate(null); + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaParameterMap", $order); + + $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99); + + $this->assertEquals($order->getCity(), $orderTest->getCity()); + } + + /// Test null replacement in ParameterMap/Hahstable property + /// for System.DateTime.MinValue + function testNullValueReplacementForDateTimeWithHashtable() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate('0001-01-01 00:00:00'); //<-- null replacement + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaParameterMap", $order); + + $orderTest = $this->sqlmap->queryForObject("GetOrderByHashTable", 99); + + $this->assertEquals($orderTest["Date"], '0001-01-01 00:00:00'); + } + + /// Test null replacement in ParameterMap property + /// for Guid + function testNullValueReplacementForGuidValue() + { + if($this->hasSupportFor('last_insert_id')) + { + $category = new Category(); + $category->setName("Totoasdasd"); + $category->setGuidString('00000000-0000-0000-0000-000000000000'); + + $key = $this->sqlmap->insert("InsertCategoryNull", $category); + + $categoryRead = $this->sqlmap->queryForObject("GetCategory", $key); + + $this->assertEquals($category->getName(), $categoryRead->getName()); + $this->assertEquals('', $categoryRead->getGuidString()); + } + } + + + +/// Test complex mapping Via hasTable + /// <example> + /// + /// map.Add("Item", Item); + /// map.Add("Order", Order); + /// + /// <statement> + /// ... #Item.prop1#...#Order.prop2# + /// </statement> + /// + /// </example> + function testComplexMappingViaHasTable() + { + $a = new Account(); + $a->setFirstName("Joe"); + + $param["Account"] = $a; + + $o = new Order(); + $o->setCity("Dalton"); + $param["Order"] = $o; + + $accountTest = $this->sqlmap->queryForObject("GetAccountComplexMapping", $param); + + $this->assertAccount1($accountTest); + } + +/* + /// Test ByteArrayTypeHandler via Picture Property + function testByteArrayTypeHandler() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate(0); + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaParameterMap", $order); + + $item = new LineItem(); + $item->setId(99); + $item->setCode("test"); + $item->setPrice(-99.99); + $item->setQuantity(99); + $item->setOrder($order); + $item->setPicture(null); + + // Check insert + $this->sqlmap->insert("InsertLineItemWithPicture", $item); + + // select + $item = null; + + $param["LineItem_ID"] = 99; + $param["Order_ID"] = 99; + + $item = $this->sqlmap->queryForObject("GetSpecificLineItemWithPicture", $param); + + $this->assertNotNull($item->getId()); +// $this->assertNotNull($item->getPicture()); +// $this->assertEquals( GetSize(item.Picture), this.GetSize( this.GetPicture() )); + } +*/ + + /// Test extend parameter map capacity + /// (Support Requests 1043181) + function testInsertOrderViaExtendParameterMap() + { + $this->sqlmap->getTypeHandlerFactory()->register('HundredsBool', new HundredsBool()); + + $account = $this->newAccount6(); + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate(null); //<-- null replacement + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaExtendParameterMap", $order); + + $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99); + + $this->assertEquals($order->getCity(), $orderTest->getCity()); + } +/**/ +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/PropertyAccessTest.php b/tests/unit/SQLMap/PropertyAccessTest.php index 04bb8c17..0e17e8d5 100644 --- a/tests/unit/SQLMap/PropertyAccessTest.php +++ b/tests/unit/SQLMap/PropertyAccessTest.php @@ -1,77 +1,77 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class PropertyAccessTest extends BaseTest
-{
- function testGetPublicProperty()
- {
- $account = new AccountBis();
-
- $account->Id = 10;
- $account->FirstName = "Luky";
- $account->LastName = "Luke";
- $account->EmailAddress = "luly.luke@somewhere.com";
-
- $two = new AccountBis();
- $two->Id = 12;
- $two->FirstName = "Mini Me!";
- $account->More = $two;
-
- $account6 = $this->NewAccount6();
- $two->More = $account6;
-
- $this->assertEquals(10, TPropertyAccess::get($account, 'Id'));
- $this->assertEquals(12, TPropertyAccess::get($account, 'More.Id'));
- $this->assertEquals(6, TPropertyAccess::get($account, 'More.More.Id'));
- }
-
- function testSetPublicProperty()
- {
- $account = new AccountBis();
-
- $account->Id = 10;
- $account->FirstName = "Luky";
- $account->LastName = "Luke";
- $account->EmailAddress = "luly.luke@somewhere.com";
-
- $two = new AccountBis();
- $two->Id = 12;
- $two->FirstName = "Mini Me!";
- TPropertyAccess::set($account, 'More', $two);
-
- $account6 = $this->NewAccount6();
- TPropertyAccess::set($account, 'More.More', $account6);
-
- TPropertyAccess::set($account, 'More.More.EmailAddress', 'hahaha');
-
- $this->assertEquals(10, TPropertyAccess::get($account, 'Id'));
- $this->assertEquals(12, TPropertyAccess::get($account, 'More.Id'));
- $this->assertEquals(6, TPropertyAccess::get($account, 'More.More.Id'));
-
- $this->assertEquals('hahaha',
- TPropertyAccess::get($account, 'More.More.EmailAddress'));
- }
-
- function testArrayAccessProperty()
- {
- $account = new AccountBis();
- $things['more'] = 1;
- $things['accounts'] = $this->NewAccount6();
- $account->More = $things;
-
- $this->assertEquals(6, TPropertyAccess::get($account, 'More.accounts.ID'));
-
- TPropertyAccess::set($account, 'More.accounts.EmailAddress', 'adssd');
- $this->assertEquals('adssd', TPropertyAccess::get($account, 'More.accounts.EmailAddress'));
-
- $this->assertEquals(1, TPropertyAccess::get($things, 'more'));
- }
-
-}
-
-
+<?php + +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class PropertyAccessTest extends BaseTest +{ + function testGetPublicProperty() + { + $account = new AccountBis(); + + $account->Id = 10; + $account->FirstName = "Luky"; + $account->LastName = "Luke"; + $account->EmailAddress = "luly.luke@somewhere.com"; + + $two = new AccountBis(); + $two->Id = 12; + $two->FirstName = "Mini Me!"; + $account->More = $two; + + $account6 = $this->NewAccount6(); + $two->More = $account6; + + $this->assertEquals(10, TPropertyAccess::get($account, 'Id')); + $this->assertEquals(12, TPropertyAccess::get($account, 'More.Id')); + $this->assertEquals(6, TPropertyAccess::get($account, 'More.More.Id')); + } + + function testSetPublicProperty() + { + $account = new AccountBis(); + + $account->Id = 10; + $account->FirstName = "Luky"; + $account->LastName = "Luke"; + $account->EmailAddress = "luly.luke@somewhere.com"; + + $two = new AccountBis(); + $two->Id = 12; + $two->FirstName = "Mini Me!"; + TPropertyAccess::set($account, 'More', $two); + + $account6 = $this->NewAccount6(); + TPropertyAccess::set($account, 'More.More', $account6); + + TPropertyAccess::set($account, 'More.More.EmailAddress', 'hahaha'); + + $this->assertEquals(10, TPropertyAccess::get($account, 'Id')); + $this->assertEquals(12, TPropertyAccess::get($account, 'More.Id')); + $this->assertEquals(6, TPropertyAccess::get($account, 'More.More.Id')); + + $this->assertEquals('hahaha', + TPropertyAccess::get($account, 'More.More.EmailAddress')); + } + + function testArrayAccessProperty() + { + $account = new AccountBis(); + $things['more'] = 1; + $things['accounts'] = $this->NewAccount6(); + $account->More = $things; + + $this->assertEquals(6, TPropertyAccess::get($account, 'More.accounts.ID')); + + TPropertyAccess::set($account, 'More.accounts.EmailAddress', 'adssd'); + $this->assertEquals('adssd', TPropertyAccess::get($account, 'More.accounts.EmailAddress')); + + $this->assertEquals(1, TPropertyAccess::get($things, 'more')); + } + +} + + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/ResultClassTest.php b/tests/unit/SQLMap/ResultClassTest.php index 93f93069..ec82b983 100644 --- a/tests/unit/SQLMap/ResultClassTest.php +++ b/tests/unit/SQLMap/ResultClassTest.php @@ -1,282 +1,282 @@ -<?php
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class ResultClassTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- }
-
- /**
- * Test a boolean resultClass
- */
- function testBoolean()
- {
- $bit = $this->sqlmap->queryForObject("GetBoolean", 1);
-
- $this->assertEquals(true, $bit);
- }
-
- /**
- * Test a boolean implicit resultClass
- */
- function testBooleanWithoutResultClass()
- {
- $bit = (boolean)$this->sqlmap->queryForObject("GetBooleanWithoutResultClass", 1);
-
- $this->assertEquals(true, $bit);
- }
-
- /**
- * Test a byte resultClass
- */
- function testByte()
- {
- $letter = $this->sqlmap->queryForObject("GetByte", 1);
-
- $this->assertEquals(155, (int)$letter);
- }
-
- /**
- * Test a byte implicit resultClass
- */
- function testByteWithoutResultClass()
- {
- $letter = $this->sqlmap->queryForObject("GetByteWithoutResultClass", 1);
-
- $this->assertEquals(155, (int)$letter);
- }
-
- /**
- * Test a char resultClass
- */
- function testChar()
- {
- $letter = $this->sqlmap->queryForObject("GetChar", 1);
-
- $this->assertEquals('a', trim($letter));
- }
-
- /**
- * Test a char implicit resultClass
- */
- function testCharWithoutResultClass()
- {
- $letter = $this->sqlmap->queryForObject("GetCharWithoutResultClass", 1);
-
- $this->assertEquals('a', trim($letter));
- }
-
- /**
- * Test a DateTime resultClass
- */
- function testDateTime()
- {
- $orderDate = $this->sqlmap->queryForObject("GetDate", 1);
-
- $date = @mktime(8, 15, 00, 2, 15, 2003);
-
- $this->assertEquals($date, $orderDate->getTimeStamp());
- }
-
- /**
- * Test a DateTime implicit resultClass
- */
- function testDateTimeWithoutResultClass()
- {
- $date = $this->sqlmap->queryForObject("GetDateWithoutResultClass", 1);
- $orderDate = new TDateTime;
- $orderDate->setDateTime($date);
- $date = @mktime(8, 15, 00, 2, 15, 2003);
-
- $this->assertEquals($date, $orderDate->getTimeStamp());
- }
-
- /**
- * Test a decimal resultClass
- */
- function testDecimal()
- {
- $price = $this->sqlmap->queryForObject("GetDecimal", 1);
-
- $this->assertEquals(1.56, $price);
- }
-
- /**
- * Test a decimal implicit resultClass
- */
- function testDecimalWithoutResultClass()
- {
- $price = $this->sqlmap->queryForObject("GetDecimalWithoutResultClass", 1);
-
- $this->assertEquals(1.56, (float)$price);
- }
-
- /**
- * Test a double resultClass
- */
- function testDouble()
- {
- $price = $this->sqlmap->queryForObject("GetDouble", 1);
-
- $this->assertEquals(99.5, $price);
- }
-
- /**
- * Test a double implicit resultClass
- */
-
- function testDoubleWithoutResultClass()
- {
- $price = $this->sqlmap->queryForObject("GetDoubleWithoutResultClass", 1);
-
- $this->assertEquals(99.5, (float)$price);
- }
-
- /**
- * IBATISNET-25 Error applying ResultMap when using 'Guid' in resultClass
- */
-/* function testGuid()
- {
- Guid newGuid = new Guid("CD5ABF17-4BBC-4C86-92F1-257735414CF4");
-
- Guid guid = (Guid) $this->sqlmap->queryForObject("GetGuid", 1);
-
- $this->assertEquals(newGuid, guid);
- }
-*/
-
- /**
- * Test a Guid implicit resultClass
- */
-/* function testGuidWithoutResultClass()
- {
- Guid newGuid = new Guid("CD5ABF17-4BBC-4C86-92F1-257735414CF4");
-
- string guidString = Convert.ToString($this->sqlmap->queryForObject("GetGuidWithoutResultClass", 1));
-
- Guid guid = new Guid(guidString);
-
- $this->assertEquals(newGuid, guid);
- }
-*/
- /**
- * Test a int16 resultClass (integer in PHP)
- */
-
- function testInt16()
- {
- $integer = $this->sqlmap->queryForObject("GetInt16", 1);
-
- $this->assertEquals(32111, $integer);
- }
-
- /**
- * Test a int16 implicit resultClass (integer in PHP)
- */
-
- function testInt16WithoutResultClass()
- {
- $integer = $this->sqlmap->queryForObject("GetInt16WithoutResultClass", 1);
-
- $this->assertEquals(32111, (int)$integer);
- }
-
- /**
- * Test a int 32 resultClass (integer in PHP)
- */
-
-
- function testInt32()
- {
- $integer = $this->sqlmap->queryForObject("GetInt32", 1);
-
- $this->assertEquals(999999, $integer);
- }
-
- /**
- * Test a int 32 implicit resultClass (integer in PHP)
- */
-
-
- function testInt32WithoutResultClass()
- {
- $integer = $this->sqlmap->queryForObject("GetInt32WithoutResultClass", 1);
-
- $this->assertEquals(999999, (int)$integer);
- }
-
- /**
- * Test a int64 resultClass (float in PHP)
- */
-
- function testInt64()
- {
- $bigInt = $this->sqlmap->queryForObject("GetInt64", 1);
-
- $this->assertEquals(9223372036854775800, $bigInt);
- }
-
- /**
- * Test a int64 implicit resultClass (float in PHP)
- */
-
- function testInt64WithoutResultClass()
- {
- $bigInt = $this->sqlmap->queryForObject("GetInt64WithoutResultClass", 1);
-
- $this->assertEquals(9223372036854775800, (double)$bigInt);
- }
-
- /**
- * Test a single/float resultClass
- */
-
- function testSingle()
- {
- $price = (float)$this->sqlmap->queryForObject("GetSingle", 1);
-
- $this->assertEquals(92233.5, $price);
- }
-
- /**
- * Test a single/float implicit resultClass
- */
-
- function testSingleWithoutResultClass()
- {
- $price = $this->sqlmap->queryForObject("GetSingleWithoutResultClass", 1);
-
- $this->assertEquals(92233.5, (float)$price);
- }
-
- /**
- * Test a string resultClass
- */
-
- function testString()
- {
- $cardType = $this->sqlmap->queryForObject("GetString", 1);
-
- $this->assertEquals("VISA", $cardType);
- }
-
- /**
- * Test a string implicit resultClass
- */
-
- function testStringWithoutResultClass()
- {
- $cardType = $this->sqlmap->queryForObject("GetStringWithoutResultClass", 1);
-
- $this->assertEquals("VISA", $cardType);
- }
-/**/
-}
-
+<?php +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class ResultClassTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + } + + /** + * Test a boolean resultClass + */ + function testBoolean() + { + $bit = $this->sqlmap->queryForObject("GetBoolean", 1); + + $this->assertEquals(true, $bit); + } + + /** + * Test a boolean implicit resultClass + */ + function testBooleanWithoutResultClass() + { + $bit = (boolean)$this->sqlmap->queryForObject("GetBooleanWithoutResultClass", 1); + + $this->assertEquals(true, $bit); + } + + /** + * Test a byte resultClass + */ + function testByte() + { + $letter = $this->sqlmap->queryForObject("GetByte", 1); + + $this->assertEquals(155, (int)$letter); + } + + /** + * Test a byte implicit resultClass + */ + function testByteWithoutResultClass() + { + $letter = $this->sqlmap->queryForObject("GetByteWithoutResultClass", 1); + + $this->assertEquals(155, (int)$letter); + } + + /** + * Test a char resultClass + */ + function testChar() + { + $letter = $this->sqlmap->queryForObject("GetChar", 1); + + $this->assertEquals('a', trim($letter)); + } + + /** + * Test a char implicit resultClass + */ + function testCharWithoutResultClass() + { + $letter = $this->sqlmap->queryForObject("GetCharWithoutResultClass", 1); + + $this->assertEquals('a', trim($letter)); + } + + /** + * Test a DateTime resultClass + */ + function testDateTime() + { + $orderDate = $this->sqlmap->queryForObject("GetDate", 1); + + $date = @mktime(8, 15, 00, 2, 15, 2003); + + $this->assertEquals($date, $orderDate->getTimeStamp()); + } + + /** + * Test a DateTime implicit resultClass + */ + function testDateTimeWithoutResultClass() + { + $date = $this->sqlmap->queryForObject("GetDateWithoutResultClass", 1); + $orderDate = new TDateTime; + $orderDate->setDateTime($date); + $date = @mktime(8, 15, 00, 2, 15, 2003); + + $this->assertEquals($date, $orderDate->getTimeStamp()); + } + + /** + * Test a decimal resultClass + */ + function testDecimal() + { + $price = $this->sqlmap->queryForObject("GetDecimal", 1); + + $this->assertEquals(1.56, $price); + } + + /** + * Test a decimal implicit resultClass + */ + function testDecimalWithoutResultClass() + { + $price = $this->sqlmap->queryForObject("GetDecimalWithoutResultClass", 1); + + $this->assertEquals(1.56, (float)$price); + } + + /** + * Test a double resultClass + */ + function testDouble() + { + $price = $this->sqlmap->queryForObject("GetDouble", 1); + + $this->assertEquals(99.5, $price); + } + + /** + * Test a double implicit resultClass + */ + + function testDoubleWithoutResultClass() + { + $price = $this->sqlmap->queryForObject("GetDoubleWithoutResultClass", 1); + + $this->assertEquals(99.5, (float)$price); + } + + /** + * IBATISNET-25 Error applying ResultMap when using 'Guid' in resultClass + */ +/* function testGuid() + { + Guid newGuid = new Guid("CD5ABF17-4BBC-4C86-92F1-257735414CF4"); + + Guid guid = (Guid) $this->sqlmap->queryForObject("GetGuid", 1); + + $this->assertEquals(newGuid, guid); + } +*/ + + /** + * Test a Guid implicit resultClass + */ +/* function testGuidWithoutResultClass() + { + Guid newGuid = new Guid("CD5ABF17-4BBC-4C86-92F1-257735414CF4"); + + string guidString = Convert.ToString($this->sqlmap->queryForObject("GetGuidWithoutResultClass", 1)); + + Guid guid = new Guid(guidString); + + $this->assertEquals(newGuid, guid); + } +*/ + /** + * Test a int16 resultClass (integer in PHP) + */ + + function testInt16() + { + $integer = $this->sqlmap->queryForObject("GetInt16", 1); + + $this->assertEquals(32111, $integer); + } + + /** + * Test a int16 implicit resultClass (integer in PHP) + */ + + function testInt16WithoutResultClass() + { + $integer = $this->sqlmap->queryForObject("GetInt16WithoutResultClass", 1); + + $this->assertEquals(32111, (int)$integer); + } + + /** + * Test a int 32 resultClass (integer in PHP) + */ + + + function testInt32() + { + $integer = $this->sqlmap->queryForObject("GetInt32", 1); + + $this->assertEquals(999999, $integer); + } + + /** + * Test a int 32 implicit resultClass (integer in PHP) + */ + + + function testInt32WithoutResultClass() + { + $integer = $this->sqlmap->queryForObject("GetInt32WithoutResultClass", 1); + + $this->assertEquals(999999, (int)$integer); + } + + /** + * Test a int64 resultClass (float in PHP) + */ + + function testInt64() + { + $bigInt = $this->sqlmap->queryForObject("GetInt64", 1); + + $this->assertEquals(9223372036854775800, $bigInt); + } + + /** + * Test a int64 implicit resultClass (float in PHP) + */ + + function testInt64WithoutResultClass() + { + $bigInt = $this->sqlmap->queryForObject("GetInt64WithoutResultClass", 1); + + $this->assertEquals(9223372036854775800, (double)$bigInt); + } + + /** + * Test a single/float resultClass + */ + + function testSingle() + { + $price = (float)$this->sqlmap->queryForObject("GetSingle", 1); + + $this->assertEquals(92233.5, $price); + } + + /** + * Test a single/float implicit resultClass + */ + + function testSingleWithoutResultClass() + { + $price = $this->sqlmap->queryForObject("GetSingleWithoutResultClass", 1); + + $this->assertEquals(92233.5, (float)$price); + } + + /** + * Test a string resultClass + */ + + function testString() + { + $cardType = $this->sqlmap->queryForObject("GetString", 1); + + $this->assertEquals("VISA", $cardType); + } + + /** + * Test a string implicit resultClass + */ + + function testStringWithoutResultClass() + { + $cardType = $this->sqlmap->queryForObject("GetStringWithoutResultClass", 1); + + $this->assertEquals("VISA", $cardType); + } +/**/ +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/ResultMapTest.php b/tests/unit/SQLMap/ResultMapTest.php index 4909c37f..09fff11d 100644 --- a/tests/unit/SQLMap/ResultMapTest.php +++ b/tests/unit/SQLMap/ResultMapTest.php @@ -1,280 +1,280 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class ResultMapTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- new Order;
- new LineItemCollection;
- new Account;
- }
-
- function resetDatabase()
- {
- $this->initScript('account-init.sql');
- $this->initScript('order-init.sql');
- $this->initScript('line-item-init.sql');
-// $this->initScript('enumeration-init.sql');
- }
-
- function testColumnsByName()
- {
- $order = $this->sqlmap->QueryForObject('GetOrderLiteByColumnName', 1);
- $this->assertOrder1($order);
- }
-
- function testColumnsByIndex()
- {
- $order = $this->sqlmap->QueryForObject("GetOrderLiteByColumnIndex", 1);
- $this->assertOrder1($order);
- }
-
-
- function testExtendedResultMap()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItemsNoLazyLoad", 1);
- $this->assertOrder1($order);
- $this->assertTrue($order->getLineItemsList() instanceof TList);
- $this->assertEquals(2, $order->getLineItemsList()->getCount());
- }
-
- function testLazyLoad()
- {
- $order = $this->sqlmap->QueryForObject("GetOrderWithLineItems", 1);
- $this->assertOrder1($order);
- $this->assertNotNull($order->getLineItemsList());
- $this->assertFalse($order->getLineItemsList() instanceof TList);
- $this->assertEquals(2, $order->getLineItemsList()->getCount());
-
- // After a call to a method from a proxy object,
- // the proxy object is replaced by the real object.
- $this->assertTrue($order->getLineItemsList() instanceof TList);
- $this->assertEquals(2, $order->getLineItemsList()->getCount());
- }
-
- function testLazyLoadWithOpenConnection()
- {
- $this->sqlmap->openConnection();
-
- $this->testLazyLoad();
- $this->sqlmap->closeConnection();
- }
-
- function testLazyWithTypedCollectionMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItemCollection", 1);
- $this->assertOrder1($order);
- $this->assertNotNull($order->getLineItems());
- $this->assertFalse($order->getLineItemsList() instanceof LineItemCollection);
-
- $this->assertEquals(2, $order->getLineItems()->getCount());
-
- // After a call to a method from a proxy object,
- // the proxy object is replaced by the real object.
- $this->assertTrue($order->getLineItems() instanceof LineItemCollection);
- foreach($order->getLineItems() as $item)
- {
- $this->assertNotNull($item);
- $this->assertTrue($item instanceof LineItem);
- }
- }
-
- function testNullValueReplacementOnString()
- {
- $account = $this->sqlmap->queryForObject("GetAccountViaColumnName", 5);
- $this->assertEquals("no_email@provided.com", $account->getEmailAddress());
- }
-
- function testTypeSpecified()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithTypes", 1);
- $this->assertOrder1($order);
- }
-
-
- function testComplexObjectMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithAccount", 1);
- $this->assertOrder1($order);
- $this->assertAccount1($order->getAccount());
- }
-
- function testCollectionMappingAndExtends()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItemsCollection", 1);
- $this->assertOrder1($order);
-
- // Check strongly typed collection
- $this->assertNotNull($order->getLineItems());
- $this->assertEquals(2, $order->getLineItems()->getCount());
- }
-
- function testListMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItems", 1);
- $this->assertOrder1($order);
-
- // Check TList collection
- $this->assertNotNull($order->getLineItemsList());
- $this->assertEquals(2, $order->getLineItemsList()->getCount());
- }
-
- function testArrayMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItemArray", 1);
- $this->assertOrder1($order);
- $this->assertNotNull($order->getLineItemsArray());
- $this->assertTrue(is_array($order->getLineItemsArray()));
- $this->assertEquals(2, count($order->getLineItemsArray()));
- }
-
- function testTypedCollectionMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderWithLineItemCollectionNoLazy", 1);
- $this->assertOrder1($order);
- $this->assertNotNull($order->getLineItems());
- $this->assertTrue($order->getLineItems() instanceof LineItemCollection);
- $this->assertEquals(2, $order->getLineItems()->getCount());
- foreach($order->getLineItems() as $item)
- {
- $this->assertNotNull($item);
- $this->assertTrue($item instanceof LineItem);
- }
- }
-
- function testHashArrayMapping()
- {
- $order = $this->sqlmap->queryForObject("GetOrderAsHastable", 1);
- $this->assertOrder1AsHashArray($order);
- }
-
- function testNestedObjects()
- {
- $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite", 1);
-
- $this->assertOrder1($order);
- $this->assertNotNull($order->getFavouriteLineItem());
- $this->assertEquals(2, (int)$order->getFavouriteLineItem()->getID());
- $this->assertEquals("ESM-23", $order->getFavouriteLineItem()->getCode());
-
- }
- function testNestedObjects2()
- {
- $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite2", 1);
- $this->assertOrder1($order);
-
- $this->assertNotNull($order->getFavouriteLineItem());
- $this->assertEquals(2, (int)$order->getFavouriteLineItem()->getID());
- $this->assertEquals("ESM-23", $order->getFavouriteLineItem()->getCode());
- }
-
- function testImplicitResultMaps()
- {
- $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite3", 1);
-
- // *** force date to timestamp since data type can't be
- // *** explicity known without mapping
- $order->setDate(new TDateTime($order->getDate()));
-
- $this->assertOrder1($order);
-
- $this->assertNotNull($order->getFavouriteLineItem());
- $this->assertEquals(2, $order->getFavouriteLineItem()->getID());
- $this->assertEquals("ESM-23", $order->getFavouriteLineItem()->getCode());
- }
-
- function testCompositeKeyMapping()
- {
- $this->resetDatabase();
-
- $order1 = $this->sqlmap->queryForObject("GetOrderWithFavouriteLineItem", 1);
- $order2 = $this->sqlmap->queryForObject("GetOrderWithFavouriteLineItem", 2);
-
- $this->assertNotNull($order1);
- $this->assertNotNull($order1->getFavouriteLineItem());
- $this->assertEquals(2, $order1->getFavouriteLineItem()->getID());
-
- $this->assertNotNull($order2);
- $this->assertNotNull($order2->getFavouriteLineItem());
- $this->assertEquals(1, $order2->getFavouriteLineItem()->getID());
- }
-
- function testSimpleTypeMapping()
- {
- $this->resetDatabase();
-
- $list = $this->sqlmap->QueryForList("GetAllCreditCardNumbersFromOrders", null);
-
- $this->assertEquals(5, count($list));
- $this->assertEquals("555555555555", $list[0]);
- }
-
-
- function testDecimalTypeMapping()
- {
- $this->resetDatabase();
-
- $param["LineItem_ID"] = 1;
- $param["Order_ID"] = 10;
- $price = $this->sqlmap->queryForObject("GetLineItemPrice", $param);
- $this->assertEquals(gettype($price), 'double');
- $this->assertEquals(45.43, $price);
- }
-
-//todo
-/*
- function testNullValueReplacementOnEnum()
- {
- $enum['Id'] = 99;
- $enum['Day'] = 'Days.Thu';
- $enum['Color'] = 'Colors.Blue';
- $enum['Month'] = 'Months.All';
-
- $this->sqlmap->insert("InsertEnumViaParameterMap", $enum);
-
- $enumClass = $this->sqlmap->queryForObject("GetEnumerationNullValue", 99);
-
- $this->assertEquals($enumClass['Day'], 'Days.Thu');
- $this->asserEquals($enumClass['Color'], 'Colors.Blue');
- $this->assertEquals($enumClass['Month'], 'Months.All');
- }
-
-
- function testByteArrayMapping()
- {
- }
-
- function testNullValueReplacementOnDecimal()
- {
- }
-
- function testNullValueReplacementOnDateTime()
- {
- }
-*/
-
-//future work
-
-/*
- //requires dynamic SQL
- function testDynamiqueCompositeKeyMapping()
- {
- $order1 = $this->sqlmap->queryForObject("GetOrderWithDynFavouriteLineItem", 1);
-
- $this->assertNotNull($order1);
- $this->assertNotNull($order1->getFavouriteLineItem());
- var_dump($order1);
- $this->assertEquals(2, $order1->getFavouriteLineItem()->getID());
- }
-*/
-
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class ResultMapTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + new Order; + new LineItemCollection; + new Account; + } + + function resetDatabase() + { + $this->initScript('account-init.sql'); + $this->initScript('order-init.sql'); + $this->initScript('line-item-init.sql'); +// $this->initScript('enumeration-init.sql'); + } + + function testColumnsByName() + { + $order = $this->sqlmap->QueryForObject('GetOrderLiteByColumnName', 1); + $this->assertOrder1($order); + } + + function testColumnsByIndex() + { + $order = $this->sqlmap->QueryForObject("GetOrderLiteByColumnIndex", 1); + $this->assertOrder1($order); + } + + + function testExtendedResultMap() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItemsNoLazyLoad", 1); + $this->assertOrder1($order); + $this->assertTrue($order->getLineItemsList() instanceof TList); + $this->assertEquals(2, $order->getLineItemsList()->getCount()); + } + + function testLazyLoad() + { + $order = $this->sqlmap->QueryForObject("GetOrderWithLineItems", 1); + $this->assertOrder1($order); + $this->assertNotNull($order->getLineItemsList()); + $this->assertFalse($order->getLineItemsList() instanceof TList); + $this->assertEquals(2, $order->getLineItemsList()->getCount()); + + // After a call to a method from a proxy object, + // the proxy object is replaced by the real object. + $this->assertTrue($order->getLineItemsList() instanceof TList); + $this->assertEquals(2, $order->getLineItemsList()->getCount()); + } + + function testLazyLoadWithOpenConnection() + { + $this->sqlmap->openConnection(); + + $this->testLazyLoad(); + $this->sqlmap->closeConnection(); + } + + function testLazyWithTypedCollectionMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItemCollection", 1); + $this->assertOrder1($order); + $this->assertNotNull($order->getLineItems()); + $this->assertFalse($order->getLineItemsList() instanceof LineItemCollection); + + $this->assertEquals(2, $order->getLineItems()->getCount()); + + // After a call to a method from a proxy object, + // the proxy object is replaced by the real object. + $this->assertTrue($order->getLineItems() instanceof LineItemCollection); + foreach($order->getLineItems() as $item) + { + $this->assertNotNull($item); + $this->assertTrue($item instanceof LineItem); + } + } + + function testNullValueReplacementOnString() + { + $account = $this->sqlmap->queryForObject("GetAccountViaColumnName", 5); + $this->assertEquals("no_email@provided.com", $account->getEmailAddress()); + } + + function testTypeSpecified() + { + $order = $this->sqlmap->queryForObject("GetOrderWithTypes", 1); + $this->assertOrder1($order); + } + + + function testComplexObjectMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderWithAccount", 1); + $this->assertOrder1($order); + $this->assertAccount1($order->getAccount()); + } + + function testCollectionMappingAndExtends() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItemsCollection", 1); + $this->assertOrder1($order); + + // Check strongly typed collection + $this->assertNotNull($order->getLineItems()); + $this->assertEquals(2, $order->getLineItems()->getCount()); + } + + function testListMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItems", 1); + $this->assertOrder1($order); + + // Check TList collection + $this->assertNotNull($order->getLineItemsList()); + $this->assertEquals(2, $order->getLineItemsList()->getCount()); + } + + function testArrayMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItemArray", 1); + $this->assertOrder1($order); + $this->assertNotNull($order->getLineItemsArray()); + $this->assertTrue(is_array($order->getLineItemsArray())); + $this->assertEquals(2, count($order->getLineItemsArray())); + } + + function testTypedCollectionMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderWithLineItemCollectionNoLazy", 1); + $this->assertOrder1($order); + $this->assertNotNull($order->getLineItems()); + $this->assertTrue($order->getLineItems() instanceof LineItemCollection); + $this->assertEquals(2, $order->getLineItems()->getCount()); + foreach($order->getLineItems() as $item) + { + $this->assertNotNull($item); + $this->assertTrue($item instanceof LineItem); + } + } + + function testHashArrayMapping() + { + $order = $this->sqlmap->queryForObject("GetOrderAsHastable", 1); + $this->assertOrder1AsHashArray($order); + } + + function testNestedObjects() + { + $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite", 1); + + $this->assertOrder1($order); + $this->assertNotNull($order->getFavouriteLineItem()); + $this->assertEquals(2, (int)$order->getFavouriteLineItem()->getID()); + $this->assertEquals("ESM-23", $order->getFavouriteLineItem()->getCode()); + + } + function testNestedObjects2() + { + $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite2", 1); + $this->assertOrder1($order); + + $this->assertNotNull($order->getFavouriteLineItem()); + $this->assertEquals(2, (int)$order->getFavouriteLineItem()->getID()); + $this->assertEquals("ESM-23", $order->getFavouriteLineItem()->getCode()); + } + + function testImplicitResultMaps() + { + $order = $this->sqlmap->queryForObject("GetOrderJoinedFavourite3", 1); + + // *** force date to timestamp since data type can't be + // *** explicity known without mapping + $order->setDate(new TDateTime($order->getDate())); + + $this->assertOrder1($order); + + $this->assertNotNull($order->getFavouriteLineItem()); + $this->assertEquals(2, $order->getFavouriteLineItem()->getID()); + $this->assertEquals("ESM-23", $order->getFavouriteLineItem()->getCode()); + } + + function testCompositeKeyMapping() + { + $this->resetDatabase(); + + $order1 = $this->sqlmap->queryForObject("GetOrderWithFavouriteLineItem", 1); + $order2 = $this->sqlmap->queryForObject("GetOrderWithFavouriteLineItem", 2); + + $this->assertNotNull($order1); + $this->assertNotNull($order1->getFavouriteLineItem()); + $this->assertEquals(2, $order1->getFavouriteLineItem()->getID()); + + $this->assertNotNull($order2); + $this->assertNotNull($order2->getFavouriteLineItem()); + $this->assertEquals(1, $order2->getFavouriteLineItem()->getID()); + } + + function testSimpleTypeMapping() + { + $this->resetDatabase(); + + $list = $this->sqlmap->QueryForList("GetAllCreditCardNumbersFromOrders", null); + + $this->assertEquals(5, count($list)); + $this->assertEquals("555555555555", $list[0]); + } + + + function testDecimalTypeMapping() + { + $this->resetDatabase(); + + $param["LineItem_ID"] = 1; + $param["Order_ID"] = 10; + $price = $this->sqlmap->queryForObject("GetLineItemPrice", $param); + $this->assertEquals(gettype($price), 'double'); + $this->assertEquals(45.43, $price); + } + +//todo +/* + function testNullValueReplacementOnEnum() + { + $enum['Id'] = 99; + $enum['Day'] = 'Days.Thu'; + $enum['Color'] = 'Colors.Blue'; + $enum['Month'] = 'Months.All'; + + $this->sqlmap->insert("InsertEnumViaParameterMap", $enum); + + $enumClass = $this->sqlmap->queryForObject("GetEnumerationNullValue", 99); + + $this->assertEquals($enumClass['Day'], 'Days.Thu'); + $this->asserEquals($enumClass['Color'], 'Colors.Blue'); + $this->assertEquals($enumClass['Month'], 'Months.All'); + } + + + function testByteArrayMapping() + { + } + + function testNullValueReplacementOnDecimal() + { + } + + function testNullValueReplacementOnDateTime() + { + } +*/ + +//future work + +/* + //requires dynamic SQL + function testDynamiqueCompositeKeyMapping() + { + $order1 = $this->sqlmap->queryForObject("GetOrderWithDynFavouriteLineItem", 1); + + $this->assertNotNull($order1); + $this->assertNotNull($order1->getFavouriteLineItem()); + var_dump($order1); + $this->assertEquals(2, $order1->getFavouriteLineItem()->getID()); + } +*/ + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/SelectKeyTest.php b/tests/unit/SQLMap/SelectKeyTest.php index 6ed48165..34ffbbb7 100644 --- a/tests/unit/SQLMap/SelectKeyTest.php +++ b/tests/unit/SQLMap/SelectKeyTest.php @@ -1,120 +1,120 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class SelectKeyTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
-
- //force autoload
- new Account;
- new Order;
- new LineItem;
- new LineItemCollection;
- new A; new B; new C; new D; new E; new F;
- }
-
- /**
- * Test Insert with post GeneratedKey
- */
- function testInsertPostKey()
- {
- $this->initScript('line-item-init.sql');
-
- $item = new LineItem();
-
- $item->setId(10);
- $item->setCode("blah");
- $item->setOrder(new Order());
- $item->getOrder()->setId(9);
- $item->setPrice(44.00);
- $item->setQuantity(1);
-
- $key = $this->sqlmap->Insert("InsertLineItemPostKey", $item);
-
- $this->assertEquals(99, $key);
- $this->assertEquals(99, $item->getId());
-
- $param["Order_ID"] = 9;
- $param["LineItem_ID"] =10;
- $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
-
- $this->assertNotNull($testItem);
- $this->assertEquals(10, $testItem->getId());
-
- $this->initScript('line-item-init.sql');
- }
-
- /**
- * Test Insert pre GeneratedKey
- */
- function testInsertPreKey()
- {
- $this->initScript('line-item-init.sql');
-
- $item = new LineItem();
-
- $item->setId(10);
- $item->setCode("blah");
- $item->setOrder(new Order());
- $item->getOrder()->setId(9);
- $item->setPrice(44.00);
- $item->setQuantity(1);
-
- $key = $this->sqlmap->Insert("InsertLineItemPreKey", $item);
-
- $this->assertEquals(99, $key);
- $this->assertEquals(99, $item->getId());
-
- $param["Order_ID"] = 9;
- $param["LineItem_ID"] = 99;
-
- $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
-
- $this->assertNotNull($testItem);
- $this->assertEquals(99, $testItem->getId());
-
- $this->initScript('line-item-init.sql');
- }
-
- /**
- * Test Test Insert No Key
- */
- function testInsertNoKey()
- {
- $this->initScript('line-item-init.sql');
-
- $item = new LineItem();
-
- $item->setId(100);
- $item->setCode("blah");
- $item->setOrder(new Order());
- $item->getOrder()->setId(9);
- $item->setPrice(44.00);
- $item->setQuantity(1);
-
-
- $key = $this->sqlmap->Insert("InsertLineItemNoKey", $item);
-
- $this->assertNull($key);
- $this->assertEquals(100, $item->getId());
-
- $param["Order_ID"] = 9;
- $param["LineItem_ID"] = 100;
-
- $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
-
- $this->assertNotNull($testItem);
- $this->assertEquals(100, $testItem->getId());
-
- $this->initScript('line-item-init.sql');
- }
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class SelectKeyTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + + //force autoload + new Account; + new Order; + new LineItem; + new LineItemCollection; + new A; new B; new C; new D; new E; new F; + } + + /** + * Test Insert with post GeneratedKey + */ + function testInsertPostKey() + { + $this->initScript('line-item-init.sql'); + + $item = new LineItem(); + + $item->setId(10); + $item->setCode("blah"); + $item->setOrder(new Order()); + $item->getOrder()->setId(9); + $item->setPrice(44.00); + $item->setQuantity(1); + + $key = $this->sqlmap->Insert("InsertLineItemPostKey", $item); + + $this->assertEquals(99, $key); + $this->assertEquals(99, $item->getId()); + + $param["Order_ID"] = 9; + $param["LineItem_ID"] =10; + $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param); + + $this->assertNotNull($testItem); + $this->assertEquals(10, $testItem->getId()); + + $this->initScript('line-item-init.sql'); + } + + /** + * Test Insert pre GeneratedKey + */ + function testInsertPreKey() + { + $this->initScript('line-item-init.sql'); + + $item = new LineItem(); + + $item->setId(10); + $item->setCode("blah"); + $item->setOrder(new Order()); + $item->getOrder()->setId(9); + $item->setPrice(44.00); + $item->setQuantity(1); + + $key = $this->sqlmap->Insert("InsertLineItemPreKey", $item); + + $this->assertEquals(99, $key); + $this->assertEquals(99, $item->getId()); + + $param["Order_ID"] = 9; + $param["LineItem_ID"] = 99; + + $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param); + + $this->assertNotNull($testItem); + $this->assertEquals(99, $testItem->getId()); + + $this->initScript('line-item-init.sql'); + } + + /** + * Test Test Insert No Key + */ + function testInsertNoKey() + { + $this->initScript('line-item-init.sql'); + + $item = new LineItem(); + + $item->setId(100); + $item->setCode("blah"); + $item->setOrder(new Order()); + $item->getOrder()->setId(9); + $item->setPrice(44.00); + $item->setQuantity(1); + + + $key = $this->sqlmap->Insert("InsertLineItemNoKey", $item); + + $this->assertNull($key); + $this->assertEquals(100, $item->getId()); + + $param["Order_ID"] = 9; + $param["LineItem_ID"] = 100; + + $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param); + + $this->assertNotNull($testItem); + $this->assertEquals(100, $testItem->getId()); + + $this->initScript('line-item-init.sql'); + } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/SqlMapCacheTest.php b/tests/unit/SQLMap/SqlMapCacheTest.php index a2593e1a..f1746115 100644 --- a/tests/unit/SQLMap/SqlMapCacheTest.php +++ b/tests/unit/SQLMap/SqlMapCacheTest.php @@ -1,77 +1,77 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class SqlMapCacheTest extends PHPUnit2_Framework_TestCase
-{
- function testFIFOCache()
- {
- $fifo = new TSqlMapFifoCache(2);
- $object1 = new TSqlMapper;
- $object2 = new TComponent;
- $object3 = new TMapper;
-
- $key1 = 'key1';
- $key2 = 'key2';
- $key3 = 'key3';
-
- $fifo->set($key1, $object1);
- $fifo->set($key2, $object2);
-
- $this->assertTrue($object1 === $fifo->get($key1));
- $this->assertTrue($object2 === $fifo->get($key2));
-
- //object 1 should be removed
- $fifo->set($key3, $object3);
-
- $this->assertNull($fifo->get($key1));
- $this->assertTrue($object2 === $fifo->get($key2));
- $this->assertTrue($object3 === $fifo->get($key3));
-
- //object 2 should be removed
- $fifo->set($key1, $object1);
-
- $this->assertNull($fifo->get($key2));
- $this->assertTrue($object3 === $fifo->get($key3));
- $this->assertTrue($object1 === $fifo->get($key1));
- }
-
- function testLruCache()
- {
- $lru = new TSqlMapLruCache(2);
-
- $object1 = new TSqlMapper;
- $object2 = new TComponent;
- $object3 = new TMapper;
-
- $key1 = 'key1';
- $key2 = 'key2';
- $key3 = 'key3';
-
- $lru->set($key1, $object1);
- $lru->set($key2, $object2);
-
- $this->assertTrue($object2 === $lru->get($key2));
- $this->assertTrue($object1 === $lru->get($key1));
-
- //object 2 should be removed, i.e. least recently used
- $lru->set($key3, $object3);
-
- $this->assertNull($lru->get($key2));
- $this->assertTrue($object1 === $lru->get($key1));
- $this->assertTrue($object3 === $lru->get($key3));
-
- //object 1 will be removed
- $lru->set($key2, $object2);
-
- $this->assertNull($lru->get($key1));
- $this->assertTrue($object2 === $lru->get($key2));
- $this->assertTrue($object3 === $lru->get($key3));
- }
-}
-
-
+<?php + +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class SqlMapCacheTest extends PHPUnit2_Framework_TestCase +{ + function testFIFOCache() + { + $fifo = new TSqlMapFifoCache(2); + $object1 = new TSqlMapper; + $object2 = new TComponent; + $object3 = new TMapper; + + $key1 = 'key1'; + $key2 = 'key2'; + $key3 = 'key3'; + + $fifo->set($key1, $object1); + $fifo->set($key2, $object2); + + $this->assertTrue($object1 === $fifo->get($key1)); + $this->assertTrue($object2 === $fifo->get($key2)); + + //object 1 should be removed + $fifo->set($key3, $object3); + + $this->assertNull($fifo->get($key1)); + $this->assertTrue($object2 === $fifo->get($key2)); + $this->assertTrue($object3 === $fifo->get($key3)); + + //object 2 should be removed + $fifo->set($key1, $object1); + + $this->assertNull($fifo->get($key2)); + $this->assertTrue($object3 === $fifo->get($key3)); + $this->assertTrue($object1 === $fifo->get($key1)); + } + + function testLruCache() + { + $lru = new TSqlMapLruCache(2); + + $object1 = new TSqlMapper; + $object2 = new TComponent; + $object3 = new TMapper; + + $key1 = 'key1'; + $key2 = 'key2'; + $key3 = 'key3'; + + $lru->set($key1, $object1); + $lru->set($key2, $object2); + + $this->assertTrue($object2 === $lru->get($key2)); + $this->assertTrue($object1 === $lru->get($key1)); + + //object 2 should be removed, i.e. least recently used + $lru->set($key3, $object3); + + $this->assertNull($lru->get($key2)); + $this->assertTrue($object1 === $lru->get($key1)); + $this->assertTrue($object3 === $lru->get($key3)); + + //object 1 will be removed + $lru->set($key2, $object2); + + $this->assertNull($lru->get($key1)); + $this->assertTrue($object2 === $lru->get($key2)); + $this->assertTrue($object3 === $lru->get($key3)); + } +} + + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/StatementTest.php b/tests/unit/SQLMap/StatementTest.php index b014dea4..b549835f 100644 --- a/tests/unit/SQLMap/StatementTest.php +++ b/tests/unit/SQLMap/StatementTest.php @@ -1,1134 +1,1134 @@ -<?php
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class StatementTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
-
- //force autoload
- new Account;
- new Order;
- new LineItem;
- new LineItemCollection;
- new A; new B; new C; new D; new E; new F;
- }
-
- public function setup()
- {
-
- }
-
- function resetDatabase()
- {
- $this->initScript('account-init.sql');
- $this->initScript('order-init.sql');
- $this->initScript('line-item-init.sql');
-// $this->initScript('enumeration-init.sql');
- $this->initScript('other-init.sql');
- }
-
-
- #region Object Query tests
-
- /**
- * Test Open connection with a connection string
- */
- function testOpenConnection()
- {
- $this->sqlmap->OpenConnection($this->sqlmap->getDataProvider()->getConnectionString());
- $account= $this->sqlmap->QueryForObject("SelectWithProperty");
- $this->sqlmap->CloseConnection();
- $this->assertAccount1($account);
- }
-
- /**
- * Test use a statement with property subtitution
- * (JIRA 22)
- */
- function testSelectWithProperty()
- {
- $account= $this->sqlmap->QueryForObject("SelectWithProperty");
- $this->assertAccount1($account);
- }
-
- /**
- * Test ExecuteQueryForObject Via ColumnName
- */
- function testExecuteQueryForObjectViaColumnName()
- {
- $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
- $this->assertAccount1($account);
- }
-
- /**
- * Test ExecuteQueryForObject Via ColumnIndex
- */
- function testExecuteQueryForObjectViaColumnIndex()
- {
- $account= $this->sqlmap->QueryForObject("GetAccountViaColumnIndex", 1);
- $this->assertAccount1($account);
- }
-
- /**
- * Test ExecuteQueryForObject Via ResultClass
- */
- function testExecuteQueryForObjectViaResultClass()
- {
- $account= $this->sqlmap->QueryForObject("GetAccountViaResultClass", 1);
- $this->assertAccount1($account);
- }
-
- /**
- * Test ExecuteQueryForObject With simple ResultClass : string
- */
- function testExecuteQueryForObjectWithSimpleResultClass()
- {
- $email = $this->sqlmap->QueryForObject("GetEmailAddressViaResultClass", 1);
- $this->assertEquals("Joe.Dalton@somewhere.com", $email);
- }
-
- /**
- * Test ExecuteQueryForObject With simple ResultMap : string
- */
- function testExecuteQueryForObjectWithSimpleResultMap()
- {
- $email = $this->sqlmap->QueryForObject("GetEmailAddressViaResultMap", 1);
- $this->assertEquals("Joe.Dalton@somewhere.com", $email);
- }
-
- /**
- * Test Primitive ReturnValue : TDateTime
- */
- function testPrimitiveReturnValue()
- {
- $CardExpiry = $this->sqlmap->QueryForObject("GetOrderCardExpiryViaResultClass", 1);
- $date = @mktime(8, 15, 00, 2, 15, 2003);
- $this->assertEquals($date, $CardExpiry->getTimeStamp());
- }
-
- /**
- * Test ExecuteQueryForObject with result object : Account
- */
- function testExecuteQueryForObjectWithResultObject()
- {
- $account= new Account();
- $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1, $account);
- $this->assertAccount1($account);
- $this->assertTrue($account == $testAccount);
- }
-
- /**
- * Test ExecuteQueryForObject as array
- */
- function testExecuteQueryForObjectAsHashArray()
- {
- $account = $this->sqlmap->QueryForObject("GetAccountAsHashtable", 1);
- $this->assertAccount1AsHashArray($account);
- }
-
- /**
- * Test ExecuteQueryForObject as Hashtable ResultClass
- */
- function testExecuteQueryForObjectAsHashtableResultClass()
- {
- $account = $this->sqlmap->QueryForObject("GetAccountAsHashtableResultClass", 1);
- $this->assertAccount1AsHashArray($account);
- }
-
- /**
- * Test ExecuteQueryForObject via Hashtable
- */
- function testExecuteQueryForObjectViaHashtable()
- {
- $param["LineItem_ID"] = 2;
- $param["Order_ID"] = 9;
-
- $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param);
-
- $this->assertNotNull($testItem);
- $this->assertEquals("TSM-12", $testItem->getCode());
- }
- /**/
-
- //TODO: Test Query Dynamic Sql Element
- function testQueryDynamicSqlElement()
- {
- //$list = $this->sqlmap->QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_ID");
-
- //$this->assertEquals("Joe.Dalton@somewhere.com", $list[0]);
-
- //list = $this->sqlmap->QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_FirstName");
-
- //$this->assertEquals("Averel.Dalton@somewhere.com", $list[0]);
-
- }
-
- // TODO: Test Execute QueryForList With ResultMap With Dynamic Element
- function testExecuteQueryForListWithResultMapWithDynamicElement()
- {
- //$list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "LIKE");
-
- //$this->assertAccount1$list[0]);
- //$this->assertEquals(3, $list->getCount());
- //$this->assertEquals(1, $list[0]->getID());
- //$this->assertEquals(2, $list[1]->getID());
- //$this->assertEquals(4, $list[2]->getID());
-
- //list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "=");
-
- //$this->assertEquals(0, $list->getCount());
- }
-
-
-
- /**
- * Test Get Account Via Inline Parameters
- */
- function testExecuteQueryForObjectViaInlineParameters()
- {
- $account= new Account();
- $account->setID(1);
-
- $testAccount = $this->sqlmap->QueryForObject("GetAccountViaInlineParameters", $account);
-
- $this->assertAccount1($testAccount);
- }
- /**/
-
- // TODO: Test ExecuteQuery For Object With Enum property
-
- function testExecuteQueryForObjectWithEnum()
- {
- //$enumClass = $this->sqlmap->QueryForObject("GetEnumeration", 1);
-
- //$this->assertEquals(enumClass.Day, Days.Sat);
- //$this->assertEquals(enumClass.Color, Colors.Red);
- //$this->assertEquals(enumClass.Month, Months.August);
-
- //enumClass = $this->sqlmap->QueryForObject("GetEnumeration", 3) as Enumeration;
-
- //$this->assertEquals(enumClass.Day, Days.Mon);
- //$this->assertEquals(enumClass.Color, Colors.Blue);
- //$this->assertEquals(enumClass.Month, Months.September);*/
- }
-
- #endregion
-
- #region List Query tests
-
- /**
- * Test QueryForList with Hashtable ResultMap
- */
- function testQueryForListWithHashtableResultMap()
- {
- $this->initScript('account-init.sql');
- $list = $this->sqlmap->QueryForList("GetAllAccountsAsHashMapViaResultMap");
-
- $this->assertAccount1AsHashArray($list[0]);
- $this->assertEquals(5, count($list));
-
- $this->assertEquals(1, (int)$list[0]["Id"]);
- $this->assertEquals(2, (int)$list[1]["Id"]);
- $this->assertEquals(3, (int)$list[2]["Id"]);
- $this->assertEquals(4, (int)$list[3]["Id"]);
- $this->assertEquals(5, (int)$list[4]["Id"]);
- }
-
- /**
- * Test QueryForList with Hashtable ResultClass
- */
- function testQueryForListWithHashtableResultClass()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsAsHashtableViaResultClass");
-
- $this->assertAccount1AsHashArray($list[0]);
- $this->assertEquals(5, count($list));
-
- $this->assertEquals(1, (int)$list[0]["Id"]);
- $this->assertEquals(2, (int)$list[1]["Id"]);
- $this->assertEquals(3, (int)$list[2]["Id"]);
- $this->assertEquals(4, (int)$list[3]["Id"]);
- $this->assertEquals(5, (int)$list[4]["Id"]);
- }
-
- /**
- * Test QueryForList with IList ResultClass
- */
- function testQueryForListWithIListResultClass()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsAsArrayListViaResultClass");
-
- $listAccount = $list[0];
-
- $this->assertEquals(1,(int)$listAccount[0]);
- $this->assertEquals("Joe",$listAccount[1]);
- $this->assertEquals("Dalton",$listAccount[2]);
- $this->assertEquals("Joe.Dalton@somewhere.com",$listAccount[3]);
-
- $this->assertEquals(5, count($list));
-
- $listAccount = $list[0];
- $this->assertEquals(1, (int)$listAccount[0]);
- $listAccount = $list[1];
- $this->assertEquals(2, (int)$listAccount[0]);
- $listAccount = $list[2];
- $this->assertEquals(3, (int)$listAccount[0]);
- $listAccount = $list[3];
- $this->assertEquals(4, (int)$listAccount[0]);
- $listAccount = $list[4];
- $this->assertEquals(5, (int)$listAccount[0]);
- }
-
- /**
- * Test QueryForList With ResultMap, result collection as ArrayList
- */
- function testQueryForListWithResultMap()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMap");
-
- $this->assertAccount1($list[0]);
- $this->assertEquals(5, count($list));
- $this->assertEquals(1, $list[0]->getID());
- $this->assertEquals(2, $list[1]->getID());
- $this->assertEquals(3, $list[2]->getID());
- $this->assertEquals(4, $list[3]->getID());
- $this->assertEquals(5, $list[4]->getID());
- }
-
- /**
- * Test ExecuteQueryForPaginatedList
- */
- function testExecuteQueryForPaginatedList()
- {
- // Get List of all 5
- $list = $this->sqlmap->QueryForPagedList("GetAllAccountsViaResultMap", null, 2);
-
- // Test initial state (page 0)
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertAccount1($list[0]);
- $this->assertEquals(2, $list->getCount());
- $this->assertEquals(1, $list[0]->getID());
- $this->assertEquals(2, $list[1]->getID());
-
- // Test illegal previous page (no effect, state should be same)
- $list->PreviousPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertAccount1($list[0]);
- $this->assertEquals(2, $list->getCount());
- $this->assertEquals(1, $list[0]->getID());
- $this->assertEquals(2, $list[1]->getID());
-
- // Test next (page 1)
- $list->NextPage();
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertEquals(2, $list->getCount());
- $this->assertEquals(3, $list[0]->getID());
- $this->assertEquals(4, $list[1]->getID());
-
- // Test next (page 2 -last)
- $list->NextPage();
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(1, $list->getCount());
- $this->assertEquals(5, $list[0]->getID());
-
- // Test previous (page 1)
- $list->PreviousPage();
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertEquals(2, $list->getCount());
- $this->assertEquals(3, $list[0]->getID());
- $this->assertEquals(4, $list[1]->getID());
-
- // Test previous (page 0 -first)
- $list->PreviousPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertAccount1($list[0]);
- $this->assertEquals(2, $list->getCount());
- $this->assertEquals(1, $list[0]->getID());
- $this->assertEquals(2, $list[1]->getID());
-
- // Test goto (page 0)
- $list->GotoPage(0);
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertEquals(2, $list->getCount());
- $this->assertEquals(1, $list[0]->getID());
- $this->assertEquals(2, $list[1]->getID());
-
- // Test goto (page 1)
- $list->GotoPage(1);
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertTrue($list->getIsNextPageAvailable());
- $this->assertEquals(2, $list->getCount());
- $this->assertEquals(3, $list[0]->getID());
- $this->assertEquals(4, $list[1]->getID());
-
- // Test goto (page 2)
- $list->GotoPage(2);
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(1, $list->getCount());
- $this->assertEquals(5, $list[0]->getID());
-
- // Test illegal goto (page 0)
- $list->GotoPage(3);
- $this->assertTrue($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(0, $list->getCount());
-
- $list = $this->sqlmap->QueryForPagedList("GetNoAccountsViaResultMap", null, 2);
-
- // Test empty list
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(0, $list->getCount());
-
- // Test next
- $list->NextPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(0, $list->getCount());
-
- // Test previous
- $list->PreviousPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(0, $list->getCount());
-
- // Test previous
- $list->GotoPage(0);
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(0, $list->getCount());
- $list = $this->sqlmap->QueryForPagedList("GetFewAccountsViaResultMap", null, 2);
-
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(1, $list->getCount());
-
- // Test next
- $list->NextPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(1, $list->getCount());
- // Test previous
- $list->PreviousPage();
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(1, $list->getCount());
-
- // Test previous
- $list->GotoPage(0);
- $this->assertFalse($list->getIsPreviousPageAvailable());
- $this->assertFalse($list->getIsNextPageAvailable());
- $this->assertEquals(1, $list->getCount());
-
-
- $list = $this->sqlmap->QueryForPagedList("GetAllAccountsViaResultMap", null, 5);
-
- $this->assertEquals(5, $list->getCount());
-
- $list->NextPage();
- $this->assertEquals(5, $list->getCount());
-
- $b = $list->getIsPreviousPageAvailable();
- $list->PreviousPage();
- $this->assertEquals(5, $list->getCount());
- }
-
- /**
- * Test QueryForList with ResultObject :
- * AccountCollection strongly typed collection
- */
- function testQueryForListWithResultObject()
- {
- $accounts = new AccountCollection();
-
- $this->sqlmap->QueryForList("GetAllAccountsViaResultMap", null, $accounts);
- $this->assertAccount1($accounts[0]);
- $this->assertEquals(5, $accounts->getCount());
- $this->assertEquals(1, $accounts[0]->getID());
- $this->assertEquals(2, $accounts[1]->getID());
- $this->assertEquals(3, $accounts[2]->getID());
- $this->assertEquals(4, $accounts[3]->getID());
- $this->assertEquals(5, $accounts[4]->GetId());
- }
-
- /**
- * Test QueryForList with ListClass : LineItemCollection
- */
- function testQueryForListWithListClass()
- {
- $linesItem = $this->sqlmap->QueryForList("GetLineItemsForOrderWithListClass", 10);
-
- $this->assertNotNull($linesItem);
- $this->assertEquals(2, $linesItem->getCount());
- $this->assertEquals("ESM-34", $linesItem[0]->getCode());
- $this->assertEquals("QSM-98", $linesItem[1]->getCode());
- }
-
- /**
- * Test QueryForList with no result.
- */
- function testQueryForListWithNoResult()
- {
- $list = $this->sqlmap->QueryForList("GetNoAccountsViaResultMap");
-
- $this->assertEquals(0, count($list));
- }
-
- /**
- * Test QueryForList with ResultClass : Account.
- */
- function testQueryForListResultClass()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultClass");
-
- $this->assertAccount1($list[0]);
- $this->assertEquals(5, count($list));
- $this->assertEquals(1, $list[0]->getID());
- $this->assertEquals(2, $list[1]->getID());
- $this->assertEquals(3, $list[2]->getID());
- $this->assertEquals(4, $list[3]->getID());
- $this->assertEquals(5, $list[4]->getID());
- }
-
- /**
- * Test QueryForList with simple resultClass : string
- */
- function testQueryForListWithSimpleResultClass()
- {
- $list = $this->sqlmap->QueryForList("GetAllEmailAddressesViaResultClass");
-
- $this->assertEquals("Joe.Dalton@somewhere.com", $list[0]);
- $this->assertEquals("Averel.Dalton@somewhere.com", $list[1]);
- $this->assertEquals('', $list[2]);
- $this->assertEquals("Jack.Dalton@somewhere.com", $list[3]);
- $this->assertEquals('', $list[4]);
- }
-
- /**
- * Test QueryForList with simple ResultMap : string
- */
- function testQueryForListWithSimpleResultMap()
- {
- $list = $this->sqlmap->QueryForList("GetAllEmailAddressesViaResultMap");
-
- $this->assertEquals("Joe.Dalton@somewhere.com", $list[0]);
- $this->assertEquals("Averel.Dalton@somewhere.com", $list[1]);
- $this->assertEquals('', $list[2]);
- $this->assertEquals("Jack.Dalton@somewhere.com", $list[3]);
- $this->assertEquals('', $list[4]);
- }
-
- /**
- * Test QueryForListWithSkipAndMax
- */
- function testQueryForListWithSkipAndMax()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMap", null, null, 2, 2);
-
- $this->assertEquals(2, count($list));
- $this->assertEquals(3, $list[0]->getID());
- $this->assertEquals(4, $list[1]->getID());
- }
-
-
- /**
- * Test row delegate
- */
- function testQueryWithRowDelegate()
- {
- //$handler = new SqlMapper.RowDelegate(this.RowHandler);
-
- //$list = $this->sqlmap->QueryWithRowDelegate("GetAllAccountsViaResultMap", null, handler);
-
- //$this->assertEquals(5, _index);
- //$this->assertEquals(5, $list->getCount());
- //$this->assertAccount1$list[0]);
- //$this->assertEquals(1, $list[0]->getID());
- //$this->assertEquals(2, $list[1]->getID());
- //$this->assertEquals(3, $list[2]->getID());
- //$this->assertEquals(4, $list[3]->getID());
- //$this->assertEquals(5, $list[4]->getID());
- }
-
- #endregion
-
- #region Map Tests
-
- /**
- * Test ExecuteQueryForMap : Hashtable.
- */
- function testExecuteQueryForMap()
- {
- $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, "FirstName");
-
- $this->assertEquals(5, count($map));
- $this->assertAccount1($map["Joe"]);
-
- $this->assertEquals(1, $map["Joe"]->getID());
- $this->assertEquals(2, $map["Averel"]->getID());
- $this->assertEquals(3, $map["William"]->getID());
- $this->assertEquals(4, $map["Jack"]->getID());
- $this->assertEquals(5, $map["Gilles"]->getID());
- }
-
- /**
- * Test ExecuteQueryForMap : Hashtable.
- *
- * If the keyProperty is an integer, you must acces the map
- * by map[integer] and not by map["integer"]
- */
- function testExecuteQueryForMap2()
- {
- $map = $this->sqlmap->QueryForMap("GetAllOrderWithLineItems", null, "PostalCode");
-
- $this->assertEquals(11, count($map));
- $order = $map["T4H 9G4"];
-
- $this->assertEquals(2, $order->getLineItemsList()->getCount());
- }
-
- /**
- * Test ExecuteQueryForMap with value property :
- * "FirstName" as key, "EmailAddress" as value
- */
- function testExecuteQueryForMapWithValueProperty()
- {
- $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null,
- "FirstName", "EmailAddress");
-
- $this->assertEquals(5, count($map));
-
- $this->assertEquals("Joe.Dalton@somewhere.com", $map["Joe"]);
- $this->assertEquals("Averel.Dalton@somewhere.com", $map["Averel"]);
- $this->assertNull($map["William"]);
- $this->assertEquals("Jack.Dalton@somewhere.com", $map["Jack"]);
- $this->assertNull($map["Gilles"]);
- }
-
- /**
- * Test ExecuteQueryForWithJoined
- */
- function testExecuteQueryForWithJoined()
- {
- $order = $this->sqlmap->QueryForObject("GetOrderJoinWithAccount",10);
-
- $this->assertNotNull($order->getAccount());
-
- $order = $this->sqlmap->QueryForObject("GetOrderJoinWithAccount",11);
-
- $this->assertNull($order->getAccount());
- }
-
- /**
- * Test ExecuteQueryFor With Complex Joined
- *
- * A->B->C
- * ->E
- * ->F
- */
- function testExecuteQueryForWithComplexJoined()
- {
- $a = $this->sqlmap->QueryForObject("SelectComplexJoined",null);
- $this->assertNotNull($a);
- $this->assertNotNull($a->getB());
- $this->assertNotNull($a->getB()->getC());
- $this->assertNull($a->getB()->getD());
- $this->assertNotNull($a->getE());
- $this->assertNull($a->getF());
- }
- #endregion
-
- #region Extends statement
-
- /**
- * Test base Extends statement
- */
- function testExtendsGetAllAccounts()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccounts");
-
- $this->assertAccount1($list[0]);
- $this->assertEquals(5, count($list));
- $this->assertEquals(1, $list[0]->getID());
- $this->assertEquals(2, $list[1]->getID());
- $this->assertEquals(3, $list[2]->getID());
- $this->assertEquals(4, $list[3]->getID());
- $this->assertEquals(5, $list[4]->getID());
- }
-
- /**
- * Test Extends statement GetAllAccountsOrderByName extends GetAllAccounts
- */
- function testExtendsGetAllAccountsOrderByName()
- {
- $list = $this->sqlmap->QueryForList("GetAllAccountsOrderByName");
-
- $this->assertAccount1($list[3]);
- $this->assertEquals(5, count($list));
-
- $this->assertEquals(2, $list[0]->getID());
- $this->assertEquals(5, $list[1]->getID());
- $this->assertEquals(4, $list[2]->getID());
- $this->assertEquals(1, $list[3]->getID());
- $this->assertEquals(3, $list[4]->getID());
- }
-
- /**
- * Test Extends statement GetOneAccount extends GetAllAccounts
- */
- function testExtendsGetOneAccount()
- {
- $account= $this->sqlmap->QueryForObject("GetOneAccount", 1);
- $this->assertAccount1($account);
- }
-
- /**
- * Test Extends statement GetSomeAccount extends GetAllAccounts
- */
- function testExtendsGetSomeAccount()
- {
- $param["lowID"] = 2;
- $param["hightID"] = 4;
-
- $list = $this->sqlmap->QueryForList("GetSomeAccount", $param);
-
- $this->assertEquals(3, count($list));
-
- $this->assertEquals(2, $list[0]->getID());
- $this->assertEquals(3, $list[1]->getID());
- $this->assertEquals(4, $list[2]->getID());
- }
-
- #endregion
-
- #region Update tests
-
-
- /**
- * Test Insert account via public fields
- */
- function testInsertAccountViaPublicFields()
- {
- $this->initScript('account-init.sql');
-
- $account = new AccountBis();
-
- $account->Id = 10;
- $account->FirstName = "Luky";
- $account->LastName = "Luke";
- $account->EmailAddress = "luly.luke@somewhere.com";
-
- $this->sqlmap->Insert("InsertAccountViaPublicFields", $account);
-
- $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 10);
-
- $this->assertNotNull($testAccount);
-
- $this->assertEquals(10, $testAccount->getID());
-
- $this->initScript('account-init.sql');
- }
-
- /**
- *
- */
- function testInsertOrderViaProperties()
- {
- $this->initScript('account-init.sql');
- $this->initScript('order-init.sql');
- $account= $this->NewAccount6();
-
- $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate('2005-05-20');
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->Insert("InsertOrderViaPublicFields", $order);
-
- $this->initScript('account-init.sql');
- $this->initScript('order-init.sql');
- }
-
-
- /**
- * Test Insert account via inline parameters
- */
- function testInsertAccountViaInlineParameters()
- {
- $this->initScript('account-init.sql');
- $account= new Account();
-
- $account->setId(10);
- $account->setFirstName("Luky");
- $account->setLastName("Luke");
- $account->setEmailAddress("luly.luke@somewhere.com");
-
- $this->sqlmap->Insert("InsertAccountViaInlineParameters", $account);
-
- $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnIndex", 10);
-
- $this->assertNotNull($testAccount);
- $this->assertEquals(10, $testAccount->getId());
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Insert account via parameterMap
- */
- function testInsertAccountViaParameterMap()
- {
- $this->initScript('account-init.sql');
- $account= $this->NewAccount6();
- $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
-
- $account = $this->sqlmap->QueryForObject("GetAccountNullableEmail", 6);
- $this->AssertAccount6($account);
-
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Update via parameterMap
- */
- function testUpdateViaParameterMap()
- {
- $this->initScript('account-init.sql');
- $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $account->setEmailAddress("new@somewhere.com");
- $this->sqlmap->Update("UpdateAccountViaParameterMap", $account);
-
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $this->assertEquals("new@somewhere.com", $account->getEmailAddress());
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Update via parameterMap V2
- */
- function testUpdateViaParameterMap2()
- {
- $this->initScript('account-init.sql');
- $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $account->setEmailAddress("new@somewhere.com");
- $this->sqlmap->Update("UpdateAccountViaParameterMap2", $account);
-
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $this->assertEquals("new@somewhere.com", $account->getEmailAddress());
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Update with inline parameters
- */
- function testUpdateWithInlineParameters()
- {
- $this->initScript('account-init.sql');
- $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $account->setEmailAddress("new@somewhere.com");
- $this->sqlmap->Update("UpdateAccountViaInlineParameters", $account);
-
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1);
-
- $this->assertEquals("new@somewhere.com", $account->getEmailAddress());
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Execute Update With Parameter Class
- */
- function testExecuteUpdateWithParameterClass()
- {
- $this->initScript('account-init.sql');
- $account= $this->NewAccount6();
-
- $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
-
- $noRowsDeleted = $this->sqlmap->Update("DeleteAccount", null);
-
- $this->sqlmap->Update("DeleteAccount", $account);
-
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6);
-
- $this->assertNull($account);
- $this->assertEquals(0, $noRowsDeleted);
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Execute Delete
- */
- function testExecuteDelete()
- {
- $this->initScript('account-init.sql');
- $account= $this->NewAccount6();
-
- $this->sqlmap->Insert("InsertAccountViaParameterMap", $account);
-
- $account = null;
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6);
-
- $this->assertTrue($account->getId() == 6);
-
- $rowNumber = $this->sqlmap->Delete("DeleteAccount", $account);
- $this->assertTrue($rowNumber == 1);
-
- $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6);
-
- $this->assertNull($account);
- $this->initScript('account-init.sql');
- }
-
- /**
- * Test Execute Delete
- */
- function testDeleteWithComments()
- {
- $this->initScript('line-item-init.sql');
- $rowNumber = $this->sqlmap->Delete("DeleteWithComments");
-
- $this->assertEquals($rowNumber, 2);
- $this->initScript('line-item-init.sql');
- }
-
-
-
- #endregion
-
- #region Row delegate
-
- private $_index = 0;
-
- function RowHandler($sender, $paramterObject, $list)
- {
- //_index++;
- //$this->assertEquals(_index, (($account) obj).Id);
- //$list->Add(obj);
- }
-
- #endregion
-
- #region JIRA Tests
-
- /**
- * Test JIRA 30 (repeating property)
- */
- function testJIRA30()
- {
- $account= new Account();
- $account->setId(1);
- $account->setFirstName("Joe");
- $account->setLastName("Dalton");
- $account->setEmailAddress("Joe.Dalton@somewhere.com");
-
- $result = $this->sqlmap->QueryForObject("GetAccountWithRepeatingProperty", $account);
-
- $this->assertAccount1($result);
- }
-
- /**
- * Test Bit column
- */
- function testJIRA42()
- {
- $other = new Other();
-
- $other->setInt(100);
- $other->setBool(true);
- $other->setLong(789456321);
-
- $this->sqlmap->Insert("InsertBool", $other);
- }
-
- /**
- * Test for access a result map in a different namespace
- */
- function testJIRA45()
- {
- $account= $this->sqlmap->QueryForObject("GetAccountJIRA45", 1);
- $this->assertAccount1($account);
- }
-
- /**
- * Test : Whitespace is not maintained properly when CDATA tags are used
- */
- function testJIRA110()
- {
- $account= $this->sqlmap->QueryForObject("Get1Account");
- $this->assertAccount1($account);
- }
-
- /**
- * Test : Whitespace is not maintained properly when CDATA tags are used
- */
- function testJIRA110Bis()
- {
- $list = $this->sqlmap->QueryForList("GetAccounts");
-
- $this->assertAccount1($list[0]);
- $this->assertEquals(5, count($list));
- }
-
- /**
- * Test for cache stats only being calculated on CachingStatments
- */
- function testJIRA113()
- {
- // $this->sqlmap->FlushCaches();
-
- // taken from TestFlushDataCache()
- // first query is not cached, second query is: 50% cache hit
- /*$list = $this->sqlmap->QueryForList("GetCachedAccountsViaResultMap");
- $firstId = HashCodeProvider.GetIdentityHashCode(list);
- list = $this->sqlmap->QueryForList("GetCachedAccountsViaResultMap");
- int secondId = HashCodeProvider.GetIdentityHashCode(list);
- $this->assertEquals(firstId, secondId);
-
- string cacheStats = $this->sqlmap->GetDataCacheStats();
-
- $this->assertNotNull(cacheStats);*/
- }
-
- #endregion
-
- #region CustomTypeHandler tests
-
- /**
- * Test CustomTypeHandler
- */
- function testExecuteQueryWithCustomTypeHandler()
- {
- $this->sqlmap->getTypeHandlerFactory()->register('HundredsBool', new HundredsBool());
- $this->sqlmap->getTypeHandlerFactory()->register('OuiNonBool', new OuiNonBool());
-
- $list = $this->sqlmap->QueryForList("GetAllAccountsViaCustomTypeHandler");
-
- $this->assertAccount1($list[0]);
- $this->assertEquals(5, count($list));
- $this->assertEquals(1, $list[0]->getID());
- $this->assertEquals(2, $list[1]->getID());
- $this->assertEquals(3, $list[2]->getID());
- $this->assertEquals(4, $list[3]->getID());
- $this->assertEquals(5, $list[4]->getID());
-
- $this->assertFalse($list[0]->getCartOptions());
- $this->assertFalse($list[1]->getCartOptions());
- $this->assertTrue($list[2]->getCartOptions());
- $this->assertTrue($list[3]->getCartOptions());
- $this->assertTrue($list[4]->getCartOptions());
-
- $this->assertTrue($list[0]->getBannerOptions());
- $this->assertTrue($list[1]->getBannerOptions());
- $this->assertFalse($list[2]->getBannerOptions());
- $this->assertFalse($list[3]->getBannerOptions());
- $this->assertTrue($list[4]->getBannerOptions());
- }
-
- /**
- * Test CustomTypeHandler Oui/Non
- */
- function testCustomTypeHandler()
- {
- $this->initScript('other-init.sql');
- $this->initScript('account-init.sql');
-
- $this->sqlmap->getTypeHandlerFactory()->register('OuiNonBool', new OuiNonBool());
-
- $other = new Other();
- $other->setInt(99);
- $other->setLong(1966);
- $other->setBool(true);
- $other->setBool2(false);
- $this->sqlmap->Insert("InsertCustomTypeHandler", $other);
-
- $anOther = $this->sqlmap->QueryForObject("SelectByInt", 99);
- $this->assertNotNull( $anOther );
- $this->assertEquals(99, (int)$anOther->getInt());
- $this->assertEquals(1966, (int)$anOther->getLong());
- $this->assertEquals(true, (boolean)$anOther->getBool());
- $this->assertEquals(false, (boolean)$anOther->getBool2());
-
- }
-
- /**
- * Test CustomTypeHandler Oui/Non
- */
- function testInsertInlineCustomTypeHandlerV1()
- {
- $this->initScript('other-init.sql');
- $this->initScript('account-init.sql');
-
- $other = new Other();
- $other->setInt(99);
- $other->setLong(1966);
- $other->setBool(true);
- $other->setBool2(false);
-
- $this->sqlmap->Insert("InsertInlineCustomTypeHandlerV1", $other);
-
- $anOther = $this->sqlmap->QueryForObject("SelectByIntV1", 99);
-
- $this->assertNotNull( $anOther );
- $this->assertEquals(99, (int)$anOther->getInt());
- $this->assertEquals(1966, (int)$anOther->getLong());
- $this->assertEquals(true, (boolean)$anOther->getBool());
- $this->assertEquals(false, (boolean)$anOther->getBool2());
-
- }
-
- /**
- * Test CustomTypeHandler Oui/Non
- */
- function testInsertInlineCustomTypeHandlerV2()
- {
- $this->initScript('other-init.sql');
- $this->initScript('account-init.sql');
-
- $other = new Other();
- $other->setInt(99);
- $other->setLong(1966);
- $other->setBool(true);
- $other->setBool2(false);
-
- $this->sqlmap->Insert("InsertInlineCustomTypeHandlerV2", $other);
-
- $anOther = $this->sqlmap->QueryForObject("SelectByInt", 99);
-
- $this->assertNotNull( $anOther );
- $this->assertEquals(99, (int)$anOther->getInt());
- $this->assertEquals(1966, (int)$anOther->getLong());
- $this->assertEquals(true, (boolean)$anOther->getBool());
- $this->assertEquals(false, (boolean)$anOther->getBool2());
- }
- #endregion
- /**/
-}
-
+<?php +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class StatementTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + + //force autoload + new Account; + new Order; + new LineItem; + new LineItemCollection; + new A; new B; new C; new D; new E; new F; + } + + public function setup() + { + + } + + function resetDatabase() + { + $this->initScript('account-init.sql'); + $this->initScript('order-init.sql'); + $this->initScript('line-item-init.sql'); +// $this->initScript('enumeration-init.sql'); + $this->initScript('other-init.sql'); + } + + + #region Object Query tests + + /** + * Test Open connection with a connection string + */ + function testOpenConnection() + { + $this->sqlmap->OpenConnection($this->sqlmap->getDataProvider()->getConnectionString()); + $account= $this->sqlmap->QueryForObject("SelectWithProperty"); + $this->sqlmap->CloseConnection(); + $this->assertAccount1($account); + } + + /** + * Test use a statement with property subtitution + * (JIRA 22) + */ + function testSelectWithProperty() + { + $account= $this->sqlmap->QueryForObject("SelectWithProperty"); + $this->assertAccount1($account); + } + + /** + * Test ExecuteQueryForObject Via ColumnName + */ + function testExecuteQueryForObjectViaColumnName() + { + $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + $this->assertAccount1($account); + } + + /** + * Test ExecuteQueryForObject Via ColumnIndex + */ + function testExecuteQueryForObjectViaColumnIndex() + { + $account= $this->sqlmap->QueryForObject("GetAccountViaColumnIndex", 1); + $this->assertAccount1($account); + } + + /** + * Test ExecuteQueryForObject Via ResultClass + */ + function testExecuteQueryForObjectViaResultClass() + { + $account= $this->sqlmap->QueryForObject("GetAccountViaResultClass", 1); + $this->assertAccount1($account); + } + + /** + * Test ExecuteQueryForObject With simple ResultClass : string + */ + function testExecuteQueryForObjectWithSimpleResultClass() + { + $email = $this->sqlmap->QueryForObject("GetEmailAddressViaResultClass", 1); + $this->assertEquals("Joe.Dalton@somewhere.com", $email); + } + + /** + * Test ExecuteQueryForObject With simple ResultMap : string + */ + function testExecuteQueryForObjectWithSimpleResultMap() + { + $email = $this->sqlmap->QueryForObject("GetEmailAddressViaResultMap", 1); + $this->assertEquals("Joe.Dalton@somewhere.com", $email); + } + + /** + * Test Primitive ReturnValue : TDateTime + */ + function testPrimitiveReturnValue() + { + $CardExpiry = $this->sqlmap->QueryForObject("GetOrderCardExpiryViaResultClass", 1); + $date = @mktime(8, 15, 00, 2, 15, 2003); + $this->assertEquals($date, $CardExpiry->getTimeStamp()); + } + + /** + * Test ExecuteQueryForObject with result object : Account + */ + function testExecuteQueryForObjectWithResultObject() + { + $account= new Account(); + $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1, $account); + $this->assertAccount1($account); + $this->assertTrue($account == $testAccount); + } + + /** + * Test ExecuteQueryForObject as array + */ + function testExecuteQueryForObjectAsHashArray() + { + $account = $this->sqlmap->QueryForObject("GetAccountAsHashtable", 1); + $this->assertAccount1AsHashArray($account); + } + + /** + * Test ExecuteQueryForObject as Hashtable ResultClass + */ + function testExecuteQueryForObjectAsHashtableResultClass() + { + $account = $this->sqlmap->QueryForObject("GetAccountAsHashtableResultClass", 1); + $this->assertAccount1AsHashArray($account); + } + + /** + * Test ExecuteQueryForObject via Hashtable + */ + function testExecuteQueryForObjectViaHashtable() + { + $param["LineItem_ID"] = 2; + $param["Order_ID"] = 9; + + $testItem = $this->sqlmap->QueryForObject("GetSpecificLineItem", $param); + + $this->assertNotNull($testItem); + $this->assertEquals("TSM-12", $testItem->getCode()); + } + /**/ + + //TODO: Test Query Dynamic Sql Element + function testQueryDynamicSqlElement() + { + //$list = $this->sqlmap->QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_ID"); + + //$this->assertEquals("Joe.Dalton@somewhere.com", $list[0]); + + //list = $this->sqlmap->QueryForList("GetDynamicOrderedEmailAddressesViaResultMap", "Account_FirstName"); + + //$this->assertEquals("Averel.Dalton@somewhere.com", $list[0]); + + } + + // TODO: Test Execute QueryForList With ResultMap With Dynamic Element + function testExecuteQueryForListWithResultMapWithDynamicElement() + { + //$list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "LIKE"); + + //$this->assertAccount1$list[0]); + //$this->assertEquals(3, $list->getCount()); + //$this->assertEquals(1, $list[0]->getID()); + //$this->assertEquals(2, $list[1]->getID()); + //$this->assertEquals(4, $list[2]->getID()); + + //list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMapWithDynamicElement", "="); + + //$this->assertEquals(0, $list->getCount()); + } + + + + /** + * Test Get Account Via Inline Parameters + */ + function testExecuteQueryForObjectViaInlineParameters() + { + $account= new Account(); + $account->setID(1); + + $testAccount = $this->sqlmap->QueryForObject("GetAccountViaInlineParameters", $account); + + $this->assertAccount1($testAccount); + } + /**/ + + // TODO: Test ExecuteQuery For Object With Enum property + + function testExecuteQueryForObjectWithEnum() + { + //$enumClass = $this->sqlmap->QueryForObject("GetEnumeration", 1); + + //$this->assertEquals(enumClass.Day, Days.Sat); + //$this->assertEquals(enumClass.Color, Colors.Red); + //$this->assertEquals(enumClass.Month, Months.August); + + //enumClass = $this->sqlmap->QueryForObject("GetEnumeration", 3) as Enumeration; + + //$this->assertEquals(enumClass.Day, Days.Mon); + //$this->assertEquals(enumClass.Color, Colors.Blue); + //$this->assertEquals(enumClass.Month, Months.September);*/ + } + + #endregion + + #region List Query tests + + /** + * Test QueryForList with Hashtable ResultMap + */ + function testQueryForListWithHashtableResultMap() + { + $this->initScript('account-init.sql'); + $list = $this->sqlmap->QueryForList("GetAllAccountsAsHashMapViaResultMap"); + + $this->assertAccount1AsHashArray($list[0]); + $this->assertEquals(5, count($list)); + + $this->assertEquals(1, (int)$list[0]["Id"]); + $this->assertEquals(2, (int)$list[1]["Id"]); + $this->assertEquals(3, (int)$list[2]["Id"]); + $this->assertEquals(4, (int)$list[3]["Id"]); + $this->assertEquals(5, (int)$list[4]["Id"]); + } + + /** + * Test QueryForList with Hashtable ResultClass + */ + function testQueryForListWithHashtableResultClass() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsAsHashtableViaResultClass"); + + $this->assertAccount1AsHashArray($list[0]); + $this->assertEquals(5, count($list)); + + $this->assertEquals(1, (int)$list[0]["Id"]); + $this->assertEquals(2, (int)$list[1]["Id"]); + $this->assertEquals(3, (int)$list[2]["Id"]); + $this->assertEquals(4, (int)$list[3]["Id"]); + $this->assertEquals(5, (int)$list[4]["Id"]); + } + + /** + * Test QueryForList with IList ResultClass + */ + function testQueryForListWithIListResultClass() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsAsArrayListViaResultClass"); + + $listAccount = $list[0]; + + $this->assertEquals(1,(int)$listAccount[0]); + $this->assertEquals("Joe",$listAccount[1]); + $this->assertEquals("Dalton",$listAccount[2]); + $this->assertEquals("Joe.Dalton@somewhere.com",$listAccount[3]); + + $this->assertEquals(5, count($list)); + + $listAccount = $list[0]; + $this->assertEquals(1, (int)$listAccount[0]); + $listAccount = $list[1]; + $this->assertEquals(2, (int)$listAccount[0]); + $listAccount = $list[2]; + $this->assertEquals(3, (int)$listAccount[0]); + $listAccount = $list[3]; + $this->assertEquals(4, (int)$listAccount[0]); + $listAccount = $list[4]; + $this->assertEquals(5, (int)$listAccount[0]); + } + + /** + * Test QueryForList With ResultMap, result collection as ArrayList + */ + function testQueryForListWithResultMap() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMap"); + + $this->assertAccount1($list[0]); + $this->assertEquals(5, count($list)); + $this->assertEquals(1, $list[0]->getID()); + $this->assertEquals(2, $list[1]->getID()); + $this->assertEquals(3, $list[2]->getID()); + $this->assertEquals(4, $list[3]->getID()); + $this->assertEquals(5, $list[4]->getID()); + } + + /** + * Test ExecuteQueryForPaginatedList + */ + function testExecuteQueryForPaginatedList() + { + // Get List of all 5 + $list = $this->sqlmap->QueryForPagedList("GetAllAccountsViaResultMap", null, 2); + + // Test initial state (page 0) + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertAccount1($list[0]); + $this->assertEquals(2, $list->getCount()); + $this->assertEquals(1, $list[0]->getID()); + $this->assertEquals(2, $list[1]->getID()); + + // Test illegal previous page (no effect, state should be same) + $list->PreviousPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertAccount1($list[0]); + $this->assertEquals(2, $list->getCount()); + $this->assertEquals(1, $list[0]->getID()); + $this->assertEquals(2, $list[1]->getID()); + + // Test next (page 1) + $list->NextPage(); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertEquals(2, $list->getCount()); + $this->assertEquals(3, $list[0]->getID()); + $this->assertEquals(4, $list[1]->getID()); + + // Test next (page 2 -last) + $list->NextPage(); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(1, $list->getCount()); + $this->assertEquals(5, $list[0]->getID()); + + // Test previous (page 1) + $list->PreviousPage(); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertEquals(2, $list->getCount()); + $this->assertEquals(3, $list[0]->getID()); + $this->assertEquals(4, $list[1]->getID()); + + // Test previous (page 0 -first) + $list->PreviousPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertAccount1($list[0]); + $this->assertEquals(2, $list->getCount()); + $this->assertEquals(1, $list[0]->getID()); + $this->assertEquals(2, $list[1]->getID()); + + // Test goto (page 0) + $list->GotoPage(0); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertEquals(2, $list->getCount()); + $this->assertEquals(1, $list[0]->getID()); + $this->assertEquals(2, $list[1]->getID()); + + // Test goto (page 1) + $list->GotoPage(1); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertTrue($list->getIsNextPageAvailable()); + $this->assertEquals(2, $list->getCount()); + $this->assertEquals(3, $list[0]->getID()); + $this->assertEquals(4, $list[1]->getID()); + + // Test goto (page 2) + $list->GotoPage(2); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(1, $list->getCount()); + $this->assertEquals(5, $list[0]->getID()); + + // Test illegal goto (page 0) + $list->GotoPage(3); + $this->assertTrue($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(0, $list->getCount()); + + $list = $this->sqlmap->QueryForPagedList("GetNoAccountsViaResultMap", null, 2); + + // Test empty list + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(0, $list->getCount()); + + // Test next + $list->NextPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(0, $list->getCount()); + + // Test previous + $list->PreviousPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(0, $list->getCount()); + + // Test previous + $list->GotoPage(0); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(0, $list->getCount()); + $list = $this->sqlmap->QueryForPagedList("GetFewAccountsViaResultMap", null, 2); + + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(1, $list->getCount()); + + // Test next + $list->NextPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(1, $list->getCount()); + // Test previous + $list->PreviousPage(); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(1, $list->getCount()); + + // Test previous + $list->GotoPage(0); + $this->assertFalse($list->getIsPreviousPageAvailable()); + $this->assertFalse($list->getIsNextPageAvailable()); + $this->assertEquals(1, $list->getCount()); + + + $list = $this->sqlmap->QueryForPagedList("GetAllAccountsViaResultMap", null, 5); + + $this->assertEquals(5, $list->getCount()); + + $list->NextPage(); + $this->assertEquals(5, $list->getCount()); + + $b = $list->getIsPreviousPageAvailable(); + $list->PreviousPage(); + $this->assertEquals(5, $list->getCount()); + } + + /** + * Test QueryForList with ResultObject : + * AccountCollection strongly typed collection + */ + function testQueryForListWithResultObject() + { + $accounts = new AccountCollection(); + + $this->sqlmap->QueryForList("GetAllAccountsViaResultMap", null, $accounts); + $this->assertAccount1($accounts[0]); + $this->assertEquals(5, $accounts->getCount()); + $this->assertEquals(1, $accounts[0]->getID()); + $this->assertEquals(2, $accounts[1]->getID()); + $this->assertEquals(3, $accounts[2]->getID()); + $this->assertEquals(4, $accounts[3]->getID()); + $this->assertEquals(5, $accounts[4]->GetId()); + } + + /** + * Test QueryForList with ListClass : LineItemCollection + */ + function testQueryForListWithListClass() + { + $linesItem = $this->sqlmap->QueryForList("GetLineItemsForOrderWithListClass", 10); + + $this->assertNotNull($linesItem); + $this->assertEquals(2, $linesItem->getCount()); + $this->assertEquals("ESM-34", $linesItem[0]->getCode()); + $this->assertEquals("QSM-98", $linesItem[1]->getCode()); + } + + /** + * Test QueryForList with no result. + */ + function testQueryForListWithNoResult() + { + $list = $this->sqlmap->QueryForList("GetNoAccountsViaResultMap"); + + $this->assertEquals(0, count($list)); + } + + /** + * Test QueryForList with ResultClass : Account. + */ + function testQueryForListResultClass() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultClass"); + + $this->assertAccount1($list[0]); + $this->assertEquals(5, count($list)); + $this->assertEquals(1, $list[0]->getID()); + $this->assertEquals(2, $list[1]->getID()); + $this->assertEquals(3, $list[2]->getID()); + $this->assertEquals(4, $list[3]->getID()); + $this->assertEquals(5, $list[4]->getID()); + } + + /** + * Test QueryForList with simple resultClass : string + */ + function testQueryForListWithSimpleResultClass() + { + $list = $this->sqlmap->QueryForList("GetAllEmailAddressesViaResultClass"); + + $this->assertEquals("Joe.Dalton@somewhere.com", $list[0]); + $this->assertEquals("Averel.Dalton@somewhere.com", $list[1]); + $this->assertEquals('', $list[2]); + $this->assertEquals("Jack.Dalton@somewhere.com", $list[3]); + $this->assertEquals('', $list[4]); + } + + /** + * Test QueryForList with simple ResultMap : string + */ + function testQueryForListWithSimpleResultMap() + { + $list = $this->sqlmap->QueryForList("GetAllEmailAddressesViaResultMap"); + + $this->assertEquals("Joe.Dalton@somewhere.com", $list[0]); + $this->assertEquals("Averel.Dalton@somewhere.com", $list[1]); + $this->assertEquals('', $list[2]); + $this->assertEquals("Jack.Dalton@somewhere.com", $list[3]); + $this->assertEquals('', $list[4]); + } + + /** + * Test QueryForListWithSkipAndMax + */ + function testQueryForListWithSkipAndMax() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsViaResultMap", null, null, 2, 2); + + $this->assertEquals(2, count($list)); + $this->assertEquals(3, $list[0]->getID()); + $this->assertEquals(4, $list[1]->getID()); + } + + + /** + * Test row delegate + */ + function testQueryWithRowDelegate() + { + //$handler = new SqlMapper.RowDelegate(this.RowHandler); + + //$list = $this->sqlmap->QueryWithRowDelegate("GetAllAccountsViaResultMap", null, handler); + + //$this->assertEquals(5, _index); + //$this->assertEquals(5, $list->getCount()); + //$this->assertAccount1$list[0]); + //$this->assertEquals(1, $list[0]->getID()); + //$this->assertEquals(2, $list[1]->getID()); + //$this->assertEquals(3, $list[2]->getID()); + //$this->assertEquals(4, $list[3]->getID()); + //$this->assertEquals(5, $list[4]->getID()); + } + + #endregion + + #region Map Tests + + /** + * Test ExecuteQueryForMap : Hashtable. + */ + function testExecuteQueryForMap() + { + $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, "FirstName"); + + $this->assertEquals(5, count($map)); + $this->assertAccount1($map["Joe"]); + + $this->assertEquals(1, $map["Joe"]->getID()); + $this->assertEquals(2, $map["Averel"]->getID()); + $this->assertEquals(3, $map["William"]->getID()); + $this->assertEquals(4, $map["Jack"]->getID()); + $this->assertEquals(5, $map["Gilles"]->getID()); + } + + /** + * Test ExecuteQueryForMap : Hashtable. + * + * If the keyProperty is an integer, you must acces the map + * by map[integer] and not by map["integer"] + */ + function testExecuteQueryForMap2() + { + $map = $this->sqlmap->QueryForMap("GetAllOrderWithLineItems", null, "PostalCode"); + + $this->assertEquals(11, count($map)); + $order = $map["T4H 9G4"]; + + $this->assertEquals(2, $order->getLineItemsList()->getCount()); + } + + /** + * Test ExecuteQueryForMap with value property : + * "FirstName" as key, "EmailAddress" as value + */ + function testExecuteQueryForMapWithValueProperty() + { + $map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, + "FirstName", "EmailAddress"); + + $this->assertEquals(5, count($map)); + + $this->assertEquals("Joe.Dalton@somewhere.com", $map["Joe"]); + $this->assertEquals("Averel.Dalton@somewhere.com", $map["Averel"]); + $this->assertNull($map["William"]); + $this->assertEquals("Jack.Dalton@somewhere.com", $map["Jack"]); + $this->assertNull($map["Gilles"]); + } + + /** + * Test ExecuteQueryForWithJoined + */ + function testExecuteQueryForWithJoined() + { + $order = $this->sqlmap->QueryForObject("GetOrderJoinWithAccount",10); + + $this->assertNotNull($order->getAccount()); + + $order = $this->sqlmap->QueryForObject("GetOrderJoinWithAccount",11); + + $this->assertNull($order->getAccount()); + } + + /** + * Test ExecuteQueryFor With Complex Joined + * + * A->B->C + * ->E + * ->F + */ + function testExecuteQueryForWithComplexJoined() + { + $a = $this->sqlmap->QueryForObject("SelectComplexJoined",null); + $this->assertNotNull($a); + $this->assertNotNull($a->getB()); + $this->assertNotNull($a->getB()->getC()); + $this->assertNull($a->getB()->getD()); + $this->assertNotNull($a->getE()); + $this->assertNull($a->getF()); + } + #endregion + + #region Extends statement + + /** + * Test base Extends statement + */ + function testExtendsGetAllAccounts() + { + $list = $this->sqlmap->QueryForList("GetAllAccounts"); + + $this->assertAccount1($list[0]); + $this->assertEquals(5, count($list)); + $this->assertEquals(1, $list[0]->getID()); + $this->assertEquals(2, $list[1]->getID()); + $this->assertEquals(3, $list[2]->getID()); + $this->assertEquals(4, $list[3]->getID()); + $this->assertEquals(5, $list[4]->getID()); + } + + /** + * Test Extends statement GetAllAccountsOrderByName extends GetAllAccounts + */ + function testExtendsGetAllAccountsOrderByName() + { + $list = $this->sqlmap->QueryForList("GetAllAccountsOrderByName"); + + $this->assertAccount1($list[3]); + $this->assertEquals(5, count($list)); + + $this->assertEquals(2, $list[0]->getID()); + $this->assertEquals(5, $list[1]->getID()); + $this->assertEquals(4, $list[2]->getID()); + $this->assertEquals(1, $list[3]->getID()); + $this->assertEquals(3, $list[4]->getID()); + } + + /** + * Test Extends statement GetOneAccount extends GetAllAccounts + */ + function testExtendsGetOneAccount() + { + $account= $this->sqlmap->QueryForObject("GetOneAccount", 1); + $this->assertAccount1($account); + } + + /** + * Test Extends statement GetSomeAccount extends GetAllAccounts + */ + function testExtendsGetSomeAccount() + { + $param["lowID"] = 2; + $param["hightID"] = 4; + + $list = $this->sqlmap->QueryForList("GetSomeAccount", $param); + + $this->assertEquals(3, count($list)); + + $this->assertEquals(2, $list[0]->getID()); + $this->assertEquals(3, $list[1]->getID()); + $this->assertEquals(4, $list[2]->getID()); + } + + #endregion + + #region Update tests + + + /** + * Test Insert account via public fields + */ + function testInsertAccountViaPublicFields() + { + $this->initScript('account-init.sql'); + + $account = new AccountBis(); + + $account->Id = 10; + $account->FirstName = "Luky"; + $account->LastName = "Luke"; + $account->EmailAddress = "luly.luke@somewhere.com"; + + $this->sqlmap->Insert("InsertAccountViaPublicFields", $account); + + $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 10); + + $this->assertNotNull($testAccount); + + $this->assertEquals(10, $testAccount->getID()); + + $this->initScript('account-init.sql'); + } + + /** + * + */ + function testInsertOrderViaProperties() + { + $this->initScript('account-init.sql'); + $this->initScript('order-init.sql'); + $account= $this->NewAccount6(); + + $this->sqlmap->Insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate('2005-05-20'); + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->Insert("InsertOrderViaPublicFields", $order); + + $this->initScript('account-init.sql'); + $this->initScript('order-init.sql'); + } + + + /** + * Test Insert account via inline parameters + */ + function testInsertAccountViaInlineParameters() + { + $this->initScript('account-init.sql'); + $account= new Account(); + + $account->setId(10); + $account->setFirstName("Luky"); + $account->setLastName("Luke"); + $account->setEmailAddress("luly.luke@somewhere.com"); + + $this->sqlmap->Insert("InsertAccountViaInlineParameters", $account); + + $testAccount = $this->sqlmap->QueryForObject("GetAccountViaColumnIndex", 10); + + $this->assertNotNull($testAccount); + $this->assertEquals(10, $testAccount->getId()); + $this->initScript('account-init.sql'); + } + + /** + * Test Insert account via parameterMap + */ + function testInsertAccountViaParameterMap() + { + $this->initScript('account-init.sql'); + $account= $this->NewAccount6(); + $this->sqlmap->Insert("InsertAccountViaParameterMap", $account); + + $account = $this->sqlmap->QueryForObject("GetAccountNullableEmail", 6); + $this->AssertAccount6($account); + + $this->initScript('account-init.sql'); + } + + /** + * Test Update via parameterMap + */ + function testUpdateViaParameterMap() + { + $this->initScript('account-init.sql'); + $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $account->setEmailAddress("new@somewhere.com"); + $this->sqlmap->Update("UpdateAccountViaParameterMap", $account); + + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $this->assertEquals("new@somewhere.com", $account->getEmailAddress()); + $this->initScript('account-init.sql'); + } + + /** + * Test Update via parameterMap V2 + */ + function testUpdateViaParameterMap2() + { + $this->initScript('account-init.sql'); + $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $account->setEmailAddress("new@somewhere.com"); + $this->sqlmap->Update("UpdateAccountViaParameterMap2", $account); + + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $this->assertEquals("new@somewhere.com", $account->getEmailAddress()); + $this->initScript('account-init.sql'); + } + + /** + * Test Update with inline parameters + */ + function testUpdateWithInlineParameters() + { + $this->initScript('account-init.sql'); + $account= $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $account->setEmailAddress("new@somewhere.com"); + $this->sqlmap->Update("UpdateAccountViaInlineParameters", $account); + + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 1); + + $this->assertEquals("new@somewhere.com", $account->getEmailAddress()); + $this->initScript('account-init.sql'); + } + + /** + * Test Execute Update With Parameter Class + */ + function testExecuteUpdateWithParameterClass() + { + $this->initScript('account-init.sql'); + $account= $this->NewAccount6(); + + $this->sqlmap->Insert("InsertAccountViaParameterMap", $account); + + $noRowsDeleted = $this->sqlmap->Update("DeleteAccount", null); + + $this->sqlmap->Update("DeleteAccount", $account); + + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6); + + $this->assertNull($account); + $this->assertEquals(0, $noRowsDeleted); + $this->initScript('account-init.sql'); + } + + /** + * Test Execute Delete + */ + function testExecuteDelete() + { + $this->initScript('account-init.sql'); + $account= $this->NewAccount6(); + + $this->sqlmap->Insert("InsertAccountViaParameterMap", $account); + + $account = null; + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6); + + $this->assertTrue($account->getId() == 6); + + $rowNumber = $this->sqlmap->Delete("DeleteAccount", $account); + $this->assertTrue($rowNumber == 1); + + $account = $this->sqlmap->QueryForObject("GetAccountViaColumnName", 6); + + $this->assertNull($account); + $this->initScript('account-init.sql'); + } + + /** + * Test Execute Delete + */ + function testDeleteWithComments() + { + $this->initScript('line-item-init.sql'); + $rowNumber = $this->sqlmap->Delete("DeleteWithComments"); + + $this->assertEquals($rowNumber, 2); + $this->initScript('line-item-init.sql'); + } + + + + #endregion + + #region Row delegate + + private $_index = 0; + + function RowHandler($sender, $paramterObject, $list) + { + //_index++; + //$this->assertEquals(_index, (($account) obj).Id); + //$list->Add(obj); + } + + #endregion + + #region JIRA Tests + + /** + * Test JIRA 30 (repeating property) + */ + function testJIRA30() + { + $account= new Account(); + $account->setId(1); + $account->setFirstName("Joe"); + $account->setLastName("Dalton"); + $account->setEmailAddress("Joe.Dalton@somewhere.com"); + + $result = $this->sqlmap->QueryForObject("GetAccountWithRepeatingProperty", $account); + + $this->assertAccount1($result); + } + + /** + * Test Bit column + */ + function testJIRA42() + { + $other = new Other(); + + $other->setInt(100); + $other->setBool(true); + $other->setLong(789456321); + + $this->sqlmap->Insert("InsertBool", $other); + } + + /** + * Test for access a result map in a different namespace + */ + function testJIRA45() + { + $account= $this->sqlmap->QueryForObject("GetAccountJIRA45", 1); + $this->assertAccount1($account); + } + + /** + * Test : Whitespace is not maintained properly when CDATA tags are used + */ + function testJIRA110() + { + $account= $this->sqlmap->QueryForObject("Get1Account"); + $this->assertAccount1($account); + } + + /** + * Test : Whitespace is not maintained properly when CDATA tags are used + */ + function testJIRA110Bis() + { + $list = $this->sqlmap->QueryForList("GetAccounts"); + + $this->assertAccount1($list[0]); + $this->assertEquals(5, count($list)); + } + + /** + * Test for cache stats only being calculated on CachingStatments + */ + function testJIRA113() + { + // $this->sqlmap->FlushCaches(); + + // taken from TestFlushDataCache() + // first query is not cached, second query is: 50% cache hit + /*$list = $this->sqlmap->QueryForList("GetCachedAccountsViaResultMap"); + $firstId = HashCodeProvider.GetIdentityHashCode(list); + list = $this->sqlmap->QueryForList("GetCachedAccountsViaResultMap"); + int secondId = HashCodeProvider.GetIdentityHashCode(list); + $this->assertEquals(firstId, secondId); + + string cacheStats = $this->sqlmap->GetDataCacheStats(); + + $this->assertNotNull(cacheStats);*/ + } + + #endregion + + #region CustomTypeHandler tests + + /** + * Test CustomTypeHandler + */ + function testExecuteQueryWithCustomTypeHandler() + { + $this->sqlmap->getTypeHandlerFactory()->register('HundredsBool', new HundredsBool()); + $this->sqlmap->getTypeHandlerFactory()->register('OuiNonBool', new OuiNonBool()); + + $list = $this->sqlmap->QueryForList("GetAllAccountsViaCustomTypeHandler"); + + $this->assertAccount1($list[0]); + $this->assertEquals(5, count($list)); + $this->assertEquals(1, $list[0]->getID()); + $this->assertEquals(2, $list[1]->getID()); + $this->assertEquals(3, $list[2]->getID()); + $this->assertEquals(4, $list[3]->getID()); + $this->assertEquals(5, $list[4]->getID()); + + $this->assertFalse($list[0]->getCartOptions()); + $this->assertFalse($list[1]->getCartOptions()); + $this->assertTrue($list[2]->getCartOptions()); + $this->assertTrue($list[3]->getCartOptions()); + $this->assertTrue($list[4]->getCartOptions()); + + $this->assertTrue($list[0]->getBannerOptions()); + $this->assertTrue($list[1]->getBannerOptions()); + $this->assertFalse($list[2]->getBannerOptions()); + $this->assertFalse($list[3]->getBannerOptions()); + $this->assertTrue($list[4]->getBannerOptions()); + } + + /** + * Test CustomTypeHandler Oui/Non + */ + function testCustomTypeHandler() + { + $this->initScript('other-init.sql'); + $this->initScript('account-init.sql'); + + $this->sqlmap->getTypeHandlerFactory()->register('OuiNonBool', new OuiNonBool()); + + $other = new Other(); + $other->setInt(99); + $other->setLong(1966); + $other->setBool(true); + $other->setBool2(false); + $this->sqlmap->Insert("InsertCustomTypeHandler", $other); + + $anOther = $this->sqlmap->QueryForObject("SelectByInt", 99); + $this->assertNotNull( $anOther ); + $this->assertEquals(99, (int)$anOther->getInt()); + $this->assertEquals(1966, (int)$anOther->getLong()); + $this->assertEquals(true, (boolean)$anOther->getBool()); + $this->assertEquals(false, (boolean)$anOther->getBool2()); + + } + + /** + * Test CustomTypeHandler Oui/Non + */ + function testInsertInlineCustomTypeHandlerV1() + { + $this->initScript('other-init.sql'); + $this->initScript('account-init.sql'); + + $other = new Other(); + $other->setInt(99); + $other->setLong(1966); + $other->setBool(true); + $other->setBool2(false); + + $this->sqlmap->Insert("InsertInlineCustomTypeHandlerV1", $other); + + $anOther = $this->sqlmap->QueryForObject("SelectByIntV1", 99); + + $this->assertNotNull( $anOther ); + $this->assertEquals(99, (int)$anOther->getInt()); + $this->assertEquals(1966, (int)$anOther->getLong()); + $this->assertEquals(true, (boolean)$anOther->getBool()); + $this->assertEquals(false, (boolean)$anOther->getBool2()); + + } + + /** + * Test CustomTypeHandler Oui/Non + */ + function testInsertInlineCustomTypeHandlerV2() + { + $this->initScript('other-init.sql'); + $this->initScript('account-init.sql'); + + $other = new Other(); + $other->setInt(99); + $other->setLong(1966); + $other->setBool(true); + $other->setBool2(false); + + $this->sqlmap->Insert("InsertInlineCustomTypeHandlerV2", $other); + + $anOther = $this->sqlmap->QueryForObject("SelectByInt", 99); + + $this->assertNotNull( $anOther ); + $this->assertEquals(99, (int)$anOther->getInt()); + $this->assertEquals(1966, (int)$anOther->getLong()); + $this->assertEquals(true, (boolean)$anOther->getBool()); + $this->assertEquals(false, (boolean)$anOther->getBool2()); + } + #endregion + /**/ +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/TAdodbConnectionTestCase.php b/tests/unit/SQLMap/TAdodbConnectionTestCase.php index 1ba0ec04..7d566386 100644 --- a/tests/unit/SQLMap/TAdodbConnectionTestCase.php +++ b/tests/unit/SQLMap/TAdodbConnectionTestCase.php @@ -1,64 +1,64 @@ -<?php
-
-require_once dirname(__FILE__).'/../phpunit2.php';
-
-require_once(dirname(__FILE__).'/common.php');
-
-/**
- * @package System.DataAccess
- */
-class TAdodbConnectionTestCase extends PHPUnit2_Framework_TestCase
-{
- protected $db_file;
-
- function setup()
- {
- $file = dirname(__FILE__).'/resources/data.db';
- $this->db_file = dirname(__FILE__).'/resources/test.db';
- copy($file,$this->db_file);
- $provider = new TAdodb();
- }
-
- function getDsn()
- {
- return 'sqlite://'.urlencode(realpath($this->db_file));
- }
-
- function testProviderCreation()
- {
- $provider = new TAdodb();
- $connection = $provider->getConnection();
- $this->assertTrue($connection instanceof TAdodbConnection);
- try
- {
- $connection->open();
- $this->fail();
- }
- catch (TDbConnectionException $e)
- {
- $this->pass();
- }
- }
-
-
-
- function testAdodbSqliteConnection()
- {
- $connection = new TAdodbConnection($this->getDsn());
- $this->assertTrue($connection->open());
-
- $statement = "insert into person(per_id, per_first_name,
- per_last_name, per_birth_date, per_weight_kg, per_height_m)
- values(?, ?, ?, ?, ?, ?)";
- $sql = $connection->prepare($statement);
- $connection->execute($sql,
- array(2,'mini','me','2000-01-01', 50.5, 145.5));
-
- $statement = "select * from person";
- $results = $connection->execute($statement);
- $this->assertEquals($results->RecordCount(), 2);
-
- }
-}
-
+<?php + +require_once dirname(__FILE__).'/../phpunit2.php'; + +require_once(dirname(__FILE__).'/common.php'); + +/** + * @package System.DataAccess + */ +class TAdodbConnectionTestCase extends PHPUnit2_Framework_TestCase +{ + protected $db_file; + + function setup() + { + $file = dirname(__FILE__).'/resources/data.db'; + $this->db_file = dirname(__FILE__).'/resources/test.db'; + copy($file,$this->db_file); + $provider = new TAdodb(); + } + + function getDsn() + { + return 'sqlite://'.urlencode(realpath($this->db_file)); + } + + function testProviderCreation() + { + $provider = new TAdodb(); + $connection = $provider->getConnection(); + $this->assertTrue($connection instanceof TAdodbConnection); + try + { + $connection->open(); + $this->fail(); + } + catch (TDbConnectionException $e) + { + $this->pass(); + } + } + + + + function testAdodbSqliteConnection() + { + $connection = new TAdodbConnection($this->getDsn()); + $this->assertTrue($connection->open()); + + $statement = "insert into person(per_id, per_first_name, + per_last_name, per_birth_date, per_weight_kg, per_height_m) + values(?, ?, ?, ?, ?, ?)"; + $sql = $connection->prepare($statement); + $connection->execute($sql, + array(2,'mini','me','2000-01-01', 50.5, 145.5)); + + $statement = "select * from person"; + $results = $connection->execute($statement); + $this->assertEquals($results->RecordCount(), 2); + + } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/common.php b/tests/unit/SQLMap/common.php index 97f83267..f13fe829 100644 --- a/tests/unit/SQLMap/common.php +++ b/tests/unit/SQLMap/common.php @@ -1,152 +1,152 @@ -<?php
-
-
-if(!defined('SQLMAP_DIR'))
- define('SQLMAP_DIR', Prado::getFrameworkPath().'/DataAccess/SQLMap/');
-
-require_once(SQLMAP_DIR.'/TMapper.php');
-
-if(!defined('SQLMAP_TESTS'))
- define('SQLMAP_TESTS', realpath(dirname(__FILE__)));
-
-if(!class_exists('Account', false))
-{
- include(SQLMAP_TESTS.'/domain/A.php');
- include(SQLMAP_TESTS.'/domain/Account.php');
- include(SQLMAP_TESTS.'/domain/AccountBis.php');
- include(SQLMAP_TESTS.'/domain/AccountCollection.php');
- include(SQLMAP_TESTS.'/domain/B.php');
- include(SQLMAP_TESTS.'/domain/Document.php');
- include(SQLMAP_TESTS.'/domain/Book.php');
- include(SQLMAP_TESTS.'/domain/C.php');
- include(SQLMAP_TESTS.'/domain/Category.php');
- include(SQLMAP_TESTS.'/domain/Complex.php');
- include(SQLMAP_TESTS.'/domain/D.php');
- include(SQLMAP_TESTS.'/domain/DocumentCollection.php');
- include(SQLMAP_TESTS.'/domain/E.php');
- include(SQLMAP_TESTS.'/domain/F.php');
- include(SQLMAP_TESTS.'/domain/LineItem.php');
- include(SQLMAP_TESTS.'/domain/LineItemCollection.php');
- include(SQLMAP_TESTS.'/domain/Newspaper.php');
- include(SQLMAP_TESTS.'/domain/Order.php');
- include(SQLMAP_TESTS.'/domain/Other.php');
- include(SQLMAP_TESTS.'/domain/Sample.php');
- include(SQLMAP_TESTS.'/domain/Search.php');
- include(SQLMAP_TESTS.'/domain/User.php');
-}
-
-error_reporting(E_ALL);
-restore_error_handler();
-
-class DefaultScriptRunner
-{
- function runScript($connection, $script)
- {
- $sql = file_get_contents($script);
- $lines = explode(';', $sql);
- foreach($lines as $line)
- {
- $line = trim($line);
- if(strlen($line) > 0)
- $connection->execute($line);
- }
- }
-}
-
-class CopyFileScriptRunner
-{
- protected $baseFile;
- protected $targetFile;
-
- public function __construct($base, $target)
- {
- $this->baseFile = $base;
- $this->targetFile = $target;
- }
-
- function runScript($connection, $script)
- {
- copy($this->baseFile, $this->targetFile);
- }
-}
-
-class SQLiteBaseTestConfig extends BaseTestConfig
-{
- protected $baseFile;
- protected $targetFile;
-
- public function __construct()
- {
- $this->_sqlmap = SQLMAP_TESTS.'/sqlite.xml';
- $this->targetFile = realpath(SQLMAP_TESTS.'/sqlite/tests.db');
- $this->baseFile = realpath(SQLMAP_TESTS.'/sqlite/backup.db');
- $file = urlencode($this->targetFile);
- $this->_connectionString = "sqlite://{$file}/";
- $this->_scriptDir = SQLMAP_TESTS.'/scripts/sqlite/';
- }
-
- public function getScriptRunner()
- {
- return new CopyFileScriptRunner($this->baseFile, $this->targetFile);
- }
-}
-
-class MySQLBaseTestConfig extends BaseTestConfig
-{
- public function __construct()
- {
- $this->_sqlmap = SQLMAP_TESTS.'/mysql.xml';
- $this->_connectionString = 'mysql://root:weizhuo01@localhost/IBatisNet';
- $this->_scriptDir = SQLMAP_TESTS.'/scripts/mysql/';
- $this->_features = array('insert_id');
- }
-}
-
-class MSSQLBaseTestConfig extends BaseTestConfig
-{
- public function __construct()
- {
- $this->_sqlmap = SQLMAP_TESTS.'/mssql.xml';
- $this->_connectionString = 'odbc_mssql://sqlmap_tests';
- $this->_scriptDir = SQLMAP_TESTS.'/scripts/mssql/';
- $this->_features = array('insert_id');
- }
-}
-
-class BaseTestConfig
-{
- protected $_scriptDir;
- protected $_connectionString;
- protected $_sqlmap;
- protected $_features = array();
-
- public function getScriptDir() { return $this->_scriptDir; }
- public function getConnectionString() { return $this->_connectionString; }
- public function getSqlMapConfigFile(){ return $this->_sqlmap; }
-
- public function hasFeature($feature)
- {
- return in_array($feature, $this->_features);
- }
-
- public function getScriptRunner()
- {
- return new DefaultScriptRunner();
- }
-
-
- public static function createConfigInstance()
- {
- //change this to connection to a different database
-
- //return new MySQLBaseTestConfig();
-
- return new SQLiteBaseTestConfig();
-
- //return new MSSQLBaseTestConfig();
- }
-
-}
-
-
+<?php + + +if(!defined('SQLMAP_DIR')) + define('SQLMAP_DIR', Prado::getFrameworkPath().'/DataAccess/SQLMap/'); + +require_once(SQLMAP_DIR.'/TMapper.php'); + +if(!defined('SQLMAP_TESTS')) + define('SQLMAP_TESTS', realpath(dirname(__FILE__))); + +if(!class_exists('Account', false)) +{ + include(SQLMAP_TESTS.'/domain/A.php'); + include(SQLMAP_TESTS.'/domain/Account.php'); + include(SQLMAP_TESTS.'/domain/AccountBis.php'); + include(SQLMAP_TESTS.'/domain/AccountCollection.php'); + include(SQLMAP_TESTS.'/domain/B.php'); + include(SQLMAP_TESTS.'/domain/Document.php'); + include(SQLMAP_TESTS.'/domain/Book.php'); + include(SQLMAP_TESTS.'/domain/C.php'); + include(SQLMAP_TESTS.'/domain/Category.php'); + include(SQLMAP_TESTS.'/domain/Complex.php'); + include(SQLMAP_TESTS.'/domain/D.php'); + include(SQLMAP_TESTS.'/domain/DocumentCollection.php'); + include(SQLMAP_TESTS.'/domain/E.php'); + include(SQLMAP_TESTS.'/domain/F.php'); + include(SQLMAP_TESTS.'/domain/LineItem.php'); + include(SQLMAP_TESTS.'/domain/LineItemCollection.php'); + include(SQLMAP_TESTS.'/domain/Newspaper.php'); + include(SQLMAP_TESTS.'/domain/Order.php'); + include(SQLMAP_TESTS.'/domain/Other.php'); + include(SQLMAP_TESTS.'/domain/Sample.php'); + include(SQLMAP_TESTS.'/domain/Search.php'); + include(SQLMAP_TESTS.'/domain/User.php'); +} + +error_reporting(E_ALL); +restore_error_handler(); + +class DefaultScriptRunner +{ + function runScript($connection, $script) + { + $sql = file_get_contents($script); + $lines = explode(';', $sql); + foreach($lines as $line) + { + $line = trim($line); + if(strlen($line) > 0) + $connection->execute($line); + } + } +} + +class CopyFileScriptRunner +{ + protected $baseFile; + protected $targetFile; + + public function __construct($base, $target) + { + $this->baseFile = $base; + $this->targetFile = $target; + } + + function runScript($connection, $script) + { + copy($this->baseFile, $this->targetFile); + } +} + +class SQLiteBaseTestConfig extends BaseTestConfig +{ + protected $baseFile; + protected $targetFile; + + public function __construct() + { + $this->_sqlmap = SQLMAP_TESTS.'/sqlite.xml'; + $this->targetFile = realpath(SQLMAP_TESTS.'/sqlite/tests.db'); + $this->baseFile = realpath(SQLMAP_TESTS.'/sqlite/backup.db'); + $file = urlencode($this->targetFile); + $this->_connectionString = "sqlite://{$file}/"; + $this->_scriptDir = SQLMAP_TESTS.'/scripts/sqlite/'; + } + + public function getScriptRunner() + { + return new CopyFileScriptRunner($this->baseFile, $this->targetFile); + } +} + +class MySQLBaseTestConfig extends BaseTestConfig +{ + public function __construct() + { + $this->_sqlmap = SQLMAP_TESTS.'/mysql.xml'; + $this->_connectionString = 'mysql://root:weizhuo01@localhost/IBatisNet'; + $this->_scriptDir = SQLMAP_TESTS.'/scripts/mysql/'; + $this->_features = array('insert_id'); + } +} + +class MSSQLBaseTestConfig extends BaseTestConfig +{ + public function __construct() + { + $this->_sqlmap = SQLMAP_TESTS.'/mssql.xml'; + $this->_connectionString = 'odbc_mssql://sqlmap_tests'; + $this->_scriptDir = SQLMAP_TESTS.'/scripts/mssql/'; + $this->_features = array('insert_id'); + } +} + +class BaseTestConfig +{ + protected $_scriptDir; + protected $_connectionString; + protected $_sqlmap; + protected $_features = array(); + + public function getScriptDir() { return $this->_scriptDir; } + public function getConnectionString() { return $this->_connectionString; } + public function getSqlMapConfigFile(){ return $this->_sqlmap; } + + public function hasFeature($feature) + { + return in_array($feature, $this->_features); + } + + public function getScriptRunner() + { + return new DefaultScriptRunner(); + } + + + public static function createConfigInstance() + { + //change this to connection to a different database + + //return new MySQLBaseTestConfig(); + + return new SQLiteBaseTestConfig(); + + //return new MSSQLBaseTestConfig(); + } + +} + + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/A.php b/tests/unit/SQLMap/domain/A.php index 6830ea4d..af1f925d 100644 --- a/tests/unit/SQLMap/domain/A.php +++ b/tests/unit/SQLMap/domain/A.php @@ -1,27 +1,27 @@ -<?php
-
-class A
-{
- private $_ID='';
- private $_Libelle='';
- private $_B='';
- private $_E='';
- private $_F='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-
- public function getB(){ return $this->_B; }
- public function setB($value){ $this->_B = $value; }
-
- public function getE(){ return $this->_E; }
- public function setE($value){ $this->_E = $value; }
-
- public function getF(){ return $this->_F; }
- public function setF($value){ $this->_F = $value; }
-}
-
+<?php + +class A +{ + private $_ID=''; + private $_Libelle=''; + private $_B=''; + private $_E=''; + private $_F=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } + + public function getB(){ return $this->_B; } + public function setB($value){ $this->_B = $value; } + + public function getE(){ return $this->_E; } + public function setE($value){ $this->_E = $value; } + + public function getF(){ return $this->_F; } + public function setF($value){ $this->_F = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/Account.php b/tests/unit/SQLMap/domain/Account.php index f01726ba..9502eb85 100644 --- a/tests/unit/SQLMap/domain/Account.php +++ b/tests/unit/SQLMap/domain/Account.php @@ -1,36 +1,36 @@ -<?php
-
-class Account
-{
- private $_ID=0;
- private $_FirstName='';
- private $_LastName='';
- private $_EmailAddress=null;
- private $_IDS='';
- private $_BannerOptions=0;
- private $_CartOptions=0;
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = intval($value); }
-
- public function getFirstName(){ return $this->_FirstName; }
- public function setFirstName($value){ $this->_FirstName = $value; }
-
- public function getLastName(){ return $this->_LastName; }
- public function setLastName($value){ $this->_LastName = $value; }
-
- public function getEmailAddress(){ return $this->_EmailAddress; }
- public function setEmailAddress($value){ $this->_EmailAddress = $value; }
-
- public function getIDS(){ return $this->_IDS; }
- public function setIDS($value){ $this->_IDS = $value; }
-
- public function getBannerOptions(){ return $this->_BannerOptions; }
- public function setBannerOptions($value){ $this->_BannerOptions = $value; }
-
- public function getCartOptions(){ return $this->_CartOptions; }
- public function setCartOptions($value){ $this->_CartOptions = $value; }
-
-}
-
+<?php + +class Account +{ + private $_ID=0; + private $_FirstName=''; + private $_LastName=''; + private $_EmailAddress=null; + private $_IDS=''; + private $_BannerOptions=0; + private $_CartOptions=0; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = intval($value); } + + public function getFirstName(){ return $this->_FirstName; } + public function setFirstName($value){ $this->_FirstName = $value; } + + public function getLastName(){ return $this->_LastName; } + public function setLastName($value){ $this->_LastName = $value; } + + public function getEmailAddress(){ return $this->_EmailAddress; } + public function setEmailAddress($value){ $this->_EmailAddress = $value; } + + public function getIDS(){ return $this->_IDS; } + public function setIDS($value){ $this->_IDS = $value; } + + public function getBannerOptions(){ return $this->_BannerOptions; } + public function setBannerOptions($value){ $this->_BannerOptions = $value; } + + public function getCartOptions(){ return $this->_CartOptions; } + public function setCartOptions($value){ $this->_CartOptions = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/AccountBis.php b/tests/unit/SQLMap/domain/AccountBis.php index 8c96d8e4..d454f2a8 100644 --- a/tests/unit/SQLMap/domain/AccountBis.php +++ b/tests/unit/SQLMap/domain/AccountBis.php @@ -1,13 +1,13 @@ -<?php
-
-class AccountBis
-{
- public $Id;
- public $FirstName;
- public $LastName;
- public $EmailAddress;
- public $More;
-}
-
-
+<?php + +class AccountBis +{ + public $Id; + public $FirstName; + public $LastName; + public $EmailAddress; + public $More; +} + + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/AccountCollection.php b/tests/unit/SQLMap/domain/AccountCollection.php index 9fc8edb7..b14ece5e 100644 --- a/tests/unit/SQLMap/domain/AccountCollection.php +++ b/tests/unit/SQLMap/domain/AccountCollection.php @@ -1,17 +1,17 @@ -<?php
-
-class AccountCollection extends TList
-{
- public function addRange($accounts)
- {
- foreach($accounts as $account)
- $this->add($account);
- }
-
- public function copyTo(TList $array)
- {
- $array->copyFrom($this);
- }
-}
-
+<?php + +class AccountCollection extends TList +{ + public function addRange($accounts) + { + foreach($accounts as $account) + $this->add($account); + } + + public function copyTo(TList $array) + { + $array->copyFrom($this); + } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/B.php b/tests/unit/SQLMap/domain/B.php index a05e21d4..788b804e 100644 --- a/tests/unit/SQLMap/domain/B.php +++ b/tests/unit/SQLMap/domain/B.php @@ -1,23 +1,23 @@ -<?php
-
-class B
-{
- private $_C='';
- private $_D='';
- private $_ID='';
- private $_Libelle='';
-
- public function getC(){ return $this->_C; }
- public function setC($value){ $this->_C = $value; }
-
- public function getD(){ return $this->_D; }
- public function setD($value){ $this->_D = $value; }
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-}
-
+<?php + +class B +{ + private $_C=''; + private $_D=''; + private $_ID=''; + private $_Libelle=''; + + public function getC(){ return $this->_C; } + public function setC($value){ $this->_C = $value; } + + public function getD(){ return $this->_D; } + public function setD($value){ $this->_D = $value; } + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/Book.php b/tests/unit/SQLMap/domain/Book.php index cc12c30e..80877112 100644 --- a/tests/unit/SQLMap/domain/Book.php +++ b/tests/unit/SQLMap/domain/Book.php @@ -1,11 +1,11 @@ -<?php
-
-class Book extends Document
-{
- private $_PageNumber='';
-
- public function getPageNumber(){ return $this->_PageNumber; }
- public function setPageNumber($value){ $this->_PageNumber = $value; }
-}
-
+<?php + +class Book extends Document +{ + private $_PageNumber=''; + + public function getPageNumber(){ return $this->_PageNumber; } + public function setPageNumber($value){ $this->_PageNumber = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/C.php b/tests/unit/SQLMap/domain/C.php index 09fb456a..47118d44 100644 --- a/tests/unit/SQLMap/domain/C.php +++ b/tests/unit/SQLMap/domain/C.php @@ -1,15 +1,15 @@ -<?php
-
-class C
-{
- private $_ID='';
- private $_Libelle='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-}
-
+<?php + +class C +{ + private $_ID=''; + private $_Libelle=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/Category.php b/tests/unit/SQLMap/domain/Category.php index 83fecc7e..db76edb4 100644 --- a/tests/unit/SQLMap/domain/Category.php +++ b/tests/unit/SQLMap/domain/Category.php @@ -1,19 +1,19 @@ -<?php
-
-class Category
-{
- private $_ID=-1;
- private $_Name='';
- private $_Guid='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getName(){ return $this->_Name; }
- public function setName($value){ $this->_Name = $value; }
-
- public function getGuidString(){ return $this->_Guid; }
- public function setGuidString($value){ $this->_Guid = $value; }
-}
-
+<?php + +class Category +{ + private $_ID=-1; + private $_Name=''; + private $_Guid=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getName(){ return $this->_Name; } + public function setName($value){ $this->_Name = $value; } + + public function getGuidString(){ return $this->_Guid; } + public function setGuidString($value){ $this->_Guid = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/Complex.php b/tests/unit/SQLMap/domain/Complex.php index 92b500f4..99cb04b8 100644 --- a/tests/unit/SQLMap/domain/Complex.php +++ b/tests/unit/SQLMap/domain/Complex.php @@ -1,11 +1,11 @@ -<?php
-
-class Complex
-{
- private $_map;
-
- public function getMap(){ return $this->_map; }
- public function setMap(TMap $map){ $this->_map = $map; }
-}
-
+<?php + +class Complex +{ + private $_map; + + public function getMap(){ return $this->_map; } + public function setMap(TMap $map){ $this->_map = $map; } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/D.php b/tests/unit/SQLMap/domain/D.php index 5d1baabd..2cbd2883 100644 --- a/tests/unit/SQLMap/domain/D.php +++ b/tests/unit/SQLMap/domain/D.php @@ -1,16 +1,16 @@ -<?php
-
-class D
-{
- private $_ID='';
- private $_Libelle='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-
-}
-
+<?php + +class D +{ + private $_ID=''; + private $_Libelle=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/Document.php b/tests/unit/SQLMap/domain/Document.php index 63bcfd33..682f8eb3 100644 --- a/tests/unit/SQLMap/domain/Document.php +++ b/tests/unit/SQLMap/domain/Document.php @@ -1,16 +1,16 @@ -<?php
-
-class Document
-{
- private $_ID='';
- private $_Title='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getTitle(){ return $this->_Title; }
- public function setTitle($value){ $this->_Title = $value; }
-
-}
-
+<?php + +class Document +{ + private $_ID=''; + private $_Title=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getTitle(){ return $this->_Title; } + public function setTitle($value){ $this->_Title = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/DocumentCollection.php b/tests/unit/SQLMap/domain/DocumentCollection.php index c15b6f7d..c130db56 100644 --- a/tests/unit/SQLMap/domain/DocumentCollection.php +++ b/tests/unit/SQLMap/domain/DocumentCollection.php @@ -1,8 +1,8 @@ -<?php
-
-class DocumentCollection extends TList
-{
-
-}
-
+<?php + +class DocumentCollection extends TList +{ + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/E.php b/tests/unit/SQLMap/domain/E.php index 2c80bb46..8473c156 100644 --- a/tests/unit/SQLMap/domain/E.php +++ b/tests/unit/SQLMap/domain/E.php @@ -1,16 +1,16 @@ -<?php
-
-class E
-{
- private $_ID='';
- private $_Libelle='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-
-}
-
+<?php + +class E +{ + private $_ID=''; + private $_Libelle=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/F.php b/tests/unit/SQLMap/domain/F.php index b1090cc6..2bbbb2fb 100644 --- a/tests/unit/SQLMap/domain/F.php +++ b/tests/unit/SQLMap/domain/F.php @@ -1,16 +1,16 @@ -<?php
-
-class F
-{
- private $_ID='';
- private $_Libelle='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getLibelle(){ return $this->_Libelle; }
- public function setLibelle($value){ $this->_Libelle = $value; }
-
-}
-
+<?php + +class F +{ + private $_ID=''; + private $_Libelle=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getLibelle(){ return $this->_Libelle; } + public function setLibelle($value){ $this->_Libelle = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/LineItem.php b/tests/unit/SQLMap/domain/LineItem.php index d851da6c..f6908bbd 100644 --- a/tests/unit/SQLMap/domain/LineItem.php +++ b/tests/unit/SQLMap/domain/LineItem.php @@ -1,32 +1,32 @@ -<?php
-
-class LineItem
-{
- private $_ID=-1;
- private $_Order='';
- private $_Code='';
- private $_Quantity=-1;
- private $_Price=0.0;
- private $_PictureData='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getOrder(){ return $this->_Order; }
- public function setOrder($value){ $this->_Order = $value; }
-
- public function getCode(){ return $this->_Code; }
- public function setCode($value){ $this->_Code = $value; }
-
- public function getQuantity(){ return $this->_Quantity; }
- public function setQuantity($value){ $this->_Quantity = $value; }
-
- public function getPrice(){ return $this->_Price; }
- public function setPrice($value){ $this->_Price = $value; }
-
- public function getPictureData(){ return $this->_PictureData; }
- public function setPictureData($value){ $this->_PictureData = $value; }
-
-}
-
+<?php + +class LineItem +{ + private $_ID=-1; + private $_Order=''; + private $_Code=''; + private $_Quantity=-1; + private $_Price=0.0; + private $_PictureData=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getOrder(){ return $this->_Order; } + public function setOrder($value){ $this->_Order = $value; } + + public function getCode(){ return $this->_Code; } + public function setCode($value){ $this->_Code = $value; } + + public function getQuantity(){ return $this->_Quantity; } + public function setQuantity($value){ $this->_Quantity = $value; } + + public function getPrice(){ return $this->_Price; } + public function setPrice($value){ $this->_Price = $value; } + + public function getPictureData(){ return $this->_PictureData; } + public function setPictureData($value){ $this->_PictureData = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/LineItemCollection.php b/tests/unit/SQLMap/domain/LineItemCollection.php index f177487c..8bc95622 100644 --- a/tests/unit/SQLMap/domain/LineItemCollection.php +++ b/tests/unit/SQLMap/domain/LineItemCollection.php @@ -1,8 +1,8 @@ -<?php
-
-class LineItemCollection extends TList
-{
-
-}
-
+<?php + +class LineItemCollection extends TList +{ + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/Newspaper.php b/tests/unit/SQLMap/domain/Newspaper.php index 4eb56aa2..08716c6d 100644 --- a/tests/unit/SQLMap/domain/Newspaper.php +++ b/tests/unit/SQLMap/domain/Newspaper.php @@ -1,12 +1,12 @@ -<?php
-
-class Newspaper extends Document
-{
- private $_City='';
-
- public function getCity(){ return $this->_City; }
- public function setCity($value){ $this->_City = $value; }
-
-}
-
+<?php + +class Newspaper extends Document +{ + private $_City=''; + + public function getCity(){ return $this->_City; } + public function setCity($value){ $this->_City = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/Order.php b/tests/unit/SQLMap/domain/Order.php index 65d18b13..312626fe 100644 --- a/tests/unit/SQLMap/domain/Order.php +++ b/tests/unit/SQLMap/domain/Order.php @@ -1,71 +1,71 @@ -<?php
-
-class Order
-{
- private $_ID=-1;
- private $_Account='';
- private $_Date='';
- private $_CardType='';
- private $_CardExpiry='';
- private $_CardNumber='';
- private $_Street='';
- private $_City='';
- private $_Province='';
- private $_PostalCode='';
- private $_LineItemsList='';
- private $_LineItems=null;
- private $_LineItemsArray=array();
- private $_FavouriteLineItem=null;
-
- public function __construct()
- {
- $this->_LineItemsList = new TList;
- $this->_LineItems = new TList;
- $this->_FavouriteLineItem = new LineItem;
- }
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getAccount(){ return $this->_Account; }
- public function setAccount($value){ $this->_Account = $value; }
-
- public function getDate(){ return $this->_Date; }
- public function setDate($value){ $this->_Date = $value; }
-
- public function getCardType(){ return $this->_CardType; }
- public function setCardType($value){ $this->_CardType = $value; }
-
- public function getCardExpiry(){ return $this->_CardExpiry; }
- public function setCardExpiry($value){ $this->_CardExpiry = $value; }
-
- public function getCardNumber(){ return $this->_CardNumber; }
- public function setCardNumber($value){ $this->_CardNumber = $value; }
-
- public function getStreet(){ return $this->_Street; }
- public function setStreet($value){ $this->_Street = $value; }
-
- public function getCity(){ return $this->_City; }
- public function setCity($value){ $this->_City = $value; }
-
- public function getProvince(){ return $this->_Province; }
- public function setProvince($value){ $this->_Province = $value; }
-
- public function getPostalCode(){ return $this->_PostalCode; }
- public function setPostalCode($value){ $this->_PostalCode = $value; }
-
- public function getLineItemsList(){ return $this->_LineItemsList; }
- public function setLineItemsList($value){ $this->_LineItemsList = $value; }
-
- public function getLineItems(){ return $this->_LineItems; }
- public function setLineItems($value){ $this->_LineItems = $value; }
-
- public function getLineItemsArray(){ return $this->_LineItemsArray; }
- public function setLineItemsArray($value){ $this->_LineItemsArray = $value; }
-
- public function getFavouriteLineItem(){ return $this->_FavouriteLineItem; }
- public function setFavouriteLineItem($value){ $this->_FavouriteLineItem = $value; }
-
-}
-
+<?php + +class Order +{ + private $_ID=-1; + private $_Account=''; + private $_Date=''; + private $_CardType=''; + private $_CardExpiry=''; + private $_CardNumber=''; + private $_Street=''; + private $_City=''; + private $_Province=''; + private $_PostalCode=''; + private $_LineItemsList=''; + private $_LineItems=null; + private $_LineItemsArray=array(); + private $_FavouriteLineItem=null; + + public function __construct() + { + $this->_LineItemsList = new TList; + $this->_LineItems = new TList; + $this->_FavouriteLineItem = new LineItem; + } + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getAccount(){ return $this->_Account; } + public function setAccount($value){ $this->_Account = $value; } + + public function getDate(){ return $this->_Date; } + public function setDate($value){ $this->_Date = $value; } + + public function getCardType(){ return $this->_CardType; } + public function setCardType($value){ $this->_CardType = $value; } + + public function getCardExpiry(){ return $this->_CardExpiry; } + public function setCardExpiry($value){ $this->_CardExpiry = $value; } + + public function getCardNumber(){ return $this->_CardNumber; } + public function setCardNumber($value){ $this->_CardNumber = $value; } + + public function getStreet(){ return $this->_Street; } + public function setStreet($value){ $this->_Street = $value; } + + public function getCity(){ return $this->_City; } + public function setCity($value){ $this->_City = $value; } + + public function getProvince(){ return $this->_Province; } + public function setProvince($value){ $this->_Province = $value; } + + public function getPostalCode(){ return $this->_PostalCode; } + public function setPostalCode($value){ $this->_PostalCode = $value; } + + public function getLineItemsList(){ return $this->_LineItemsList; } + public function setLineItemsList($value){ $this->_LineItemsList = $value; } + + public function getLineItems(){ return $this->_LineItems; } + public function setLineItems($value){ $this->_LineItems = $value; } + + public function getLineItemsArray(){ return $this->_LineItemsArray; } + public function setLineItemsArray($value){ $this->_LineItemsArray = $value; } + + public function getFavouriteLineItem(){ return $this->_FavouriteLineItem; } + public function setFavouriteLineItem($value){ $this->_FavouriteLineItem = $value; } + +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/Other.php b/tests/unit/SQLMap/domain/Other.php index 32d85e90..9e78ab97 100644 --- a/tests/unit/SQLMap/domain/Other.php +++ b/tests/unit/SQLMap/domain/Other.php @@ -1,23 +1,23 @@ -<?php
-
-class Other
-{
- private $_Int=-1;
- private $_Long=-1;
- private $_Bool=false;
- private $_Bool2=false;
-
- public function getBool2(){ return $this->_Bool2; }
- public function setBool2($value){ $this->_Bool2 = $value; }
-
- public function getBool(){ return $this->_Bool; }
- public function setBool($value){ $this->_Bool = $value; }
-
- public function getInt(){ return $this->_Int; }
- public function setInt($value){ $this->_Int = $value; }
-
- public function getLong(){ return $this->_Long; }
- public function setLong($value){ $this->_Long = $value; }
-}
-
+<?php + +class Other +{ + private $_Int=-1; + private $_Long=-1; + private $_Bool=false; + private $_Bool2=false; + + public function getBool2(){ return $this->_Bool2; } + public function setBool2($value){ $this->_Bool2 = $value; } + + public function getBool(){ return $this->_Bool; } + public function setBool($value){ $this->_Bool = $value; } + + public function getInt(){ return $this->_Int; } + public function setInt($value){ $this->_Int = $value; } + + public function getLong(){ return $this->_Long; } + public function setLong($value){ $this->_Long = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/Sample.php b/tests/unit/SQLMap/domain/Sample.php index c9a34601..e03be2df 100644 --- a/tests/unit/SQLMap/domain/Sample.php +++ b/tests/unit/SQLMap/domain/Sample.php @@ -1,55 +1,55 @@ -<?php
-
-class Sample
-{
- private $_FirstID='';
- private $_SecondID='';
- private $_ThirdID='';
- private $_FourthID='';
- private $_FifthID='';
- private $_SequenceID='';
- private $_DistributedID='';
- private $_SampleChar='';
- private $_SampleDecimal='';
- private $_SampleMoney='';
- private $_SampleDate='';
- private $_SequenceDate='';
-
- public function getFirstID(){ return $this->_FirstID; }
- public function setFirstID($value){ $this->_FirstID = $value; }
-
- public function getSecondID(){ return $this->_SecondID; }
- public function setSecondID($value){ $this->_SecondID = $value; }
-
- public function getThirdID(){ return $this->_ThirdID; }
- public function setThirdID($value){ $this->_ThirdID = $value; }
-
- public function getFourthID(){ return $this->_FourthID; }
- public function setFourthID($value){ $this->_FourthID = $value; }
-
- public function getFifthID(){ return $this->_FifthID; }
- public function setFifthID($value){ $this->_FifthID = $value; }
-
- public function getSequenceID(){ return $this->_SequenceID; }
- public function setSequenceID($value){ $this->_SequenceID = $value; }
-
- public function getDistributedID(){ return $this->_DistributedID; }
- public function setDistributedID($value){ $this->_DistributedID = $value; }
-
- public function getSampleChar(){ return $this->_SampleChar; }
- public function setSampleChar($value){ $this->_SampleChar = $value; }
-
- public function getSampleDecimal(){ return $this->_SampleDecimal; }
- public function setSampleDecimal($value){ $this->_SampleDecimal = $value; }
-
- public function getSampleMoney(){ return $this->_SampleMoney; }
- public function setSampleMoney($value){ $this->_SampleMoney = $value; }
-
- public function getSampleDate(){ return $this->_SampleDate; }
- public function setSampleDate($value){ $this->_SampleDate = $value; }
-
- public function getSequenceDate(){ return $this->_SequenceDate; }
- public function setSequenceDate($value){ $this->_SequenceDate = $value; }
-}
-
+<?php + +class Sample +{ + private $_FirstID=''; + private $_SecondID=''; + private $_ThirdID=''; + private $_FourthID=''; + private $_FifthID=''; + private $_SequenceID=''; + private $_DistributedID=''; + private $_SampleChar=''; + private $_SampleDecimal=''; + private $_SampleMoney=''; + private $_SampleDate=''; + private $_SequenceDate=''; + + public function getFirstID(){ return $this->_FirstID; } + public function setFirstID($value){ $this->_FirstID = $value; } + + public function getSecondID(){ return $this->_SecondID; } + public function setSecondID($value){ $this->_SecondID = $value; } + + public function getThirdID(){ return $this->_ThirdID; } + public function setThirdID($value){ $this->_ThirdID = $value; } + + public function getFourthID(){ return $this->_FourthID; } + public function setFourthID($value){ $this->_FourthID = $value; } + + public function getFifthID(){ return $this->_FifthID; } + public function setFifthID($value){ $this->_FifthID = $value; } + + public function getSequenceID(){ return $this->_SequenceID; } + public function setSequenceID($value){ $this->_SequenceID = $value; } + + public function getDistributedID(){ return $this->_DistributedID; } + public function setDistributedID($value){ $this->_DistributedID = $value; } + + public function getSampleChar(){ return $this->_SampleChar; } + public function setSampleChar($value){ $this->_SampleChar = $value; } + + public function getSampleDecimal(){ return $this->_SampleDecimal; } + public function setSampleDecimal($value){ $this->_SampleDecimal = $value; } + + public function getSampleMoney(){ return $this->_SampleMoney; } + public function setSampleMoney($value){ $this->_SampleMoney = $value; } + + public function getSampleDate(){ return $this->_SampleDate; } + public function setSampleDate($value){ $this->_SampleDate = $value; } + + public function getSequenceDate(){ return $this->_SequenceDate; } + public function setSequenceDate($value){ $this->_SequenceDate = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/Search.php b/tests/unit/SQLMap/domain/Search.php index a09ca6e6..c01891a9 100644 --- a/tests/unit/SQLMap/domain/Search.php +++ b/tests/unit/SQLMap/domain/Search.php @@ -1,23 +1,23 @@ -<?php
-
-class Search
-{
- private $_NumberSearch='';
- private $_StartDate='';
- private $_Operande='';
- private $_StartDateAnd='';
-
- public function getNumberSearch(){ return $this->_NumberSearch; }
- public function setNumberSearch($value){ $this->_NumberSearch = $value; }
-
- public function getStartDate(){ return $this->_StartDate; }
- public function setStartDate($value){ $this->_StartDate = $value; }
-
- public function getOperande(){ return $this->_Operande; }
- public function setOperande($value){ $this->_Operande = $value; }
-
- public function getStartDateAnd(){ return $this->_StartDateAnd; }
- public function setStartDateAnd($value){ $this->_StartDateAnd = $value; }
-}
-
+<?php + +class Search +{ + private $_NumberSearch=''; + private $_StartDate=''; + private $_Operande=''; + private $_StartDateAnd=''; + + public function getNumberSearch(){ return $this->_NumberSearch; } + public function setNumberSearch($value){ $this->_NumberSearch = $value; } + + public function getStartDate(){ return $this->_StartDate; } + public function setStartDate($value){ $this->_StartDate = $value; } + + public function getOperande(){ return $this->_Operande; } + public function setOperande($value){ $this->_Operande = $value; } + + public function getStartDateAnd(){ return $this->_StartDateAnd; } + public function setStartDateAnd($value){ $this->_StartDateAnd = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/unit/SQLMap/domain/User.php b/tests/unit/SQLMap/domain/User.php index 0c3a547f..b21712a3 100644 --- a/tests/unit/SQLMap/domain/User.php +++ b/tests/unit/SQLMap/domain/User.php @@ -1,27 +1,27 @@ -<?php
-
-class User
-{
- private $_ID='';
- private $_UserName='';
- private $_Password='';
- private $_EmailAddress='';
- private $_LastLogon='';
-
- public function getID(){ return $this->_ID; }
- public function setID($value){ $this->_ID = $value; }
-
- public function getUserName(){ return $this->_UserName; }
- public function setUserName($value){ $this->_UserName = $value; }
-
- public function getPassword(){ return $this->_Password; }
- public function setPassword($value){ $this->_Password = $value; }
-
- public function getEmailAddress(){ return $this->_EmailAddress; }
- public function setEmailAddress($value){ $this->_EmailAddress = $value; }
-
- public function getLastLogon(){ return $this->_LastLogon; }
- public function setLastLogon($value){ $this->_LastLogon = $value; }
-}
-
+<?php + +class User +{ + private $_ID=''; + private $_UserName=''; + private $_Password=''; + private $_EmailAddress=''; + private $_LastLogon=''; + + public function getID(){ return $this->_ID; } + public function setID($value){ $this->_ID = $value; } + + public function getUserName(){ return $this->_UserName; } + public function setUserName($value){ $this->_UserName = $value; } + + public function getPassword(){ return $this->_Password; } + public function setPassword($value){ $this->_Password = $value; } + + public function getEmailAddress(){ return $this->_EmailAddress; } + public function setEmailAddress($value){ $this->_EmailAddress = $value; } + + public function getLastLogon(){ return $this->_LastLogon; } + public function setLastLogon($value){ $this->_LastLogon = $value; } +} + ?>
\ No newline at end of file diff --git a/tests/unit/Util/TDateTimeStampTest.php b/tests/unit/Util/TDateTimeStampTest.php index 8c6baf03..e9a0a22f 100644 --- a/tests/unit/Util/TDateTimeStampTest.php +++ b/tests/unit/Util/TDateTimeStampTest.php @@ -1,149 +1,149 @@ -<?php
-
-require_once dirname(__FILE__).'/../phpunit.php';
-
-Prado::using('System.Util.TDateTimeStamp');
-
-class TDateTimeStampTest extends PHPUnit_Framework_TestCase {
-
- public function testGetTimeStampAndFormat() {
- $s = new TDateTimeStamp;
- $t = $s->getTimeStamp(0,0,0);
- $this->assertEquals($s->formatDate('Y-m-d'), date('Y-m-d'));
-
- $t = $s->getTimeStamp(0,0,0,6,1,2102);
- $this->assertEquals($s->formatDate('Y-m-d',$t), '2102-06-01');
-
- $t = $s->getTimeStamp(0,0,0,2,1,2102);
- $this->assertEquals($s->formatDate('Y-m-d',$t), '2102-02-01');
- }
-
- public function testGregorianToJulianConversion() {
- $s = new TDateTimeStamp;
- $t = $s->getTimeStamp(0,0,0,10,11,1492);
-
- //http://www.holidayorigins.com/html/columbus_day.html - Friday check
- $this->assertEquals($s->formatDate('D Y-m-d',$t), 'Fri 1492-10-11');
-
- $t = $s->getTimeStamp(0,0,0,2,29,1500);
- $this->assertEquals($s->formatDate('Y-m-d',$t), '1500-02-29');
-
- $t = $s->getTimeStamp(0,0,0,2,29,1700);
- $this->assertEquals($s->formatDate('Y-m-d',$t), '1700-03-01');
-
- }
-
- public function testGregorianCorrection() {
- $s = new TDateTimeStamp;
- $diff = $s->getTimeStamp(0,0,0,10,15,1582) - $s->getTimeStamp(0,0,0,10,4,1582);
-
- //This test case fails on my windows machine!
- //$this->assertEquals($diff, 3600*24,
- // "Error in gregorian correction = ".($diff/3600/24)." days");
-
- $this->assertEquals($s->getDayOfWeek(1582,10,15), 5.0);
- $this->assertEquals($s->getDayOfWeek(1582,10,4), 4.0);
- }
-
- public function testOverFlow() {
- $s = new TDateTimeStamp;
- $t = $s->getTimeStamp(0,0,0,3,33,1965);
- $this->assertEquals($s->formatDate('Y-m-d',$t), '1965-04-02', 'Error in day overflow 1');
-
- $t = $s->getTimeStamp(0,0,0,4,33,1971);
- $this->assertEquals($s->formatDate('Y-m-d',$t), '1971-05-03', 'Error in day overflow 2');
- $t = $s->getTimeStamp(0,0,0,1,60,1965);
- $this->assertEquals($s->formatDate('Y-m-d',$t), '1965-03-01', 'Error in day overflow 3 '.$s->getDate('Y-m-d',$t));
- $t = $s->getTimeStamp(0,0,0,12,32,1965);
- $this->assertEquals($s->formatDate('Y-m-d',$t), '1966-01-01', 'Error in day overflow 4 '.$s->getDate('Y-m-d',$t));
- $t = $s->getTimeStamp(0,0,0,12,63,1965);
- $this->assertEquals($s->formatDate('Y-m-d',$t), '1966-02-01', 'Error in day overflow 5 '.$s->getDate('Y-m-d',$t));
- $t = $s->getTimeStamp(0,0,0,13,3,1965);
- $this->assertEquals($s->formatDate('Y-m-d',$t), '1966-01-03', 'Error in mth overflow 1');
- }
-
- public function test2DigitTo4DigitYearConversion() {
- $s = new TDateTimeStamp;
- $this->assertEquals($s->get4DigitYear(00), 2000, "Err 2-digit 2000");
- $this->assertEquals($s->get4DigitYear(10), 2010, "Err 2-digit 2010");
- $this->assertEquals($s->get4DigitYear(20), 2020, "Err 2-digit 2020");
- $this->assertEquals($s->get4DigitYear(30), 2030, "Err 2-digit 2030");
- $this->assertEquals($s->get4DigitYear(40), 2040, "Err 2-digit 2040");
- $this->assertEquals($s->get4DigitYear(50), 1950, "Err 2-digit 1950");
- $this->assertEquals($s->get4DigitYear(90), 1990, "Err 2-digit 1990");
- }
-
- public function testStringFormating() {
- $s = new TDateTimeStamp;
- $fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C2822 r s t U w y Y z Z 2003';
- $s1 = date($fmt,0);
- $s2 = $s->formatDate($fmt,0);
- $this->assertEquals($s1, $s2);//, " date() 0 failed \n $s1 \n $s2");
-
- for ($i=10; --$i > 0; ) {
- $ts = 3600.0*((rand()%60000)+(rand()%60000))+(rand()%60000);
- $s1 = date($fmt,$ts);
- $s2 = $s->formatDate($fmt,$ts);
- //print "$s1 <br>$s2 <p>";
- $this->assertEquals($s1,$s2);
-
- $a1 = getdate($ts);
- $a2 = $s->getDate($ts,false);
- $this->assertEquals($a1,$a2);
- }
- }
-
- public function testRandomDatesBetween100And4000() {
- $this->assertIsValidDate(100,1);
- //echo "Testing year ";
- for ($i=10; --$i >= 0;) {
- $y1 = 100+rand(0,1970-100);
- //echo $y1." ";
- $m = rand(1,12);
- $this->assertIsValidDate($y1,$m);
-
- $y1 = 3000-rand(0,3000-1970);
- //echo $y1." ";
- $this->assertIsValidDate($y1,$m);
- }
- }
-
- public function assertIsValidDate($y1,$m,$d=13) {
- $s = new TDateTimeStamp;
- $t = $s->getTimeStamp(0,0,0,$m,$d,$y1);
- $rez = $s->formatDate('Y-n-j H:i:s',$t);
-
- $this->assertEquals("$y1-$m-$d 00:00:00", $rez);
- }
-
- function testRandomDates() {
- $start = 1960+rand(0,10);
- $yrs = 12;
- $i = 365.25*86400*($start-1970);
- $offset = 36000+rand(10000,60000);
- $max = 365*$yrs*86400;
- $lastyear = 0;
- $s = new TDateTimeStamp;
-
- // we generate a timestamp, convert it to a date, and convert it back to a timestamp
- // and check if the roundtrip broke the original timestamp value.
- //print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";
- $fails = 0;
- for ($max += $i; $i < $max; $i += $offset) {
- $ret = $s->formatDate('m,d,Y,H,i,s',$i);
- $arr = explode(',',$ret);
- if ($lastyear != $arr[2])
- $lastyear = $arr[2];
-
- $newi = $s->getTimestamp($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]);
- if ($i != $newi) {
- $fails++;
- //$j = mktime($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]);
- //print "Error at $i, $j, getTimestamp() returned $newi ($ret)\n";
- }
- }
- $this->assertEquals($fails, 0);
- }
-}
-
-?>
+<?php + +require_once dirname(__FILE__).'/../phpunit.php'; + +Prado::using('System.Util.TDateTimeStamp'); + +class TDateTimeStampTest extends PHPUnit_Framework_TestCase { + + public function testGetTimeStampAndFormat() { + $s = new TDateTimeStamp; + $t = $s->getTimeStamp(0,0,0); + $this->assertEquals($s->formatDate('Y-m-d'), date('Y-m-d')); + + $t = $s->getTimeStamp(0,0,0,6,1,2102); + $this->assertEquals($s->formatDate('Y-m-d',$t), '2102-06-01'); + + $t = $s->getTimeStamp(0,0,0,2,1,2102); + $this->assertEquals($s->formatDate('Y-m-d',$t), '2102-02-01'); + } + + public function testGregorianToJulianConversion() { + $s = new TDateTimeStamp; + $t = $s->getTimeStamp(0,0,0,10,11,1492); + + //http://www.holidayorigins.com/html/columbus_day.html - Friday check + $this->assertEquals($s->formatDate('D Y-m-d',$t), 'Fri 1492-10-11'); + + $t = $s->getTimeStamp(0,0,0,2,29,1500); + $this->assertEquals($s->formatDate('Y-m-d',$t), '1500-02-29'); + + $t = $s->getTimeStamp(0,0,0,2,29,1700); + $this->assertEquals($s->formatDate('Y-m-d',$t), '1700-03-01'); + + } + + public function testGregorianCorrection() { + $s = new TDateTimeStamp; + $diff = $s->getTimeStamp(0,0,0,10,15,1582) - $s->getTimeStamp(0,0,0,10,4,1582); + + //This test case fails on my windows machine! + //$this->assertEquals($diff, 3600*24, + // "Error in gregorian correction = ".($diff/3600/24)." days"); + + $this->assertEquals($s->getDayOfWeek(1582,10,15), 5.0); + $this->assertEquals($s->getDayOfWeek(1582,10,4), 4.0); + } + + public function testOverFlow() { + $s = new TDateTimeStamp; + $t = $s->getTimeStamp(0,0,0,3,33,1965); + $this->assertEquals($s->formatDate('Y-m-d',$t), '1965-04-02', 'Error in day overflow 1'); + + $t = $s->getTimeStamp(0,0,0,4,33,1971); + $this->assertEquals($s->formatDate('Y-m-d',$t), '1971-05-03', 'Error in day overflow 2'); + $t = $s->getTimeStamp(0,0,0,1,60,1965); + $this->assertEquals($s->formatDate('Y-m-d',$t), '1965-03-01', 'Error in day overflow 3 '.$s->getDate('Y-m-d',$t)); + $t = $s->getTimeStamp(0,0,0,12,32,1965); + $this->assertEquals($s->formatDate('Y-m-d',$t), '1966-01-01', 'Error in day overflow 4 '.$s->getDate('Y-m-d',$t)); + $t = $s->getTimeStamp(0,0,0,12,63,1965); + $this->assertEquals($s->formatDate('Y-m-d',$t), '1966-02-01', 'Error in day overflow 5 '.$s->getDate('Y-m-d',$t)); + $t = $s->getTimeStamp(0,0,0,13,3,1965); + $this->assertEquals($s->formatDate('Y-m-d',$t), '1966-01-03', 'Error in mth overflow 1'); + } + + public function test2DigitTo4DigitYearConversion() { + $s = new TDateTimeStamp; + $this->assertEquals($s->get4DigitYear(00), 2000, "Err 2-digit 2000"); + $this->assertEquals($s->get4DigitYear(10), 2010, "Err 2-digit 2010"); + $this->assertEquals($s->get4DigitYear(20), 2020, "Err 2-digit 2020"); + $this->assertEquals($s->get4DigitYear(30), 2030, "Err 2-digit 2030"); + $this->assertEquals($s->get4DigitYear(40), 2040, "Err 2-digit 2040"); + $this->assertEquals($s->get4DigitYear(50), 1950, "Err 2-digit 1950"); + $this->assertEquals($s->get4DigitYear(90), 1990, "Err 2-digit 1990"); + } + + public function testStringFormating() { + $s = new TDateTimeStamp; + $fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C2822 r s t U w y Y z Z 2003'; + $s1 = date($fmt,0); + $s2 = $s->formatDate($fmt,0); + $this->assertEquals($s1, $s2);//, " date() 0 failed \n $s1 \n $s2"); + + for ($i=10; --$i > 0; ) { + $ts = 3600.0*((rand()%60000)+(rand()%60000))+(rand()%60000); + $s1 = date($fmt,$ts); + $s2 = $s->formatDate($fmt,$ts); + //print "$s1 <br>$s2 <p>"; + $this->assertEquals($s1,$s2); + + $a1 = getdate($ts); + $a2 = $s->getDate($ts,false); + $this->assertEquals($a1,$a2); + } + } + + public function testRandomDatesBetween100And4000() { + $this->assertIsValidDate(100,1); + //echo "Testing year "; + for ($i=10; --$i >= 0;) { + $y1 = 100+rand(0,1970-100); + //echo $y1." "; + $m = rand(1,12); + $this->assertIsValidDate($y1,$m); + + $y1 = 3000-rand(0,3000-1970); + //echo $y1." "; + $this->assertIsValidDate($y1,$m); + } + } + + public function assertIsValidDate($y1,$m,$d=13) { + $s = new TDateTimeStamp; + $t = $s->getTimeStamp(0,0,0,$m,$d,$y1); + $rez = $s->formatDate('Y-n-j H:i:s',$t); + + $this->assertEquals("$y1-$m-$d 00:00:00", $rez); + } + + function testRandomDates() { + $start = 1960+rand(0,10); + $yrs = 12; + $i = 365.25*86400*($start-1970); + $offset = 36000+rand(10000,60000); + $max = 365*$yrs*86400; + $lastyear = 0; + $s = new TDateTimeStamp; + + // we generate a timestamp, convert it to a date, and convert it back to a timestamp + // and check if the roundtrip broke the original timestamp value. + //print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: "; + $fails = 0; + for ($max += $i; $i < $max; $i += $offset) { + $ret = $s->formatDate('m,d,Y,H,i,s',$i); + $arr = explode(',',$ret); + if ($lastyear != $arr[2]) + $lastyear = $arr[2]; + + $newi = $s->getTimestamp($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]); + if ($i != $newi) { + $fails++; + //$j = mktime($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]); + //print "Error at $i, $j, getTimestamp() returned $newi ($ret)\n"; + } + } + $this->assertEquals($fails, 0); + } +} + +?> |