From: gggeek <giunta.gaetano@gmail.com> Date: Wed, 10 Dec 2014 00:53:05 +0000 (+0000) Subject: WIP testsuite refactoring X-Git-Tag: 4.0.0-alpha^2~205 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=33b92a395f2d2bbcc3522b7ef984df2b02d1ddf7;p=plcapi.git WIP testsuite refactoring --- diff --git a/test/benchmark.php b/test/benchmark.php index 0c183d5b..8c0f6941 100644 --- a/test/benchmark.php +++ b/test/benchmark.php @@ -8,9 +8,9 @@ * @todo add a test for response ok in call testing? **/ - include(dirname(__FILE__).'/parse_args.php'); + include_once(__DIR__.'/../vendor/autoload.php'); - require_once('xmlrpc.inc'); + include(__DIR__.'/parse_args.php'); // Set up PHP structures to be used in many tests $data1 = array(1, 1.0, 'hello world', true, '20051021T23:43:00', -1, 11.0, '~!@#$%^&*()_+|', false, '20051021T23:43:00'); diff --git a/test/parse_args.php b/test/parse_args.php index 418b18c7..f8e2f558 100644 --- a/test/parse_args.php +++ b/test/parse_args.php @@ -13,17 +13,6 @@ * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt **/ - require_once('xmlrpc.inc'); - require_once('xmlrpcs.inc'); - - // play nice to older PHP versions that miss superglobals - if(!isset($_SERVER)) - { - $_SERVER = $HTTP_SERVER_VARS; - $_GET = isset($HTTP_GET_VARS) ? $HTTP_GET_VARS : array(); - $_POST = isset($HTTP_POST_VARS) ? $HTTP_POST_VARS : array(); - } - // check for command line vs web page input params if(!isset($_SERVER['REQUEST_METHOD'])) { @@ -135,5 +124,5 @@ } if(!isset($LOCALPATH)) { - $LOCALPATH = dirname(__FILE__); + $LOCALPATH = __DIR__; } diff --git a/test/testsuite.php b/test/testsuite.php index a5fe24b8..c1a111b5 100644 --- a/test/testsuite.php +++ b/test/testsuite.php @@ -1,24 +1,23 @@ <?php -include(dirname(__FILE__).'/parse_args.php'); +include_once(__DIR__.'/../vendor/autoload.php'); -require_once('xmlrpc.inc'); -require_once('xmlrpcs.inc'); -require_once('xmlrpc_wrappers.inc'); +include(__DIR__.'/parse_args.php'); + +require_once(__DIR__.'/../lib/xmlrpc_wrappers.php'); -require_once 'phpunit.php'; //require_once 'PHPUnit/TestDecorator.php'; -// let testuite run for the needed time +// let testsuite run for the needed time if ((int)ini_get('max_execution_time') < 180) ini_set('max_execution_time', 180); -$suite = new PHPUnit_TestSuite(); +$suite = new PHPUnit_Framework_TestSuite(); // array with list of failed tests $failed_tests = array(); -class LocalhostTests extends PHPUnit_TestCase +class LocalhostTests extends PHPUnit_Framework_TestCase { var $client = null; var $method = 'http'; @@ -26,9 +25,9 @@ class LocalhostTests extends PHPUnit_TestCase var $request_compression = null; var $accepted_compression = ''; - function fail($message = '') + static function fail($message = '') { - PHPUnit_TestCase::fail($message); + parent::fail($message); // save in global var that this particular test has failed // (but only if not called from subclass objects / multitests) if (function_exists('debug_backtrace') && strtolower(get_class($this)) == 'localhosttests') @@ -841,7 +840,7 @@ class LocalHostMultiTests extends LocalhostTests } } -class ParsingBugsTests extends PHPUnit_TestCase +class ParsingBugsTests extends PHPUnit_Framework_TestCase { function testMinusOneString() { @@ -1322,7 +1321,7 @@ $f = '<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><valu } } -class InvalidHostTests extends PHPUnit_TestCase +class InvalidHostTests extends PHPUnit_Framework_TestCase { var $client = null; @@ -1477,22 +1476,23 @@ else if(isset($_SERVER['REQUEST_METHOD'])) { echo "<h3>Using lib version: $xmlrpcVersion on PHP version: ".phpversion()."</h3>\n"; - echo '<h3>Running '.$suite->testCount().' tests (some of which are multiple) against servers: http://'.htmlspecialchars($LOCALSERVER.$URI).' and https://'.htmlspecialchars($HTTPSSERVER.$HTTPSURI)."\n ...</h3>\n"; + echo '<h3>Running '.$suite->count().' tests (some of which are multiple) against servers: http://'.htmlspecialchars($LOCALSERVER.$URI).' and https://'.htmlspecialchars($HTTPSSERVER.$HTTPSURI)."\n ...</h3>\n"; flush(); @ob_flush(); } else { echo "Using lib version: $xmlrpcVersion on PHP version: ".phpversion()."\n"; - echo 'Running '.$suite->testCount().' tests (some of which are multiple) against servers: http://'.$LOCALSERVER.$URI.' and https://'.$HTTPSSERVER.$HTTPSURI."\n\n"; + echo 'Running '.$suite->count().' tests (some of which are multiple) against servers: http://'.$LOCALSERVER.$URI.' and https://'.$HTTPSSERVER.$HTTPSURI."\n\n"; } // do some basic timing measurement list($micro, $sec) = explode(' ', microtime()); $start_time = $sec + $micro; -$PHPUnit = new PHPUnit; -$result = $PHPUnit->run($suite, ($DEBUG == 0 ? '.' : '<hr/>')); +//$PHPUnit = new PHPUnit; +//$result = $PHPUnit->run($suite, ($DEBUG == 0 ? '.' : '<hr/>')); +$result = $suite->run(); list($micro, $sec) = explode(' ', microtime()); $end_time = $sec + $micro;