Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"illuminate/support": "^10.0|^11.0 || ^12.0",
"illuminate/validation": "^10.0|^11.0 || ^12.0",
"illuminate/view": "^10.0|^11.0 || ^12.0",
"symfony/cache": "^6.0|^7.0",
"symfony/serializer": "^5.0|^6.0|^7.0"
"symfony/cache": "^6.0|^7.0|^8.0",
"symfony/serializer": "^5.0|^6.0|^7.0|^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^12.0",
Expand Down
8 changes: 8 additions & 0 deletions src/EntityManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
use function class_exists;
use function in_array;
use function is_array;
use function method_exists;

use const PHP_VERSION_ID;

class EntityManagerFactory
{
Expand Down Expand Up @@ -101,6 +104,11 @@ public function create(array $settings = []): EntityManagerInterface

$configuration->setEntityListenerResolver($this->resolver);

if (PHP_VERSION_ID >= 80400 && method_exists(Configuration::class, 'enableNativeLazyObjects')) {
// TODO: remove check when dropping PHP <8.4 and ORM <3.4
$configuration->enableNativeLazyObjects(true);
}

$manager = new EntityManager(
$connection,
$configuration,
Expand Down
36 changes: 25 additions & 11 deletions tests/Feature/EntityManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@

use function array_key_exists;
use function count;
use function method_exists;
use function rmdir;

use const PHP_VERSION_ID;

class EntityManagerFactoryTest extends TestCase
{
protected CacheManager $cache;
Expand Down Expand Up @@ -958,26 +961,37 @@ protected function mockORMConfiguration(): void
->atLeast()->once()
->with(m::type(EntityListenerResolver::class));

$this->configuration->shouldReceive('getProxyDir')
->atLeast()->once()
->andReturn('dir');
if (PHP_VERSION_ID >= 80400 && method_exists(Configuration::class, 'enableNativeLazyObjects')) {
// TODO: remove check when dropping PHP <8.4 and ORM <3.4
$this->configuration->shouldReceive('enableNativeLazyObjects')
->atLeast()->once()
->with(true);
} else {
$this->configuration->shouldReceive('getProxyDir')
->andReturn('dir');

$this->configuration->shouldReceive('getProxyNamespace')
->andReturn('namespace');

$this->configuration->shouldReceive('getAutoGenerateProxyClasses')
->andReturn(false);
}

if (method_exists(Configuration::class, 'isNativeLazyObjectsEnabled')) {
// TODO: remove check when dropping PHP <8.4 and ORM <3.4
$this->configuration->shouldReceive('isNativeLazyObjectsEnabled')
->atLeast()->once()
->andReturn(true);
}

$this->configuration->shouldReceive('setProxyDir')
->atLeast()->once()
->with('dir');

$this->configuration->shouldReceive('getProxyNamespace')
->atLeast()->once()
->andReturn('namespace');

$this->configuration->shouldReceive('setProxyNamespace')
->atLeast()->once()
->with('namespace');

$this->configuration->shouldReceive('getAutoGenerateProxyClasses')
->atLeast()->once()
->andReturn(false);

$this->configuration->shouldReceive('setAutoGenerateProxyClasses')
->atLeast()->once()
->with(false);
Expand Down
9 changes: 9 additions & 0 deletions tests/Feature/Testing/FactoryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\ORMSetup as Setup;
Expand All @@ -19,8 +20,11 @@
use Mockery\Mock;

use function array_merge;
use function method_exists;
use function random_int;

use const PHP_VERSION_ID;

class FactoryBuilderTest extends MockeryTestCase
{
private ManagerRegistry $aRegistry;
Expand Down Expand Up @@ -94,6 +98,11 @@ protected function getEntityManager(): EntityManager
{
$config = Setup::createAttributeMetadataConfiguration([__DIR__], true);

if (PHP_VERSION_ID >= 80400 && method_exists(Configuration::class, 'enableNativeLazyObjects')) {
// TODO: remove check when dropping PHP <8.4 and ORM <3.4
$config->enableNativeLazyObjects(true);
}

$conn = DriverManager::getConnection([
'driver' => 'pdo_sqlite',
'database' => ':memory:',
Expand Down
Loading