Skip to content

Commit

Permalink
upgrade PHPUnit to v10+
Browse files Browse the repository at this point in the history
  • Loading branch information
deminy committed May 25, 2024
1 parent 8d15127 commit 459c6c7
Show file tree
Hide file tree
Showing 30 changed files with 80 additions and 254 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"ext-json": "*",
"ext-redis": "*",
"ext-curl": "*",
"phpunit/phpunit": "~9.0 || ~10.0 || ~11.0",
"phpunit/phpunit": "~10.0 || ~11.0",
"swoole/ide-helper": "dev-master"
},
"suggest": {
Expand Down
23 changes: 2 additions & 21 deletions tests/unit/ArrayObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

namespace Swoole;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @internal
* @coversNothing
*/
#[CoversClass(ArrayObject::class)]
class ArrayObjectTest extends TestCase
{
private ArrayObject $data;
Expand All @@ -29,12 +30,6 @@ class ArrayObjectTest extends TestCase

private array $control_data;

/**
* ArrayObjectTest constructor.
* @covers \Swoole\ArrayObject::each()
* @covers \Swoole\ArrayObject::split()
* @param string $dataName
*/
public function __construct(?string $name = null, array $data = [], $dataName = '')
{
$_data = '11, 33, 22, 44,12,32,55, 23,19,23';
Expand Down Expand Up @@ -63,19 +58,11 @@ public function __construct(?string $name = null, array $data = [], $dataName =
parent::__construct($name, $data, $dataName);
}

/**
* @covers \Swoole\ArrayObject::toArray()
*/
public function testToArray()
{
$this->assertEquals($this->data->toArray(), $this->control_data);
}

/**
* @covers \Swoole\ArrayObject::each()
* @covers \Swoole\ArrayObject::sort()
* @covers \Swoole\ArrayObject::unique()
*/
public function testMix()
{
$datao = clone $this->data;
Expand All @@ -88,17 +75,11 @@ public function testMix()
$this->assertEquals($data, $expectResult);
}

/**
* @covers \Swoole\ArrayObject::serialize()
*/
public function testSerialize()
{
$this->assertEquals(serialize($this->data->toArray()), $this->data->serialize());
}

/**
* @covers \Swoole\ArrayObject::unique()
*/
public function testUnique()
{
$data = $this->data->unique()->toArray();
Expand Down
17 changes: 2 additions & 15 deletions tests/unit/Coroutine/BarrierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@

namespace Swoole\Coroutine;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Swoole\Coroutine;

/**
* @internal
* @coversNothing
*/
#[CoversClass(Barrier::class)]
class BarrierTest extends TestCase
{
/**
* @covers \Swoole\Coroutine\Barrier
*/
public function testWait()
{
run(function () {
Expand All @@ -43,9 +41,6 @@ public function testWait()
});
}

/**
* @covers \Swoole\Coroutine\Barrier
*/
public function testWaitTimeout()
{
run(function () {
Expand Down Expand Up @@ -73,8 +68,6 @@ public function testWaitTimeout()

/**
* Test without execution switching between coroutines.
*
* @covers \Swoole\Coroutine\Barrier
*/
public function testNoCoroutineSwitching()
{
Expand All @@ -95,8 +88,6 @@ public function testNoCoroutineSwitching()

/**
* Test without any child coroutines created. Ideally we shouldn't use the Barrier class this way.
*
* @covers \Swoole\Coroutine\Barrier
*/
public function testWithoutAnyChildCoroutines()
{
Expand All @@ -109,8 +100,6 @@ public function testWithoutAnyChildCoroutines()

/**
* Test with the Barrier object destroyed in a child coroutine. Ideally we shouldn't use the Barrier class this way.
*
* @covers \Swoole\Coroutine\Barrier
*/
public function testUnexpectedDestroy()
{
Expand All @@ -129,8 +118,6 @@ public function testUnexpectedDestroy()

/**
* Test with the Barrier object destroyed in a child coroutine following by a coroutine switching. Ideally we shouldn't use the Barrier class this way.
*
* @covers \Swoole\Coroutine\Barrier
*/
public function testUnexpectedDestroyWithCoroutineSwitching()
{
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/Coroutine/FunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@

namespace Swoole\Coroutine;

use PHPUnit\Framework\Attributes\CoversFunction;
use PHPUnit\Framework\TestCase;
use Swoole\Runtime;

/**
* @internal
* @coversNothing
*/
#[CoversFunction('Swoole\Coroutine\batch')]
#[CoversFunction('Swoole\Coroutine\go')]
#[CoversFunction('Swoole\Coroutine\parallel')]
#[CoversFunction('Swoole\Coroutine\map')]
class FunctionTest extends TestCase
{
public function testBatchTimeout()
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/Coroutine/HttpFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Swoole\Coroutine;

use PHPUnit\Framework\Attributes\CoversFunction;
use PHPUnit\Framework\TestCase;
use Swoole\Constant;
use Swoole\Coroutine;
Expand All @@ -22,6 +23,8 @@
* @internal
* @coversNothing
*/
#[CoversFunction('Swoole\Coroutine\Http\get')]
#[CoversFunction('Swoole\Coroutine\Http\post')]
class HttpFunctionTest extends TestCase
{
public function testGet()
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Coroutine/WaitGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

namespace Swoole\Coroutine;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @internal
* @coversNothing
*/
#[CoversClass(WaitGroup::class)]
class WaitGroupTest extends TestCase
{
public function testWait()
Expand Down
39 changes: 4 additions & 35 deletions tests/unit/Curl/HandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Swoole\Curl;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\TestCase;
use Swoole\Coroutine;
use Swoole\Tests\HookFlagsTrait;
Expand All @@ -19,9 +21,9 @@
* Class HandlerTest
*
* @internal
* @coversNothing
* @runTestsInSeparateProcesses
*/
#[CoversClass(Handler::class)]
#[RunTestsInSeparateProcesses]
class HandlerTest extends TestCase
{
use HookFlagsTrait;
Expand All @@ -44,9 +46,6 @@ public function setUp(): void
self::setHookFlags(SWOOLE_HOOK_CURL);
}

/**
* @covers \Swoole\Curl\Handler::execute()
*/
public function testRedirect()
{
Coroutine\run(function () {
Expand All @@ -62,9 +61,6 @@ public function testRedirect()
});
}

/**
* @covers \Swoole\Curl\Handler::__toString()
*/
public function testToString()
{
Coroutine\run(function () {
Expand All @@ -73,9 +69,6 @@ public function testToString()
});
}

/**
* @covers \Swoole\Curl\Handler::execute()
*/
public function testCustomHost()
{
Coroutine\run(function () {
Expand All @@ -90,9 +83,6 @@ public function testCustomHost()
});
}

/**
* @covers \Swoole\Curl\Handler::execute()
*/
public function testHeaderName()
{
Coroutine\run(function () {
Expand All @@ -109,9 +99,6 @@ public function testHeaderName()
});
}

/**
* @covers \Swoole\Curl\Handler::execute()
*/
public function testWriteFunction()
{
Coroutine\run(function () {
Expand All @@ -132,9 +119,6 @@ public function testWriteFunction()
});
}

/**
* @covers \Swoole\Curl\Handler::execute()
*/
public function testResolve()
{
Coroutine\run(function () {
Expand All @@ -157,9 +141,6 @@ public function testResolve()
});
}

/**
* @covers \Swoole\Curl\Handler::execute()
*/
public function testInvalidResolve()
{
Coroutine\run(function () {
Expand All @@ -180,9 +161,6 @@ public function testInvalidResolve()
});
}

/**
* @covers \Swoole\Curl\Handler::execute()
*/
public function testResolve2()
{
Coroutine\run(function () {
Expand All @@ -204,9 +182,6 @@ public function testResolve2()
});
}

/**
* @covers \Swoole\Curl\Handler::execute()
*/
public function testInvalidResolve2()
{
Coroutine\run(function () {
Expand All @@ -227,9 +202,6 @@ public function testInvalidResolve2()
});
}

/**
* @covers \Swoole\Curl\Handler::execute()
*/
public function testInvalidResolve3()
{
Coroutine\run(function () {
Expand All @@ -250,9 +222,6 @@ public function testInvalidResolve3()
});
}

/**
* @covers \Swoole\Curl\Handler::execute()
*/
public function testResolve3()
{
Coroutine\run(function () {
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Database/PDOPoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Swoole\Database;

use PHPUnit\Framework\Attributes\CoversClass;
use Swoole\Coroutine;
use Swoole\Coroutine\WaitGroup;
use Swoole\Tests\DatabaseTestCase;
Expand All @@ -23,8 +24,8 @@
* Class PDOPoolTest
*
* @internal
* @coversNothing
*/
#[CoversClass(PDOPool::class)]
class PDOPoolTest extends DatabaseTestCase
{
use HookFlagsTrait;
Expand Down
17 changes: 4 additions & 13 deletions tests/unit/Database/PDOStatementProxyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@

namespace Swoole\Database;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Swoole\Coroutine;
use Swoole\Tests\DatabaseTestCase;

/**
* Class PDOStatementProxyTest
*
* @internal
* @coversNothing
*/
#[CoversClass(PDOStatementProxy::class)]
class PDOStatementProxyTest extends DatabaseTestCase
{
/**
* @covers \Swoole\Database\PDOStatementProxy::__call()
*/
public function testRun()
{
Coroutine\run(function () {
Expand Down Expand Up @@ -68,10 +65,7 @@ public static function dataSetFetchMode(): array
];
}

/**
* @dataProvider dataSetFetchMode
* @covers \Swoole\Database\PDOStatementProxy::setFetchMode
*/
#[DataProvider('dataSetFetchMode')]
public function testSetFetchMode(array $expected, array $args, string $message)
{
Coroutine\run(function () use ($expected, $args, $message) {
Expand All @@ -89,9 +83,6 @@ public function testSetFetchMode(array $expected, array $args, string $message)
});
}

/**
* @covers \Swoole\Database\PDOStatementProxy::bindParam()
*/
public function testBindParam()
{
Coroutine\run(function () {
Expand Down
Loading

0 comments on commit 459c6c7

Please sign in to comment.