Source for file ViewTestResults.php
Documentation is available at ViewTestResults.php
// include the config file
require_once '../util/AlphaConfig.inc';
// add PHPUnit to the include_path
ini_set('include_path', ini_get('include_path'). PATH_SEPARATOR. $config->get('sysRoot'). 'alpha/lib/PEAR/PHPUnit-3.2.9');
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once $config->get('sysRoot'). 'alpha/util/Logger.inc';
require_once $config->get('sysRoot'). 'alpha/model/PersonObject.inc';
require_once $config->get('sysRoot'). 'alpha/model/TagObject.inc';
require_once $config->get('sysRoot'). 'alpha/controller/AlphaControllerInterface.inc';
require_once $config->get('sysRoot'). 'alpha/controller/AlphaController.inc';
require_once $config->get('sysRoot'). 'alpha/tests/Enum_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/DEnum_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Sequence_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Boolean_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Date_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Timestamp_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Integer_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Double_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Exceptions_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/String_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Text_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Relation_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Tag_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/AlphaDAO_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/AlphaValidator_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/AlphaController_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/FrontController_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/AlphaView_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/Image_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/AlphaAgentUtils_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/AlphaConfig_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/AlphaFeed_Test.php';
require_once $config->get('sysRoot'). 'alpha/tests/AlphaFilters_Test.php';
* Controller which displays all of the unit test results
* @package alpha::controller
* @author John Collins <dev@alphaframework.org>
* @version $Id: ViewTestResults.php 1453 2011-12-04 15:12:54Z johnc $
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @copyright Copyright (c) 2011, John Collins (founder of Alpha Framework).
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
* * Neither the name of the Alpha Framework nor the names
* of its contributors may be used to endorse or promote
* products derived from this software without specific
* prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
private static $logger = null;
* we are supressing the display and logging of errors on this page, as we
* are only interested in tests that fail and the reasons given for failing
$config->set('sysTraceLevel', 'FATAL');
// ensure that the super class constructor is called, indicating the rights group
// set up the title and meta details
$this->setTitle('Alpha Core Unit Test Results');
public function doGET($params) {
// flip the standard database settings with the test ones
$config->set('sysDB', $config->get('sysDBTest'));
$config->set('sysDBUsername', $config->get('sysDBTestUsername'));
$config->set('sysDBPassword', $config->get('sysDBTestPassword'));
$config->set('sysDBHost', $config->get('sysDBTestHost'));
// force a disconnect to break any existing connections to the main database
if($config->get('sysDB') == '') {
echo '<h2>Core Complex Data Types</h2>';
// **** begin test suite ****
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Enum_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('DEnum_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>Sequence:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Sequence_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>Boolean:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Boolean_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Date_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>Timestamp:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Timestamp_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>Integer:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Integer_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Double_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('String_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Text_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>Relation:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Relation_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>Exception Handling:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Exceptions_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Tag_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>MySQL AlphaDAO:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('AlphaDAO_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>AlphaValidator helper:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('AlphaValidator_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>AlphaController:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('AlphaController_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>FrontController:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('FrontController_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>AlphaView:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('AlphaView_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('Image_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>AlphaAgentUtils:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('AlphaAgentUtils_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>AlphaConfig:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('AlphaConfig_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>AlphaFeed:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('AlphaFeed_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
// **** begin test suite ****
echo '<h3>AlphaFilters:</h3>';
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('AlphaFilters_Test');
$runningTime+= $result->time();
$testCount+= $result->count();
$this->printTestResult($result);
echo '<p>Running time: '. $runningTime. '</p>';
echo '<h3>Total tests ran: '. $testCount. '</h3>';
echo '<h3>Total running time: '. $runningTime. '</h3>';
public function doPOST($params) {
* Prints the test result HTML & CSS for the passed PHPUnit test result
* @param PHPUnit_Framework_TestResult $result
private function printTestResult($result) {
if($result->wasSuccessful()) {
echo '<div class="ui-state-highlight ui-corner-all" style="padding: 0pt 0.7em;">';
echo '<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: 0.3em;"></span>';
echo '<strong>Success</strong><pre>';
echo '<div class="ui-state-error ui-corner-all" style="padding: 0pt 0.7em;">';
echo '<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: 0.3em;"></span>';
echo '<strong>Fail</strong><pre>';
$report = new PHPUnit_TextUI_ResultPrinter();
$report->printResult($result);
// now build the new controller if this file is called directly
if ('ViewTestResults.php' == basename($_SERVER['PHP_SELF'])) {
$controller->doGET($_GET);
|