|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +declare(strict_types=1); |
| 4 | + |
3 | 5 | /* |
4 | 6 | * This file is part of the HWIOAuthBundle package. |
5 | 7 | * |
|
15 | 17 | use Doctrine\Persistence\ManagerRegistry; |
16 | 18 | use Doctrine\Persistence\ObjectManager; |
17 | 19 | use Doctrine\Persistence\ObjectRepository; |
| 20 | +use ErrorException; |
18 | 21 | use HWI\Bundle\OAuthBundle\OAuth\ResourceOwnerInterface; |
19 | 22 | use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface; |
20 | 23 | use HWI\Bundle\OAuthBundle\Security\Core\User\EntityUserProvider; |
| 24 | +use HWI\Bundle\OAuthBundle\Tests\Fixtures\UlidUser; |
21 | 25 | use HWI\Bundle\OAuthBundle\Tests\Fixtures\User; |
22 | 26 | use PHPUnit\Framework\Attributes\Group; |
23 | 27 | use PHPUnit\Framework\Attributes\IgnoreDeprecations; |
@@ -184,4 +188,33 @@ private function assertUserNotFoundException(): void |
184 | 188 | { |
185 | 189 | $this->expectException(UserNotFoundException::class); |
186 | 190 | } |
| 191 | + |
| 192 | + public function testRefreshUserWorksWithUlid(): void |
| 193 | + { |
| 194 | + // Simulate `framework.php_errors.throw: true` |
| 195 | + set_error_handler(static function ( |
| 196 | + int $severity, |
| 197 | + string $message, |
| 198 | + string $file, |
| 199 | + int $line |
| 200 | + ): never { |
| 201 | + throw new ErrorException($message, 0, $severity, $file, $line); |
| 202 | + }); |
| 203 | + |
| 204 | + try { |
| 205 | + $this->assertUserNotFoundException(); |
| 206 | + $this->expectExceptionMessage('User with ID "01KGW7EGJX0SHRF6RZ5YYFBR40" could not be reloaded.'); |
| 207 | + |
| 208 | + $provider = new EntityUserProvider( |
| 209 | + $this->createManagerRegistryMock(), |
| 210 | + UlidUser::class, |
| 211 | + [] |
| 212 | + ); |
| 213 | + |
| 214 | + $provider->refreshUser(new UlidUser()); |
| 215 | + } finally { |
| 216 | + restore_error_handler(); |
| 217 | + } |
| 218 | + } |
| 219 | + |
187 | 220 | } |
0 commit comments