Skip to content

Commit e9d6bc8

Browse files
Bumps phpunit to 10.x (#5802)
Co-authored-by: 李铭昕 <[email protected]>
1 parent f41452d commit e9d6bc8

File tree

6 files changed

+13
-18
lines changed

6 files changed

+13
-18
lines changed

co-phpunit

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ if (!version_compare(PHP_VERSION, PHP_VERSION, '=')) {
1313
fwrite(STDERR, sprintf('%s declares an invalid value for PHP_VERSION.' . PHP_EOL . 'This breaks fundamental functionality such as version_compare().' . PHP_EOL . 'Please use a different PHP interpreter.' . PHP_EOL, PHP_BINARY));
1414
die(1);
1515
}
16-
if (version_compare('7.3.0', PHP_VERSION, '>')) {
17-
fwrite(STDERR, sprintf('This version of PHPUnit requires PHP >= 7.3.' . PHP_EOL . 'You are using PHP %s (%s).' . PHP_EOL, PHP_VERSION, PHP_BINARY));
16+
if (version_compare('8.1.0', PHP_VERSION, '>')) {
17+
fwrite(STDERR, sprintf('This version of PHPUnit requires PHP >= 8.1.' . PHP_EOL . 'You are using PHP %s (%s).' . PHP_EOL, PHP_VERSION, PHP_BINARY));
1818
die(1);
1919
}
2020
$requiredExtensions = ['dom', 'json', 'libxml', 'mbstring', 'tokenizer', 'xml', 'xmlwriter'];
@@ -45,11 +45,6 @@ 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-
$options = getopt('', array('prepend:'));
49-
if (isset($options['prepend'])) {
50-
require $options['prepend'];
51-
}
52-
unset($options);
5348
if (!isset(getopt('', ['prepend:'])['prepend'])) {
5449
(function () {
5550
$prepend = null;
@@ -76,7 +71,7 @@ Swoole\Coroutine::set(['hook_flags' => SWOOLE_HOOK_ALL, 'exit_condition' => func
7671
return Swoole\Coroutine::stats()['coroutine_num'] === 0;
7772
}]);
7873
Swoole\Coroutine\run(function () use(&$code) {
79-
$code = PHPUnit\TextUI\Command::main(false);
74+
$code = (new PHPUnit\TextUI\Application())->run($_SERVER['argv']);
8075
Swoole\Timer::clearAll();
8176
Hyperf\Coordinator\CoordinatorManager::until(Hyperf\Coordinator\Constants::WORKER_EXIT)->resume();
8277
});

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"require": {
2222
"php": ">=8.1",
2323
"psr/container": "^1.0|^2.0",
24-
"phpunit/phpunit": "^9.5",
24+
"phpunit/phpunit": "^10.0",
2525
"hyperf/codec": "~3.1.0",
2626
"hyperf/collection": "~3.1.0",
2727
"hyperf/contract": "~3.1.0",

src/Constraint/ArraySubset.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use ArrayObject;
1515
use PHPUnit\Framework\Constraint\Constraint;
16+
use PHPUnit\Framework\ExpectationFailedException;
1617
use SebastianBergmann\Comparator\ComparisonFailure;
1718
use Traversable;
1819

@@ -52,8 +53,7 @@ public function __construct(iterable $subset, bool $strict = false)
5253
*
5354
* @param mixed $other
5455
*
55-
* @throws \PHPUnit\Framework\ExpectationFailedException
56-
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
56+
* @throws ExpectationFailedException
5757
*/
5858
public function evaluate($other, string $description = '', bool $returnResult = false): ?bool
5959
{
@@ -90,8 +90,6 @@ public function evaluate($other, string $description = '', bool $returnResult =
9090

9191
/**
9292
* Returns a string representation of the constraint.
93-
*
94-
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
9593
*/
9694
public function toString(): string
9795
{
@@ -105,8 +103,6 @@ public function toString(): string
105103
* cases. This method should return the second part of that sentence.
106104
*
107105
* @param mixed $other
108-
*
109-
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
110106
*/
111107
protected function failureDescription($other): string
112108
{

tests/ClientTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@
3737
use HyperfTest\Testing\Stub\Exception\Handler\FooExceptionHandler;
3838
use HyperfTest\Testing\Stub\FooController;
3939
use Mockery;
40+
use PHPUnit\Framework\Attributes\CoversNothing;
4041
use PHPUnit\Framework\TestCase;
4142
use Psr\EventDispatcher\EventDispatcherInterface;
4243

4344
/**
4445
* @internal
4546
* @coversNothing
4647
*/
48+
#[CoversNothing]
4749
class ClientTest extends TestCase
4850
{
4951
public function testClientRequest()

tests/DebugTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
namespace HyperfTest\Testing;
1313

1414
use Hyperf\Testing\Debug;
15+
use PHPUnit\Framework\Attributes\CoversNothing;
1516
use PHPUnit\Framework\TestCase;
1617
use stdClass;
1718

1819
/**
1920
* @internal
2021
* @coversNothing
2122
*/
23+
#[CoversNothing]
2224
class DebugTest extends TestCase
2325
{
2426
public function testGetRefCount()

tests/HttpClientTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Hyperf\Testing\HttpClient;
1515
use Mockery;
16+
use PHPUnit\Framework\Attributes\CoversNothing;
1617
use PHPUnit\Framework\TestCase;
1718
use Psr\Container\ContainerInterface;
1819

@@ -22,16 +23,15 @@
2223
* @internal
2324
* @coversNothing
2425
*/
26+
#[CoversNothing]
2527
class HttpClientTest extends TestCase
2628
{
2729
protected function tearDown(): void
2830
{
2931
Mockery::close();
3032
}
3133

32-
/**
33-
* @group NonCoroutine
34-
*/
34+
#[\PHPUnit\Framework\Attributes\Group('NonCoroutine')]
3535
public function testJsonRequest()
3636
{
3737
run(function () {

0 commit comments

Comments
 (0)