From a4fe339775fd2158120f62e391967c9ae5a2750f Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 12 Jan 2025 19:08:29 +0300 Subject: [PATCH 1/4] Remove scrutinizer --- .gitattributes | 1 - .github/workflows/build.yml | 2 ++ README.md | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitattributes b/.gitattributes index 5583f36..9f9e9af 100644 --- a/.gitattributes +++ b/.gitattributes @@ -26,7 +26,6 @@ /.editorconfig export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.scrutinizer.yml export-ignore /phpunit.xml.dist export-ignore /tests export-ignore /docs export-ignore diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d96407d..b951971 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,8 @@ name: build jobs: phpunit: uses: yiisoft/actions/.github/workflows/phpunit.yml@master + secrets: + codecovToken: ${{ secrets.CODECOV_TOKEN }} with: extensions: fileinfo, pdo, pdo_sqlite, sqlite3 os: >- diff --git a/README.md b/README.md index 8031695..32ea336 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,7 @@ [![Latest Stable Version](https://poser.pugx.org/yiisoft/yii-debug-api/v)](https://packagist.org/packages/yiisoft/yii-debug-api) [![Total Downloads](https://poser.pugx.org/yiisoft/yii-debug-api/downloads)](https://packagist.org/packages/yiisoft/yii-debug-api) [![Build status](https://github.com/yiisoft/yii-debug-api/actions/workflows/build.yml/badge.svg)](https://github.com/yiisoft/yii-debug-api/actions/workflows/build.yml) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yiisoft/yii-debug-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/yii-debug-api/?branch=master) -[![Code Coverage](https://scrutinizer-ci.com/g/yiisoft/yii-debug-api/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yiisoft/yii-debug-api/?branch=master) +[![Code Coverage](https://codecov.io/gh/yiisoft/yii-debug-api/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/yii-debug-api) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fyii-debug-api%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/yii-debug-api/master) [![static analysis](https://github.com/yiisoft/yii-debug-api/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/yii-debug-api/actions?query=workflow%3A%22static+analysis%22) From 744da9f91d58ac0775d6c4d628e7bcc94be4345a Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 12 Jan 2025 19:24:40 +0300 Subject: [PATCH 2/4] fix tests --- .../Repository/CollectorRepositoryTest.php | 88 ++++++++----------- 1 file changed, 35 insertions(+), 53 deletions(-) diff --git a/tests/Unit/Debug/Repository/CollectorRepositoryTest.php b/tests/Unit/Debug/Repository/CollectorRepositoryTest.php index b62153b..170a4ad 100644 --- a/tests/Unit/Debug/Repository/CollectorRepositoryTest.php +++ b/tests/Unit/Debug/Repository/CollectorRepositoryTest.php @@ -9,92 +9,74 @@ use Yiisoft\Yii\Debug\Api\Tests\Support\StubCollector; use Yiisoft\Yii\Debug\DebuggerIdGenerator; use Yiisoft\Yii\Debug\Storage\MemoryStorage; -use Yiisoft\Yii\Debug\Storage\StorageInterface; final class CollectorRepositoryTest extends TestCase { public function testSummary(): void { - $idGenerator = new DebuggerIdGenerator(); - $stubCollector = new StubCollector(['key' => 'value']); - - $storage = $this->createStorage($idGenerator); + $storage = new MemoryStorage(); $repository = new CollectorRepository($storage); - $this->assertIsArray($repository->getSummary()); - $this->assertEquals([ - [ - 'id' => $idGenerator->getId(), - 'collectors' => [], - ], - ], $repository->getSummary()); + $this->assertSame([], $repository->getSummary()); - $storage->addCollector($stubCollector); + $storage->write('testId', ['stub' => ['key' => 'value']], [], ['total' => 7]); - $this->assertIsArray($repository->getSummary()); - $this->assertEquals([ + $this->assertSame( [ - 'id' => $idGenerator->getId(), - 'collectors' => [$stubCollector->getName()], + ['total' => 7], ], - ], $repository->getSummary()); + $repository->getSummary() + ); } public function testDetail(): void { - $idGenerator = new DebuggerIdGenerator(); - $stubCollector = new StubCollector(['key' => 'value']); - - $storage = $this->createStorage($idGenerator); - $storage->addCollector($stubCollector); + $storage = new MemoryStorage(); + $storage->write('testId', ['stub' => ['key' => 'value']], [], ['total' => 7]); $repository = new CollectorRepository($storage); - $this->assertIsArray($repository->getDetail($idGenerator->getId())); - $this->assertEquals([ - $stubCollector->getName() => $stubCollector->getCollected(), - ], $repository->getDetail($idGenerator->getId())); + $this->assertSame( + ['stub' => ['key' => 'value']], + $repository->getDetail('testId') + ); } public function testDumpObject(): void { - $idGenerator = new DebuggerIdGenerator(); - $stubCollector = new StubCollector(['key' => 'value']); - - $storage = $this->createStorage($idGenerator); - $storage->addCollector($stubCollector); + $storage = new MemoryStorage(); + $storage->write('testId', ['stub' => ['key' => 'value']], ['object' => []], ['total' => 7]); $repository = new CollectorRepository($storage); - $this->assertIsArray($repository->getDumpObject($idGenerator->getId())); - $this->assertEquals([ - 'key' => 'value', - ], $repository->getDumpObject($idGenerator->getId())); + $this->assertSame( + ['object' => []], + $repository->getDumpObject('testId') + ); } public function testObject(): void { - $idGenerator = new DebuggerIdGenerator(); + $storage = new MemoryStorage(); $objectId = '123'; - $stubCollector = new StubCollector([ - 'stdClass#' . $objectId => 'value', - ]); - - $storage = $this->createStorage($idGenerator); - $storage->addCollector($stubCollector); + $storage->write( + 'testId', + ['stub' => ['key' => 'value']], + ['stdClass#' . $objectId => 'value'], + ['total' => 7], + ); $repository = new CollectorRepository($storage); - $this->assertIsArray($repository->getObject($idGenerator->getId(), $objectId)); - $this->assertEquals([ - 'stdClass', - 'value', - ], $repository->getObject($idGenerator->getId(), $objectId)); - } - - private function createStorage(DebuggerIdGenerator $idGenerator): StorageInterface - { - return new MemoryStorage($idGenerator); + $object = $repository->getObject('testId', $objectId); + $this->assertIsArray($object); + $this->assertSame( + [ + 'stdClass', + 'value', + ], + $object + ); } } From b3aef299347fa5806e545bad0f02af9449026003 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sun, 12 Jan 2025 16:24:58 +0000 Subject: [PATCH 3/4] Apply fixes from StyleCI --- tests/Unit/Debug/Repository/CollectorRepositoryTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/Unit/Debug/Repository/CollectorRepositoryTest.php b/tests/Unit/Debug/Repository/CollectorRepositoryTest.php index 170a4ad..69f1f82 100644 --- a/tests/Unit/Debug/Repository/CollectorRepositoryTest.php +++ b/tests/Unit/Debug/Repository/CollectorRepositoryTest.php @@ -6,8 +6,6 @@ use PHPUnit\Framework\TestCase; use Yiisoft\Yii\Debug\Api\Debug\Repository\CollectorRepository; -use Yiisoft\Yii\Debug\Api\Tests\Support\StubCollector; -use Yiisoft\Yii\Debug\DebuggerIdGenerator; use Yiisoft\Yii\Debug\Storage\MemoryStorage; final class CollectorRepositoryTest extends TestCase From 0023a8ec7ebfa715eec652a5095b8011253c5fe8 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 12 Jan 2025 19:29:11 +0300 Subject: [PATCH 4/4] fix psalm --- composer.json | 1 + src/Debug/Http/HttpApplicationWrapper.php | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index a51b8e2..91858e3 100644 --- a/composer.json +++ b/composer.json @@ -76,6 +76,7 @@ "yiisoft/router-fastroute": "^3.0", "yiisoft/test-support": "^3.0", "yiisoft/yii-cycle": "dev-master", + "yiisoft/yii-http": "^1.0", "yiisoft/yii-view": "^6.0" }, "suggest": { diff --git a/src/Debug/Http/HttpApplicationWrapper.php b/src/Debug/Http/HttpApplicationWrapper.php index 3392001..8ca0782 100644 --- a/src/Debug/Http/HttpApplicationWrapper.php +++ b/src/Debug/Http/HttpApplicationWrapper.php @@ -17,9 +17,6 @@ public function __construct( ) { } - /** - * @psalm-suppress UndefinedClass - */ public function wrap(Application $application): void { $middlewareDispatcher = $this->middlewareDispatcher; @@ -27,7 +24,7 @@ public function wrap(Application $application): void $closure = Closure::bind( /** - * @psalm-suppress UndefinedClass + * @psalm-suppress InaccessibleProperty */ static fn (Application $application) => $application->dispatcher = $middlewareDispatcher->withMiddlewares([ ...$middlewareDefinitions,