forked from doctrine/orm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DDC-1129] Fix bug in version changeset computation aswell as inline …
…ClassMetadata::isCollectionValuedAssociation to increase performance by 2-5%
- Loading branch information
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1129Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\ORM\Functional\Ticket; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
require_once __DIR__ . '/../../../TestInit.php'; | ||
|
||
/** | ||
* @group DDC-1129 | ||
*/ | ||
class DDC1129Test extends \Doctrine\Tests\OrmFunctionalTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->useModelSet('cms'); | ||
parent::setUp(); | ||
} | ||
|
||
public function testVersionFieldIgnoredInChangesetComputation() | ||
{ | ||
$article = new \Doctrine\Tests\Models\CMS\CmsArticle(); | ||
$article->text = "I don't know."; | ||
$article->topic = "Who is John Galt?"; | ||
|
||
$this->_em->persist($article); | ||
$this->_em->flush(); | ||
|
||
$this->assertEquals(1, $article->version); | ||
|
||
$class = $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsArticle'); | ||
$uow = $this->_em->getUnitOfWork(); | ||
|
||
$uow->computeChangeSet($class, $article); | ||
$changeSet = $uow->getEntityChangeSet($article); | ||
$this->assertEquals(0, count($changeSet), "No changesets should be computed."); | ||
|
||
$article->text = "This is John Galt speaking."; | ||
$this->_em->flush(); | ||
|
||
$this->assertEquals(2, $article->version); | ||
|
||
$uow->computeChangeSet($class, $article); | ||
$changeSet = $uow->getEntityChangeSet($article); | ||
$this->assertEquals(0, count($changeSet), "No changesets should be computed."); | ||
} | ||
} |