Skip to content

Commit

Permalink
Fix phpunit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msmakouz committed Sep 15, 2024
1 parent 8a2bc4c commit 49142c4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/Unit/RetryMetricsTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

declare(strict_types=1);

namespace Spiral\RoadRunner\Metrics\Tests\Unit;

use PHPUnit\Framework\MockObject\Rule\InvokedCount;
use PHPUnit\Framework\TestCase;
use Spiral\RoadRunner\Metrics\Collector;
use Spiral\RoadRunner\Metrics\Exception\MetricsException;
Expand All @@ -21,7 +22,7 @@ public function testAddWithMetricsException(): void
1,
);

self::expectException(MetricsException::class);
$this->expectException(MetricsException::class);

$retryMetrics->add('counter', 1);
}
Expand Down Expand Up @@ -49,7 +50,7 @@ public function testSubWithMetricsException(): void
1,
);

self::expectException(MetricsException::class);
$this->expectException(MetricsException::class);

$retryMetrics->sub('counter', 1);
}
Expand Down Expand Up @@ -77,7 +78,7 @@ public function testObserveWithMetricsException(): void
1,
);

self::expectException(MetricsException::class);
$this->expectException(MetricsException::class);

$retryMetrics->observe('counter', 1);
}
Expand Down Expand Up @@ -105,7 +106,7 @@ public function testSetWithMetricsException(): void
1,
);

self::expectException(MetricsException::class);
$this->expectException(MetricsException::class);

$retryMetrics->set('counter', 1);
}
Expand Down Expand Up @@ -133,7 +134,7 @@ public function testDeclareWithMetricsException(): void
1,
);

self::expectException(MetricsException::class);
$this->expectException(MetricsException::class);

$retryMetrics->declare('counter', Collector::counter());
}
Expand Down Expand Up @@ -161,7 +162,7 @@ public function testUnregisterWithMetricsException(): void
1,
);

self::expectException(MetricsException::class);
$this->expectException(MetricsException::class);

$retryMetrics->unregister('counter');
}
Expand All @@ -183,14 +184,13 @@ private function createMetricsMock(string $method, int $expectedCalls, int $exce
{
$metrics = $this->createMock(MetricsInterface::class);

$returnValues = \array_fill(0, $exceptions, $this->throwException(new MetricsException()));
$returnValues[] = null;

$metrics
->expects(new InvokedCount($expectedCalls))
->expects($this->exactly($expectedCalls))
->method($method)
->willReturnOnConsecutiveCalls(...array_fill(
0,
$exceptions,
$this->throwException(new MetricsException()),
));
->willReturnOnConsecutiveCalls(...$returnValues);

return $metrics;
}
Expand Down

0 comments on commit 49142c4

Please sign in to comment.