Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #259 from danielholmes/m2m_extra_lazy_contains
Added fix for collection->contains with many-to-many extra lazy fetchMode
- Loading branch information
Showing
2 changed files
with
59 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
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); | ||
} | ||
} |