From 98215a603fb798cdb4178e49061977544aaa45b7 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Sat, 10 Dec 2005 11:49:29 +0000
Subject: Initial import selenium functional test framework.
---
tests/FunctionalTests/selenium/php/TestRunner.php | 156 +++++++
tests/FunctionalTests/selenium/php/results.php | 166 ++++++++
tests/FunctionalTests/selenium/php/selenium.php | 485 ++++++++++++++++++++++
3 files changed, 807 insertions(+)
create mode 100644 tests/FunctionalTests/selenium/php/TestRunner.php
create mode 100644 tests/FunctionalTests/selenium/php/results.php
create mode 100644 tests/FunctionalTests/selenium/php/selenium.php
(limited to 'tests/FunctionalTests/selenium/php')
diff --git a/tests/FunctionalTests/selenium/php/TestRunner.php b/tests/FunctionalTests/selenium/php/TestRunner.php
new file mode 100644
index 00000000..fb3cefb3
--- /dev/null
+++ b/tests/FunctionalTests/selenium/php/TestRunner.php
@@ -0,0 +1,156 @@
+
+
+
+
+
+
+
+
+
+
+Prado Functional Test Runner
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/FunctionalTests/selenium/php/results.php b/tests/FunctionalTests/selenium/php/results.php
new file mode 100644
index 00000000..2ad9c56b
--- /dev/null
+++ b/tests/FunctionalTests/selenium/php/results.php
@@ -0,0 +1,166 @@
+parse_data();
+ $this->browser = $_SERVER['HTTP_USER_AGENT'];
+ $this->date = time();
+ }
+
+ protected function parse_data()
+ {
+ $this->result = $_POST['result']; // failed || passed
+ $this->totalTime = $_POST['totalTime'];
+ $this->numTestPasses = $_POST['numTestPasses'];
+ $this->numTestFailures = $_POST['numTestFailures'];
+ $this->numCommandPasses = $_POST['numCommandPasses'];
+ $this->numCommandFailures = $_POST['numCommandFailures'];
+ $this->numCommandErrors = $_POST['numCommandErrors'];
+
+ foreach($_POST['tests'] as $test)
+ {
+ $case = new SeleniumTestCaseResult();
+ $case->name = $test['testcase'];
+ $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);
+ if($case->commands[$i]['result'] == 'failed')
+ {
+ $case->result = 'failed';
+ array_push($case->failures, $case->commands[$i]);
+ }
+ }
+
+ $this->suites[$case->name] = $case;
+ }
+
+ }
+}
+
+class SeleniumHtmlReporter
+{
+ protected $test;
+
+ public function __construct($result)
+ {
+ $this->test = $result;
+ }
+
+ protected function renderHeader()
+ {
+ $contents = <<
+
+Functional Test Results
+
+
+
+
+EOD;
+ return $contents;
+ }
+
+ public function render()
+ {
+ echo $this->renderHeader();
+ echo $this->renderBody();
+ echo $this->renderFooter();
+ }
+
+ protected function renderBody()
+ {
+ /* SeleniumTestResult */
+ $test = $this->test;
+ $total = count($test->suites);
+ $date = @strftime('%Y-%m-%d %H:%M',$test->date);
+$contents = <<Functional Test Results
+
+ {$total} test cases completed,
+ {$test->numTestPasses} passes
+ ({$test->numCommandPasses} commands), and
+ {$test->numTestFailures} fails
+ ({$test->numCommandErrors} commands).
+
+
+ {$date}, {$test->browser}
+
+EOD;
+ $count = 1;
+ foreach($test->suites as $suite)
+ {
+ foreach($suite->failures as $error)
+ $contents .= $this->getErrorMsg($error, $count++);
+ }
+
+ return $contents;
+ }
+
+
+ protected function getErrorMsg($info, $count)
+ {
+ $args = array();
+ foreach($info['trace']['args'] as $arg)
+ $args[] = "'{$arg}'";
+ $args = implode(",", $args);
+ $parity = $count%2==0 ? 'even' : 'odd';
+$msg = <<
+ #{$count}.
+ "{$info['msg']}" in
+
+ {$info['trace']['class']}::{$info['trace']['function']}({$args})
+
+ near
+
+ {$info['trace']['file']}:({$info['trace']['line']})
+
+
+EOD;
+ return $msg;
+ }
+
+ protected function renderFooter()
+ {
+ return "