1
0
mirror of synced 2025-01-18 22:41:43 +03:00

[2.0][DDC-493] Added coverage to DDC-493 and optimized DDC-513 unit tests. Previous commit fixed the issue.

This commit is contained in:
Guilherme Blanco 2010-04-13 00:40:45 -03:00
parent 56a8f5cd53
commit dd2dd80281
2 changed files with 69 additions and 8 deletions

View File

@ -0,0 +1,69 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
require_once __DIR__ . '/../../../TestInit.php';
class DDC493Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC493Customer'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC493Distributor'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC493Contact')
));
}
public function testIssue()
{
$q = $this->_em->createQuery("select u, u.contact.data from ".__NAMESPACE__."\\DDC493Distributor u");
$this->assertEquals('SELECT d0_.id AS id0, d1_.data AS data1, d0_.discr AS discr2, d0_.contact AS contact3 FROM DDC493Distributor d2_ INNER JOIN DDC493Customer d0_ ON d2_.id = d0_.id INNER JOIN DDC493Contact d1_ ON d0_.contact = d1_.id', $q->getSQL());
}
}
/**
* @Entity
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({"distributor" = "DDC493Distributor", "customer" = "DDC493Customer"})
*/
class DDC493Customer {
/**
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public $id;
/**
* @OneToOne(targetEntity="DDC493Contact", cascade={"remove","persist"})
* @JoinColumn(name="contact", referencedColumnName="id")
*/
public $contact;
}
/**
* @Entity
*/
class DDC493Distributor extends DDC493Customer {
}
/**
* @Entity
*/
class DDC493Contact
{
/**
* @Id
* @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public $id;
/** @Column(type="string") */
public $data;
}

View File

@ -17,14 +17,6 @@ class DDC513Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function testIssue()
{
$item = new DDC513OfferItem();
$this->_em->persist($item);
$this->_em->flush();
//$q = $this->_em->createQuery("select u from ".__NAMESPACE__."\\DDC513Item u left join u.price p");
//$this->assertEquals('SELECT d0_.id AS id0, d0_.discr AS discr1, d0_.price AS price2 FROM DDC513Item d0_ LEFT JOIN DDC513OfferItem d1_ ON d0_.id = d1_.id LEFT JOIN DDC513Price d2_ ON d0_.price = d2_.id', $q->getSQL());
/* THIS QUERY CAUSE EXCEPTION */
$q = $this->_em->createQuery("select u from ".__NAMESPACE__."\\DDC513OfferItem u left join u.price p");
$this->assertEquals('SELECT d0_.id AS id0, d0_.discr AS discr1, d0_.price AS price2 FROM DDC513OfferItem d1_ INNER JOIN DDC513Item d0_ ON d1_.id = d0_.id LEFT JOIN DDC513Price d2_ ON d0_.price = d2_.id', $q->getSQL());
}