From 3b11f3555426a50664e130148fa37e18b8098e28 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 6 Jan 2006 04:37:22 +0000 Subject: --- tests/FunctionalTests/config.php | 88 +++------------------- .../framework/Demos/testControls.php | 16 ---- .../framework/Demos/testHangMan.php | 32 -------- tests/FunctionalTests/framework/IndexPage.tpl | 13 ---- tests/FunctionalTests/framework/Web/UI/config.xml | 7 -- .../framework/Web/UI/testTButton.php | 23 ------ .../framework/Web/UI/testTButton.tpl | 7 -- tests/FunctionalTests/framework/Web/config.xml | 5 -- tests/FunctionalTests/framework/application.xml | 12 --- tests/FunctionalTests/framework/config.xml | 6 -- tests/FunctionalTests/index.php | 15 +++- .../selenium/html-xpath/html-xpath-patched.js | 2 +- tests/FunctionalTests/selenium/php/results.php | 22 ++---- tests/FunctionalTests/selenium/php/selenium.php | 31 +++----- .../selenium/prado-functional-test.js | 4 +- tests/FunctionalTests/tests.php | 2 +- 16 files changed, 48 insertions(+), 237 deletions(-) delete mode 100644 tests/FunctionalTests/framework/Demos/testControls.php delete mode 100644 tests/FunctionalTests/framework/Demos/testHangMan.php delete mode 100644 tests/FunctionalTests/framework/IndexPage.tpl delete mode 100644 tests/FunctionalTests/framework/Web/UI/config.xml delete mode 100644 tests/FunctionalTests/framework/Web/UI/testTButton.php delete mode 100644 tests/FunctionalTests/framework/Web/UI/testTButton.tpl delete mode 100644 tests/FunctionalTests/framework/Web/config.xml delete mode 100644 tests/FunctionalTests/framework/application.xml delete mode 100644 tests/FunctionalTests/framework/config.xml (limited to 'tests/FunctionalTests') diff --git a/tests/FunctionalTests/config.php b/tests/FunctionalTests/config.php index ebef6f8c..99644888 100644 --- a/tests/FunctionalTests/config.php +++ b/tests/FunctionalTests/config.php @@ -10,6 +10,7 @@ require_once($SIMPLE_TEST.'/simpletest/web_tester.php'); require_once($SIMPLE_TEST.'/simpletest/mock_objects.php'); require_once($SIMPLE_TEST.'/simpletest/reporter.php'); require(dirname(__FILE__).'/selenium/php/selenium.php'); +require_once(PradoTestConfig::framework().'/prado.php'); /** test configurations , OVERRIDE to suite your enviornment !!! **/ class PradoTestConfig @@ -23,7 +24,7 @@ class PradoTestConfig //test directory base public function tests_directory() { - return dirname(__FILE__).'/framework/'; + return dirname(__FILE__).'/protected/'; } //prado frame work directory @@ -39,18 +40,16 @@ class PradoTestConfig } //run the prado application - public function runApplication($appUrl='tests.php', $file=null, $class='PradoApplicationTester') + public function runApplication($appUrl='tests.php', $class='PradoApplicationTester') { - if(is_null($file)) - $file = $this->tests_directory().'/application.xml'; - $app = new $class($file, $this, $appUrl); + $app = new $class($this, $appUrl); $app->run(); } //file patterns to accept for test public function acceptPattern() { - return '/test(\w+)\.php/'; + return '/\w+\.php/'; } public function rejectPattern() @@ -66,61 +65,33 @@ class PradoTestConfig //set up the PradoApplication Testing stub. -require_once(PradoTestConfig::framework().'/prado.php'); -require_once(PradoTestConfig::framework().'/TApplication.php'); - class PradoApplicationTester extends TApplication { + protected $appUrl; protected $testConfig; - - public function __construct($spec, $config, $appUrl) + public function __construct($config, $appUrl) { + $this->appUrl = $appUrl; $this->testConfig = $config; - parent::__construct($spec); - $request = new FunctionTestRequest(); - $request->init($this, null); - $request->setAppUrl($appUrl); - $this->setRequest($request); - $response = new FunctionTestResponse(); - $response->init($this, null); - $this->setResponse($response); + parent::__construct(); } public function run() { - $this->initApplication($this->getConfigurationFile(),null); - } - - public function getServiceConfig() - { - $config=new TApplicationConfiguration; - $config->loadFromFile($this->getConfigurationFile()); - return $config->getService($this->getTestServiceID()); - } - - public function getTestServiceID() - { - if(($serviceID=$this->getRequest()->getServiceID())===null) - $serviceID=self::DEFAULT_SERVICE; - return $serviceID; + $this->initApplication(); } public function getTestPage($file) { $parameter = $this->getTestServiceParameter($file); - $this->getRequest()->setServiceParameter($parameter); - $service = $this->getService(); - $config = $this->getServiceConfig(); - $service->init($this, $config[2]); - $service->run(); - return $service->getRequestedPage(); + return $this->appUrl.'?page='.$parameter; } protected function getTestServiceParameter($file) { $file = realpath($file); - $base = realpath($this->testConfig->tests_directory()); + $base = realpath($this->testConfig->tests_directory().'/pages/'); $search = array($base, '.php'); $replace = array('', ''); $pagePath = str_replace($search, $replace, $file); @@ -131,41 +102,6 @@ class PradoApplicationTester extends TApplication } } -class FunctionTestRequest extends THttpRequest -{ - protected $appUrl; - - public function setServiceParameter($parameter) - { - parent::setServiceParameter($parameter); - } - - public function setAppUrl($url) - { - $this->appUrl = $url; - } - - public function getApplicationPath() - { - return $this->appUrl; - } - - public function getTestUrl() - { - $serviceParam = $this->getServiceParameter(); - $serviceID= prado::getApplication()->getTestServiceID(); - return $this->constructUrl($serviceID, $serviceParam); - } -} - -class FunctionTestResponse extends THttpResponse -{ - public function write($str) - { - - } -} - /** set up the tests **/ class PradoSimpleTester diff --git a/tests/FunctionalTests/framework/Demos/testControls.php b/tests/FunctionalTests/framework/Demos/testControls.php deleted file mode 100644 index 49f8e99e..00000000 --- a/tests/FunctionalTests/framework/Demos/testControls.php +++ /dev/null @@ -1,16 +0,0 @@ -open('../../demos/controls/index.php'); - } - - function testControlSamples() - { - $this->assertTextPresent("Welcome! Guest"); - $this->clickAndWait('//input[@value="Toggle Button"]'); - $this->assertTextPresent("Login"); - } -} \ No newline at end of file diff --git a/tests/FunctionalTests/framework/Demos/testHangMan.php b/tests/FunctionalTests/framework/Demos/testHangMan.php deleted file mode 100644 index e6bc8c94..00000000 --- a/tests/FunctionalTests/framework/Demos/testHangMan.php +++ /dev/null @@ -1,32 +0,0 @@ -open('../../demos/hangman/index.php'); - } - - function testHangManGame() - { - $this->assertLocation('hangman/index.php'); - $this->assertTextPresent('Prado Hangman Game'); - - //use xpath to select input with value "HardLevel", - //i.e the radio button with value "HardLevel" - $this->click('//input[@value="HardLevel"]'); - $this->clickAndWait('//input[@value="Play!"]'); - - //try 3 alphabets that sure doesn't exists - $this->clickAndWait('link=X'); - $this->assertTextPresent('made 1 bad guesses'); - - $this->clickAndWait('link=J'); - $this->assertTextPresent('made 2 bad guesses'); - - $this->clickAndWait('link=Q'); - $this->assertTextPresent('You Lose!'); - } -} - -?> \ No newline at end of file diff --git a/tests/FunctionalTests/framework/IndexPage.tpl b/tests/FunctionalTests/framework/IndexPage.tpl deleted file mode 100644 index 733c495e..00000000 --- a/tests/FunctionalTests/framework/IndexPage.tpl +++ /dev/null @@ -1,13 +0,0 @@ - - - -
-{$t[1]} | \n"; echo "{$t[2]} | \n"; @@ -464,6 +456,7 @@ class SeleniumTestCase extends UnitTestCase $server = SimpleSeleniumProxyServer::getInstance(); if(!is_null($server)) $this->selenium = $server->proxy(); + parent::__construct(); } public function initPage($file) diff --git a/tests/FunctionalTests/selenium/prado-functional-test.js b/tests/FunctionalTests/selenium/prado-functional-test.js index 1d0ef39a..37e26516 100644 --- a/tests/FunctionalTests/selenium/prado-functional-test.js +++ b/tests/FunctionalTests/selenium/prado-functional-test.js @@ -148,7 +148,7 @@ function parse_resultCell(resultCell,rowNum,form) form.createHiddenField("tests["+rowNum+"][testcase]",testname); - var trace = window.testSuiteFrame.prado_trace[testname]; + //var trace = window.testSuiteFrame.prado_trace[testname]; for(var i = 1; i