From 71722e30de490c6e43f3959796307c3d7e072670 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 3 Jun 2019 16:46:45 -0700 Subject: [PATCH] tools/scripts/phpunit - Accept `--tap` on PHP 7.x / PHPUnit 6.x The `--tap` option was removed in PHPUnit 6.x. For backwared compatibility, the preceding commit adds a printer with same/similar output format. This continues adding the backward comapt by respecting `--tap` as an alias for `--printer Civi/Test/TAP`. --- tools/scripts/phpunit | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/scripts/phpunit b/tools/scripts/phpunit index 88617e471e..fd28402746 100755 --- a/tools/scripts/phpunit +++ b/tools/scripts/phpunit @@ -10,11 +10,20 @@ * This script is an adapter for backwards compatibility. */ +$argFilters = []; + if (PHP_SAPI !== 'cli') { die("phpunit can only be run from command line."); } if (version_compare(PHP_VERSION, '7.0', '>=')) { $phpunit = findCommand('phpunit6'); + $argFilters[] = function ($argv) { + $pos = array_search('--tap', $argv); + if ($pos !== FALSE) { + array_splice($argv, $pos, 1, ['--printer', '\Civi\Test\TAP']); + } + return $argv; + }; } elseif (version_compare(PHP_VERSION, '5.6', '>=')) { $phpunit = findCommand('phpunit5'); @@ -64,6 +73,10 @@ if (is_dir('packages/PHPUnit/')) { } } +foreach ($argFilters as $filter) { + $argv = $filter($argv); +} + $cmd = findPhp() // In case this system has multiple copies of PHP, use the active/preferred one. // . ' -ddisplay_errors=1' -- 2.25.1