Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC812Test.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5 use Doctrine\Tests\Models\CMS\CmsArticle;
6 use Doctrine\Tests\Models\CMS\CmsComment;
7
8 require_once __DIR__ . '/../../../TestInit.php';
9
10 class DDC812Test extends \Doctrine\Tests\OrmFunctionalTestCase
11 {
12     protected function setUp()
13     {
14         $this->useModelSet('cms');
15         parent::setUp();
16     }
17
18     /**
19      * @group DDC-812
20      */
21     public function testFetchJoinInitializesPreviouslyUninitializedCollectionOfManagedEntity()
22     {
23         //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
24         $article = new CmsArticle;
25         $article->topic = "hello";
26         $article->text = "talk talk talk";
27
28         $comment = new CmsComment;
29         $comment->topic = "good!";
30         $comment->text = "stuff!";
31         $comment->article = $article;
32
33         $this->_em->persist($article);
34         $this->_em->persist($comment);
35         $this->_em->flush();
36         $this->_em->clear();
37
38         $article2 = $this->_em->find(get_class($article), $article->id);
39
40         $article2Again = $this->_em->createQuery(
41             "select a, c from Doctrine\Tests\Models\CMS\CmsArticle a join a.comments c where a.id = ?1")
42             ->setParameter(1, $article->id)
43             ->getSingleResult();
44
45         $this->assertTrue($article2Again === $article2);
46         $this->assertTrue($article2Again->comments->isInitialized());
47     }
48 }