Skip to content

Commit

Permalink
Fix debug collector + Disable Yii Config plugin (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Nov 22, 2023
1 parent 027989a commit 339d713
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
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);
}
}
}
}

0 comments on commit 339d713

Please sign in to comment.