Skip to content

Commit

Permalink
Remove getInvocationCount method
Browse files Browse the repository at this point in the history
  • Loading branch information
Sephster committed Jan 8, 2024
1 parent c8a3493 commit f5ffc21
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 29 deletions.
20 changes: 6 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
colors="true"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="false"
stopOnSkipped="false"
bootstrap="tests/Bootstrap.php"
>
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" colors="true" stopOnError="true" stopOnFailure="true" stopOnIncomplete="false" stopOnSkipped="false" bootstrap="tests/Bootstrap.php">
<testsuites>
<testsuite name="Tests">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
20 changes: 10 additions & 10 deletions tests/Grant/AuthCodeGrantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down Expand Up @@ -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();
}
});
Expand Down
10 changes: 5 additions & 5 deletions tests/Grant/ImplicitGrantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down

0 comments on commit f5ffc21

Please sign in to comment.