forked from zenstruck/foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: propagte "schedule for insert" to factory collection
- Loading branch information
Showing
8 changed files
with
229 additions
and
33 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
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
39 changes: 39 additions & 0 deletions
39
tests/Fixture/Entity/EdgeCases/InversedOneToOneWithOneToMany/InverseSide.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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <kevinbond@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\InversedOneToOneWithOneToMany; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Zenstruck\Foundry\Tests\Fixture\Model\Base; | ||
|
||
/** | ||
* @author Nicolas PHILIPPE <nikophil@gmail.com> | ||
*/ | ||
#[ORM\Entity] | ||
#[ORM\Table('inversed_one_to_one_with_one_to_many_inverse_side')] | ||
class InverseSide extends Base | ||
{ | ||
#[ORM\OneToOne(mappedBy: 'inverseSide')] | ||
private ?OwningSide $owningSide = null; | ||
|
||
public function getOwningSide(): ?OwningSide | ||
{ | ||
return $this->owningSide; | ||
} | ||
|
||
public function setOwningSide(OwningSide $owningSide): void | ||
{ | ||
$this->owningSide = $owningSide; | ||
$owningSide->inverseSide = $this; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/Fixture/Entity/EdgeCases/InversedOneToOneWithOneToMany/Item.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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <kevinbond@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\InversedOneToOneWithOneToMany; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Zenstruck\Foundry\Tests\Fixture\Model\Base; | ||
|
||
/** | ||
* @author Nicolas PHILIPPE <nikophil@gmail.com> | ||
*/ | ||
#[ORM\Entity] | ||
#[ORM\Table('inversed_one_to_one_with_one_to_many_item_if_collection')] | ||
class Item extends Base | ||
{ | ||
#[ORM\ManyToOne(inversedBy: 'items')] | ||
public ?OwningSide $owningSide = null; | ||
} |
63 changes: 63 additions & 0 deletions
63
tests/Fixture/Entity/EdgeCases/InversedOneToOneWithOneToMany/OwningSide.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,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <kevinbond@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Tests\Fixture\Entity\EdgeCases\InversedOneToOneWithOneToMany; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Zenstruck\Foundry\Tests\Fixture\Model\Base; | ||
|
||
/** | ||
* @author Nicolas PHILIPPE <nikophil@gmail.com> | ||
*/ | ||
#[ORM\Entity] | ||
#[ORM\Table('inversed_one_to_one_with_one_to_many_owning_side')] | ||
class OwningSide extends Base | ||
{ | ||
#[ORM\OneToOne(inversedBy: 'owningSide')] | ||
public ?InverseSide $inverseSide = null; | ||
|
||
/** @var Collection<int, Item> */ | ||
#[ORM\OneToMany(targetEntity: Item::class, mappedBy: 'owningSide')] | ||
private Collection $items; | ||
|
||
public function __construct() | ||
{ | ||
$this->items = new ArrayCollection(); | ||
} | ||
|
||
/** | ||
* @return Collection<int, Item> | ||
*/ | ||
public function getItems(): Collection | ||
{ | ||
return $this->items; | ||
} | ||
|
||
public function addItem(Item $item): void | ||
{ | ||
if (!$this->items->contains($item)) { | ||
$this->items->add($item); | ||
$item->owningSide = $this; | ||
} | ||
} | ||
|
||
public function removeItem(Item $item): void | ||
{ | ||
if ($this->items->contains($item)) { | ||
$this->items->removeElement($item); | ||
$item->owningSide = null; | ||
} | ||
} | ||
} |
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