3 namespace Doctrine\Tests\ORM\Functional\Ticket;
5 use Doctrine\Common\Collections\ArrayCollection;
6 use Doctrine\ORM\UnitOfWork;
8 require_once __DIR__ . '/../../../TestInit.php';
13 class DDC1452Test extends \Doctrine\Tests\OrmFunctionalTestCase
15 protected function setUp()
17 $this->useModelSet('cms');
21 $this->_schemaTool->createSchema(array(
22 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1452EntityA'),
23 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1452EntityB'),
25 } catch (\Exception $ignored) {
29 public function testIssue()
31 $a1 = new DDC1452EntityA();
34 $a2 = new DDC1452EntityA();
37 $b = new DDC1452EntityB();
38 $b->entityAFrom = $a1;
41 $this->_em->persist($a1);
42 $this->_em->persist($a2);
43 $this->_em->persist($b);
47 $dql = "SELECT a, b, ba FROM " . __NAMESPACE__ . "\DDC1452EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba";
48 $results = $this->_em->createQuery($dql)->setMaxResults(1)->getResult();
50 $this->assertSame($results[0], $results[0]->entitiesB[0]->entityAFrom);
51 $this->assertFalse( $results[0]->entitiesB[0]->entityATo instanceof \Doctrine\ORM\Proxy\Proxy );
52 $this->assertInstanceOf('Doctrine\Common\Collections\Collection', $results[0]->entitiesB[0]->entityATo->getEntitiesB());
55 public function testFetchJoinOneToOneFromInverse()
57 $address = new \Doctrine\Tests\Models\CMS\CmsAddress();
58 $address->city = "Bonn";
59 $address->country = "Germany";
60 $address->street = "Somestreet";
61 $address->zip = 12345;
63 $user = new \Doctrine\Tests\Models\CMS\CmsUser();
64 $user->name = "beberlei";
65 $user->username = "beberlei";
66 $user->status = "active";
67 $user->address = $address;
68 $address->user = $user;
70 $this->_em->persist($address);
71 $this->_em->persist($user);
75 $dql = "SELECT a, u FROM Doctrine\Tests\Models\CMS\CmsAddress a INNER JOIN a.user u";
76 $data = $this->_em->createQuery($dql)->getResult();
79 $this->assertFalse($data[0]->user instanceof \Doctrine\ORM\Proxy\Proxy);
81 $dql = "SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.address a";
82 $data = $this->_em->createQuery($dql)->getResult();
84 $this->assertFalse($data[0]->address instanceof \Doctrine\ORM\Proxy\Proxy);
93 /** @Id @Column(type="integer") @GeneratedValue */
97 /** @ManyToMany(targetEntity="DDC1452EntityB", mappedBy="entityAFrom") */
100 public function __construct()
102 $this->entitiesB = new ArrayCollection();
105 public function getEntitiesB()
107 return $this->entitiesB;
116 /** @Id @Column(type="integer") @GeneratedValue */
120 * @ManyToOne(targetEntity="DDC1452EntityA", inversedBy="entitiesB")
124 * @ManyToOne(targetEntity="DDC1452EntityA")