|
7 | 7 | use Doctrine\Common\EventManager; |
8 | 8 | use Doctrine\DBAL\Connection; |
9 | 9 | use Doctrine\DBAL\Platforms\AbstractPlatform; |
| 10 | +use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; |
10 | 11 | use Doctrine\ORM\EntityNotFoundException; |
11 | 12 | use Doctrine\ORM\Mapping\ClassMetadata; |
12 | 13 | use Doctrine\ORM\Persisters\Entity\BasicEntityPersister; |
|
21 | 22 | use Doctrine\Tests\OrmTestCase; |
22 | 23 | use PHPUnit\Framework\Attributes\Group; |
23 | 24 | use PHPUnit\Framework\Attributes\RequiresPhp; |
| 25 | +use PHPUnit\Framework\Attributes\WithoutErrorHandler; |
24 | 26 | use ReflectionClass; |
25 | 27 | use ReflectionProperty; |
26 | 28 | use stdClass; |
|
34 | 36 | */ |
35 | 37 | class ProxyFactoryTest extends OrmTestCase |
36 | 38 | { |
37 | | - private UnitOfWorkMock $uowMock; |
| 39 | + use VerifyDeprecations; |
38 | 40 |
|
| 41 | + private UnitOfWorkMock $uowMock; |
39 | 42 | private EntityManagerMock $emMock; |
40 | | - |
41 | 43 | private ProxyFactory $proxyFactory; |
42 | 44 |
|
43 | 45 | protected function setUp(): void |
@@ -243,6 +245,37 @@ public function testProxyFactoryAcceptsNullProxyArgsWhenNativeLazyObjectsAreEnab |
243 | 245 |
|
244 | 246 | self::assertTrue($reflection->isUninitializedLazyObject($proxy)); |
245 | 247 | } |
| 248 | + |
| 249 | + #[RequiresPhp('8.4')] |
| 250 | + #[WithoutErrorHandler] |
| 251 | + public function testProxyFactoryTriggersDeprecationWhenNativeLazyObjectsAreDisabled(): void |
| 252 | + { |
| 253 | + $this->emMock->getConfiguration()->enableNativeLazyObjects(false); |
| 254 | + |
| 255 | + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/12005'); |
| 256 | + |
| 257 | + $this->proxyFactory = new ProxyFactory( |
| 258 | + $this->emMock, |
| 259 | + sys_get_temp_dir(), |
| 260 | + 'Proxies', |
| 261 | + ProxyFactory::AUTOGENERATE_ALWAYS, |
| 262 | + ); |
| 263 | + } |
| 264 | + |
| 265 | + #[RequiresPhp('< 8.4')] |
| 266 | + public function testProxyFactoryDoesNotTriggerDeprecationWhenNativeLazyObjectsAreDisabled(): void |
| 267 | + { |
| 268 | + $this->emMock->getConfiguration()->enableNativeLazyObjects(false); |
| 269 | + |
| 270 | + $this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/orm/pull/12005'); |
| 271 | + |
| 272 | + $this->proxyFactory = new ProxyFactory( |
| 273 | + $this->emMock, |
| 274 | + sys_get_temp_dir(), |
| 275 | + 'Proxies', |
| 276 | + ProxyFactory::AUTOGENERATE_ALWAYS, |
| 277 | + ); |
| 278 | + } |
246 | 279 | } |
247 | 280 |
|
248 | 281 | abstract class AbstractClass |
|
0 commit comments