summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests
diff options
context:
space:
mode:
authorwei <>2006-01-06 04:37:22 +0000
committerwei <>2006-01-06 04:37:22 +0000
commit3b11f3555426a50664e130148fa37e18b8098e28 (patch)
treed1bcba66c8d2fc0a7cfbbde92975b9e972fa7aab /tests/FunctionalTests
parent2d5b96ba9878ec36df7bb2af3493bb771c85b032 (diff)
Diffstat (limited to 'tests/FunctionalTests')
-rw-r--r--tests/FunctionalTests/config.php88
-rw-r--r--tests/FunctionalTests/framework/Demos/testControls.php16
-rw-r--r--tests/FunctionalTests/framework/Demos/testHangMan.php32
-rw-r--r--tests/FunctionalTests/framework/IndexPage.tpl13
-rw-r--r--tests/FunctionalTests/framework/Web/UI/config.xml7
-rw-r--r--tests/FunctionalTests/framework/Web/UI/testTButton.php23
-rw-r--r--tests/FunctionalTests/framework/Web/UI/testTButton.tpl7
-rw-r--r--tests/FunctionalTests/framework/Web/config.xml5
-rw-r--r--tests/FunctionalTests/framework/application.xml12
-rw-r--r--tests/FunctionalTests/framework/config.xml6
-rw-r--r--tests/FunctionalTests/index.php15
-rw-r--r--tests/FunctionalTests/selenium/html-xpath/html-xpath-patched.js2
-rw-r--r--tests/FunctionalTests/selenium/php/results.php22
-rw-r--r--tests/FunctionalTests/selenium/php/selenium.php31
-rw-r--r--tests/FunctionalTests/selenium/prado-functional-test.js4
-rw-r--r--tests/FunctionalTests/tests.php2
16 files changed, 48 insertions, 237 deletions
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 @@
-<?php
-
-class testControls extends SeleniumTestCase
-{
- function setup()
- {
- $this->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 @@
-<?php
-
-class testHangMan extends SeleniumTestCase
-{
- function setup()
- {
- $this->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 @@
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>Functional Tests</title>
-</head>
-
-<body>
-<h1>Functional Test Pages</h1>
-</body>
-</html> \ No newline at end of file
diff --git a/tests/FunctionalTests/framework/Web/UI/config.xml b/tests/FunctionalTests/framework/Web/UI/config.xml
deleted file mode 100644
index 7e71f4aa..00000000
--- a/tests/FunctionalTests/framework/Web/UI/config.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<configuration>
- <pages>
- <page id="testTButton" class="testTButton" />
- </pages>
-</configuration> \ No newline at end of file
diff --git a/tests/FunctionalTests/framework/Web/UI/testTButton.php b/tests/FunctionalTests/framework/Web/UI/testTButton.php
deleted file mode 100644
index 09ba28f6..00000000
--- a/tests/FunctionalTests/framework/Web/UI/testTButton.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-class testTButton extends TPage
-{
-}
-
-
-class testTButtonCase extends SeleniumTestCase
-{
- function setup()
- {
- $this->initPage(__FILE__);
- $this->open($this->Page->Request->TestUrl);
- }
-
- function testButtonClick()
- {
- $this->assertTextPresent("TButton Functional Test");
- $this->click($this->Page->button1);
- }
-}
-
-?> \ No newline at end of file
diff --git a/tests/FunctionalTests/framework/Web/UI/testTButton.tpl b/tests/FunctionalTests/framework/Web/UI/testTButton.tpl
deleted file mode 100644
index ac051f28..00000000
--- a/tests/FunctionalTests/framework/Web/UI/testTButton.tpl
+++ /dev/null
@@ -1,7 +0,0 @@
-<com:TForm>
-
- <h1>TButton Functional Test</h1>
-
- <com:TButton ID="button1" Text="Click Me!" />
-
-</com:TForm> \ No newline at end of file
diff --git a/tests/FunctionalTests/framework/Web/config.xml b/tests/FunctionalTests/framework/Web/config.xml
deleted file mode 100644
index f9533de1..00000000
--- a/tests/FunctionalTests/framework/Web/config.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<configuration>
-
-</configuration> \ No newline at end of file
diff --git a/tests/FunctionalTests/framework/application.xml b/tests/FunctionalTests/framework/application.xml
deleted file mode 100644
index 16377248..00000000
--- a/tests/FunctionalTests/framework/application.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<application id="functional" mode="Debug">
- <paths>
- <alias id="Tests" path="." />
- </paths>
- <!-- modules configured and loaded for all services -->
- <services>
- <!-- page service, BasePath is required -->
- <service id="page" BasePath="Tests" DefaultPage="IndexPage" />
- </services>
-</application> \ No newline at end of file
diff --git a/tests/FunctionalTests/framework/config.xml b/tests/FunctionalTests/framework/config.xml
deleted file mode 100644
index 918c49df..00000000
--- a/tests/FunctionalTests/framework/config.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <pages>
- <page id="IndexPage" class="TPage" TemplateFile="Tests.IndexPage" />
- </pages>
-</configuration> \ No newline at end of file
diff --git a/tests/FunctionalTests/index.php b/tests/FunctionalTests/index.php
index b2c9e16c..442c4bbf 100644
--- a/tests/FunctionalTests/index.php
+++ b/tests/FunctionalTests/index.php
@@ -7,10 +7,19 @@ class BrowserTestConfig extends PradoTestConfig
//functional test groups
public function unit_test_groups()
{
- $groups['Web/UI'] = realpath($this->tests_directory().'/Web/UI/');
- $groups['Demos'] = realpath($this->tests_directory().'/Demos/');
+ $groups = array();
+ $this->get_directories($this->tests_directory(),$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())
+ $this->get_directories($dir->getPathName(), $groups);
+ }
}
@@ -19,7 +28,7 @@ $server = SimpleSeleniumProxyServer::getInstance($root);
$tester = new PradoSimpleTester(new BrowserTestConfig());
$browser_tests = $tester->getTests();
-$browser_tests->run(new SeleniumReporter());
+$browser_tests->run(new SimpleReporter());
$server->handleRequest();
diff --git a/tests/FunctionalTests/selenium/html-xpath/html-xpath-patched.js b/tests/FunctionalTests/selenium/html-xpath/html-xpath-patched.js
index 4b9e05f6..d135e879 100644
--- a/tests/FunctionalTests/selenium/html-xpath/html-xpath-patched.js
+++ b/tests/FunctionalTests/selenium/html-xpath/html-xpath-patched.js
@@ -602,7 +602,7 @@ if (isIe)
{
var attribute = node.attributes[i];
var attributeValue = attribute.nodeValue;
- if (attributeValue && attribute.specified)
+ if (attributeValue && (attribute.specified || attribute.nodeName == 'value'))
{
var domAttribute = dom.createAttribute(attribute.nodeName);
domAttribute.value = attributeValue;
diff --git a/tests/FunctionalTests/selenium/php/results.php b/tests/FunctionalTests/selenium/php/results.php
index 2ad9c56b..77dab43b 100644
--- a/tests/FunctionalTests/selenium/php/results.php
+++ b/tests/FunctionalTests/selenium/php/results.php
@@ -45,9 +45,9 @@ class SeleniumTestResult
$case->commands = $test['commands'];
for($i = 0; $i < count($case->commands); $i++)
{
- $trace = $case->commands[$i]['trace'];
- $trace = html_entity_decode($trace);
- $case->commands[$i]['trace'] = @unserialize($trace);
+ //$trace = $case->commands[$i]['trace'];
+ //$trace = html_entity_decode($trace);
+ //$case->commands[$i]['trace'] = @unserialize($trace);
if($case->commands[$i]['result'] == 'failed')
{
$case->result = 'failed';
@@ -126,33 +126,27 @@ EOD;
foreach($test->suites as $suite)
{
foreach($suite->failures as $error)
- $contents .= $this->getErrorMsg($error, $count++);
+ $contents .= $this->getErrorMsg($suite, $error, $count++);
}
return $contents;
}
- protected function getErrorMsg($info, $count)
+ protected function getErrorMsg($suite, $info, $count)
{
- $args = array();
- foreach($info['trace']['args'] as $arg)
- $args[] = "'{$arg}'";
- $args = implode(",", $args);
$parity = $count%2==0 ? 'even' : 'odd';
+ $command = explode("|",$info['command']);
$msg = <<<EOD
<div class="error_msg {$parity}">
<strong>#{$count}.</strong>
&quot;<span class="msg">{$info['msg']}</span>&quot; in
<span class="function">
- {$info['trace']['class']}::{$info['trace']['function']}({$args})
- </span>
- near
- <span class="file">
- {$info['trace']['file']}:({$info['trace']['line']})
+ {$suite->name}::{$command[1]}('{$command[2]}');
</span>
</div>
EOD;
+
return $msg;
}
diff --git a/tests/FunctionalTests/selenium/php/selenium.php b/tests/FunctionalTests/selenium/php/selenium.php
index a06a6eab..33dc8801 100644
--- a/tests/FunctionalTests/selenium/php/selenium.php
+++ b/tests/FunctionalTests/selenium/php/selenium.php
@@ -142,9 +142,9 @@ class SeleniumTestTrace
{
$group = array_pop($trace);
$info = $trace[3];
- $test = $group['args'][0]->getTestStack();
+ $test = $group['args'][0]->getTestList();
$i = count($test);
- $name = $test[1].'::'.$test[$i-1];
+ $name = $test[$i-2].'::'.$test[$i-1];
$suite = $test[0];
unset($info['object']);
for($i = 0; $i < count($info['args']); $i++)
@@ -158,14 +158,6 @@ class SeleniumTestTrace
}
}
-class SeleniumReporter extends SimpleReporter
-{
- function getTestStack()
- {
- return $this->_test_stack;
- }
-}
-
class SimpleSeleniumProxyServer// extends SeleniumProxyServer
{
protected $runner;
@@ -250,8 +242,7 @@ class SeleniumTestSuiteWriter
$contents = <<<EOD
<html>
<head>
-<meta content="text/html; charset=ISO-8859-1"
-http-equiv="content-type">
+<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<title>Test Suite</title>
</head>
@@ -287,19 +278,18 @@ EOD;
foreach($this->suites as $name => $suite)
{
$name = $name;
- $contents .= "prado_trace['{$name}'] = new Array();\n";
+ $contents .= "prado_trace['{$name}'] = [";
+ $cases = array();
foreach($suite as $testcase)
- {
- $trace = addslashes(htmlspecialchars(serialize($testcase['trace'])));
- $contents .= "prado_trace['{$name}'].push('{$trace}')\n";
- }
+ $cases[] = "'".addslashes(htmlspecialchars(serialize($testcase['trace'])))."'";
+ $contents .= implode(",\n", $cases)."];\n\n";
}
return $contents;
}
protected function renderFooter()
{
- $trace = $this->getJsTraceInfo();
+ $trace = '';//$this->getJsTraceInfo();
$contents = <<<EOD
</tbody>
</table>
@@ -333,7 +323,7 @@ class SeleniumTestCaseWriter
<html>
<head>
<title>{$this->case}</title>
- <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
+ <meta content="text/html; charset=UTF-8" http-equiv="content-type">
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1" id=TABLE1>
@@ -351,6 +341,8 @@ EOD;
foreach($this->tests as $test)
{
$t = explode('|', $test['test']);
+ if($t[1] == "open")
+ $t[2] = "<a href=\"{$t[2]}\" target=\"_blank\">{$t[2]}</a>";
echo "<tr>\n";
echo "<td>{$t[1]}</td>\n";
echo "<td>{$t[2]}</td>\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<table.rows.length; i++)
{
@@ -161,7 +161,7 @@ function parse_resultCell(resultCell,rowNum,form)
form.createHiddenField(id+"[command]", "|"+action+"|"+target+"|"+param+"|");
form.createHiddenField(id+"[result]", result);
form.createHiddenField(id+"[msg]", msg);
- form.createHiddenField(id+"[trace]", trace[i-1]);
+ //form.createHiddenField(id+"[trace]", trace[i-1]);
}
}
diff --git a/tests/FunctionalTests/tests.php b/tests/FunctionalTests/tests.php
index 4e3c83d8..706c0661 100644
--- a/tests/FunctionalTests/tests.php
+++ b/tests/FunctionalTests/tests.php
@@ -4,7 +4,7 @@ require_once(dirname(__FILE__).'/../../framework/prado.php');
require_once(dirname(__FILE__).'/config.php');
-$application=new TApplication(dirname(__FILE__).'/framework/application.xml');
+$application=new TApplication();
$application->run();
?> \ No newline at end of file