diff --git a/tests/Doctrine/Tests/Models/AbstractFetchEager/WithFetchEager/AbstractRemoveControl.php b/tests/Doctrine/Tests/Models/AbstractFetchEager/WithFetchEager/AbstractRemoveControl.php new file mode 100644 index 00000000000..7dc1157c889 --- /dev/null +++ b/tests/Doctrine/Tests/Models/AbstractFetchEager/WithFetchEager/AbstractRemoveControl.php @@ -0,0 +1,50 @@ + + */ + public $users; + + public function __construct(string $name) + { + $this->name = $name; + $this->users = new ArrayCollection(); + } +} diff --git a/tests/Doctrine/Tests/Models/AbstractFetchEager/WithFetchEager/MobileRemoteControl.php b/tests/Doctrine/Tests/Models/AbstractFetchEager/WithFetchEager/MobileRemoteControl.php new file mode 100644 index 00000000000..cdbca6f3f0f --- /dev/null +++ b/tests/Doctrine/Tests/Models/AbstractFetchEager/WithFetchEager/MobileRemoteControl.php @@ -0,0 +1,14 @@ +remoteControl = $control; + } +} diff --git a/tests/Doctrine/Tests/Models/AbstractFetchEager/WithoutFetchEager/AbstractRemoveControl.php b/tests/Doctrine/Tests/Models/AbstractFetchEager/WithoutFetchEager/AbstractRemoveControl.php new file mode 100644 index 00000000000..7f2c14aa361 --- /dev/null +++ b/tests/Doctrine/Tests/Models/AbstractFetchEager/WithoutFetchEager/AbstractRemoveControl.php @@ -0,0 +1,50 @@ + + */ + public $users; + + public function __construct(string $name) + { + $this->name = $name; + $this->users = new ArrayCollection(); + } +} diff --git a/tests/Doctrine/Tests/Models/AbstractFetchEager/WithoutFetchEager/MobileRemoteControl.php b/tests/Doctrine/Tests/Models/AbstractFetchEager/WithoutFetchEager/MobileRemoteControl.php new file mode 100644 index 00000000000..6628234450f --- /dev/null +++ b/tests/Doctrine/Tests/Models/AbstractFetchEager/WithoutFetchEager/MobileRemoteControl.php @@ -0,0 +1,14 @@ +remoteControl = $control; + } +} diff --git a/tests/Doctrine/Tests/ORM/Functional/AbstractFetchEagerTest.php b/tests/Doctrine/Tests/ORM/Functional/AbstractFetchEagerTest.php new file mode 100644 index 00000000000..148e1976817 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/AbstractFetchEagerTest.php @@ -0,0 +1,58 @@ +createSchemaForModels( + AbstractRemoveControl::class, + User::class + ); + + $control = new MobileRemoteControl('smart'); + $user = new User($control); + + $this->_em->persist($control); + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->find(User::class, $user->id); + + self::assertNotNull($user); + self::assertEquals('smart', $user->remoteControl->name); + } + + public function testWithoutAbstractFetchEager(): void + { + $this->createSchemaForModels( + AbstractRemoveControlWithoutFetchEager::class, + UserWithoutFetchEager::class + ); + + $control = new MobileRemoteControlWithoutFetchEager('smart'); + $user = new UserWithoutFetchEager($control); + + $this->_em->persist($control); + $this->_em->persist($user); + $this->_em->flush(); + $this->_em->clear(); + + $user = $this->_em->find(UserWithoutFetchEager::class, $user->id); + + self::assertNotNull($user); + self::assertEquals('smart', $user->remoteControl->name); + } +}