before_script:
# Output what version of phpunit we got going
- - ./vendor/bin/phpunit --version
+ #- ./vendor/bin/phpunit --version
# Enable code coverage for a single version of php
- - if [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then export PHP_OPTS="-d zend_extension=xdebug.so -d xdebug.mode=coverage" && export PHPUNIT_OPTS="--coverage-clover=coverage.clover"; fi
- - echo "php $PHP_OPTS ./vendor/phpunit/phpunit/phpunit $PHPUNIT_OPTS tests"
+ - if [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then ./tests/ci/setup/setup_code_coverage.sh enable && export PHPUNIT_OPTS="--coverage-clover=coverage.clover"; fi
script:
- php $PHP_OPTS ./vendor/phpunit/phpunit/phpunit $PHPUNIT_OPTS tests
+ ./vendor/bin/phpunit -v $PHPUNIT_OPTS tests
after_failure:
# Troubleshoot test env build problems
$GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = '/tmp/phpxmlrpc_coverage';
if (!is_dir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) {
mkdir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY']);
+ chmod($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'], 0777);
}
include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/prepend.php";
$GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = '/tmp/phpxmlrpc_coverage';
if (!is_dir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) {
mkdir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY']);
+ chmod($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'], 0777);
}
include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/prepend.php";
<whitelist>
<directory suffix=".php">./</directory>
<exclude>
- <directory>./Resources</directory>
+ <directory>./build</directory>
+ <directory>./doc</directory>
+ <directory>./extras</directory>
<directory>./tests</directory>
<directory>./vendor</directory>
<file>./pakefile.php</file>
protected $collectCodeCoverageInformation;
protected $coverageScriptUrl;
+ /**
+ * @todo instead of overriding run via _fail, implement PHPUnit_Framework_TestListener - IFF there is such an API portable across PHPUnit 5 to 9...
+ */
public static function _fail($message = '')
{
// save in a static var that this particular test has failed
* @param TestResult $result
* @return TestResult
* @throws Exception
+ *
+ * @todo instead of overriding run via _run, subclass PHPUnit_Extensions_TestDecorator - IFF there is such an API portable across PHPUnit 5 to 9...
*/
public function _run($result = NULL)
{
/**
* Returns all test methods from the base class, except the ones which failed already
*
- * @todo reintroduce skipping of tests which failed when executed individually if test runs happen as separate processes
+ * @todo (re)introduce skipping of tests which failed when executed individually even if test runs happen as separate processes
* @todo reintroduce skipping of tests within the loop
*/
public function getSingleHttpTestMethods()
/**
* Tests for php files in the 'extras' directory
+ *
*/
class ExtraTest extends PhpXmlRpc_LocalFileTestCase
{
$this->coverageScriptUrl = 'http://' . $this->args['HTTPSERVER'] . '/' . str_replace( '/demo/server/server.php', 'tests/phpunit_coverage.php', $this->args['HTTPURI'] );
}
+ /**
+ * @todo collect code coverage for this...
+ */
+ public function testBenchmark()
+ {
+ $page = $this->request('benchmark.php');
+ }
+
+ /**
+ * @todo collect code coverage for this...
+ */
public function testVerifyCompat()
{
$page = $this->request('verify_compat.php');
protected $collectCodeCoverageInformation;
protected $coverageScriptUrl;
+ /**
+ * Reimplemented to allow us to collect code coverage info for the target php files executed via an http request.
+ * Code taken from PHPUnit_Extensions_Selenium2TestCase
+ *
+ * @todo instead of overriding run via _run, subclass PHPUnit_Extensions_TestDecorator - IFF there is such an API portable across PHPUnit 5 to 9...
+ */
public function _run($result = NULL)
{
$this->testId = get_class($this) . '__' . $this->getName();
}
if ($this->collectCodeCoverageInformation)
{
- curl_setopt($ch, CURLOPT_COOKIE, 'PHPUNIT_SELENIUM_TEST_ID=true');
+ curl_setopt($ch, CURLOPT_COOKIE, 'PHPUNIT_SELENIUM_TEST_ID='.$this->testId);
}
if ($this->args['DEBUG'] > 0) {
curl_setopt($ch, CURLOPT_VERBOSE, 1);
--- /dev/null
+#!/bin/sh
+
+# @todo add 'query' action
+# @todo avoid reloading php-fpm if config did not change
+
+# Note: we have php set up either via phpenv (TRAVIS=true), Ubuntu packages (PHP_VERSION=default) or Sury packages.
+# xdebug comes either at version 2 or 3
+
+set -e
+
+if [ "$TRAVIS" != true ]; then
+ PHPCONFDIR_CLI=$(php -i | grep 'Scan this dir for additional .ini files' | sed 's|Scan this dir for additional .ini files => ||')
+ PHPCONFDIR_FPM=$(echo "$PHPCONFDIR_CLI" | sed 's|/cli/|/fpm/|')
+fi
+
+enable_cc() {
+ if [ "$TRAVIS" = true ]; then
+ phpenv config-add tests/ci/config/codecoverage_xdebug.ini
+
+ pkill php-fpm
+ ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
+ else
+ if [ -L "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"; fi
+ sudo ln -s $(realpath tests/ci/config/codecoverage_xdebug.ini) "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"
+ if [ -L "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"; fi
+ sudo ln -s $(realpath tests/ci/config/codecoverage_xdebug.ini) "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"
+
+ sudo service php-fpm restart
+ fi
+}
+
+disable_cc() {
+ if [ "$TRAVIS" = true ]; then
+ phpenv config-rm tests/ci/config/codecoverage_xdebug.ini
+
+ pkill php-fpm
+ ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
+ else
+ if [ -L "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"; fi
+ if [ -L "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"; fi
+
+ sudo service php-fpm restart
+ fi
+}
+
+case "$1" in
+ enable | on)
+ enable_cc
+ ;;
+ disable | off)
+ disable_cc
+ ;;
+ *)
+ echo "ERROR: unknown action '${1}', please use 'enable' or 'disable'" >&2
+ exit 1
+ ;;
+esac
# To be kept in sync with setup_php_travis.sh
+# @todo make it optional to disable xdebug ?
+
set -e
configure_php_ini() {
+ # note: these settings are not required for cli config
echo "cgi.fix_pathinfo = 1" >> "${1}"
echo "always_populate_raw_post_data = -1" >> "${1}"
- # @todo this only disables xdebug for CLI. To do the same for the FPM config as well, should we use instead `phpdismod` ?
- XDEBUG_INI=$(php -i | grep xdebug.ini | grep -v '=>' | head -1)
- if [ "$XDEBUG_INI" != "" ]; then
- XDEBUG_INI="$(echo "$XDEBUG_INI" | tr -d ',')"
- mv "$XDEBUG_INI" "$XDEBUG_INI.bak";
- fi
+ # we disable xdebug for speed for both cli and web mode
+ phpdismod xdebug
}
# install php
# To be kept in sync with setup_php.sh
+# @todo make it optional to disable xdebug ?
+
set -e
SCRIPT_DIR="$(dirname -- "$(readlink -f "$0")")"
echo "cgi.fix_pathinfo = 1" >> "${1}"
echo "always_populate_raw_post_data = -1" >> "${1}"
- # @todo this only disables xdebug for CLI. To do the same for the FPM config as well, should we use instead `phpdismod` ?
- XDEBUG_INI=$(php -i | grep xdebug.ini | grep -v '=>' | head -1)
- if [ "$XDEBUG_INI" != "" ]; then
- XDEBUG_INI="$(echo "$XDEBUG_INI" | tr -d ',')"
- mv "$XDEBUG_INI" "$XDEBUG_INI.bak";
- fi
+ # we disable xdebug for speed for both cli and web mode
+ phpenv config-rm xdebug.ini
}
PHPVER=$(phpenv version-name)