Skip to content

Commit

Permalink
minor #191 [ci] php-cs-fixer it up
Browse files Browse the repository at this point in the history
  • Loading branch information
jrushlow authored Jul 30, 2024
1 parent 244a53c commit a88ba79
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/Model/VerifyEmailSignatureComponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getExpirationMessageData(): array
public function getExpiresAtIntervalInstance(): \DateInterval
{
if (null === $this->generatedAt) {
throw new \LogicException(sprintf('%s initialized without setting the $generatedAt timestamp.', self::class));
throw new \LogicException(\sprintf('%s initialized without setting the $generatedAt timestamp.', self::class));
}

$createdAtTime = \DateTimeImmutable::createFromFormat('U', (string) $this->generatedAt);
Expand Down
2 changes: 1 addition & 1 deletion src/VerifyEmailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function validateEmailConfirmationFromRequest(Request $request, string $u
{
/** @legacy - Remove in 2.0 */
if (!$this->uriSigner instanceof UriSigner) {
throw new \RuntimeException(sprintf('An instance of %s is required, provided by symfony/http-kernel >=6.4, to validate an email confirmation.', UriSigner::class));
throw new \RuntimeException(\sprintf('An instance of %s is required, provided by symfony/http-kernel >=6.4, to validate an email confirmation.', UriSigner::class));
}

if (!$this->uriSigner->checkRequest($request)) {
Expand Down
12 changes: 6 additions & 6 deletions tests/AcceptanceTests/VerifyEmailAcceptanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testGenerateSignature(): void

$expectedSignature = base64_encode(hash_hmac(
'sha256',
sprintf('http://localhost/verify/user?expires=%s&token=%s', $expiresAt, urlencode($expectedToken)),
\sprintf('http://localhost/verify/user?expires=%s&token=%s', $expiresAt, urlencode($expectedToken)),
'foo',
true
));
Expand All @@ -59,7 +59,7 @@ public function testGenerateSignature(): void

self::assertTrue(hash_equals($expectedSignature, $result['signature']));
self::assertSame(
sprintf('http://localhost/verify/user?expires=%s&signature=%s&token=%s', $expiresAt, urlencode($expectedSignature), urlencode($expectedToken)),
\sprintf('http://localhost/verify/user?expires=%s&signature=%s&token=%s', $expiresAt, urlencode($expectedSignature), urlencode($expectedToken)),
$signature
);
}
Expand All @@ -75,7 +75,7 @@ public function testValidateEmailSignature(): void
$helper = $container->get(VerifyEmailAcceptanceFixture::class)->helper;
$expires = new \DateTimeImmutable('+1 hour');

$uriToTest = sprintf(
$uriToTest = \sprintf(
'/verify/user?%s',
http_build_query([
'expires' => $expires->getTimestamp(),
Expand All @@ -90,7 +90,7 @@ public function testValidateEmailSignature(): void

$signature = base64_encode(hash_hmac('sha256', $uriToTest, 'foo', true));

$test = sprintf('%s&signature=%s', $uriToTest, urlencode($signature));
$test = \sprintf('%s&signature=%s', $uriToTest, urlencode($signature));

$helper->validateEmailConfirmation($test, '1234', 'jr@rushlow.dev');
$this->assertTrue(true, 'Test correctly does not throw an exception');
Expand All @@ -107,7 +107,7 @@ public function testValidateUsingRequestObject(): void
$helper = $container->get(VerifyEmailAcceptanceFixture::class)->helper;
$expires = new \DateTimeImmutable('+1 hour');

$uriToTest = sprintf(
$uriToTest = \sprintf(
'http://localhost/verify/user?%s',
http_build_query([
'expires' => $expires->getTimestamp(),
Expand All @@ -122,7 +122,7 @@ public function testValidateUsingRequestObject(): void

$signature = base64_encode(hash_hmac('sha256', $uriToTest, 'foo', true));

$test = sprintf('%s&signature=%s', $uriToTest, urlencode($signature));
$test = \sprintf('%s&signature=%s', $uriToTest, urlencode($signature));

$helper->validateEmailConfirmationFromRequest(Request::create(uri: $test), '1234', 'jr@rushlow.dev');
$this->assertTrue(true, 'Test correctly does not throw an exception');
Expand Down
8 changes: 4 additions & 4 deletions tests/FunctionalTests/VerifyEmailHelperFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testGenerateSignature(): void
->expects($this->once())
->method('generate')
->with('app_verify_route', ['expires' => $this->expiryTimestamp, 'token' => $token])
->willReturn(sprintf('/verify?expires=%s&token=%s', $this->expiryTimestamp, urlencode($token)))
->willReturn(\sprintf('/verify?expires=%s&token=%s', $this->expiryTimestamp, urlencode($token)))
;

$result = $this->getHelper()->generateSignature('app_verify_route', '1234', 'jr@rushlow.dev');
Expand Down Expand Up @@ -91,7 +91,7 @@ private function getTestToken(): string
private function getTestSignature(): string
{
$query = http_build_query(['expires' => $this->expiryTimestamp, 'token' => $this->getTestToken()], '', '&');
$uri = sprintf('/verify?%s', $query);
$uri = \sprintf('/verify?%s', $query);

return base64_encode(hash_hmac('sha256', $uri, 'foo', true));
}
Expand All @@ -100,7 +100,7 @@ private function getTestSignedUri(): string
{
$token = urlencode($this->getTestToken());

$uri = sprintf('/verify?expires=%s&token=%s', $this->expiryTimestamp, $token);
$uri = \sprintf('/verify?expires=%s&token=%s', $this->expiryTimestamp, $token);
$signature = base64_encode(hash_hmac('sha256', $uri, 'foo', true));

$uriComponents = parse_url($uri);
Expand All @@ -111,7 +111,7 @@ private function getTestSignedUri(): string

$sortedParams = http_build_query($params);

return sprintf('/verify?%s', $sortedParams);
return \sprintf('/verify?%s', $sortedParams);
}

private function getHelper(): VerifyEmailHelperInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testTranslations(int $lifetime, int $expectedInterval, string $u
$components = new VerifyEmailSignatureComponents($expire, 'some-uri', $created);

self::assertSame(
sprintf('%%count%% %s|%%count%% %ss', $unitOfMeasure, $unitOfMeasure),
\sprintf('%%count%% %s|%%count%% %ss', $unitOfMeasure, $unitOfMeasure),
$components->getExpirationMessageKey()
);

Expand Down
6 changes: 3 additions & 3 deletions tests/UnitTests/VerifyEmailHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testSignatureIsGenerated(): void
{
$expires = time() + 3600;

$expectedSignedUrl = sprintf('/verify?expires=%s&signature=1234&token=hashedToken', $expires);
$expectedSignedUrl = \sprintf('/verify?expires=%s&signature=1234&token=hashedToken', $expires);

$this->tokenGenerator
->expects($this->once())
Expand All @@ -72,13 +72,13 @@ public function testSignatureIsGenerated(): void
->expects($this->once())
->method('generate')
->with('app_verify_route', ['token' => 'hashedToken', 'expires' => $expires])
->willReturn(sprintf('/verify?expires=%s&token=hashedToken', $expires))
->willReturn(\sprintf('/verify?expires=%s&token=hashedToken', $expires))
;

$this->mockSigner
->expects($this->once())
->method('sign')
->with(sprintf('/verify?expires=%s&token=hashedToken', $expires))
->with(\sprintf('/verify?expires=%s&token=hashedToken', $expires))
->willReturn($expectedSignedUrl)
;

Expand Down

0 comments on commit a88ba79

Please sign in to comment.