Skip to content

Commit 05a9f7f

Browse files
committed
upgrade phpunit to version 8
1 parent 8aea39a commit 05a9f7f

9 files changed

+28
-34
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: yii2-openapi
22
on:
33
push:
4-
branches: [ master, wip]
4+
branches: [ master ]
55
pull_request:
6-
branches: [ master, wip ]
6+
branches: [ master ]
77
paths-ignore:
88
- 'docs/**'
99
- '*.md'

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/phpunit.xml
44
/.php_cs.cache
55
/.env
6+
/.phpunit.result.cache

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ up:
4242
docker-compose exec -T mysql timeout 60s sh -c "while ! (mysql --execute \"ALTER USER 'dbuser'@'%' IDENTIFIED WITH mysql_native_password BY 'dbpass';\" > /dev/null 2>&1); do echo -n '.'; sleep 0.1 ; done; echo 'ok'" || (docker-compose ps; docker-compose logs; exit 1)
4343

4444
cli:
45-
docker-compose exec php bash
45+
docker-compose exec --user=$$(id -u) php bash
4646

4747
migrate:
48-
docker-compose run --rm php sh -c 'mkdir -p "tests/tmp/app"'
49-
docker-compose run --rm php sh -c 'mkdir -p "tests/tmp/docker_app"'
50-
docker-compose run --rm php sh -c 'cd /app/tests && ./yii migrate --interactive=0'
48+
docker-compose run --user=$$(id -u) --rm php sh -c 'mkdir -p "tests/tmp/app"'
49+
docker-compose run --user=$$(id -u) --rm php sh -c 'mkdir -p "tests/tmp/docker_app"'
50+
docker-compose run --user=$$(id -u) --rm php sh -c 'cd /app/tests && ./yii migrate --interactive=0'
5151

5252
installdocker:
53-
docker-compose run --rm php composer install && chmod +x tests/yii
53+
docker-compose run --user=$$(id -u) --rm php composer install && chmod +x tests/yii
5454

5555
testdocker:
56-
docker-compose run --rm php sh -c 'vendor/bin/phpunit'
56+
docker-compose run --user=$$(id -u) --rm php sh -c 'vendor/bin/phpunit'
5757

5858
efs: clean_all up migrate # Everything From Scratch
5959

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"require-dev": {
3131
"cebe/indent": "*",
3232
"friendsofphp/php-cs-fixer": "~2.16",
33-
"phpunit/phpunit": "^6.5|^8.0|^9.0",
33+
"phpunit/phpunit": "^8.0",
3434
"yiisoft/yii2-gii": ">=2.1.0"
3535
},
3636
"autoload": {

phpunit.xml.dist

+12-9
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
convertNoticesToExceptions="true"
66
convertWarningsToExceptions="true"
77
stopOnFailure="false">
8-
<testsuites>
9-
<testsuite name="Test Suite">
10-
<directory suffix="Test.php">./tests/unit</directory>
11-
</testsuite>
12-
</testsuites>
13-
<filter>
14-
<blacklist>
8+
<testsuites>
9+
<testsuite name="Test Suite">
10+
<directory suffix="Test.php">./tests/unit</directory>
11+
</testsuite>
12+
</testsuites>
13+
<filter>
14+
<whitelist processUncoveredFilesFromWhitelist="true">
15+
<directory suffix=".php">./src</directory>
16+
<exclude>
1517
<directory>./vendor</directory>
1618
<directory>./tests</directory>
17-
</blacklist>
18-
</filter>
19+
</exclude>
20+
</whitelist>
21+
</filter>
1922
</phpunit>

tests/DbTestCase.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function destroyApplication()
3535
Yii::$container = new Container();
3636
}
3737

38-
protected function setUp()
38+
protected function setUp(): void
3939
{
4040
if (getenv('IN_DOCKER') !== 'docker') {
4141
$this->markTestSkipped('For docker env only');
@@ -45,7 +45,7 @@ protected function setUp()
4545
parent::setUp();
4646
}
4747

48-
protected function tearDown()
48+
protected function tearDown(): void
4949
{
5050
parent::tearDown();
5151
if (getenv('IN_DOCKER') === 'docker') {

tests/TestCase.php

-10
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@
1313

1414
class TestCase extends \PHPUnit\Framework\TestCase
1515
{
16-
public static function assertEqualsCanonicalizing($expected, $actual, string $message = '')
17-
{
18-
if ((int)Version::id()[0] >= 8) {
19-
parent::assertEqualsCanonicalizing($expected, $actual, $message);
20-
} else {
21-
self::assertTrue(empty(array_diff($expected, $actual)) && empty(array_diff($actual, $expected)));
22-
}
23-
24-
}
25-
2616
protected function prepareTempDir()
2717
{
2818
FileHelper::removeDirectory(__DIR__ . '/tmp/app');

tests/unit/MultiDbFreshMigrationTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testMysql()
5858
$this->compareFiles($expectedFiles, $testFile);
5959
}
6060

61-
protected function setUp()
61+
protected function setUp(): void
6262
{
6363
if (getenv('IN_DOCKER') !== 'docker') {
6464
$this->markTestSkipped('For docker env only');
@@ -68,7 +68,7 @@ protected function setUp()
6868
parent::setUp();
6969
}
7070

71-
protected function tearDown()
71+
protected function tearDown(): void
7272
{
7373
parent::tearDown();
7474
if (getenv('IN_DOCKER') === 'docker') {

tests/unit/MultiDbSecondaryMigrationTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testMysql()
6767
$this->compareFiles($expectedFiles, $testFile);
6868
}
6969

70-
protected function setUp()
70+
protected function setUp(): void
7171
{
7272
if (getenv('IN_DOCKER') !== 'docker') {
7373
$this->markTestSkipped('For docker env only');
@@ -77,7 +77,7 @@ protected function setUp()
7777
parent::setUp();
7878
}
7979

80-
protected function tearDown()
80+
protected function tearDown(): void
8181
{
8282
parent::tearDown();
8383
if (getenv('IN_DOCKER') === 'docker') {

0 commit comments

Comments
 (0)