Skip to content

Commit 1536bbd

Browse files
authored
Fix co-phpunit and co-pest, optimize ci workflows (#5825)
1 parent e89ec3f commit 1536bbd

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed
File renamed without changes.

co-phpunit

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,29 @@ if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
4545
fwrite(STDERR, 'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL . ' composer install' . PHP_EOL . PHP_EOL . 'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL);
4646
die(1);
4747
}
48-
if (!isset(getopt('', ['prepend:'])['prepend'])) {
49-
(function () {
50-
$prepend = null;
51-
foreach ($_SERVER['argv'] as $index => $argv) {
52-
// --prepend /path/to/file
53-
if ($argv === '--prepend') {
54-
$prepend = $_SERVER['argv'][$index + 1] ?? null;
55-
break;
56-
}
57-
// --prepend=/path/to/file
58-
if (strpos($argv, '--prepend=') === 0) {
59-
$prepend = substr($argv, 10);
60-
break;
48+
(function () {
49+
$prepend = null;
50+
foreach ($_SERVER["argv"] as $index => $argv) {
51+
// --prepend /path/to/file
52+
if ($argv === "--prepend") {
53+
unset($_SERVER["argv"][$index]);
54+
if (isset($_SERVER["argv"][$index + 1])) {
55+
$prepend = $_SERVER["argv"][$index + 1];
56+
unset($_SERVER["argv"][$index + 1]);
6157
}
58+
break;
6259
}
63-
if ($prepend !== null && file_exists($prepend)) {
64-
require $prepend;
60+
// --prepend=/path/to/file
61+
if (strpos($argv, "--prepend=") === 0) {
62+
$prepend = substr($argv, 10);
63+
unset($_SERVER["argv"][$index]);
64+
break;
6565
}
66-
})();
67-
}
66+
}
67+
if ($prepend !== null && file_exists($prepend)) {
68+
require $prepend;
69+
}
70+
})();
6871
require PHPUNIT_COMPOSER_INSTALL;
6972
$code = 0;
7073
Swoole\Coroutine::set(['hook_flags' => SWOOLE_HOOK_ALL, 'exit_condition' => function () {

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@
3232
"hyperf/utils": "~3.1.0",
3333
"symfony/http-foundation": "^5.4|^6.0"
3434
},
35+
"suggest": {
36+
"pestphp/pest": "For testing with Pest"
37+
},
3538
"extra": {
3639
"branch-alias": {
3740
"dev-master": "3.0-dev"
3841
}
3942
},
4043
"bin": [
4144
"co-phpunit",
42-
"co-pest"
45+
"bin/co-pest"
4346
]
4447
}

src/AssertableJsonString.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use Hyperf\Testing\Assert as PHPUnit;
2121
use JsonSerializable;
2222

23+
use function Hyperf\Collection\data_get;
24+
2325
class AssertableJsonString implements ArrayAccess, Countable
2426
{
2527
/**

0 commit comments

Comments
 (0)