Skip to content

Commit ea17354

Browse files
committed
relax mock class name matching
Instead of performing some fuzzy matching on the automatically generated mock name (the pattern varies between different PHPUnit versions) we can simply use the actual exact class name.
1 parent bd25dae commit ea17354

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Tests/Authentication/AuthenticatorManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public function log($level, $message, array $context = []): void
368368
$manager = $this->createManager([$authenticator], 'main', true, [], $logger);
369369
$response = $manager->authenticateRequest($this->request);
370370
$this->assertSame($this->response, $response);
371-
$this->assertStringContainsString('Mock_TestInteractiveAuthenticator', $logger->logContexts[0]['authenticator']);
371+
$this->assertStringContainsString($authenticator::class, $logger->logContexts[0]['authenticator']);
372372
}
373373

374374
private function createAuthenticator(?bool $supports = true)

Tests/Controller/UserValueResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function testResolveThrowsAccessDeniedWithWrongUserClass()
120120
$metadata = new ArgumentMetadata('foo', InMemoryUser::class, false, false, null, false, [new CurrentUser()]);
121121

122122
$this->expectException(AccessDeniedException::class);
123-
$this->expectExceptionMessageMatches('/^The logged-in user is an instance of "Mock_UserInterface[^"]+" but a user of type "Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\InMemoryUser" is expected.$/');
123+
$this->expectExceptionMessageMatches(\sprintf('/^The logged-in user is an instance of "%s" but a user of type "Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\InMemoryUser" is expected.$/', $user::class));
124124
$resolver->resolve(Request::create('/'), $metadata);
125125
}
126126

0 commit comments

Comments
 (0)