From 5d9f6fc77131d75e6c73a7e57df8d967b6b09215 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Mon, 6 Jan 2014 22:34:49 +0100 Subject: Fixed some function tests; start working on porting them to Selenium2 interface --- .../active-controls/tests/ActiveButtonTestCase.php | 4 +- .../tickets/tests/Ticket656TestCase.php | 9 ++-- .../validators/tests/DatePickerTestCase.php | 2 - .../validators/tests/RequiredFieldTestCase.php | 2 +- tests/test_tools/PradoGenericSelenium2Test.php | 49 ++++++++++++++++++++++ tests/test_tools/PradoGenericSeleniumTest.php | 25 +---------- tests/test_tools/phpunit_bootstrap.php | 3 +- 7 files changed, 60 insertions(+), 34 deletions(-) create mode 100644 tests/test_tools/PradoGenericSelenium2Test.php diff --git a/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php b/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php index c8fcfa57..880c46fe 100755 --- a/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php +++ b/tests/FunctionalTests/active-controls/tests/ActiveButtonTestCase.php @@ -1,13 +1,13 @@ open("active-controls/index.php?page=ActiveButtonTest"); $this->verifyTextPresent("TActiveButton Functional Test"); $this->assertText("label1", "Label 1"); - $this->click("button2"); + $this->clickOnElement("button2"); $this->pause(800); $this->assertText("label1", "Button 1 was clicked using callback!"); } diff --git a/tests/FunctionalTests/tickets/tests/Ticket656TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket656TestCase.php index ff167b0e..9fe238b9 100755 --- a/tests/FunctionalTests/tickets/tests/Ticket656TestCase.php +++ b/tests/FunctionalTests/tickets/tests/Ticket656TestCase.php @@ -6,19 +6,20 @@ class Ticket656TestCase extends PradoGenericSeleniumTest $base = 'ctl0_Content_'; $this->open('tickets/index.php?page=Ticket656'); $this->assertTitle("Verifying Ticket 656"); - + // First test, current date $this->click($base."btnUpdate"); $this->pause(800); $this->assertText($base."lblStatus",date("d-m-Y")); - + // Then, set another date + $year=date('Y')-2; $this->select($base."datePicker_day",20); $this->select($base."datePicker_month", 10); - $this->select($base."datePicker_year", 2008); + $this->select($base."datePicker_year", $year); $this->click($base."btnUpdate"); $this->pause(800); - $this->assertText($base."lblStatus",date("d-m-Y", mktime(0,0,0,10,20,2008))); + $this->assertText($base."lblStatus",date("d-m-Y", mktime(0,0,0,10,20,$year))); } } \ No newline at end of file diff --git a/tests/FunctionalTests/validators/tests/DatePickerTestCase.php b/tests/FunctionalTests/validators/tests/DatePickerTestCase.php index ab37ec06..bbefd2a7 100755 --- a/tests/FunctionalTests/validators/tests/DatePickerTestCase.php +++ b/tests/FunctionalTests/validators/tests/DatePickerTestCase.php @@ -28,8 +28,6 @@ class DatePickerTestCase extends PradoGenericSeleniumTest $this->assertNotVisible("{$base}validator6", ""); $this->assertVisible("{$base}validator8", ""); - $this->clickAndWait("{$base}submit1"); - $this->type("{$base}picker1", "13/4/$year"); $this->select("{$base}picker2_month", "label=9"); $this->select("{$base}picker2_day", "label=10"); diff --git a/tests/FunctionalTests/validators/tests/RequiredFieldTestCase.php b/tests/FunctionalTests/validators/tests/RequiredFieldTestCase.php index f8b54eb0..8ee278f8 100755 --- a/tests/FunctionalTests/validators/tests/RequiredFieldTestCase.php +++ b/tests/FunctionalTests/validators/tests/RequiredFieldTestCase.php @@ -48,7 +48,7 @@ class RequiredFieldTestCase extends PradoGenericSeleniumTest $this->type("{$base}text1", "Hello"); $this->click("{$base}check1"); - $this->click("{$base}submit2"); + $this->clickAndWait("{$base}submit2"); $this->assertNotVisible("{$base}validator5"); $this->assertNotVisible("{$base}validator6"); diff --git a/tests/test_tools/PradoGenericSelenium2Test.php b/tests/test_tools/PradoGenericSelenium2Test.php new file mode 100644 index 00000000..66350e11 --- /dev/null +++ b/tests/test_tools/PradoGenericSelenium2Test.php @@ -0,0 +1,49 @@ +setBrowser(static::$browser); + $this->setBrowserUrl(static::$baseurl); + $this->setSeleniumServerRequestsTimeout(static::$timeout); + } + + public function setUpPage() + { + $this->timeouts()->implicitWait(static::$wait); + } + + protected function open($url) + { + $this->url($url); + } + + protected function tearDown() + { + } + + protected function verifyTextPresent($txt) + { + $this->assertContains($txt, $this->source()); + } + + protected function assertText($id, $txt) + { + $element = $this->byId($id); + $this->assertEquals($txt, $element->text()); + } + + protected function pause($msec) + { + usleep($msec*1000); + } + +} \ No newline at end of file diff --git a/tests/test_tools/PradoGenericSeleniumTest.php b/tests/test_tools/PradoGenericSeleniumTest.php index 2c9ceb21..9a60f95a 100644 --- a/tests/test_tools/PradoGenericSeleniumTest.php +++ b/tests/test_tools/PradoGenericSeleniumTest.php @@ -1,7 +1,6 @@ setBrowserUrl(static::$baseurl); } - protected function tearDown() - { - } -} - -// TODO: stub -class PradoGenericSelenium2Test extends PHPUnit_Extensions_Selenium2TestCase -{ - static $browser='chrome'; - static $baseurl='http://127.0.0.1/prado-3.2/tests/FunctionalTests/'; - - protected function setUp() - { - $this->setBrowser(static::$browser); - $this->setBrowserUrl(static::$baseurl); - } - - protected function open($url) - { - $this->setBrowserUrl(static::$baseurl.$url); - } - protected function tearDown() { } diff --git a/tests/test_tools/phpunit_bootstrap.php b/tests/test_tools/phpunit_bootstrap.php index 1154e5fc..23e25a1c 100644 --- a/tests/test_tools/phpunit_bootstrap.php +++ b/tests/test_tools/phpunit_bootstrap.php @@ -22,4 +22,5 @@ if (!@include_once VENDOR_DIR.'/autoload.php') { require_once(PRADO_FRAMEWORK_DIR.'/prado.php'); // for FunctionalTests -require_once(__DIR__.'/PradoGenericSeleniumTest.php'); \ No newline at end of file +require_once(__DIR__.'/PradoGenericSeleniumTest.php'); +require_once(__DIR__.'/PradoGenericSelenium2Test.php'); \ No newline at end of file -- cgit v1.2.3