Skip to content

Commit 3e43aa9

Browse files
minor #58391 relax mock class name matching (xabbuh)
This PR was merged into the 7.2 branch. Discussion ---------- relax mock class name matching | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT 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. Commits ------- 2c99e009d09 relax mock class name matching
2 parents 4dade04 + ea17354 commit 3e43aa9

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)