From f5ffc219c05f3b8c7b96e1e720414a60e9a7c69c Mon Sep 17 00:00:00 2001 From: Andrew Millington Date: Mon, 8 Jan 2024 21:43:21 +0000 Subject: [PATCH] Remove getInvocationCount method --- phpunit.xml.dist | 20 ++++++-------------- tests/Grant/AuthCodeGrantTest.php | 20 ++++++++++---------- tests/Grant/ImplicitGrantTest.php | 10 +++++----- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9ab509138..52b17a4a7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,21 +1,13 @@ - - - - src - - + ./tests/ + + + src + + diff --git a/tests/Grant/AuthCodeGrantTest.php b/tests/Grant/AuthCodeGrantTest.php index 1a58983ae..61b672d78 100644 --- a/tests/Grant/AuthCodeGrantTest.php +++ b/tests/Grant/AuthCodeGrantTest.php @@ -1893,13 +1893,13 @@ public function testAuthCodeRepositoryUniqueConstraintCheck(): void $authCodeRepository = $this->getMockBuilder(AuthCodeRepositoryInterface::class)->getMock(); $authCodeRepository->method('getNewAuthCode')->willReturn(new AuthCodeEntity()); - $matcher = self::exactly(2); - $authCodeRepository - ->expects($matcher) + ->expects(self::exactly(2)) ->method('persistNewAuthCode') - ->willReturnCallback(function () use ($matcher): void { - if ($matcher->getInvocationCount() === 1) { + ->willReturnCallback(function (): void { + static $counter = 0; + + if (1 === ++$counter) { throw UniqueTokenIdentifierConstraintViolationException::create(); } }); @@ -1992,13 +1992,13 @@ public function testRefreshTokenRepositoryUniqueConstraintCheck(): void $refreshTokenRepositoryMock = $this->getMockBuilder(RefreshTokenRepositoryInterface::class)->getMock(); $refreshTokenRepositoryMock->method('getNewRefreshToken')->willReturn(new RefreshTokenEntity()); - $matcher = self::exactly(2); - $refreshTokenRepositoryMock - ->expects($matcher) + ->expects(self::exactly(2)) ->method('persistNewRefreshToken') - ->willReturnCallback(function () use ($matcher): void { - if ($matcher->getInvocationCount() === 1) { + ->willReturnCallback(function (): void { + static $count = 0; + + if (1 === ++$count) { throw UniqueTokenIdentifierConstraintViolationException::create(); } }); diff --git a/tests/Grant/ImplicitGrantTest.php b/tests/Grant/ImplicitGrantTest.php index 31d85a8aa..515629247 100644 --- a/tests/Grant/ImplicitGrantTest.php +++ b/tests/Grant/ImplicitGrantTest.php @@ -286,13 +286,13 @@ public function testAccessTokenRepositoryUniqueConstraintCheck(): void $accessTokenRepositoryMock = $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(); $accessTokenRepositoryMock->method('getNewToken')->willReturn($accessToken); - $matcher = self::exactly(2); - $accessTokenRepositoryMock - ->expects($matcher) + ->expects(self::exactly(2)) ->method('persistNewAccessToken') - ->willReturnCallback(function () use ($matcher): void { - if ($matcher->getInvocationCount() === 1) { + ->willReturnCallback(function (): void { + static $count = 0; + + if (1 === ++$count) { throw UniqueTokenIdentifierConstraintViolationException::create(); } });