Skip to content

Commit

Permalink
Add a test reproducing GH7259
Browse files Browse the repository at this point in the history
  • Loading branch information
stof authored and Majkl578 committed Sep 23, 2018
1 parent 6ff677d commit 6219f72
Showing 1 changed file with 167 additions and 0 deletions.
167 changes: 167 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH7259Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\ORM\Annotation as ORM;
use Doctrine\Tests\OrmFunctionalTestCase;

final class GH7259Test extends OrmFunctionalTestCase
{
protected function setUp() : void
{
parent::setUp();

$this->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;
}

0 comments on commit 6219f72

Please sign in to comment.