From 6219f72dc621da4b635e8560167fe39918553904 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 15 Jun 2018 13:09:59 +0200 Subject: [PATCH] Add a test reproducing GH7259 --- .../ORM/Functional/Ticket/GH7259Test.php | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php new file mode 100644 index 00000000000..b43bbf81d80 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php @@ -0,0 +1,167 @@ +setUpEntitySchema([GH7259Space::class, GH7259File::class, GH7259FileVersion::class, GH7259Feed::class]); + } + + /** + * @group 7259 + */ + public function testPersistFileBeforeVersion() : void + { + $space = new GH7259Space(); + + $this->em->persist($space); + $this->em->flush(); + + $feed = new GH7259Feed(); + $feed->space = $space; + + $file = new GH7259File(); + $file->space = $space; + $fileVersion = new GH7259FileVersion(); + $fileVersion->file = $file; + + $this->em->persist($file); + $this->em->persist($fileVersion); + $this->em->persist($feed); + + $this->em->flush(); + + self::assertNotNull($fileVersion->id); + } + + /** + * @group 7259 + */ + public function testPersistFileAfterVersion() : void + { + $space = new GH7259Space(); + + $this->em->persist($space); + $this->em->flush(); + $this->em->clear(); + + $space = $this->em->find(GH7259Space::class, $space->id); + + $feed = new GH7259Feed(); + $feed->space = $space; + + $file = new GH7259File(); + $file->space = $space; + $fileVersion = new GH7259FileVersion(); + $fileVersion->file = $file; + + $this->em->persist($fileVersion); + $this->em->persist($file); + $this->em->persist($feed); + + $this->em->flush(); + + self::assertNotNull($fileVersion->id); + } +} + +/** + * @ORM\Entity() + */ +class GH7259File +{ + /** + * @ORM\Id + * @ORM\GeneratedValue + * @ORM\Column(type="integer") + * + * @var int + */ + public $id; + + /** + * @ORM\ManyToOne(targetEntity=GH7259Space::class) + * @ORM\JoinColumn(nullable=false) + * + * @var GH7259Space|null + */ + public $space; +} + +/** + * @ORM\Entity() + */ +class GH7259FileVersion +{ + /** + * @ORM\Id + * @ORM\GeneratedValue + * @ORM\Column(type="integer") + * + * @var int + */ + public $id; + + /** + * @ORM\ManyToOne(targetEntity=GH7259File::class) + * @ORM\JoinColumn(nullable=false) + * + * @var GH7259File|null + */ + public $file; +} + +/** + * @ORM\Entity() + */ +class GH7259Space +{ + /** + * @ORM\Id + * @ORM\GeneratedValue + * @ORM\Column(type="integer") + * + * @var int + */ + public $id; + + /** + * @ORM\ManyToOne(targetEntity=GH7259File::class) + * @ORM\JoinColumn(nullable=true) + * + * @var GH7259File|null + */ + public $ruleFile; +} + +/** + * @ORM\Entity() + */ +class GH7259Feed +{ + /** + * @ORM\Id + * @ORM\GeneratedValue + * @ORM\Column(type="integer") + * + * @var int + */ + public $id; + + /** + * @ORM\ManyToOne(targetEntity=GH7259Space::class) + * @ORM\JoinColumn(nullable=false) + * + * @var GH7259Space|null + */ + public $space; +}