1
0
mirror of synced 2025-01-19 23:11:41 +03:00

95 lines
2.2 KiB
PHP
Raw Normal View History

2014-07-22 15:20:44 +02:00
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Tests\OrmFunctionalTestCase;
/**
* Functional tests for get Id after clone child entity
*
* @author Lallement Thomas <thomas.lallement@9online.fr>
*/
class DDC3223Test extends OrmFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
$this->setUpEntitySchema(array(
'Doctrine\Tests\ORM\Functional\Ticket\Journalist',
'Doctrine\Tests\ORM\Functional\Ticket\Participant',
'Doctrine\Tests\ORM\Functional\Ticket\Status',
'Doctrine\Tests\ORM\Functional\Ticket\ProfileStatus',
));
}
public function testIssueGetId()
{
$profileStatus = new ProfileStatus();
$participant = new Journalist();
$participant->profileStatus = $profileStatus;
$this->_em->persist($profileStatus);
$this->_em->persist($participant);
$this->_em->flush();
$this->_em->clear();
$participant = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\Participant', $participant->id);
$profileStatus = clone $participant->profileStatus;
$this->assertSame(1, $profileStatus->getId(), 'The identifier on the cloned instance is an integer');
}
}
/** @Entity @Table(name="ddc3223_journalist") */
2014-07-22 15:20:44 +02:00
class Journalist extends Participant
{
}
/**
* @Entity @Table(name="ddc3223_participant")
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({
* "journalist" = "Journalist",
* "participant" = "Participant",
2014-07-22 15:20:44 +02:00
* })
*/
class Participant
{
/** @Id @Column(type="integer") @GeneratedValue */
2014-07-22 15:20:44 +02:00
public $id;
/** @ManyToOne(targetEntity="ProfileStatus") */
2014-07-22 15:20:44 +02:00
public $profileStatus;
}
/**
* @Entity @Table(name="ddc3223_status")
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({
* "profile" = "ProfileStatus",
* "status" = "Status",
2014-07-22 15:20:44 +02:00
* })
*/
class Status
{
/** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
2014-07-22 15:20:44 +02:00
private $id;
public function getId()
{
return $this->id;
}
}
/**
* @Entity
*/
class ProfileStatus extends Status
{
}