Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC1129Test.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5 use Doctrine\Common\Collections\ArrayCollection;
6 require_once __DIR__ . '/../../../TestInit.php';
7
8 /**
9  * @group DDC-1129
10  */
11 class DDC1129Test extends \Doctrine\Tests\OrmFunctionalTestCase
12 {
13     public function setUp()
14     {
15         $this->useModelSet('cms');
16         parent::setUp();
17     }
18
19     public function testVersionFieldIgnoredInChangesetComputation()
20     {
21         $article = new \Doctrine\Tests\Models\CMS\CmsArticle();
22         $article->text = "I don't know.";
23         $article->topic = "Who is John Galt?";
24
25         $this->_em->persist($article);
26         $this->_em->flush();
27
28         $this->assertEquals(1, $article->version);
29
30         $class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle');
31         $uow = $this->_em->getUnitOfWork();
32
33         $uow->computeChangeSet($class, $article);
34         $changeSet = $uow->getEntityChangeSet($article);
35         $this->assertEquals(0, count($changeSet), "No changesets should be computed.");
36
37         $article->text = "This is John Galt speaking.";
38         $this->_em->flush();
39
40         $this->assertEquals(2, $article->version);
41
42         $uow->computeChangeSet($class, $article);
43         $changeSet = $uow->getEntityChangeSet($article);
44         $this->assertEquals(0, count($changeSet), "No changesets should be computed.");
45     }
46 }