summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorxue <>2006-03-12 16:28:21 +0000
committerxue <>2006-03-12 16:28:21 +0000
commit6ae6538555d45b3e947f5ce0d948d9b88d95364a (patch)
tree55c9622a90debe81de45f8af5cf10e3293862965 /tests
parent5f66433898f89865a6682ad9aebfeef14b596dea (diff)
reorganized FT.
Diffstat (limited to 'tests')
-rw-r--r--tests/FunctionalTests/PradoTester.php54
-rw-r--r--tests/FunctionalTests/config.php8
-rw-r--r--tests/FunctionalTests/features.php37
-rw-r--r--tests/FunctionalTests/quickstart.php37
-rw-r--r--tests/FunctionalTests/selenium/php/selenium.php1
-rw-r--r--tests/FunctionalTests/tests.php10
-rw-r--r--tests/FunctionalTests/tickets.php37
7 files changed, 67 insertions, 117 deletions
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 @@
+<?php
+
+$SIMPLE_TEST = dirname(__FILE__).'/../UnitTests';
+
+require_once($SIMPLE_TEST.'/simpletest/unit_tester.php');
+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');
+
+class PradoTester
+{
+ private $_name;
+ private $_basePath;
+
+ public function __construct($basePath,$name='All Tests')
+ {
+ $this->_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 @@
<?php
-require('config.php');
-header("Content-Type: text/html; charset=UTF-8");
-class BrowserTestConfig extends PradoTestConfig
-{
- //functional test groups
- public function unit_test_groups()
- {
- $groups = array();
+require(dirname(__FILE__).'/PradoTester.php');
- //tests for quickstart samples
- $this->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 @@
<?php
-require('config.php');
-header("Content-Type: text/html; charset=UTF-8");
-class BrowserTestConfig extends PradoTestConfig
-{
- //functional test groups
- public function unit_test_groups()
- {
- $groups = array();
+require(dirname(__FILE__).'/PradoTester.php');
- //tests for quickstart samples
- $this->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 "<tr>\n";
echo "<td><a href=\"{$url}\">{$name}</a></td>\n";
diff --git a/tests/FunctionalTests/tests.php b/tests/FunctionalTests/tests.php
deleted file mode 100644
index 706c0661..00000000
--- a/tests/FunctionalTests/tests.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-require_once(dirname(__FILE__).'/../../framework/prado.php');
-require_once(dirname(__FILE__).'/config.php');
-
-
-$application=new TApplication();
-$application->run();
-
-?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets.php b/tests/FunctionalTests/tickets.php
index a2ea99d2..36511e73 100644
--- a/tests/FunctionalTests/tickets.php
+++ b/tests/FunctionalTests/tickets.php
@@ -1,39 +1,8 @@
<?php
-require('config.php');
-header("Content-Type: text/html; charset=UTF-8");
-class BrowserTestConfig extends PradoTestConfig
-{
- //functional test groups
- public function unit_test_groups()
- {
- $groups = array();
+require(dirname(__FILE__).'/PradoTester.php');
- //tests for quickstart samples
- $this->get_directories(dirname(__FILE__).'/tickets/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__).'/tickets/tests');
+$tester->run(new SimpleReporter());
?> \ No newline at end of file