Skip to content

Commit 0d24d6c

Browse files
authored
Handle change in PHPUnit invocation syntax (#235)
* Handle change in PHPUnit invocation syntax * Add todo to remove PHPUnit v 9 support in future release
1 parent 4e0b6f9 commit 0d24d6c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
},
6161
"require-dev": {
6262
"phpstan/phpstan-strict-rules": "^1.5 || ^2.0",
63-
"drupal/core": "*"
63+
"drupal/core": "*",
64+
"phpunit/phpunit": "*"
6465
}
6566
}

src/Robo/Plugin/Commands/CICommands.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ class CICommands extends Tasks
2222
*/
2323
protected const PHPCS_DEFAULT_PHP_VERSION = '8.1';
2424

25+
/**
26+
* The maximum PHPUnit version that allows the --verbose flag.
27+
*/
28+
protected const PHPUNIT_MAX_VERSION_WITH_VERBOSE_FLAG = 9;
29+
2530
/**
2631
* RoboFile constructor.
2732
*/
@@ -35,9 +40,22 @@ public function __construct()
3540
* Command to run unit tests.
3641
*
3742
* @aliases punit
43+
*
44+
* @todo Remove support for PHPUnit --verbose syntax in next major Usher
45+
* version.
3846
*/
3947
public function jobRunUnitTests(): Result
4048
{
49+
exec("phpunit --version | awk '{print $2}'", $output, $result_code);
50+
if ($result_code === 0) {
51+
$major_version = (int) $output[0];
52+
if ($major_version > self::PHPUNIT_MAX_VERSION_WITH_VERBOSE_FLAG) {
53+
return $this->taskExec(
54+
'XDEBUG_MODE=coverage vendor/bin/phpunit --debug --log-events-verbose-text phpunit.log'
55+
)->run();
56+
}
57+
}
58+
// Default to old PHPUnit verbose flag syntax.
4159
return $this->taskExec('XDEBUG_MODE=coverage vendor/bin/phpunit --debug --verbose')->run();
4260
}
4361

0 commit comments

Comments
 (0)