summaryrefslogtreecommitdiff
path: root/tests/test_tools/functional_tests.php
diff options
context:
space:
mode:
authorxue <>2006-07-07 14:54:15 +0000
committerxue <>2006-07-07 14:54:15 +0000
commit61bb16ee2e5f0a66234e1575242169a10fde47b5 (patch)
tree3ee24dcc36ceae2c213130df1ea3d5c9fc110a27 /tests/test_tools/functional_tests.php
parent7b84938b1b5964f2274d66e28ba17435924ffe35 (diff)
Merge from 3.0 branch till 1253.
Diffstat (limited to 'tests/test_tools/functional_tests.php')
-rw-r--r--tests/test_tools/functional_tests.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/test_tools/functional_tests.php b/tests/test_tools/functional_tests.php
new file mode 100644
index 00000000..73bd6226
--- /dev/null
+++ b/tests/test_tools/functional_tests.php
@@ -0,0 +1,66 @@
+<?php
+
+$TEST_TOOLS = dirname(__FILE__);
+
+if(isset($_GET['sr']))
+{
+
+ if(($selenium_resource=realpath($TEST_TOOLS.'/selenium/'.$_GET['sr']))!==false)
+ echo file_get_contents($selenium_resource);
+ exit;
+}
+
+require_once($TEST_TOOLS.'/simpletest/unit_tester.php');
+require_once($TEST_TOOLS.'/simpletest/web_tester.php');
+require_once($TEST_TOOLS.'/simpletest/mock_objects.php');
+require_once($TEST_TOOLS.'/simpletest/reporter.php');
+require_once($TEST_TOOLS.'/selenium/php/selenium.php');
+
+class PradoFunctionalTester
+{
+ private $_name;
+ private $_basePath;
+ private $_selenium;
+
+ public function __construct($basePath,$selenium='',$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,'\\','/');
+
+ $this->_selenium = $selenium.'selenium/';
+ }
+
+ public function run($simpleReporter)
+ {
+ $server=SimpleSeleniumProxyServer::getInstance(dirname(__FILE__));//, '', $this->_selenium);
+
+ $groupTest=new GroupTest($this->_name);
+ $this->collectTestFiles($groupTest,$this->_basePath);
+ $groupTest->run($simpleReporter);
+
+ $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