-
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.
Add failing test for failing to update child-parent relation when the…
… child has been prefetched in QB
- Loading branch information
Showing
3 changed files
with
139 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Models\GH7212; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
#[ORM\Entity] | ||
class GH7212Child | ||
{ | ||
/** @var int */ | ||
#[ORM\Column(type: 'integer')] | ||
#[ORM\Id] | ||
private $id; | ||
|
||
/** @var GH7212Parent|null */ | ||
#[ORM\ManyToOne(targetEntity: GH7212Parent::class, inversedBy: 'children')] | ||
private $parent; | ||
|
||
public function __construct(int $id, GH7212Parent|null $parent = null) | ||
{ | ||
$this->id = $id; | ||
|
||
$this->setParent($parent); | ||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getParent(): GH7212Parent|null | ||
{ | ||
return $this->parent; | ||
} | ||
|
||
public function setParent(GH7212Parent|null $parent): void | ||
{ | ||
$this->parent = $parent; | ||
} | ||
} |
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,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Models\GH7212; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Doctrine\ORM\Mapping\Column; | ||
use Doctrine\ORM\Mapping\Id; | ||
use Doctrine\ORM\Mapping\OneToMany; | ||
|
||
#[ORM\Entity] | ||
class GH7212Parent | ||
{ | ||
/** @var int */ | ||
#[Id] | ||
#[Column(type: 'integer')] | ||
private $id; | ||
|
||
/** @var Collection<int, GH7212Child> */ | ||
#[OneToMany(targetEntity: GH7212Child::class, mappedBy: 'parent', indexBy: 'id')] | ||
private $children; | ||
|
||
public function __construct(int $id) | ||
{ | ||
$this->id = $id; | ||
$this->children = new ArrayCollection(); | ||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function addChild(GH7212Child $child): void | ||
{ | ||
$this->children->set($child->getId(), $child); | ||
} | ||
|
||
public function removeChild(GH7212Child $child): void | ||
{ | ||
$this->children->remove($child->getId()); | ||
} | ||
|
||
/** @return Collection<int, GH7212Child> */ | ||
public function getChildren(): Collection | ||
{ | ||
return $this->children; | ||
} | ||
} |
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