Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fix for collection->contains when many-to-many extra lazy fetch…
…Mode
- Loading branch information
1 parent
286eef1
commit be6890e
Showing
2 changed files
with
58 additions
and
1 deletion.
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
55 changes: 55 additions & 0 deletions
55
tests/Doctrine/Tests/ORM/Functional/ManyToManyExtraLazyContainsTest.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,55 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\ORM\Functional; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
require_once __DIR__ . '/../../TestInit.php'; | ||
|
||
/** | ||
* | ||
*/ | ||
class ManyToManyExtraLazyContainsTest extends \Doctrine\Tests\OrmFunctionalTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->useModelSet('company'); | ||
parent::setUp(); | ||
} | ||
|
||
public function testManyToManyExtraLazyContainsAddedPendingInsertEntityIsTrue() | ||
{ | ||
$contract = new \Doctrine\Tests\Models\Company\CompanyFlexContract(); | ||
|
||
$this->_em->persist($contract); | ||
$this->_em->flush(); | ||
|
||
$this->_em->clear(); | ||
$contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexContract', $contract->getId()); | ||
|
||
$pendingInsertManager = new \Doctrine\Tests\Models\Company\CompanyManager(); | ||
$this->_em->persist($pendingInsertManager); | ||
$contract->getManagers()->add($pendingInsertManager); | ||
|
||
$result = $contract->getManagers()->contains($pendingInsertManager); | ||
|
||
$this->assertTrue($result); | ||
} | ||
|
||
public function testManyToManyExtraLazyContainsNonAddedPendingInsertEntityIsFalse() | ||
{ | ||
$contract = new \Doctrine\Tests\Models\Company\CompanyFlexContract(); | ||
|
||
$this->_em->persist($contract); | ||
$this->_em->flush(); | ||
|
||
$this->_em->clear(); | ||
$contract = $this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexContract', $contract->getId()); | ||
|
||
$pendingInsertManager = new \Doctrine\Tests\Models\Company\CompanyManager(); | ||
$this->_em->persist($pendingInsertManager); | ||
|
||
$result = $contract->getManagers()->contains($pendingInsertManager); | ||
|
||
$this->assertFalse($result); | ||
} | ||
} |