Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PersistentCollection - initialize coll - create failing tests
- Loading branch information
1 parent
063280b
commit 8956cfc
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
tests/Doctrine/Tests/ORM/PersistentCollectionFunctionalTest.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,73 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\ORM; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\ORM\PersistentCollection; | ||
use Doctrine\Tests\Models\ECommerce\ECommerceCart; | ||
use Doctrine\Tests\Models\ECommerce\ECommerceProduct; | ||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
require_once __DIR__ . '/../TestInit.php'; | ||
|
||
/** | ||
* Tests the initialization of persistent collections. | ||
* @author Austin Morris <austin.morris@gmail.com> | ||
*/ | ||
class PersistentCollectionFunctionalTest extends OrmFunctionalTestCase | ||
{ | ||
/** | ||
* @var PersistentCollection | ||
*/ | ||
protected $collection; | ||
|
||
/** | ||
* Setup tests. | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->useModelSet('ecommerce'); | ||
parent::setUp(); | ||
|
||
$classMetaData = $this->_em->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceCart'); | ||
$this->collection = new PersistentCollection($this->_em, $classMetaData, new ArrayCollection); | ||
$this->collection->setInitialized(false); | ||
$this->collection->setOwner(new ECommerceCart(), $classMetaData->getAssociationMapping('products')); | ||
} | ||
|
||
/** | ||
* Test that PersistentCollection::add() initializes the collection. | ||
*/ | ||
public function testAddInitializesCollection() | ||
{ | ||
$this->collection->add(new ECommerceProduct); | ||
$this->assertTrue($this->collection->isInitialized()); | ||
} | ||
|
||
/** | ||
* Test that PersistentCollection::current() initializes the collection. | ||
*/ | ||
public function testCurrentInitializesCollection() | ||
{ | ||
$this->collection->current(); | ||
$this->assertTrue($this->collection->isInitialized()); | ||
} | ||
|
||
/** | ||
* Test that PersistentCollection::key() initializes the collection. | ||
*/ | ||
public function testKeyInitializesCollection() | ||
{ | ||
$this->collection->key(); | ||
$this->assertTrue($this->collection->isInitialized()); | ||
} | ||
|
||
/** | ||
* Test that PersistentCollection::next() initializes the collection. | ||
*/ | ||
public function testNextInitializesCollection() | ||
{ | ||
$this->collection->next(); | ||
$this->assertTrue($this->collection->isInitialized()); | ||
} | ||
} |