Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debug collector + Disable Yii Config plugin #179

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"allow-plugins": {
"infection/extension-installer": true,
"composer/package-versions-deprecated": true,
"yiisoft/config": true
"yiisoft/config": false
}
},
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/Debug/QueueCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ final class QueueCollector implements SummaryCollectorInterface

public function getCollected(): array
{
if (!$this->isActive()) {
return [];
}

return [
'pushes' => $this->pushes,
'statuses' => $this->statuses,
Expand Down Expand Up @@ -77,6 +81,10 @@ private function reset(): void

public function getSummary(): array
{
if (!$this->isActive()) {
return [];
}

$countPushes = array_sum(array_map(fn ($messages) => is_countable($messages) ? count($messages) : 0, $this->pushes));
$countStatuses = count($this->statuses);
$countProcessingMessages = array_sum(array_map(fn ($messages) => is_countable($messages) ? count($messages) : 0, $this->processingMessages));
Expand Down
16 changes: 0 additions & 16 deletions tests/Unit/Debug/QueueCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Yiisoft\Yii\Queue\Tests\Unit\Debug;

use Yiisoft\Yii\Debug\Collector\CollectorInterface;
use Yiisoft\Yii\Debug\Collector\SummaryCollectorInterface;
use Yiisoft\Yii\Debug\Tests\Shared\AbstractCollectorTestCase;
use Yiisoft\Yii\Queue\Debug\QueueCollector;
use Yiisoft\Yii\Queue\Enum\JobStatus;
Expand Down Expand Up @@ -105,19 +104,4 @@ protected function checkSummaryData(array $data): void
$this->assertEquals(1, $countStatuses);
$this->assertEquals(3, $countProcessingMessages);
}

public function testEmptyCollector(): void
{
$collector = $this->getCollector();

foreach ($collector->getCollected() as $collected) {
$this->assertEquals([], $collected);
}

if ($collector instanceof SummaryCollectorInterface) {
foreach ($collector->getSummary()['queue'] as $count) {
$this->assertEquals(0, $count);
}
}
}
}
Loading