* improved: all php code is now formatted according to the PSR-2 standard
* improved: this release is now tested using Travis ( https://travis-ci.org/ ).
+ Tests are executed using all php versions from 5.3 to 7.0 nightly, plus HHVM
* improved: no need to call anymore $client->setSSLVerifyHost(2) to silence a curl warning when using https
with recent curl builds
* improved: phpunit is now installed via composer, not bundled anymore
-* improved: debug messages are not html-escaped when executing from the command line
+* improved: when phpunit is used to generate code-coverage data, the code executed server-side is accounted for
+
+* improved: debug messages are not html-escaped any more when executing from the command line
+
+* improved: a specific option allow users to decide the version of SSL to use for https calls.
+ This is useful f.e. for the testing suite, when the server target of calls has no proper ssl certificate,
+ and the cURL extension has been compiled with GnuTLS (such as Travis)
XML-RPC for PHP version 3.0.0 - 2014/6/15
include_once __DIR__ . "/../../vendor/autoload.php";
+// out-of-band information: let the client manipulate the server operations.
+// we do this to help the testsuite script: do not reproduce in production!
+if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
+ $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = '/tmp/phpxmlrpc_coverage';
+ if (!is_dir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) {
+ mkdir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY']);
+ }
+
+ include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/prepend.php";
+}
+
include_once __DIR__ . "/../../lib/xmlrpc.inc";
include_once __DIR__ . "/../../lib/xmlrpcs.inc";
include_once __DIR__ . "/../../lib/xmlrpc_wrappers.inc";
}
/**
- * Method used to testcatching of exceptions in the server.
+ * Method used to test catching of exceptions in the server.
*/
public function exceptiongenerator($m)
{
}
$s->service();
// that should do all we need!
+
+// out-of-band information: let the client manipulate the server operations.
+// we do this to help the testsuite script: do not reproduce in production!
+if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
+ include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/append.php";
+}
\ No newline at end of file
class LocalhostTest extends PHPUnit_Framework_TestCase
{
/** @var xmlrpc_client $client */
- public $client = null;
- public $method = 'http';
- public $timeout = 10;
- public $request_compression = null;
- public $accepted_compression = '';
- public $args = array();
+ protected $client = null;
+ protected $method = 'http';
+ protected $timeout = 10;
+ protected $request_compression = null;
+ protected $accepted_compression = '';
+ protected $args = array();
protected static $failed_tests = array();
+ protected $testId;
+ /** @var boolean $collectCodeCoverageInformation */
+ protected $collectCodeCoverageInformation;
+ protected $coverageScriptUrl;
+
public static function fail($message = '')
{
- // save in global var that this particular test has failed
+ // save in a static var that this particular test has failed
// (but only if not called from subclass objects / multitests)
if (function_exists('debug_backtrace') && strtolower(get_called_class()) == 'localhosttests') {
- global $failed_tests;
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
for ($i = 0; $i < count($trace); $i++) {
if (strpos($trace[$i]['function'], 'test') === 0) {
}
/**
- * @todo be smarter with setup, do not use global variables anymore
+ * Reimplemented to allow us to collect code coverage info from the target server.
+ * Code taken from PHPUnit_Extensions_Selenium2TestCase
+ *
+ * @param PHPUnit_Framework_TestResult $result
+ * @return PHPUnit_Framework_TestResult
+ * @throws Exception
*/
+ public function run(PHPUnit_Framework_TestResult $result = NULL)
+ {
+ $this->testId = get_class($this) . '__' . $this->getName();
+
+ if ($result === NULL) {
+ $result = $this->createResult();
+ }
+
+ $this->collectCodeCoverageInformation = $result->getCollectCodeCoverageInformation();
+
+ parent::run($result);
+
+ if ($this->collectCodeCoverageInformation) {
+ $coverage = new PHPUnit_Extensions_SeleniumCommon_RemoteCoverage(
+ $this->coverageScriptUrl,
+ $this->testId
+ );
+ $result->getCodeCoverage()->append(
+ $coverage->get(), $this
+ );
+ }
+
+ // do not call this before to give the time to the Listeners to run
+ //$this->getStrategy()->endOfTest($this->session);
+
+ return $result;
+ }
+
public function setUp()
{
$this->args = argParser::getArgs();
}
$this->client->request_compression = $this->request_compression;
$this->client->accepted_compression = $this->accepted_compression;
+
+ $this->coverageScriptUrl = 'http://' . $this->args['LOCALSERVER'] . '/' . str_replace( '/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['URI'] );
}
- public function send($msg, $errrorcode = 0, $return_response = false)
+ protected function send($msg, $errrorcode = 0, $return_response = false)
{
+ if ($this->collectCodeCoverageInformation) {
+ $this->client->setCookie('PHPUNIT_SELENIUM_TEST_ID', $this->testId);
+ }
+
$r = $this->client->send($msg, $this->timeout, $this->method);
// for multicall, return directly array of responses
if (is_array($r)) {
if (!$r->faultCode()) {
$v = $r->value();
$v = php_xmlrpc_decode($v);
+
+ // take care for the extra cookie used for coverage collection
+ if (isset($v['PHPUNIT_SELENIUM_TEST_ID'])) {
+ unset($v['PHPUNIT_SELENIUM_TEST_ID']);
+ }
+
// on IIS and Apache getallheaders returns something slightly different...
$this->assertEquals($v, $cookies);
}