Skip to content

Commit 166142b

Browse files
committed
Allow flexibilty in CI unit test runner
1 parent ce991ac commit 166142b

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,12 @@ jobs:
5454
- name: Install latest dependencies
5555
run: composer update ${{ env.COMPOSER_FLAGS }}
5656

57+
# Provides flexibilty for using either simple-phpunit or phpunit
58+
- name: Determine PHPUnit binary
59+
run: |
60+
name=$([ -f vendor/bin/simple-phpunit ] && echo simple-phpunit || echo phpunit)
61+
echo "BIN_PHPUNIT=vendor/bin/$name" >> $GITHUB_ENV
62+
shell: bash
63+
5764
- name: Run tests
58-
run: vendor/bin/simple-phpunit --verbose
65+
run: ${{ env.BIN_PHPUNIT }} --verbose

tests/bootstrap_phpstan.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
<?php
2+
/**
3+
* Provides flexibilty for using either simple-phpunit or phpunit
4+
*/
25

36
$vendorBin = __DIR__.'/../vendor/bin';
7+
8+
// See if we using simple-phpunit
49
$path = realpath($vendorBin.'/simple-phpunit');
510

6-
if (!file_exists($vendorBin.'/phpunit') && $path !== false) {
7-
passthru(escapeshellarg($path).' install');
11+
if ($path !== false) {
12+
// simple-phpunit will update the .phpunit symlink/junction
13+
$phpunit = escapeshellarg(PHP_BINARY).' '.escapeshellarg($path);
14+
passthru($phpunit.' install');
815

916
$autoloader = $vendorBin.'/.phpunit/phpunit/vendor/autoload.php';
10-
if (file_exists($autoloader)) {
11-
require $autoloader;
17+
if (!file_exists($autoloader)) {
18+
echo 'Cannot run PHPStan: simple-phpunit did not install PHPUnit as expected'.PHP_EOL;
19+
exit(1);
1220
}
21+
22+
include $autoloader;
23+
return;
24+
}
25+
26+
if (realpath($vendorBin.'/phpunit') === false) {
27+
echo 'Cannot run PHPStan: PHPUnit has not been installed'.PHP_EOL;
28+
exit(1);
1329
}

0 commit comments

Comments
 (0)