1
0
mirror of synced 2025-01-05 16:53:21 +03:00

Fix DDC440Test to comply with Oracle Identifier-Name Restrictions

This commit is contained in:
Benjamin Eberlei 2010-07-29 00:10:23 +02:00
parent 5bebf13d58
commit af59a581f0

View File

@ -6,13 +6,14 @@ require_once __DIR__ . '/../../../TestInit.php';
class DDC440Test extends \Doctrine\Tests\OrmFunctionalTestCase class DDC440Test extends \Doctrine\Tests\OrmFunctionalTestCase
{ {
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
try { try {
$this->_schemaTool->createSchema(array( $this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone'), $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC440Client') $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Ticket\DDC440Client')
)); ));
} catch (\Exception $e) { } catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here. // Swallow all exceptions. We do not test the schema tool here.
@ -25,17 +26,17 @@ class DDC440Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function testOriginalEntityDataEmptyWhenProxyLoadedFromTwoAssociations() public function testOriginalEntityDataEmptyWhenProxyLoadedFromTwoAssociations()
{ {
/* The key of the problem is that the first phone is fetched via two association, main_phone and phones. /* The key of the problem is that the first phone is fetched via two association, main_phone and phones.
* *
* You will notice that the original_entity_datas are not loaded for the first phone. (They are for the second) * You will notice that the original_entity_datas are not loaded for the first phone. (They are for the second)
* *
* In the Client entity definition, if you define the main_phone relation after the phones relation, both assertions pass. * In the Client entity definition, if you define the main_phone relation after the phones relation, both assertions pass.
* (for the sake or this test, I defined the main_phone relation before the phones relation) * (for the sake or this test, I defined the main_phone relation before the phones relation)
* *
*/ */
//Initialize some data //Initialize some data
$client = new DDC440Client; $client = new DDC440Client;
$client->setName('Client1'); $client->setName('Client1');
@ -46,9 +47,9 @@ class DDC440Test extends \Doctrine\Tests\OrmFunctionalTestCase
$phone2 = new DDC440Phone; $phone2 = new DDC440Phone;
$phone2->setNumber('418 222-2222'); $phone2->setNumber('418 222-2222');
$phone2->setClient($client); $phone2->setClient($client);
$client->setMainPhone($phone); $client->setMainPhone($phone);
$this->_em->persist($client); $this->_em->persist($client);
$this->_em->flush(); $this->_em->flush();
$id = $client->getId(); $id = $client->getId();
@ -72,80 +73,83 @@ class DDC440Test extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertType('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone', $p2); $this->assertType('Doctrine\Tests\ORM\Functional\Ticket\DDC440Phone', $p2);
$originalData = $uw->getOriginalEntityData($p2); $originalData = $uw->getOriginalEntityData($p2);
$this->assertEquals($phone2->getNumber(), $originalData['number']); $this->assertEquals($phone2->getNumber(), $originalData['number']);
} }
} }
/** /**
* @Entity * @Entity
* @Table(name="phone") * @Table(name="phone")
*/ */
class DDC440Phone { class DDC440Phone
{
/**
/**
* @Column(name="id", type="integer") * @Column(name="id", type="integer")
* @Id * @Id
* @GeneratedValue(strategy="AUTO") * @GeneratedValue(strategy="AUTO")
*/ */
protected $id; protected $id;
/**
/**
* @ManyToOne(targetEntity="DDC440Client",inversedBy="phones") * @ManyToOne(targetEntity="DDC440Client",inversedBy="phones")
* @JoinColumns({ * @JoinColumns({
* @JoinColumn(name="client_id", referencedColumnName="id") * @JoinColumn(name="client_id", referencedColumnName="id")
* }) * })
*/ */
protected $client; protected $client;
/** /**
* @Column(name="number", type="string") * @Column(name="phonenumber", type="string")
*/ */
protected $number; protected $number;
public function setNumber($value){ public function setNumber($value)
$this->number = $value; {
$this->number = $value;
} }
public function getNumber(){ public function getNumber()
return $this->number; {
return $this->number;
} }
public function setClient(DDC440Client $value, $update_inverse=true) public function setClient(DDC440Client $value, $update_inverse=true)
{ {
$this->client = $value; $this->client = $value;
if($update_inverse){ if ($update_inverse) {
$value->addPhone($this); $value->addPhone($this);
} }
} }
public function getClient() public function getClient()
{ {
return $this->client; return $this->client;
} }
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
public function setId($value){ public function setId($value)
$this->id = $value; {
$this->id = $value;
} }
} }
/** /**
* @Entity * @Entity
* @Table(name="client") * @Table(name="client")
*/ */
class DDC440Client { class DDC440Client
{
/**
/**
* @Column(name="id", type="integer") * @Column(name="id", type="integer")
* @Id * @Id
* @GeneratedValue(strategy="AUTO") * @GeneratedValue(strategy="AUTO")
*/ */
protected $id; protected $id;
/** /**
* @OneToOne(targetEntity="DDC440Phone", fetch="EAGER") * @OneToOne(targetEntity="DDC440Phone", fetch="EAGER")
* @JoinColumns({ * @JoinColumns({
@ -153,55 +157,59 @@ class DDC440Client {
* }) * })
*/ */
protected $main_phone; protected $main_phone;
/** /**
* @OneToMany(targetEntity="DDC440Phone", mappedBy="client", cascade={"persist", "remove"}, fetch="EAGER") * @OneToMany(targetEntity="DDC440Phone", mappedBy="client", cascade={"persist", "remove"}, fetch="EAGER")
*/ */
protected $phones; protected $phones;
/** /**
* @Column(name="name", type="string") * @Column(name="name", type="string")
*/ */
protected $name; protected $name;
public function __construct(){ public function __construct()
{
} }
public function setName($value){ public function setName($value)
$this->name = $value; {
$this->name = $value;
} }
public function getName(){ public function getName()
return $this->name; {
return $this->name;
} }
public function addPhone(DDC440Phone $value) public function addPhone(DDC440Phone $value)
{ {
$this->phones[] = $value; $this->phones[] = $value;
$value->setClient($this, false); $value->setClient($this, false);
} }
public function getPhones() public function getPhones()
{ {
return $this->phones; return $this->phones;
} }
public function setMainPhone(DDC440Phone $value){ public function setMainPhone(DDC440Phone $value)
$this->main_phone = $value; {
$this->main_phone = $value;
} }
public function getMainPhone(){ public function getMainPhone()
return $this->main_phone; {
return $this->main_phone;
} }
public function getId() public function getId()
{ {
return $this->id; return $this->id;
} }
public function setId($value){ public function setId($value)
$this->id = $value; {
$this->id = $value;
} }
} }