public function testCanBePutInLazyLoadingMode() { $class = $this->_emMock->getClassMetadata('Doctrine\\Tests\\Models\\ECommerce\\ECommerceProduct'); $collection = new PersistentCollection($this->_emMock, $class, new ArrayCollection()); $collection->setInitialized(false); $this->assertFalse($collection->isInitialized()); }
/** * {@inheritdoc} */ public function update(PersistentCollection $collection) { $isInitialized = $collection->isInitialized(); $isDirty = $collection->isDirty(); if (!$isInitialized && !$isDirty) { return; } $ownerId = $this->uow->getEntityIdentifier($collection->getOwner()); $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); // Invalidate non initialized collections OR ordered collection if ($isDirty && !$isInitialized || isset($this->association['orderBy'])) { $this->persister->update($collection); $this->queuedCache['delete'][spl_object_hash($collection)] = $key; return; } $this->persister->update($collection); $this->queuedCache['update'][spl_object_hash($collection)] = ['key' => $key, 'list' => $collection]; }
/** * {@inheritdoc} */ public function update(PersistentCollection $collection) { $isInitialized = $collection->isInitialized(); $isDirty = $collection->isDirty(); if (!$isInitialized && !$isDirty) { return; } $this->persister->update($collection); $ownerId = $this->uow->getEntityIdentifier($collection->getOwner()); $key = new CollectionCacheKey($this->sourceEntity->rootEntityName, $this->association['fieldName'], $ownerId); $lock = $this->region->lock($key); if ($lock === null) { return; } $this->queuedCache['update'][spl_object_hash($collection)] = array('key' => $key, 'lock' => $lock); }
/** * Test that PersistentCollection::next() initializes the collection. */ public function testNextInitializesCollection() { $this->setUpPersistentCollection(); $this->collection->next(); $this->assertTrue($this->collection->isInitialized()); }