PersistentCollectionTest.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Doctrine\Tests\ORM;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\PersistentCollection;
  5. use Doctrine\Tests\Mocks\ConnectionMock;
  6. use Doctrine\Tests\Mocks\EntityManagerMock;
  7. use Doctrine\Tests\Models\ECommerce\ECommerceProduct;
  8. require_once __DIR__ . '/../TestInit.php';
  9. /**
  10. * Tests the lazy-loading capabilities of the PersistentCollection.
  11. * @author Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
  12. */
  13. class PersistentCollectionTest extends \Doctrine\Tests\OrmTestCase
  14. {
  15. private $_connectionMock;
  16. private $_emMock;
  17. protected function setUp()
  18. {
  19. parent::setUp();
  20. // SUT
  21. $this->_connectionMock = new ConnectionMock(array(), new \Doctrine\Tests\Mocks\DriverMock());
  22. $this->_emMock = EntityManagerMock::create($this->_connectionMock);
  23. }
  24. public function testCanBePutInLazyLoadingMode()
  25. {
  26. $class = $this->_emMock->getClassMetadata('Doctrine\Tests\Models\ECommerce\ECommerceProduct');
  27. $collection = new PersistentCollection($this->_emMock, $class, new ArrayCollection);
  28. $collection->setInitialized(false);
  29. $this->assertFalse($collection->isInitialized());
  30. }
  31. }