Skip to content

Commit

Permalink
Raise PhpUnit to ^10.5 + Improve CI + Remove asset-packagist.org us…
Browse files Browse the repository at this point in the history
…age (#238)
  • Loading branch information
vjik authored Jan 7, 2024
1 parent 37cd41b commit d39ffff
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 90 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
| Is bugfix? | ✔️/❌
| New feature? | ✔️/❌
| Breaks BC? | ✔️/❌
| Fixed issues | comma-separated list of tickets # fixed by the PR, if any
26 changes: 13 additions & 13 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions.
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
# Too noisy. See https://github.community/t/increase-if-necessary-for-github-actions-in-dependabot/179581
open-pull-requests-limit: 0
# Maintain dependencies for GitHub Actions.
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
# Too noisy. See https://github.community/t/increase-if-necessary-for-github-actions-in-dependabot/179581
open-pull-requests-limit: 0

# Maintain dependencies for Composer
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
versioning-strategy: increase-if-necessary
# Maintain dependencies for Composer
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
versioning-strategy: increase-if-necessary
40 changes: 29 additions & 11 deletions .github/workflows/bc.yml_
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
on:
- pull_request
- push
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
- 'psalm.xml'
push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
- 'psalm.xml'

name: backwards compatibility

jobs:
roave_bc_check:
name: Roave BC Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Roave BC Check
uses: docker://nyholm/roave-bc-check-ga
roave_bc_check:
uses: yiisoft/actions/.github/workflows/bc.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.1']
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- 'psalm.xml'

push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- 'psalm.xml'

push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -30,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.1']
['8.1', '8.2', '8.3']
3 changes: 2 additions & 1 deletion .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'psalm.xml'

push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -26,6 +27,6 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.1']
['8.2']
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
4 changes: 3 additions & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ name: rector
jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector.yml@master
secrets:
token: ${{ secrets.YIISOFT_GITHUB_TOKEN }}
with:
os: >-
['ubuntu-latest']
php: >-
['8.1']
['8.3']
1 change: 1 addition & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- 'phpunit.xml.dist'

push:
branches: ['master']
paths-ignore:
- 'docs/**'
- 'README.md'
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ composer.phar
# Mac DS_Store Files
.DS_Store

# phpunit itself is not needed
# PhpUnit itself is not needed
phpunit.phar
# local phpunit config
# local PhpUnit config
/phpunit.xml
# PhpUnit cache
/.phpunit.cache

# local tests configuration
/tests/data/config.local.php
/tests/Storage/runtime

.phpunit.result.cache
8 changes: 1 addition & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"ext-sockets": "*",
"maglnet/composer-require-checker": "^4.2",
"nyholm/psr7": "^1.3",
"phpunit/phpunit": "^9.4",
"phpunit/phpunit": "^10.5",
"rector/rector": "^0.15.18",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
Expand Down Expand Up @@ -87,12 +87,6 @@
"events-console": "events-console.php"
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"config": {
"sort-packages": true,
"allow-plugins": {
Expand Down
30 changes: 17 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
failOnRisky="true"
failOnWarning="true"
executionOrder="random"
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
executionOrder="random"
failOnRisky="true"
failOnWarning="true"
stopOnFailure="false"
colors="true"
>
<php>
<ini name="error_reporting" value="-1"/>
Expand All @@ -19,9 +22,10 @@
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory>src</directory>
<directory suffix=".php">./src</directory>
<directory suffix=".php">./config</directory>
</include>
</coverage>
</source>
</phpunit>
7 changes: 3 additions & 4 deletions tests/Unit/Collector/FilesystemStreamCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Yiisoft\Yii\Debug\Tests\Unit\Collector;

use PHPUnit\Framework\Attributes\DataProvider;
use Yiisoft\Files\FileHelper;
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
use Yiisoft\Yii\Debug\Collector\Stream\FilesystemStreamCollector;
Expand Down Expand Up @@ -33,9 +34,7 @@ protected function collectTestData(CollectorInterface $collector): void
);
}

/**
* @dataProvider dataSkipCollectOnMatchIgnoreReferences
*/
#[DataProvider('dataSkipCollectOnMatchIgnoreReferences')]
public function testSkipCollectOnMatchIgnoreReferences(
string $path,
callable $before,
Expand Down Expand Up @@ -64,7 +63,7 @@ public function testSkipCollectOnMatchIgnoreReferences(
$this->assertEquals($result, $collected);
}

public function dataSkipCollectOnMatchIgnoreReferences(): iterable
public static function dataSkipCollectOnMatchIgnoreReferences(): iterable
{
$mkdirBefore = function (string $path) {
if (is_dir($path)) {
Expand Down
34 changes: 17 additions & 17 deletions tests/Unit/Collector/HttpStreamCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Yiisoft\Yii\Debug\Tests\Unit\Collector;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
use Yiisoft\Yii\Debug\Collector\Stream\HttpStreamCollector;
use Yiisoft\Yii\Debug\Tests\Shared\AbstractCollectorTestCase;
Expand All @@ -27,9 +29,7 @@ protected function collectTestData(CollectorInterface $collector): void
);
}

/**
* @dataProvider dataSkipCollectOnMatchIgnoreReferences
*/
#[DataProvider('dataSkipCollectOnMatchIgnoreReferences')]
public function testSkipCollectOnMatchIgnoreReferences(
string $url,
callable $before,
Expand Down Expand Up @@ -60,11 +60,11 @@ public function testSkipCollectOnMatchIgnoreReferences(
if (is_array($assertResult)) {
$this->assertSame($assertResult, $collected);
} else {
$assertResult($url, $collected);
$assertResult($this, $url, $collected);
}
}

public function dataSkipCollectOnMatchIgnoreReferences(): iterable
public static function dataSkipCollectOnMatchIgnoreReferences(): iterable
{
$httpStreamBefore = function (string $url) {
};
Expand All @@ -86,23 +86,23 @@ public function dataSkipCollectOnMatchIgnoreReferences(): iterable
[],
$httpStreamOperation,
$httpStreamAfter,
function (string $url, array $collected) {
$this->assertArrayHasKey('read', $collected);
$this->assertIsArray($collected['read']);
$this->assertCount(1, $collected['read']);
function (TestCase $testCase, string $url, array $collected) {
$testCase->assertArrayHasKey('read', $collected);
$testCase->assertIsArray($collected['read']);
$testCase->assertCount(1, $collected['read']);

$readItem = $collected['read'][0];
$this->assertSame($url, $readItem['uri']);
$this->assertArrayHasKey('args', $readItem);
$testCase->assertSame($url, $readItem['uri']);
$testCase->assertArrayHasKey('args', $readItem);

$readItemArgs = $readItem['args'];
$this->assertCount(3, $readItemArgs);
$testCase->assertCount(3, $readItemArgs);

$this->assertSame('GET', $readItemArgs['method']);
$this->assertIsArray($readItemArgs['response_headers']);
$this->assertNotEmpty($readItemArgs['response_headers']);
$this->assertIsArray($readItemArgs['request_headers']);
$this->assertEmpty($readItemArgs['request_headers']);
$testCase->assertSame('GET', $readItemArgs['method']);
$testCase->assertIsArray($readItemArgs['response_headers']);
$testCase->assertNotEmpty($readItemArgs['response_headers']);
$testCase->assertIsArray($readItemArgs['request_headers']);
$testCase->assertEmpty($readItemArgs['request_headers']);
},
];
yield 'file stream ignored by path' => [
Expand Down
7 changes: 0 additions & 7 deletions tests/Unit/DebugServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Psr\EventDispatcher\ListenerProviderInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Yiisoft\Definitions\Exception\InvalidConfigException;
use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;
use Yiisoft\EventDispatcher\Dispatcher\Dispatcher;
Expand All @@ -20,12 +19,6 @@

final class DebugServiceProviderTest extends TestCase
{
/**
* @throws InvalidConfigException
*
* @covers \Yiisoft\Yii\Debug\DebugServiceProvider::getDefinitions()
* @covers \Yiisoft\Yii\Debug\DebugServiceProvider::getExtensions()
*/
public function testRegister(): void
{
$config = ContainerConfig::create()
Expand Down
7 changes: 0 additions & 7 deletions tests/Unit/ProxyServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Psr\EventDispatcher\ListenerProviderInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Yiisoft\Definitions\Exception\InvalidConfigException;
use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;
use Yiisoft\EventDispatcher\Dispatcher\Dispatcher;
Expand All @@ -20,12 +19,6 @@

final class ProxyServiceProviderTest extends TestCase
{
/**
* @throws InvalidConfigException
*
* @covers \Yiisoft\Yii\Debug\ProxyServiceProvider::getDefinitions()
* @covers \Yiisoft\Yii\Debug\ProxyServiceProvider::getExtensions()
*/
public function testRegister(): void
{
$config = ContainerConfig::create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Yiisoft\Yii\Debug\Storage\MemoryStorage;
use Yiisoft\Yii\Debug\Storage\StorageInterface;

abstract class AbstractStorageTest extends TestCase
abstract class AbstractStorageTestCase extends TestCase
{
/**
* @dataProvider dataProvider()
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Storage/FileStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Yiisoft\Yii\Debug\Storage\FileStorage;
use Yiisoft\Yii\Debug\Storage\StorageInterface;

final class FileStorageTest extends AbstractStorageTest
final class FileStorageTest extends AbstractStorageTestCase
{
private string $path = __DIR__ . '/runtime';

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Storage/MemoryStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Yiisoft\Yii\Debug\Storage\MemoryStorage;
use Yiisoft\Yii\Debug\Storage\StorageInterface;

final class MemoryStorageTest extends AbstractStorageTest
final class MemoryStorageTest extends AbstractStorageTestCase
{
public function getStorage(DebuggerIdGenerator $idGenerator): StorageInterface
{
Expand Down

0 comments on commit d39ffff

Please sign in to comment.