-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11363 from greg0ire/3.1.x
Merge 2.19.x up into 3.1.x
- Loading branch information
Showing
8 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
:orphan: | ||
|
||
Installation | ||
============ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
:orphan: | ||
|
||
.. toc:: | ||
|
||
.. tocheader:: Tutorials | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/Tests/Models/AbstractFetchEager/AbstractRemoteControl.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Models\AbstractFetchEager; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
#[ORM\Entity] | ||
#[ORM\Table(name: 'abstract_fetch_eager_remote_control')] | ||
#[ORM\InheritanceType('SINGLE_TABLE')] | ||
#[ORM\DiscriminatorColumn(name: 'type', type: 'string')] | ||
#[ORM\DiscriminatorMap(['mobile' => 'MobileRemoteControl'])] | ||
abstract class AbstractRemoteControl | ||
{ | ||
#[ORM\Id] | ||
#[ORM\GeneratedValue] | ||
#[ORM\Column(type: 'integer')] | ||
public int $id; | ||
|
||
#[ORM\Column(type: 'string')] | ||
public string $name; | ||
|
||
/** @var Collection<User> */ | ||
#[ORM\OneToMany(targetEntity: User::class, mappedBy: 'remoteControl', fetch: 'EAGER')] | ||
public Collection $users; | ||
|
||
public function __construct(string $name) | ||
{ | ||
$this->name = $name; | ||
$this->users = new ArrayCollection(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/Tests/Models/AbstractFetchEager/MobileRemoteControl.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Models\AbstractFetchEager; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
#[ORM\Entity] | ||
class MobileRemoteControl extends AbstractRemoteControl | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Models\AbstractFetchEager; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
#[ORM\Entity] | ||
#[ORM\Table(name: 'abstract_fetch_eager_user')] | ||
class User | ||
{ | ||
#[ORM\Id] | ||
#[ORM\GeneratedValue] | ||
#[ORM\Column(type: 'integer')] | ||
public int $id; | ||
|
||
#[ORM\ManyToOne(targetEntity: AbstractRemoteControl::class, inversedBy: 'users')] | ||
#[ORM\JoinColumn(nullable: false)] | ||
public AbstractRemoteControl $remoteControl; | ||
|
||
public function __construct(AbstractRemoteControl $control) | ||
{ | ||
$this->remoteControl = $control; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional; | ||
|
||
use Doctrine\Tests\Models\AbstractFetchEager\AbstractRemoteControl; | ||
use Doctrine\Tests\Models\AbstractFetchEager\MobileRemoteControl; | ||
use Doctrine\Tests\Models\AbstractFetchEager\User; | ||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
final class AbstractFetchEagerTest extends OrmFunctionalTestCase | ||
{ | ||
public function testWithAbstractFetchEager(): void | ||
{ | ||
$this->createSchemaForModels( | ||
AbstractRemoteControl::class, | ||
User::class, | ||
); | ||
|
||
$control = new MobileRemoteControl('smart'); | ||
$user = new User($control); | ||
|
||
$entityManage = $this->getEntityManager(); | ||
|
||
$entityManage->persist($control); | ||
$entityManage->persist($user); | ||
$entityManage->flush(); | ||
$entityManage->clear(); | ||
|
||
$user = $entityManage->find(User::class, $user->id); | ||
|
||
self::assertNotNull($user); | ||
self::assertEquals('smart', $user->remoteControl->name); | ||
self::assertTrue($user->remoteControl->users->contains($user)); | ||
} | ||
} |