Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility for PHP8 #116

Merged
merged 10 commits into from
Mar 1, 2021
18 changes: 14 additions & 4 deletions DEVELOP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ Installation

Install prerequisites::

# Install different PHP releases.
brew install php@7.3 php@7.4 php@8.0 composer
# Install different PHP releases and Composer.
brew install php@7.3 php@7.4 php@8.0 brew-php-switcher composer

# Select PHP version.
brew-php-switcher 7.3
brew-php-switcher 7.4
brew-php-switcher 8.0

# Install xdebug extension for tracking code coverage.
# Install `xdebug` extension into each environment for tracking code coverage.
pecl install xdebug

Get the sources::
Expand All @@ -113,9 +113,19 @@ Running the Tests
--mount type=bind,source=$PWD/test/provisioning/truststore,target=/vagrant/test/provisioning/truststore \
--publish 4200:4200 --publish 5432:5432 crate/crate:nightly

# Run test suite
# Run test suite on current/default version of PHP
composer run test

# Run tests on both PHP7 and PHP8 to get the full picture of coverage
composer run multicover
open build/multicover/html/index.html


Invoke code style checks
========================

::

# Run code style checks
composer run check-style

Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
},
"scripts": {
"test": "XDEBUG_MODE=coverage phpunit --coverage-clover build/logs/clover.xml",
"coverage-html": "XDEBUG_MODE=coverage phpunit --coverage-html build/logs/html",
"multicover": "./devtools/php-multicover.sh",
"check-style": "phpcs",
"fix-style": "phpcbf"
}
Expand Down
63 changes: 63 additions & 0 deletions devtools/php-multicover.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh
#
# About
# =====
#
# Run tests with coverage on both PHP7 and PHP8,
# merge coverage reports and render them as HTML.
#
# Please adjust the paths to the PHP interpreters
# to fit your needs. Make sure to `pecl install xdebug`
# in both PHP7 and PHP8 environments beforehand.
#
# Setup
# =====
#
# Install different PHP releases and Composer::
#
# brew install php@7.3 php@7.4 php@8.0 brew-php-switcher composer
#
# Select PHP version::
#
# brew-php-switcher 7.3
# brew-php-switcher 7.4
# brew-php-switcher 8.0
#
# Install `xdebug` extension into each environment for tracking code coverage::
#
# pecl install xdebug
#
# Install `phpunit-merger`::
#
# composer require --dev nimut/phpunit-merger
#
# Please make sure to remove it before committing as it is currently not available for PHP8::
#
# composer remove --dev nimut/phpunit-merger
#

# Define shortcuts to executables.
php7=/usr/local/Cellar/php@7.4/7.4.15/bin/php
php8=/usr/local/Cellar/php/8.0.2/bin/php
phpunit="$(pwd)/vendor/bin/phpunit"
phpunit_merger="$(pwd)/vendor/bin/phpunit-merger"

# Prepare output directories.
mkdir -p build/multicover/reports build/multicover/html
rm -rf build/multicover/reports/* build/multicover/html/*

# Enable coverage tracing.
export XDEBUG_MODE=coverage

# Run tests with PHP coverage output on both PHP7 and PHP8.
echo Running tests with coverage on PHP7
$php7 $phpunit --coverage-php build/multicover/reports/clover-php7.php
echo; echo

echo Running tests with coverage on PHP8
$php8 $phpunit --coverage-php build/multicover/reports/clover-php8.php
echo; echo

# Merge coverage reports and generate HTML output.
echo Merging test reports
$php7 $phpunit_merger coverage build/multicover/reports --html=build/multicover/html /dev/null