| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
$TEST_TOOLS = dirname(__FILE__);
|
|
|
4 |
|
|
|
5 |
if(isset($_GET['sr']))
|
|
|
6 |
{
|
|
|
7 |
|
|
|
8 |
if(($selenium_resource=realpath($TEST_TOOLS.'/selenium/'.$_GET['sr']))!==false)
|
|
|
9 |
echo file_get_contents($selenium_resource);
|
|
|
10 |
exit;
|
|
|
11 |
}
|
|
|
12 |
|
|
|
13 |
require_once($TEST_TOOLS.'/simpletest/unit_tester.php');
|
|
|
14 |
require_once($TEST_TOOLS.'/simpletest/web_tester.php');
|
|
|
15 |
require_once($TEST_TOOLS.'/simpletest/mock_objects.php');
|
|
|
16 |
require_once($TEST_TOOLS.'/simpletest/reporter.php');
|
|
|
17 |
require_once($TEST_TOOLS.'/selenium/php/selenium.php');
|
|
|
18 |
|
|
|
19 |
class PradoFunctionalTester
|
|
|
20 |
{
|
|
|
21 |
private $_name;
|
|
|
22 |
private $_basePath;
|
|
|
23 |
private $_selenium;
|
|
|
24 |
|
|
|
25 |
public function __construct($basePath,$selenium='',$name='All Tests')
|
|
|
26 |
{
|
|
|
27 |
$this->_name=$name;
|
|
|
28 |
if($basePath==='' || ($this->_basePath=realpath($basePath))===false)
|
|
|
29 |
throw new Exception('Invalid base path '.$basePath);
|
|
|
30 |
$this->_basePath=strtr($this->_basePath,'\\','/');
|
|
|
31 |
|
|
|
32 |
$this->_selenium = $selenium.'selenium/';
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
public function run($simpleReporter)
|
|
|
36 |
{
|
|
|
37 |
$server=SimpleSeleniumProxyServer::getInstance(dirname(__FILE__));//, '', $this->_selenium);
|
|
|
38 |
|
|
|
39 |
$groupTest=new GroupTest($this->_name);
|
|
|
40 |
$this->collectTestFiles($groupTest,$this->_basePath);
|
|
|
41 |
$groupTest->run($simpleReporter);
|
|
|
42 |
|
|
|
43 |
$server->handleRequest();
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
protected function collectTestFiles($groupTest,$basePath)
|
|
|
47 |
{
|
|
|
48 |
$folder=@opendir($basePath);
|
|
|
49 |
while($entry=@readdir($folder))
|
|
|
50 |
{
|
|
|
51 |
$fullPath=strtr($basePath.'/'.$entry,'\\','/');
|
|
|
52 |
if(is_file($fullPath) && $this->isValidFile($entry))
|
|
|
53 |
$groupTest->addTestFile($fullPath);
|
|
|
54 |
else if($entry[0]!=='.')
|
|
|
55 |
$this->collectTestFiles($groupTest,$fullPath);
|
|
|
56 |
}
|
|
|
57 |
@closedir($folder);
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
protected function isValidFile($entry)
|
|
|
61 |
{
|
|
|
62 |
return preg_match('/\w+\.php$/',$entry);
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
?>
|