Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC1225Test.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5 use Doctrine\Common\Collections\ArrayCollection;
6 use Doctrine\Tests\Models\CMS\CmsEmployee;
7
8 require_once __DIR__ . '/../../../TestInit.php';
9
10 /**
11  * @group DDC-1225
12  */
13 class DDC1225Test extends \Doctrine\Tests\OrmFunctionalTestCase
14 {
15     public function setUp()
16     {
17         parent::setUp();
18         try {
19             $this->_schemaTool->createSchema(array(
20                 $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1225_TestEntity1'),
21                 $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1225_TestEntity2'),
22             ));
23         } catch(\PDOException $e) {
24
25         }
26     }
27
28     public function testIssue()
29     {
30         $qb = $this->_em->createQueryBuilder();
31         $qb->from('Doctrine\Tests\ORM\Functional\Ticket\DDC1225_TestEntity1', 'te1')
32            ->select('te1')
33            ->where('te1.testEntity2 = ?1')
34            ->setParameter(1, 0);
35
36         $this->assertEquals(
37             strtolower('SELECT t0_.test_entity2_id AS test_entity2_id0 FROM te1 t0_ WHERE t0_.test_entity2_id = ?'),
38             strtolower($qb->getQuery()->getSQL())
39         );
40     }
41 }
42
43 /**
44  * @Entity
45  * @Table(name="te1")
46  */
47 class DDC1225_TestEntity1
48 {
49     /**
50      * @Id
51      * @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\DDC1225_TestEntity2")
52      * @JoinColumn(name="test_entity2_id", referencedColumnName="id", nullable=false)
53      */
54     private $testEntity2;
55
56     /**
57      * @param DDC1225_TestEntity2 $testEntity2
58      */
59     public function setTestEntity2(DDC1225_TestEntity2 $testEntity2)
60     {
61         $this->testEntity2 = $testEntity2;
62     }
63
64     /**
65      * @return DDC1225_TestEntity2
66      */
67     public function getTestEntity2()
68     {
69         return $this->testEntity2;
70     }
71 }
72
73 /**
74  * @Entity
75  * @Table(name="te2")
76  */
77 class DDC1225_TestEntity2
78 {
79     /**
80      * @Id
81      * @GeneratedValue(strategy="AUTO")
82      * @Column(type="integer")
83      */
84     private $id;
85 }