From 49142c490ba70f445ddbcd4620df6c2cd2a9a462 Mon Sep 17 00:00:00 2001 From: Maxim Smakouz Date: Sun, 15 Sep 2024 19:05:39 +0300 Subject: [PATCH] Fix phpunit tests --- tests/Unit/RetryMetricsTest.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/Unit/RetryMetricsTest.php b/tests/Unit/RetryMetricsTest.php index e16ef4d..453b7ed 100644 --- a/tests/Unit/RetryMetricsTest.php +++ b/tests/Unit/RetryMetricsTest.php @@ -1,8 +1,9 @@ expectException(MetricsException::class); $retryMetrics->add('counter', 1); } @@ -49,7 +50,7 @@ public function testSubWithMetricsException(): void 1, ); - self::expectException(MetricsException::class); + $this->expectException(MetricsException::class); $retryMetrics->sub('counter', 1); } @@ -77,7 +78,7 @@ public function testObserveWithMetricsException(): void 1, ); - self::expectException(MetricsException::class); + $this->expectException(MetricsException::class); $retryMetrics->observe('counter', 1); } @@ -105,7 +106,7 @@ public function testSetWithMetricsException(): void 1, ); - self::expectException(MetricsException::class); + $this->expectException(MetricsException::class); $retryMetrics->set('counter', 1); } @@ -133,7 +134,7 @@ public function testDeclareWithMetricsException(): void 1, ); - self::expectException(MetricsException::class); + $this->expectException(MetricsException::class); $retryMetrics->declare('counter', Collector::counter()); } @@ -161,7 +162,7 @@ public function testUnregisterWithMetricsException(): void 1, ); - self::expectException(MetricsException::class); + $this->expectException(MetricsException::class); $retryMetrics->unregister('counter'); } @@ -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; }