From 6ae6538555d45b3e947f5ce0d948d9b88d95364a Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 12 Mar 2006 16:28:21 +0000 Subject: reorganized FT. --- .gitattributes | 2 +- tests/FunctionalTests/PradoTester.php | 54 +++++++++++++++++++++++++ tests/FunctionalTests/config.php | 8 ++-- tests/FunctionalTests/features.php | 37 ++--------------- tests/FunctionalTests/quickstart.php | 37 ++--------------- tests/FunctionalTests/selenium/php/selenium.php | 1 + tests/FunctionalTests/tests.php | 10 ----- tests/FunctionalTests/tickets.php | 37 ++--------------- 8 files changed, 68 insertions(+), 118 deletions(-) create mode 100644 tests/FunctionalTests/PradoTester.php delete mode 100644 tests/FunctionalTests/tests.php diff --git a/.gitattributes b/.gitattributes index 33f5442b..095817ef 100644 --- a/.gitattributes +++ b/.gitattributes @@ -781,6 +781,7 @@ requirements/messages-zh.txt -text requirements/messages.txt -text requirements/template-zh.html -text requirements/template.html -text +tests/FunctionalTests/PradoTester.php -text tests/FunctionalTests/README.txt -text tests/FunctionalTests/config.php -text tests/FunctionalTests/features.php -text @@ -901,7 +902,6 @@ tests/FunctionalTests/selenium/selenium.css -text tests/FunctionalTests/selenium/user-extensions.js.sample -text tests/FunctionalTests/selenium/xmlextras.js -text tests/FunctionalTests/selenium/xpath.js -text -tests/FunctionalTests/tests.php -text tests/FunctionalTests/tickets.php -text tests/FunctionalTests/tickets/index.php -text tests/FunctionalTests/tickets/protected/pages/Layout.php -text diff --git a/tests/FunctionalTests/PradoTester.php b/tests/FunctionalTests/PradoTester.php new file mode 100644 index 00000000..8d081e0f --- /dev/null +++ b/tests/FunctionalTests/PradoTester.php @@ -0,0 +1,54 @@ +_name=$name; + if($basePath==='' || ($this->_basePath=realpath($basePath))===false) + throw new Exception('Invalid base path '.$basePath); + $this->_basePath=strtr($this->_basePath,'\\','/'); + } + + public function run($simpleReporter) + { + $groupTest=new GroupTest($this->_name); + $this->collectTestFiles($groupTest,$this->_basePath); + $groupTest->run($simpleReporter); + + $server=SimpleSeleniumProxyServer::getInstance(dirname(__FILE__)); + $server->handleRequest(); + } + + protected function collectTestFiles($groupTest,$basePath) + { + $folder=@opendir($basePath); + while($entry=@readdir($folder)) + { + $fullPath=strtr($basePath.'/'.$entry,'\\','/'); + if(is_file($fullPath) && $this->isValidFile($entry)) + $groupTest->addTestFile($fullPath); + else if($entry[0]!=='.') + $this->collectTestFiles($groupTest,$fullPath); + } + closedir($folder); + } + + protected function isValidFile($entry) + { + return preg_match('/\w+\.php$/',$entry); + } +} + +?> \ No newline at end of file diff --git a/tests/FunctionalTests/config.php b/tests/FunctionalTests/config.php index 73491c6e..358fb8e2 100644 --- a/tests/FunctionalTests/config.php +++ b/tests/FunctionalTests/config.php @@ -10,7 +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'); +//require_once(PradoTestConfig::framework().'/prado.php'); /** test configurations , OVERRIDE to suite your enviornment !!! **/ class PradoTestConfig @@ -65,7 +65,7 @@ class PradoTestConfig //set up the PradoApplication Testing stub. -class PradoApplicationTester extends TApplication +class PradoApplicationTester { protected $appUrl; protected $testConfig; @@ -74,12 +74,10 @@ class PradoApplicationTester extends TApplication { $this->appUrl = $appUrl; $this->testConfig = $config; - parent::__construct(); } public function run() { - $this->initApplication(); } public function getTestPage($file) @@ -129,7 +127,7 @@ class PradoSimpleTester while (false !== ($entry = $dir->read())) { - $file = realpath($path.'/'.$entry); + $file = strtr(realpath($path.'/'.$entry),'\\','/'); $matchFile = $this->tester->getTestCase(); if(is_file($file) && $this->filePatternMatch($file)) { diff --git a/tests/FunctionalTests/features.php b/tests/FunctionalTests/features.php index 71c8ce3a..8a3c87a6 100644 --- a/tests/FunctionalTests/features.php +++ b/tests/FunctionalTests/features.php @@ -1,39 +1,8 @@ get_directories(dirname(__FILE__).'/features/tests', $groups); - - return $groups; - } - - protected function get_directories($base,&$groups) - { - $groups[] = realpath($base); - $dirs = new DirectoryIterator($base); - foreach($dirs as $dir) - if(!$dir->isDot() && $dir->isDir() - && !preg_match("/\.svn/", $dir->getPathName())) - $this->get_directories($dir->getPathName(), $groups); - } -} - - -$root = dirname(__FILE__); -$server = SimpleSeleniumProxyServer::getInstance($root); - -$tester = new PradoSimpleTester(new BrowserTestConfig()); -$browser_tests = $tester->getTests(); -$browser_tests->run(new SimpleReporter()); - -$server->handleRequest(); +$tester=new PradoTester(dirname(__FILE__).'/features/tests'); +$tester->run(new SimpleReporter()); ?> \ No newline at end of file diff --git a/tests/FunctionalTests/quickstart.php b/tests/FunctionalTests/quickstart.php index e4157aca..aa6dc119 100644 --- a/tests/FunctionalTests/quickstart.php +++ b/tests/FunctionalTests/quickstart.php @@ -1,39 +1,8 @@ get_directories(dirname(__FILE__).'/quickstart', $groups); - - return $groups; - } - - protected function get_directories($base,&$groups) - { - $groups[] = realpath($base); - $dirs = new DirectoryIterator($base); - foreach($dirs as $dir) - if(!$dir->isDot() && $dir->isDir() - && !preg_match("/\.svn/", $dir->getPathName())) - $this->get_directories($dir->getPathName(), $groups); - } -} - - -$root = dirname(__FILE__); -$server = SimpleSeleniumProxyServer::getInstance($root); - -$tester = new PradoSimpleTester(new BrowserTestConfig()); -$browser_tests = $tester->getTests(); -$browser_tests->run(new SimpleReporter()); - -$server->handleRequest(); +$tester=new PradoTester(dirname(__FILE__).'/quickstart'); +$tester->run(new SimpleReporter()); ?> \ No newline at end of file diff --git a/tests/FunctionalTests/selenium/php/selenium.php b/tests/FunctionalTests/selenium/php/selenium.php index 03b264db..4b36b8c2 100644 --- a/tests/FunctionalTests/selenium/php/selenium.php +++ b/tests/FunctionalTests/selenium/php/selenium.php @@ -267,6 +267,7 @@ EOD; foreach($this->suites as $name => $suite) { $file = $suite[0]['trace']['file']; + $file = strtr($file,'\\','/'); $url = $this->runner->getDriver()."?case={$name}&file={$file}"; echo "