|
10 | 10 | use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
|
11 | 11 | use Doctrine\ORM\EntityNotFoundException;
|
12 | 12 | use Doctrine\ORM\Mapping\ClassMetadata;
|
| 13 | +use Doctrine\ORM\ORMInvalidArgumentException; |
13 | 14 | use Doctrine\ORM\Persisters\Entity\BasicEntityPersister;
|
14 | 15 | use Doctrine\ORM\Proxy\ProxyFactory;
|
15 | 16 | use Doctrine\Persistence\Mapping\RuntimeReflectionService;
|
|
21 | 22 | use Doctrine\Tests\Models\ECommerce\ECommerceFeature;
|
22 | 23 | use Doctrine\Tests\OrmTestCase;
|
23 | 24 | use PHPUnit\Framework\Attributes\Group;
|
| 25 | +use PHPUnit\Framework\Attributes\RequiresMethod; |
24 | 26 | use PHPUnit\Framework\Attributes\RequiresPhp;
|
25 | 27 | use PHPUnit\Framework\Attributes\WithoutErrorHandler;
|
26 | 28 | use ReflectionClass;
|
27 | 29 | use ReflectionProperty;
|
28 | 30 | use stdClass;
|
| 31 | +use Symfony\Component\VarExporter\ProxyHelper; |
29 | 32 |
|
30 | 33 | use function assert;
|
31 | 34 | use function method_exists;
|
@@ -247,6 +250,7 @@ public function testProxyFactoryAcceptsNullProxyArgsWhenNativeLazyObjectsAreEnab
|
247 | 250 | }
|
248 | 251 |
|
249 | 252 | #[RequiresPhp('8.4')]
|
| 253 | + #[RequiresMethod(ProxyHelper::class, 'generateLazyGhost')] |
250 | 254 | #[WithoutErrorHandler]
|
251 | 255 | public function testProxyFactoryTriggersDeprecationWhenNativeLazyObjectsAreDisabled(): void
|
252 | 256 | {
|
@@ -276,6 +280,25 @@ public function testProxyFactoryDoesNotTriggerDeprecationWhenNativeLazyObjectsAr
|
276 | 280 | ProxyFactory::AUTOGENERATE_ALWAYS,
|
277 | 281 | );
|
278 | 282 | }
|
| 283 | + |
| 284 | + public function testProxyFactoryThrowsIfLazyGhostsAreUnavailable(): void |
| 285 | + { |
| 286 | + if (method_exists(ProxyHelper::class, 'generateLazyGhost')) { |
| 287 | + self::markTestSkipped('This test is not relevant when lazy ghosts are available'); |
| 288 | + } |
| 289 | + |
| 290 | + $this->emMock->getConfiguration()->enableNativeLazyObjects(false); |
| 291 | + |
| 292 | + $this->expectException(ORMInvalidArgumentException::class); |
| 293 | + $this->expectExceptionMessage('Symfony LazyGhost is not available. Please install the "symfony/var-exporter" package version 6.4 or 7 to use this feature or enable PHP 8.4 native lazy objects.'); |
| 294 | + |
| 295 | + new ProxyFactory( |
| 296 | + $this->emMock, |
| 297 | + sys_get_temp_dir(), |
| 298 | + 'Proxies', |
| 299 | + ProxyFactory::AUTOGENERATE_ALWAYS, |
| 300 | + ); |
| 301 | + } |
279 | 302 | }
|
280 | 303 |
|
281 | 304 | abstract class AbstractClass
|
|
0 commit comments