DDC1129Test.php 1.3 KB

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