Commit 7297ac7b authored by romanb's avatar romanb

[2.0] Addressed #2363.

parent 82be4bf0
...@@ -376,35 +376,41 @@ class EntityManager ...@@ -376,35 +376,41 @@ class EntityManager
} }
/** /**
* Saves the given entity, persisting it's state. * Tells the EntityManager to make an instance managed and persistent.
* *
* @param object $object * The entity will be entered into the database at or before transaction
* commit or as a result of the flush operation.
*
* @param object $object The instance to make managed and persistent.
*/ */
public function save($object) public function persist($object)
{ {
$this->_errorIfClosed(); $this->_errorIfClosed();
$this->_unitOfWork->save($object); $this->_unitOfWork->persist($object);
if ($this->_flushMode == self::FLUSHMODE_IMMEDIATE) { if ($this->_flushMode == self::FLUSHMODE_IMMEDIATE) {
$this->flush(); $this->flush();
} }
} }
/** /**
* Deletes the persistent state of the given entity. * Removes an entity instance.
* *
* @param object $entity * A removed entity will be removed from the database at or before transaction commit
* or as a result of the flush operation.
*
* @param object $entity The entity instance to remove.
*/ */
public function delete($entity) public function remove($entity)
{ {
$this->_errorIfClosed(); $this->_errorIfClosed();
$this->_unitOfWork->delete($entity); $this->_unitOfWork->remove($entity);
if ($this->_flushMode == self::FLUSHMODE_IMMEDIATE) { if ($this->_flushMode == self::FLUSHMODE_IMMEDIATE) {
$this->flush(); $this->flush();
} }
} }
/** /**
* Refreshes the persistent state of the entity from the database, * Refreshes the persistent state of an entity from the database,
* overriding any local changes that have not yet been persisted. * overriding any local changes that have not yet been persisted.
* *
* @param object $entity * @param object $entity
...@@ -417,7 +423,7 @@ class EntityManager ...@@ -417,7 +423,7 @@ class EntityManager
} }
/** /**
* Detaches an entity from the EntityManager. Its lifecycle is no longer managed. * Detaches an entity from the EntityManager.
* *
* @param object $entity The entity to detach. * @param object $entity The entity to detach.
* @return boolean * @return boolean
...@@ -476,7 +482,7 @@ class EntityManager ...@@ -476,7 +482,7 @@ class EntityManager
} }
/** /**
* Checks if the instance is managed by the EntityManager. * Determines whether an entity instance is managed in this EntityManager.
* *
* @param object $entity * @param object $entity
* @return boolean TRUE if this EntityManager currently manages the given entity * @return boolean TRUE if this EntityManager currently manages the given entity
...@@ -485,7 +491,7 @@ class EntityManager ...@@ -485,7 +491,7 @@ class EntityManager
public function contains($entity) public function contains($entity)
{ {
return $this->_unitOfWork->isInIdentityMap($entity) && return $this->_unitOfWork->isInIdentityMap($entity) &&
! $this->_unitOfWork->isRegisteredRemoved($entity); ! $this->_unitOfWork->isScheduledForDelete($entity);
} }
/** /**
......
...@@ -199,7 +199,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection ...@@ -199,7 +199,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
{ {
//TODO: delete entity if shouldDeleteOrphans //TODO: delete entity if shouldDeleteOrphans
/*if ($this->_association->isOneToMany() && $this->_association->shouldDeleteOrphans()) { /*if ($this->_association->isOneToMany() && $this->_association->shouldDeleteOrphans()) {
$this->_em->delete($removed); $this->_em->remove($removed);
}*/ }*/
$removed = parent::remove($key); $removed = parent::remove($key);
if ($removed) { if ($removed) {
...@@ -377,7 +377,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection ...@@ -377,7 +377,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
//TODO: If oneToMany() && shouldDeleteOrphan() delete entities //TODO: If oneToMany() && shouldDeleteOrphan() delete entities
/*if ($this->_association->isOneToMany() && $this->_association->shouldDeleteOrphans()) { /*if ($this->_association->isOneToMany() && $this->_association->shouldDeleteOrphans()) {
foreach ($this->_data as $entity) { foreach ($this->_data as $entity) {
$this->_em->delete($entity); $this->_em->remove($entity);
} }
}*/ }*/
parent::clear(); parent::clear();
......
...@@ -351,7 +351,7 @@ class StandardEntityPersister ...@@ -351,7 +351,7 @@ class StandardEntityPersister
// Special case: One-one self-referencing of the same class. // Special case: One-one self-referencing of the same class.
if ($newVal !== null && $assocMapping->sourceEntityName == $assocMapping->targetEntityName) { if ($newVal !== null && $assocMapping->sourceEntityName == $assocMapping->targetEntityName) {
$oid = spl_object_hash($newVal); $oid = spl_object_hash($newVal);
$isScheduledForInsert = $uow->isRegisteredNew($newVal); $isScheduledForInsert = $uow->isScheduledForInsert($newVal);
if (isset($this->_queuedInserts[$oid]) || $isScheduledForInsert) { if (isset($this->_queuedInserts[$oid]) || $isScheduledForInsert) {
// The associated entity $newVal is not yet persisted, so we must // The associated entity $newVal is not yet persisted, so we must
// set $newVal = null, in order to insert a null value and schedule an // set $newVal = null, in order to insert a null value and schedule an
......
...@@ -166,7 +166,7 @@ class ResultSetMapping ...@@ -166,7 +166,7 @@ class ResultSetMapping
if ( ! $this->isMixed && $this->fieldMappings) { if ( ! $this->isMixed && $this->fieldMappings) {
$this->isMixed = true; $this->isMixed = true;
} }
} }
/** /**
* @return boolean * @return boolean
......
...@@ -58,7 +58,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -58,7 +58,7 @@ class UnitOfWork implements PropertyChangedListener
const STATE_MANAGED = 1; const STATE_MANAGED = 1;
/** /**
* An entity is new if it does not yet have an identifier/primary key * An entity is new if it has just been instantiated
* and is not (yet) managed by an EntityManager. * and is not (yet) managed by an EntityManager.
*/ */
const STATE_NEW = 2; const STATE_NEW = 2;
...@@ -66,7 +66,6 @@ class UnitOfWork implements PropertyChangedListener ...@@ -66,7 +66,6 @@ class UnitOfWork implements PropertyChangedListener
/** /**
* A detached entity is an instance with a persistent identity that is not * A detached entity is an instance with a persistent identity that is not
* (or no longer) associated with an EntityManager (and a UnitOfWork). * (or no longer) associated with an EntityManager (and a UnitOfWork).
* This means it is no longer in the identity map.
*/ */
const STATE_DETACHED = 3; const STATE_DETACHED = 3;
...@@ -88,7 +87,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -88,7 +87,7 @@ class UnitOfWork implements PropertyChangedListener
private $_identityMap = array(); private $_identityMap = array();
/** /**
* Map of all identifiers. Keys are object ids. * Map of all identifiers. Keys are object ids (spl_object_hash).
* *
* @var array * @var array
*/ */
...@@ -96,15 +95,18 @@ class UnitOfWork implements PropertyChangedListener ...@@ -96,15 +95,18 @@ class UnitOfWork implements PropertyChangedListener
/** /**
* Map of the original entity data of entities fetched from the database. * Map of the original entity data of entities fetched from the database.
* Keys are object ids. This is used for calculating changesets at commit time. * Keys are object ids (spl_object_hash). This is used for calculating changesets
* Note that PHPs "copy-on-write" behavior helps a lot with memory usage. * at commit time.
* *
* @var array * @var array
* @internal Note that PHPs "copy-on-write" behavior helps a lot with memory usage.
* A value will only really be copied if the value in the entity is modified
* by the user.
*/ */
private $_originalEntityData = array(); private $_originalEntityData = array();
/** /**
* Map of data changes. Keys are object ids. * Map of data changes. Keys are object ids (spl_object_hash).
* Filled at the beginning of a commit of the UnitOfWork and cleaned at the end. * Filled at the beginning of a commit of the UnitOfWork and cleaned at the end.
* *
* @var array * @var array
...@@ -113,6 +115,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -113,6 +115,7 @@ class UnitOfWork implements PropertyChangedListener
/** /**
* The states of entities in this UnitOfWork. * The states of entities in this UnitOfWork.
* Keys are object ids (spl_object_hash).
* *
* @var array * @var array
*/ */
...@@ -121,6 +124,9 @@ class UnitOfWork implements PropertyChangedListener ...@@ -121,6 +124,9 @@ class UnitOfWork implements PropertyChangedListener
/** /**
* Map of entities that are scheduled for dirty checking at commit time. * Map of entities that are scheduled for dirty checking at commit time.
* This is only used if automatic dirty checking is disabled. * This is only used if automatic dirty checking is disabled.
* Keys are object ids (spl_object_hash).
*
* @var array
*/ */
private $_scheduledForDirtyCheck = array(); private $_scheduledForDirtyCheck = array();
...@@ -164,7 +170,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -164,7 +170,7 @@ class UnitOfWork implements PropertyChangedListener
* *
* @var array * @var array
*/ */
private $_collectionCreations = array(); //private $_collectionCreations = array();
/** /**
* All collection updates. * All collection updates.
...@@ -355,26 +361,25 @@ class UnitOfWork implements PropertyChangedListener ...@@ -355,26 +361,25 @@ class UnitOfWork implements PropertyChangedListener
* If automatic dirty checking is disabled, only those changesets will be * If automatic dirty checking is disabled, only those changesets will be
* computed that have been scheduled through scheduleForDirtyCheck(). * computed that have been scheduled through scheduleForDirtyCheck().
*/ */
public function computeChangeSets(array $entities = null) public function computeChangeSets()
{ {
$entitySet = array(); $entitySet = $this->_identityMap;
$newEntities = array(); $entityInsertions = $this->_entityInsertions;
if ($entities !== null) {
foreach ($entities as $entity) {
$entitySet[get_class($entity)][] = $entity;
}
$newEntities = $entities;
} else {
$entitySet = $this->_identityMap;
$newEntities = $this->_entityInsertions;
}
// Compute changes for NEW entities first. This must always happen. // Compute changes for INSERTed entities first. This must always happen.
foreach ($newEntities as $entity) { foreach ($entityInsertions as $entity) {
$this->_computeEntityChanges($this->_em->getClassMetadata(get_class($entity)), $entity); $class = $this->_em->getClassMetadata(get_class($entity));
$this->_computeEntityChanges($class, $entity);
// Look for changes in associations of the entity
foreach ($class->associationMappings as $assoc) {
$val = $class->reflFields[$assoc->sourceFieldName]->getValue($entity);
if ($val !== null) {
$this->_computeAssociationChanges($assoc, $val);
}
}
} }
// Compute changes for MANAGED entities. Change tracking policies take effect here. // Compute changes for other MANAGED entities. Change tracking policies take effect here.
foreach ($entitySet as $className => $entities) { foreach ($entitySet as $className => $entities) {
$class = $this->_em->getClassMetadata($className); $class = $this->_em->getClassMetadata($className);
...@@ -388,8 +393,9 @@ class UnitOfWork implements PropertyChangedListener ...@@ -388,8 +393,9 @@ class UnitOfWork implements PropertyChangedListener
$this->_scheduledForDirtyCheck[$className] : $entities; $this->_scheduledForDirtyCheck[$className] : $entities;
foreach ($entitiesToProcess as $entity) { foreach ($entitiesToProcess as $entity) {
// Only MANAGED entities are processed here. // Only MANAGED entities that are NOT INSERTED are processed here.
if ($this->getEntityState($entity) == self::STATE_MANAGED) { $oid = spl_object_hash($entity);
if (isset($this->_entityStates[$oid]) && ! isset($entityInsertions[$oid])) {
$this->_computeEntityChanges($class, $entity); $this->_computeEntityChanges($class, $entity);
// Look for changes in associations of the entity // Look for changes in associations of the entity
foreach ($class->associationMappings as $assoc) { foreach ($class->associationMappings as $assoc) {
...@@ -454,7 +460,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -454,7 +460,7 @@ class UnitOfWork implements PropertyChangedListener
$assoc = $class->associationMappings[$name]; $assoc = $class->associationMappings[$name];
// Inject PersistentCollection // Inject PersistentCollection
$coll = new PersistentCollection($this->_em, $this->_em->getClassMetadata($assoc->targetEntityName), $coll = new PersistentCollection($this->_em, $this->_em->getClassMetadata($assoc->targetEntityName),
$actualData[$name] ? $actualData[$name] : array()); $actualData[$name] ? $actualData[$name] : array());
$coll->setOwner($entity, $assoc); $coll->setOwner($entity, $assoc);
$coll->setDirty( ! $coll->isEmpty()); $coll->setDirty( ! $coll->isEmpty());
$class->reflFields[$name]->setValue($entity, $coll); $class->reflFields[$name]->setValue($entity, $coll);
...@@ -808,13 +814,12 @@ class UnitOfWork implements PropertyChangedListener ...@@ -808,13 +814,12 @@ class UnitOfWork implements PropertyChangedListener
} }
/** /**
* Registers a new entity. The entity will be scheduled for insertion. * Schedules an entity for insertion into the database.
* If the entity already has an identifier, it will be added to the identity map. * If the entity already has an identifier, it will be added to the identity map.
* *
* @param object $entity * @param object $entity
* @todo Rename to scheduleForInsert().
*/ */
public function registerNew($entity) public function scheduleForInsert($entity)
{ {
$oid = spl_object_hash($entity); $oid = spl_object_hash($entity);
...@@ -839,9 +844,8 @@ class UnitOfWork implements PropertyChangedListener ...@@ -839,9 +844,8 @@ class UnitOfWork implements PropertyChangedListener
* *
* @param object $entity * @param object $entity
* @return boolean * @return boolean
* @todo Rename to isScheduledForInsert().
*/ */
public function isRegisteredNew($entity) public function isScheduledForInsert($entity)
{ {
return isset($this->_entityInsertions[spl_object_hash($entity)]); return isset($this->_entityInsertions[spl_object_hash($entity)]);
} }
...@@ -850,9 +854,8 @@ class UnitOfWork implements PropertyChangedListener ...@@ -850,9 +854,8 @@ class UnitOfWork implements PropertyChangedListener
* Registers a dirty entity. * Registers a dirty entity.
* *
* @param object $entity * @param object $entity
* @todo Rename to scheduleForUpdate().
*/ */
public function registerDirty($entity) public function scheduleForUpdate($entity)
{ {
$oid = spl_object_hash($entity); $oid = spl_object_hash($entity);
if ( ! isset($this->_entityIdentifiers[$oid])) { if ( ! isset($this->_entityIdentifiers[$oid])) {
...@@ -887,19 +890,18 @@ class UnitOfWork implements PropertyChangedListener ...@@ -887,19 +890,18 @@ class UnitOfWork implements PropertyChangedListener
* *
* @param object $entity * @param object $entity
* @return boolean * @return boolean
* @todo Rename to isScheduledForUpdate().
*/ */
public function isRegisteredDirty($entity) public function isScheduledForUpdate($entity)
{ {
return isset($this->_entityUpdates[spl_object_hash($entity)]); return isset($this->_entityUpdates[spl_object_hash($entity)]);
} }
/** /**
* Registers a deleted entity. * Registers a deleted entity.
* *
* @todo Rename to scheduleForDelete(). * @param object $entity
*/ */
public function registerDeleted($entity) public function scheduleForDelete($entity)
{ {
$oid = spl_object_hash($entity); $oid = spl_object_hash($entity);
if ( ! $this->isInIdentityMap($entity)) { if ( ! $this->isInIdentityMap($entity)) {
...@@ -928,9 +930,8 @@ class UnitOfWork implements PropertyChangedListener ...@@ -928,9 +930,8 @@ class UnitOfWork implements PropertyChangedListener
* *
* @param object $entity * @param object $entity
* @return boolean * @return boolean
* @todo Rename to isScheduledForDelete().
*/ */
public function isRegisteredRemoved($entity) public function isScheduledForDelete($entity)
{ {
return isset($this->_entityDeletions[spl_object_hash($entity)]); return isset($this->_entityDeletions[spl_object_hash($entity)]);
} }
...@@ -946,17 +947,17 @@ class UnitOfWork implements PropertyChangedListener ...@@ -946,17 +947,17 @@ class UnitOfWork implements PropertyChangedListener
$oid = spl_object_hash($entity); $oid = spl_object_hash($entity);
$this->removeFromIdentityMap($entity); $this->removeFromIdentityMap($entity);
unset($this->_entityInsertions[$oid], $this->_entityUpdates[$oid], unset($this->_entityInsertions[$oid], $this->_entityUpdates[$oid],
$this->_entityDeletions[$oid], $this->_entityIdentifiers[$oid], $this->_entityDeletions[$oid], $this->_entityIdentifiers[$oid],
$this->_entityStates[$oid]); $this->_entityStates[$oid]);
} }
/** /**
* * Checks whether an entity is scheduled for insertion, update or deletion.
* *
* @param $entity * @param $entity
* @return unknown_type * @return boolean
*/ */
public function isEntityRegistered($entity) public function isEntityScheduled($entity)
{ {
$oid = spl_object_hash($entity); $oid = spl_object_hash($entity);
return isset($this->_entityInsertions[$oid]) || return isset($this->_entityInsertions[$oid]) ||
...@@ -1110,28 +1111,10 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1110,28 +1111,10 @@ class UnitOfWork implements PropertyChangedListener
* *
* @param object $entity The entity to save. * @param object $entity The entity to save.
*/ */
public function save($entity) public function persist($entity)
{ {
$insertNow = array();
$visited = array(); $visited = array();
$this->_doSave($entity, $visited, $insertNow); $this->_doPersist($entity, $visited);
if ( ! empty($insertNow)) {
// We have no choice. This means that there are new entities
// with a post-insert ID generation strategy.
$this->computeChangeSets($insertNow);
$commitOrder = $this->_getCommitOrder($insertNow);
foreach ($commitOrder as $class) {
$this->_executeInserts($class);
}
// Extra updates that were requested by persisters.
if ($this->_extraUpdates) {
$this->_executeExtraUpdates();
$this->_extraUpdates = array();
}
// Remove them from _entityInsertions and _entityChangeSets
$this->_entityInsertions = array_diff_key($this->_entityInsertions, $insertNow);
$this->_entityChangeSets = array_diff_key($this->_entityChangeSets, $insertNow);
}
} }
/** /**
...@@ -1144,7 +1127,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1144,7 +1127,7 @@ class UnitOfWork implements PropertyChangedListener
* @param array $insertNow The entities that must be immediately inserted because of * @param array $insertNow The entities that must be immediately inserted because of
* post-insert ID generation. * post-insert ID generation.
*/ */
private function _doSave($entity, array &$visited, array &$insertNow) private function _doPersist($entity, array &$visited)
{ {
$oid = spl_object_hash($entity); $oid = spl_object_hash($entity);
if (isset($visited[$oid])) { if (isset($visited[$oid])) {
...@@ -1170,11 +1153,8 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1170,11 +1153,8 @@ class UnitOfWork implements PropertyChangedListener
} }
$idGen = $class->idGenerator; $idGen = $class->idGenerator;
if ($idGen->isPostInsertGenerator()) { if ( ! $idGen->isPostInsertGenerator()) {
$insertNow[$oid] = $entity;
} else {
$idValue = $idGen->generate($this->_em, $entity); $idValue = $idGen->generate($this->_em, $entity);
$this->_entityStates[$oid] = self::STATE_MANAGED;
if ( ! $idGen instanceof \Doctrine\ORM\Id\Assigned) { if ( ! $idGen instanceof \Doctrine\ORM\Id\Assigned) {
$this->_entityIdentifiers[$oid] = array($idValue); $this->_entityIdentifiers[$oid] = array($idValue);
$class->setIdentifierValues($entity, $idValue); $class->setIdentifierValues($entity, $idValue);
...@@ -1182,24 +1162,26 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1182,24 +1162,26 @@ class UnitOfWork implements PropertyChangedListener
$this->_entityIdentifiers[$oid] = $idValue; $this->_entityIdentifiers[$oid] = $idValue;
} }
} }
$this->registerNew($entity); $this->_entityStates[$oid] = self::STATE_MANAGED;
$this->scheduleForInsert($entity);
break; break;
case self::STATE_DETACHED: case self::STATE_DETACHED:
throw DoctrineException::updateMe("Behavior of save() for a detached entity " throw DoctrineException::updateMe("Behavior of save() for a detached entity "
. "is not yet defined."); . "is not yet defined.");
case self::STATE_DELETED: case self::STATE_DELETED:
// Entity becomes managed again // Entity becomes managed again
if ($this->isRegisteredRemoved($entity)) { if ($this->isScheduledForDelete($entity)) {
unset($this->_entityDeletions[$oid]); unset($this->_entityDeletions[$oid]);
} else { } else {
//FIXME: There's more to think of here... //FIXME: There's more to think of here...
$this->registerNew($entity); $this->scheduleForInsert($entity);
} }
break; break;
default: default:
throw DoctrineException::updateMe("Encountered invalid entity state."); throw DoctrineException::updateMe("Encountered invalid entity state.");
} }
$this->_cascadeSave($entity, $visited, $insertNow); $this->_cascadePersist($entity, $visited);
} }
/** /**
...@@ -1207,10 +1189,10 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1207,10 +1189,10 @@ class UnitOfWork implements PropertyChangedListener
* *
* @param object $entity * @param object $entity
*/ */
public function delete($entity) public function remove($entity)
{ {
$visited = array(); $visited = array();
$this->_doDelete($entity, $visited); $this->_doRemove($entity, $visited);
} }
/** /**
...@@ -1222,7 +1204,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1222,7 +1204,7 @@ class UnitOfWork implements PropertyChangedListener
* @param object $entity The entity to delete. * @param object $entity The entity to delete.
* @param array $visited The map of the already visited entities. * @param array $visited The map of the already visited entities.
*/ */
private function _doDelete($entity, array &$visited) private function _doRemove($entity, array &$visited)
{ {
$oid = spl_object_hash($entity); $oid = spl_object_hash($entity);
if (isset($visited[$oid])) { if (isset($visited[$oid])) {
...@@ -1244,14 +1226,14 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1244,14 +1226,14 @@ class UnitOfWork implements PropertyChangedListener
if ($this->_evm->hasListeners(Events::preDelete)) { if ($this->_evm->hasListeners(Events::preDelete)) {
$this->_evm->dispatchEvent(Events::preDelete, new LifecycleEventArgs($entity)); $this->_evm->dispatchEvent(Events::preDelete, new LifecycleEventArgs($entity));
} }
$this->registerDeleted($entity); $this->scheduleForDelete($entity);
break; break;
case self::STATE_DETACHED: case self::STATE_DETACHED:
throw DoctrineException::updateMe("A detached entity can't be deleted."); throw DoctrineException::updateMe("A detached entity can't be deleted.");
default: default:
throw DoctrineException::updateMe("Encountered invalid entity state."); throw DoctrineException::updateMe("Encountered invalid entity state.");
} }
$this->_cascadeDelete($entity, $visited); $this->_cascadeRemove($entity, $visited);
} }
/** /**
...@@ -1361,7 +1343,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1361,7 +1343,7 @@ class UnitOfWork implements PropertyChangedListener
* @param array $visited * @param array $visited
* @param array $insertNow * @param array $insertNow
*/ */
private function _cascadeSave($entity, array &$visited, array &$insertNow) private function _cascadePersist($entity, array &$visited)
{ {
$class = $this->_em->getClassMetadata(get_class($entity)); $class = $this->_em->getClassMetadata(get_class($entity));
foreach ($class->associationMappings as $assocMapping) { foreach ($class->associationMappings as $assocMapping) {
...@@ -1371,10 +1353,10 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1371,10 +1353,10 @@ class UnitOfWork implements PropertyChangedListener
$relatedEntities = $class->reflFields[$assocMapping->sourceFieldName]->getValue($entity); $relatedEntities = $class->reflFields[$assocMapping->sourceFieldName]->getValue($entity);
if (($relatedEntities instanceof Collection || is_array($relatedEntities))) { if (($relatedEntities instanceof Collection || is_array($relatedEntities))) {
foreach ($relatedEntities as $relatedEntity) { foreach ($relatedEntities as $relatedEntity) {
$this->_doSave($relatedEntity, $visited, $insertNow); $this->_doPersist($relatedEntity, $visited);
} }
} else if ($relatedEntities !== null) { } else if ($relatedEntities !== null) {
$this->_doSave($relatedEntities, $visited, $insertNow); $this->_doPersist($relatedEntities, $visited);
} }
} }
} }
...@@ -1385,7 +1367,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1385,7 +1367,7 @@ class UnitOfWork implements PropertyChangedListener
* @param object $entity * @param object $entity
* @param array $visited * @param array $visited
*/ */
private function _cascadeDelete($entity, array &$visited) private function _cascadeRemove($entity, array &$visited)
{ {
$class = $this->_em->getClassMetadata(get_class($entity)); $class = $this->_em->getClassMetadata(get_class($entity));
foreach ($class->associationMappings as $assocMapping) { foreach ($class->associationMappings as $assocMapping) {
...@@ -1396,10 +1378,10 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1396,10 +1378,10 @@ class UnitOfWork implements PropertyChangedListener
->getValue($entity); ->getValue($entity);
if ($relatedEntities instanceof Collection || is_array($relatedEntities)) { if ($relatedEntities instanceof Collection || is_array($relatedEntities)) {
foreach ($relatedEntities as $relatedEntity) { foreach ($relatedEntities as $relatedEntity) {
$this->_doDelete($relatedEntity, $visited); $this->_doRemove($relatedEntity, $visited);
} }
} else if ($relatedEntities !== null) { } else if ($relatedEntities !== null) {
$this->_doDelete($relatedEntities, $visited); $this->_doRemove($relatedEntities, $visited);
} }
} }
} }
...@@ -1429,7 +1411,7 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1429,7 +1411,7 @@ class UnitOfWork implements PropertyChangedListener
$this->_entityUpdates = array(); $this->_entityUpdates = array();
$this->_entityDeletions = array(); $this->_entityDeletions = array();
$this->_collectionDeletions = array(); $this->_collectionDeletions = array();
$this->_collectionCreations = array(); //$this->_collectionCreations = array();
$this->_collectionUpdates = array(); $this->_collectionUpdates = array();
$this->_commitOrderCalculator->clear(); $this->_commitOrderCalculator->clear();
} }
...@@ -1574,8 +1556,6 @@ class UnitOfWork implements PropertyChangedListener ...@@ -1574,8 +1556,6 @@ class UnitOfWork implements PropertyChangedListener
/** /**
* INTERNAL: * INTERNAL:
* For internal purposes only.
*
* Sets a property value of the original data array of an entity. * Sets a property value of the original data array of an entity.
* *
* @param string $oid * @param string $oid
......
...@@ -25,8 +25,10 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -25,8 +25,10 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->name = 'Roman'; $user->name = 'Roman';
$user->username = 'romanb'; $user->username = 'romanb';
$user->status = 'developer'; $user->status = 'developer';
$this->_em->save($user); $this->_em->persist($user);
$this->_em->flush();
$this->assertTrue(is_numeric($user->id)); $this->assertTrue(is_numeric($user->id));
$this->assertTrue($this->_em->contains($user)); $this->assertTrue($this->_em->contains($user));
...@@ -56,14 +58,14 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -56,14 +58,14 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertTrue($this->_em->contains($ph2)); $this->assertTrue($this->_em->contains($ph2));
// Delete // Delete
$this->_em->delete($user); $this->_em->remove($user);
$this->assertTrue($this->_em->getUnitOfWork()->isRegisteredRemoved($user)); $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($user));
$this->assertTrue($this->_em->getUnitOfWork()->isRegisteredRemoved($ph)); $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph));
$this->assertTrue($this->_em->getUnitOfWork()->isRegisteredRemoved($ph2)); $this->assertTrue($this->_em->getUnitOfWork()->isScheduledForDelete($ph2));
$this->_em->flush(); $this->_em->flush();
$this->assertFalse($this->_em->getUnitOfWork()->isRegisteredRemoved($user)); $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($user));
$this->assertFalse($this->_em->getUnitOfWork()->isRegisteredRemoved($ph)); $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph));
$this->assertFalse($this->_em->getUnitOfWork()->isRegisteredRemoved($ph2)); $this->assertFalse($this->_em->getUnitOfWork()->isScheduledForDelete($ph2));
} }
public function testOneToManyAssociationModification() public function testOneToManyAssociationModification()
...@@ -81,7 +83,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -81,7 +83,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->addPhonenumber($ph1); $user->addPhonenumber($ph1);
$user->addPhonenumber($ph2); $user->addPhonenumber($ph2);
$this->_em->save($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
//$this->assertTrue($user->phonenumbers instanceof \Doctrine\ORM\PersistentCollection); //$this->assertTrue($user->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
...@@ -111,7 +113,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -111,7 +113,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->address = $address; // inverse side $user->address = $address; // inverse side
$address->user = $user; // owning side! $address->user = $user; // owning side!
$this->_em->save($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
// Check that the foreign key has been set // Check that the foreign key has been set
...@@ -133,8 +135,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -133,8 +135,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->groups[] = $group; $user->groups[] = $group;
$group->users[] = $user; $group->users[] = $user;
$this->_em->save($user); $this->_em->persist($user);
$this->_em->save($group);
$this->_em->flush(); $this->_em->flush();
...@@ -163,10 +164,10 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -163,10 +164,10 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$group->users[] = $user; $group->users[] = $user;
} }
$this->_em->save($user); // Saves the user, 'cause of post-insert ID $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
// Check that there are indeed 10 links in the association table // Check that there are indeed 10 links in the association table
$count = $this->_em->getConnection()->execute("SELECT COUNT(*) FROM cms_users_groups", $count = $this->_em->getConnection()->execute("SELECT COUNT(*) FROM cms_users_groups",
array())->fetchColumn(); array())->fetchColumn();
...@@ -189,7 +190,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -189,7 +190,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->name = 'Guilherme'; $user->name = 'Guilherme';
$user->username = 'gblanco'; $user->username = 'gblanco';
$user->status = 'developer'; $user->status = 'developer';
$this->_em->save($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u"); $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u");
...@@ -226,7 +227,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -226,7 +227,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->name = 'Guilherme'; $user->name = 'Guilherme';
$user->username = 'gblanco'; $user->username = 'gblanco';
$user->status = 'developer'; $user->status = 'developer';
$this->_em->save($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
$query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p"); $query = $this->_em->createQuery("select u from Doctrine\Tests\Models\CMS\CmsUser u join u.phonenumbers p");
...@@ -242,7 +243,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -242,7 +243,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->name = 'Guilherme'; $user->name = 'Guilherme';
$user->username = 'gblanco'; $user->username = 'gblanco';
$user->status = 'developer'; $user->status = 'developer';
$this->_em->save($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
$query = $this->_em->createQuery("select u,p from Doctrine\Tests\Models\CMS\CmsUser u left join u.phonenumbers p"); $query = $this->_em->createQuery("select u,p from Doctrine\Tests\Models\CMS\CmsUser u left join u.phonenumbers p");
...@@ -270,9 +271,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -270,9 +271,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->addGroup($group1); $user->addGroup($group1);
$this->_em->save($user); $this->_em->persist($user);
$this->_em->save($group1);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
...@@ -304,30 +303,5 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -304,30 +303,5 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$query = $this->_em->createQuery("select u, g from Doctrine\Tests\Models\CMS\CmsUser u inner join u.groups g"); $query = $this->_em->createQuery("select u, g from Doctrine\Tests\Models\CMS\CmsUser u inner join u.groups g");
$this->assertEquals(0, count($query->getResultList())); $this->assertEquals(0, count($query->getResultList()));
/* RB: TEST */
/*
$address = new CmsAddress;
$address->country = 'Germany';
$address->zip = '103040';
$address->city = 'Berlin';
$address->user = $user;
$this->_em->save($address);
$this->_em->clear();
$proxy = $this->_em->getProxyGenerator()->getAssociationProxy($user, $this->_em->getClassMetadata('Doctrine\Tests\Models\CMS\CmsUser')->getAssociationMapping('address'));
var_dump($proxy->getId());
//var_dump(get_class($proxy));
var_dump(get_class($proxy->user));
//var_dump($proxy);
//$proxy = $this->_em->getProxyGenerator()->getReferenceProxy('Doctrine\Tests\Models\CMS\CmsUser', 1);
//echo $proxy->getId();
//var_dump(serialize($proxy));
*/
} }
} }
\ No newline at end of file
...@@ -25,14 +25,14 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -25,14 +25,14 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$person = new CompanyPerson; $person = new CompanyPerson;
$person->setName('Roman S. Borschel'); $person->setName('Roman S. Borschel');
$this->_em->save($person); $this->_em->persist($person);
$employee = new CompanyEmployee; $employee = new CompanyEmployee;
$employee->setName('Roman S. Borschel'); $employee->setName('Roman S. Borschel');
$employee->setSalary(100000); $employee->setSalary(100000);
$employee->setDepartment('IT'); $employee->setDepartment('IT');
$this->_em->save($employee); $this->_em->persist($employee);
$employee->setName('Guilherme Blanco'); $employee->setName('Guilherme Blanco');
$this->_em->flush(); $this->_em->flush();
...@@ -86,13 +86,13 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -86,13 +86,13 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$manager->setSalary(100000); $manager->setSalary(100000);
$manager->setDepartment('IT'); $manager->setDepartment('IT');
$manager->setTitle('CTO'); $manager->setTitle('CTO');
$this->_em->save($manager); $this->_em->persist($manager);
$this->_em->flush(); $this->_em->flush();
$manager->setName('Roman B.'); $manager->setName('Roman B.');
$manager->setSalary(119000); $manager->setSalary(119000);
$manager->setTitle('CEO'); $manager->setTitle('CEO');
$this->_em->save($manager); $this->_em->persist($manager);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
...@@ -119,8 +119,8 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -119,8 +119,8 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertSame($manager, $wife->getSpouse()); $this->assertSame($manager, $wife->getSpouse());
$this->assertSame($wife, $manager->getSpouse()); $this->assertSame($wife, $manager->getSpouse());
$this->_em->save($manager); $this->_em->persist($manager);
$this->_em->save($wife); $this->_em->persist($wife);
$this->_em->flush(); $this->_em->flush();
...@@ -155,8 +155,8 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -155,8 +155,8 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(1, count($person2->getFriends())); $this->assertEquals(1, count($person2->getFriends()));
$this->_em->save($person1); $this->_em->persist($person1);
$this->_em->save($person2); $this->_em->persist($person2);
$this->_em->flush(); $this->_em->flush();
......
...@@ -24,7 +24,7 @@ class DetachedEntityTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -24,7 +24,7 @@ class DetachedEntityTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->name = 'Roman'; $user->name = 'Roman';
$user->username = 'romanb'; $user->username = 'romanb';
$user->status = 'dev'; $user->status = 'dev';
$this->_em->save($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -21,7 +21,7 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -21,7 +21,7 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
{ {
$entity = new LifecycleCallbackTestEntity; $entity = new LifecycleCallbackTestEntity;
$entity->value = 'hello'; $entity->value = 'hello';
$this->_em->save($entity); $this->_em->persist($entity);
$this->_em->flush(); $this->_em->flush();
$this->assertTrue($entity->preSaveCallbackInvoked); $this->assertTrue($entity->preSaveCallbackInvoked);
......
...@@ -37,7 +37,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -37,7 +37,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
$test = new OptimisticJoinedChild(); $test = new OptimisticJoinedChild();
$test->name = 'child'; $test->name = 'child';
$test->whatever = 'whatever'; $test->whatever = 'whatever';
$this->_em->save($test); $this->_em->persist($test);
$this->_em->flush(); $this->_em->flush();
$this->assertEquals(1, $test->version); $this->assertEquals(1, $test->version);
...@@ -66,7 +66,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -66,7 +66,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
{ {
$test = new OptimisticJoinedParent(); $test = new OptimisticJoinedParent();
$test->name = 'parent'; $test->name = 'parent';
$this->_em->save($test); $this->_em->persist($test);
$this->_em->flush(); $this->_em->flush();
$this->assertEquals(1, $test->version); $this->assertEquals(1, $test->version);
...@@ -95,7 +95,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -95,7 +95,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
{ {
$test = new OptimisticStandard(); $test = new OptimisticStandard();
$test->name = 'test'; $test->name = 'test';
$this->_em->save($test); $this->_em->persist($test);
$this->_em->flush(); $this->_em->flush();
$this->assertEquals(1, $test->version); $this->assertEquals(1, $test->version);
......
...@@ -38,7 +38,7 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati ...@@ -38,7 +38,7 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
{ {
$this->firstProduct->addCategory($this->firstCategory); $this->firstProduct->addCategory($this->firstCategory);
$this->firstProduct->addCategory($this->secondCategory); $this->firstProduct->addCategory($this->secondCategory);
$this->_em->save($this->firstProduct); $this->_em->persist($this->firstProduct);
$this->_em->flush(); $this->_em->flush();
$this->assertForeignKeysContain($this->firstProduct->getId(), $this->assertForeignKeysContain($this->firstProduct->getId(),
...@@ -51,7 +51,7 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati ...@@ -51,7 +51,7 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
{ {
$this->firstProduct->addCategory($this->firstCategory); $this->firstProduct->addCategory($this->firstCategory);
$this->firstProduct->addCategory($this->secondCategory); $this->firstProduct->addCategory($this->secondCategory);
$this->_em->save($this->firstProduct); $this->_em->persist($this->firstProduct);
$this->firstProduct->removeCategory($this->firstCategory); $this->firstProduct->removeCategory($this->firstCategory);
$this->_em->flush(); $this->_em->flush();
...@@ -102,8 +102,8 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati ...@@ -102,8 +102,8 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
$this->firstProduct->addCategory($this->secondCategory); $this->firstProduct->addCategory($this->secondCategory);
$this->secondProduct->addCategory($this->firstCategory); $this->secondProduct->addCategory($this->firstCategory);
$this->secondProduct->addCategory($this->secondCategory); $this->secondProduct->addCategory($this->secondCategory);
$this->_em->save($this->firstProduct); $this->_em->persist($this->firstProduct);
$this->_em->save($this->secondProduct); $this->_em->persist($this->secondProduct);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -38,7 +38,7 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia ...@@ -38,7 +38,7 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia
{ {
$this->firstProduct->addRelated($this->firstRelated); $this->firstProduct->addRelated($this->firstRelated);
$this->firstProduct->addRelated($this->secondRelated); $this->firstProduct->addRelated($this->secondRelated);
$this->_em->save($this->firstProduct); $this->_em->persist($this->firstProduct);
$this->_em->flush(); $this->_em->flush();
$this->assertForeignKeysContain($this->firstProduct->getId(), $this->assertForeignKeysContain($this->firstProduct->getId(),
...@@ -51,7 +51,7 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia ...@@ -51,7 +51,7 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia
{ {
$this->firstProduct->addRelated($this->firstRelated); $this->firstProduct->addRelated($this->firstRelated);
$this->firstProduct->addRelated($this->secondRelated); $this->firstProduct->addRelated($this->secondRelated);
$this->_em->save($this->firstProduct); $this->_em->persist($this->firstProduct);
$this->firstProduct->removeRelated($this->firstRelated); $this->firstProduct->removeRelated($this->firstRelated);
$this->_em->flush(); $this->_em->flush();
...@@ -91,8 +91,8 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia ...@@ -91,8 +91,8 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia
$this->firstProduct->addRelated($this->secondRelated); $this->firstProduct->addRelated($this->secondRelated);
$this->secondProduct->addRelated($this->firstRelated); $this->secondProduct->addRelated($this->firstRelated);
$this->secondProduct->addRelated($this->secondRelated); $this->secondProduct->addRelated($this->secondRelated);
$this->_em->save($this->firstProduct); $this->_em->persist($this->firstProduct);
$this->_em->save($this->secondProduct); $this->_em->persist($this->secondProduct);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -38,7 +38,7 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat ...@@ -38,7 +38,7 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
{ {
$this->firstCart->addProduct($this->firstProduct); $this->firstCart->addProduct($this->firstProduct);
$this->firstCart->addProduct($this->secondProduct); $this->firstCart->addProduct($this->secondProduct);
$this->_em->save($this->firstCart); $this->_em->persist($this->firstCart);
$this->_em->flush(); $this->_em->flush();
$this->assertForeignKeysContain($this->firstCart->getId(), $this->firstProduct->getId()); $this->assertForeignKeysContain($this->firstCart->getId(), $this->firstProduct->getId());
...@@ -49,7 +49,7 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat ...@@ -49,7 +49,7 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
{ {
$this->firstCart->addProduct($this->firstProduct); $this->firstCart->addProduct($this->firstProduct);
$this->firstCart->addProduct($this->secondProduct); $this->firstCart->addProduct($this->secondProduct);
$this->_em->save($this->firstCart); $this->_em->persist($this->firstCart);
$this->firstCart->removeProduct($this->firstProduct); $this->firstCart->removeProduct($this->firstProduct);
$this->_em->flush(); $this->_em->flush();
...@@ -64,8 +64,8 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat ...@@ -64,8 +64,8 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
$this->firstCart->addProduct($this->secondProduct); $this->firstCart->addProduct($this->secondProduct);
$this->secondCart->addProduct($this->firstProduct); $this->secondCart->addProduct($this->firstProduct);
$this->secondCart->addProduct($this->secondProduct); $this->secondCart->addProduct($this->secondProduct);
$this->_em->save($this->firstCart); $this->_em->persist($this->firstCart);
$this->_em->save($this->secondCart); $this->_em->persist($this->secondCart);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -25,7 +25,7 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -25,7 +25,7 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->name = 'Roman'; $user->name = 'Roman';
$user->username = 'romanb'; $user->username = 'romanb';
$user->status = 'dev'; $user->status = 'dev';
$this->_em->save($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
$rsm = new ResultSetMapping; $rsm = new ResultSetMapping;
......
...@@ -31,7 +31,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona ...@@ -31,7 +31,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public function testSavesAOneToManyAssociationWithCascadeSaveSet() { public function testSavesAOneToManyAssociationWithCascadeSaveSet() {
$this->product->addFeature($this->firstFeature); $this->product->addFeature($this->firstFeature);
$this->product->addFeature($this->secondFeature); $this->product->addFeature($this->secondFeature);
$this->_em->save($this->product); $this->_em->persist($this->product);
$this->_em->flush(); $this->_em->flush();
$this->assertFeatureForeignKeyIs($this->product->getId(), $this->firstFeature); $this->assertFeatureForeignKeyIs($this->product->getId(), $this->firstFeature);
...@@ -40,7 +40,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona ...@@ -40,7 +40,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public function testSavesAnEmptyCollection() public function testSavesAnEmptyCollection()
{ {
$this->_em->save($this->product); $this->_em->persist($this->product);
$this->_em->flush(); $this->_em->flush();
$this->assertEquals(0, count($this->product->getFeatures())); $this->assertEquals(0, count($this->product->getFeatures()));
...@@ -48,7 +48,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona ...@@ -48,7 +48,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public function testDoesNotSaveAnInverseSideSet() { public function testDoesNotSaveAnInverseSideSet() {
$this->product->brokenAddFeature($this->firstFeature); $this->product->brokenAddFeature($this->firstFeature);
$this->_em->save($this->product); $this->_em->persist($this->product);
$this->_em->flush(); $this->_em->flush();
$this->assertFeatureForeignKeyIs(null, $this->firstFeature); $this->assertFeatureForeignKeyIs(null, $this->firstFeature);
...@@ -58,7 +58,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona ...@@ -58,7 +58,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
{ {
$this->product->addFeature($this->firstFeature); $this->product->addFeature($this->firstFeature);
$this->product->addFeature($this->secondFeature); $this->product->addFeature($this->secondFeature);
$this->_em->save($this->product); $this->_em->persist($this->product);
$this->product->removeFeature($this->firstFeature); $this->product->removeFeature($this->firstFeature);
$this->_em->flush(); $this->_em->flush();
...@@ -71,7 +71,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona ...@@ -71,7 +71,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
{ {
$this->product->addFeature($this->firstFeature); $this->product->addFeature($this->firstFeature);
$this->product->addFeature($this->secondFeature); $this->product->addFeature($this->secondFeature);
$this->_em->save($this->product); $this->_em->persist($this->product);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -30,7 +30,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio ...@@ -30,7 +30,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
public function testSavesAOneToManyAssociationWithCascadeSaveSet() { public function testSavesAOneToManyAssociationWithCascadeSaveSet() {
$this->parent->addChild($this->firstChild); $this->parent->addChild($this->firstChild);
$this->parent->addChild($this->secondChild); $this->parent->addChild($this->secondChild);
$this->_em->save($this->parent); $this->_em->persist($this->parent);
$this->_em->flush(); $this->_em->flush();
...@@ -40,7 +40,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio ...@@ -40,7 +40,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
public function testSavesAnEmptyCollection() public function testSavesAnEmptyCollection()
{ {
$this->_em->save($this->parent); $this->_em->persist($this->parent);
$this->_em->flush(); $this->_em->flush();
$this->assertEquals(0, count($this->parent->getChildren())); $this->assertEquals(0, count($this->parent->getChildren()));
...@@ -48,7 +48,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio ...@@ -48,7 +48,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
public function testDoesNotSaveAnInverseSideSet() { public function testDoesNotSaveAnInverseSideSet() {
$this->parent->brokenAddChild($this->firstChild); $this->parent->brokenAddChild($this->firstChild);
$this->_em->save($this->parent); $this->_em->persist($this->parent);
$this->_em->flush(); $this->_em->flush();
$this->assertForeignKeyIs(null, $this->firstChild); $this->assertForeignKeyIs(null, $this->firstChild);
...@@ -58,7 +58,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio ...@@ -58,7 +58,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
{ {
$this->parent->addChild($this->firstChild); $this->parent->addChild($this->firstChild);
$this->parent->addChild($this->secondChild); $this->parent->addChild($this->secondChild);
$this->_em->save($this->parent); $this->_em->persist($this->parent);
$this->parent->removeChild($this->firstChild); $this->parent->removeChild($this->firstChild);
$this->_em->flush(); $this->_em->flush();
...@@ -71,7 +71,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio ...@@ -71,7 +71,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
{ {
$this->parent->addChild($this->firstChild); $this->parent->addChild($this->firstChild);
$this->parent->addChild($this->secondChild); $this->parent->addChild($this->secondChild);
$this->_em->save($this->parent); $this->_em->persist($this->parent);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -28,7 +28,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional ...@@ -28,7 +28,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public function testSavesAOneToOneAssociationWithCascadeSaveSet() { public function testSavesAOneToOneAssociationWithCascadeSaveSet() {
$this->customer->setCart($this->cart); $this->customer->setCart($this->cart);
$this->_em->save($this->customer); $this->_em->persist($this->customer);
$this->_em->flush(); $this->_em->flush();
$this->assertCartForeignKeyIs($this->customer->getId()); $this->assertCartForeignKeyIs($this->customer->getId());
...@@ -36,7 +36,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional ...@@ -36,7 +36,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public function testDoesNotSaveAnInverseSideSet() { public function testDoesNotSaveAnInverseSideSet() {
$this->customer->brokenSetCart($this->cart); $this->customer->brokenSetCart($this->cart);
$this->_em->save($this->customer); $this->_em->persist($this->customer);
$this->_em->flush(); $this->_em->flush();
$this->assertCartForeignKeyIs(null); $this->assertCartForeignKeyIs(null);
...@@ -45,7 +45,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional ...@@ -45,7 +45,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public function testRemovesOneToOneAssociation() public function testRemovesOneToOneAssociation()
{ {
$this->customer->setCart($this->cart); $this->customer->setCart($this->cart);
$this->_em->save($this->customer); $this->_em->persist($this->customer);
$this->customer->removeCart(); $this->customer->removeCart();
$this->_em->flush(); $this->_em->flush();
...@@ -88,7 +88,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional ...@@ -88,7 +88,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$cart->setPayment('paypal'); $cart->setPayment('paypal');
$customer->setCart($cart); $customer->setCart($cart);
$this->_em->save($customer); $this->_em->persist($customer);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -30,7 +30,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction ...@@ -30,7 +30,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
public function testSavesAOneToOneAssociationWithCascadeSaveSet() { public function testSavesAOneToOneAssociationWithCascadeSaveSet() {
$this->customer->setMentor($this->mentor); $this->customer->setMentor($this->mentor);
$this->_em->save($this->customer); $this->_em->persist($this->customer);
$this->_em->flush(); $this->_em->flush();
$this->assertForeignKeyIs($this->mentor->getId()); $this->assertForeignKeyIs($this->mentor->getId());
...@@ -39,7 +39,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction ...@@ -39,7 +39,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
public function testRemovesOneToOneAssociation() public function testRemovesOneToOneAssociation()
{ {
$this->customer->setMentor($this->mentor); $this->customer->setMentor($this->mentor);
$this->_em->save($this->customer); $this->_em->persist($this->customer);
$this->customer->removeMentor(); $this->customer->removeMentor();
$this->_em->flush(); $this->_em->flush();
...@@ -55,7 +55,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction ...@@ -55,7 +55,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
$mentor->setName('Obi-wan Kenobi'); $mentor->setName('Obi-wan Kenobi');
$customer->setMentor($mentor); $customer->setMentor($mentor);
$this->_em->save($customer); $this->_em->persist($customer);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -29,7 +29,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona ...@@ -29,7 +29,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public function testSavesAOneToOneAssociationWithCascadeSaveSet() { public function testSavesAOneToOneAssociationWithCascadeSaveSet() {
$this->product->setShipping($this->shipping); $this->product->setShipping($this->shipping);
$this->_em->save($this->product); $this->_em->persist($this->product);
$this->_em->flush(); $this->_em->flush();
$this->assertForeignKeyIs($this->shipping->getId()); $this->assertForeignKeyIs($this->shipping->getId());
...@@ -38,7 +38,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona ...@@ -38,7 +38,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public function testRemovesOneToOneAssociation() public function testRemovesOneToOneAssociation()
{ {
$this->product->setShipping($this->shipping); $this->product->setShipping($this->shipping);
$this->_em->save($this->product); $this->_em->persist($this->product);
$this->product->removeShipping(); $this->product->removeShipping();
$this->_em->flush(); $this->_em->flush();
...@@ -81,7 +81,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona ...@@ -81,7 +81,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
$shipping->setDays('1'); $shipping->setDays('1');
$product->setShipping($shipping); $product->setShipping($shipping);
$this->_em->save($product); $this->_em->persist($product);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -25,7 +25,7 @@ class QueryCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -25,7 +25,7 @@ class QueryCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->name = 'Roman'; $user->name = 'Roman';
$user->username = 'romanb'; $user->username = 'romanb';
$user->status = 'dev'; $user->status = 'dev';
$this->_em->save($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
......
...@@ -26,7 +26,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -26,7 +26,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->name = 'Guilherme'; $user->name = 'Guilherme';
$user->username = 'gblanco'; $user->username = 'gblanco';
$user->status = 'developer'; $user->status = 'developer';
$this->_em->save($user); $this->_em->persist($user);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
...@@ -77,9 +77,9 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -77,9 +77,9 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$article2->text = "This is an introduction to Symfony 2."; $article2->text = "This is an introduction to Symfony 2.";
$user->addArticle($article2); $user->addArticle($article2);
$this->_em->save($user); $this->_em->persist($user);
$this->_em->save($article1); $this->_em->persist($article1);
$this->_em->save($article2); $this->_em->persist($article2);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -27,11 +27,12 @@ class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -27,11 +27,12 @@ class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase
{ {
$product = new ECommerceProduct(); $product = new ECommerceProduct();
$product->setName('Doctrine Cookbook'); $product->setName('Doctrine Cookbook');
$this->_em->save($product); $this->_em->persist($product);
$id = $product->getId();
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$id = $product->getId();
$productProxy = $this->_factory->getReferenceProxy('Doctrine\Tests\Models\ECommerce\ECommerceProduct', array('id' => $id)); $productProxy = $this->_factory->getReferenceProxy('Doctrine\Tests\Models\ECommerce\ECommerceProduct', array('id' => $id));
$this->assertEquals('Doctrine Cookbook', $productProxy->getName()); $this->assertEquals('Doctrine Cookbook', $productProxy->getName());
......
...@@ -29,32 +29,32 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -29,32 +29,32 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$parent = new ParentEntity; $parent = new ParentEntity;
$parent->setData('foobar'); $parent->setData('foobar');
$this->_em->save($parent); $this->_em->persist($parent);
$child = new ChildEntity; $child = new ChildEntity;
$child->setData('thedata'); $child->setData('thedata');
$child->setNumber(1234); $child->setNumber(1234);
$this->_em->save($child); $this->_em->persist($child);
$relatedEntity = new RelatedEntity; $relatedEntity = new RelatedEntity;
$relatedEntity->setName('theRelatedOne'); $relatedEntity->setName('theRelatedOne');
$relatedEntity->setOwner($child); $relatedEntity->setOwner($child);
$this->_em->save($relatedEntity); $this->_em->persist($relatedEntity);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery("select e from Doctrine\Tests\ORM\Functional\ParentEntity e order by e.id asc"); $query = $this->_em->createQuery("select e from Doctrine\Tests\ORM\Functional\ParentEntity e order by e.data asc");
$entities = $query->getResultList(); $entities = $query->getResultList();
$this->assertEquals(2, count($entities)); $this->assertEquals(2, count($entities));
$this->assertTrue($entities[0] instanceof ParentEntity);
$this->assertTrue($entities[1] instanceof ChildEntity);
$this->assertTrue(is_numeric($entities[0]->getId())); $this->assertTrue(is_numeric($entities[0]->getId()));
$this->assertTrue(is_numeric($entities[1]->getId())); $this->assertTrue(is_numeric($entities[1]->getId()));
$this->assertTrue($entities[0] instanceof ParentEntity);
$this->assertTrue($entities[1] instanceof ChildEntity);
$this->assertEquals('foobar', $entities[0]->getData()); $this->assertEquals('foobar', $entities[0]->getData());
$this->assertEquals('thedata', $entities[1]->getData()); $this->assertEquals('thedata', $entities[1]->getData());
$this->assertEquals(1234, $entities[1]->getNumber()); $this->assertEquals(1234, $entities[1]->getNumber());
......
...@@ -37,7 +37,7 @@ class InsertPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase ...@@ -37,7 +37,7 @@ class InsertPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
$user->status = 'user'; $user->status = 'user';
$user->username = 'user' . $i; $user->username = 'user' . $i;
$user->name = 'Mr.Smith-' . $i; $user->name = 'Mr.Smith-' . $i;
$this->_em->save($user); $this->_em->persist($user);
if (($i % $batchSize) == 0) { if (($i % $batchSize) == 0) {
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
......
...@@ -40,9 +40,9 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase ...@@ -40,9 +40,9 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
{ {
$user = new ForumUser(); $user = new ForumUser();
$user->username = 'romanb'; $user->username = 'romanb';
$this->assertFalse($this->_unitOfWork->isRegisteredRemoved($user)); $this->assertFalse($this->_unitOfWork->isScheduledForDelete($user));
$this->_unitOfWork->registerDeleted($user); $this->_unitOfWork->scheduleForDelete($user);
$this->assertFalse($this->_unitOfWork->isRegisteredRemoved($user)); $this->assertFalse($this->_unitOfWork->isScheduledForDelete($user));
} }
...@@ -60,28 +60,29 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase ...@@ -60,28 +60,29 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
// Test // Test
$user = new ForumUser(); $user = new ForumUser();
$user->username = 'romanb'; $user->username = 'romanb';
$this->_unitOfWork->save($user); $this->_unitOfWork->persist($user);
// Check // Check
$this->assertEquals(1, count($userPersister->getInserts())); // insert forced $this->assertEquals(0, count($userPersister->getInserts()));
$this->assertEquals(0, count($userPersister->getUpdates())); $this->assertEquals(0, count($userPersister->getUpdates()));
$this->assertEquals(0, count($userPersister->getDeletes())); $this->assertEquals(0, count($userPersister->getDeletes()));
$this->assertTrue($this->_unitOfWork->isInIdentityMap($user)); $this->assertFalse($this->_unitOfWork->isInIdentityMap($user));
// should no longer be scheduled for insert // should no longer be scheduled for insert
$this->assertFalse($this->_unitOfWork->isRegisteredNew($user)); $this->assertTrue($this->_unitOfWork->isScheduledForInsert($user));
// should have an id
$this->assertTrue(is_numeric($user->id));
// Now lets check whether a subsequent commit() does anything // Now lets check whether a subsequent commit() does anything
$userPersister->reset(); $userPersister->reset();
// Test // Test
$this->_unitOfWork->commit(); // shouldnt do anything $this->_unitOfWork->commit();
// Check. Verify that nothing happened. // Check.
$this->assertEquals(0, count($userPersister->getInserts())); $this->assertEquals(1, count($userPersister->getInserts()));
$this->assertEquals(0, count($userPersister->getUpdates())); $this->assertEquals(0, count($userPersister->getUpdates()));
$this->assertEquals(0, count($userPersister->getDeletes())); $this->assertEquals(0, count($userPersister->getDeletes()));
// should have an id
$this->assertTrue(is_numeric($user->id));
} }
/** /**
...@@ -109,16 +110,18 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase ...@@ -109,16 +110,18 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
$user->username = 'romanb'; $user->username = 'romanb';
$avatar = new ForumAvatar(); $avatar = new ForumAvatar();
$user->avatar = $avatar; $user->avatar = $avatar;
$this->_unitOfWork->save($user); // save cascaded to avatar $this->_unitOfWork->persist($user); // save cascaded to avatar
$this->_unitOfWork->commit();
$this->assertTrue(is_numeric($user->id)); $this->assertTrue(is_numeric($user->id));
$this->assertTrue(is_numeric($avatar->id)); $this->assertTrue(is_numeric($avatar->id));
$this->assertEquals(1, count($userPersister->getInserts())); // insert forced $this->assertEquals(1, count($userPersister->getInserts()));
$this->assertEquals(0, count($userPersister->getUpdates())); $this->assertEquals(0, count($userPersister->getUpdates()));
$this->assertEquals(0, count($userPersister->getDeletes())); $this->assertEquals(0, count($userPersister->getDeletes()));
$this->assertEquals(1, count($avatarPersister->getInserts())); // insert forced $this->assertEquals(1, count($avatarPersister->getInserts()));
$this->assertEquals(0, count($avatarPersister->getUpdates())); $this->assertEquals(0, count($avatarPersister->getUpdates()));
$this->assertEquals(0, count($avatarPersister->getDeletes())); $this->assertEquals(0, count($avatarPersister->getDeletes()));
} }
...@@ -130,13 +133,15 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase ...@@ -130,13 +133,15 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
$entity = new NotifyChangedEntity; $entity = new NotifyChangedEntity;
$entity->setData('thedata'); $entity->setData('thedata');
$this->_unitOfWork->save($entity); $this->_unitOfWork->persist($entity);
$this->_unitOfWork->commit();
$this->assertTrue($this->_unitOfWork->isInIdentityMap($entity)); $this->assertTrue($this->_unitOfWork->isInIdentityMap($entity));
$entity->setData('newdata'); $entity->setData('newdata');
$this->assertTrue($this->_unitOfWork->isRegisteredDirty($entity)); $this->assertTrue($this->_unitOfWork->isScheduledForUpdate($entity));
$this->assertEquals(array('data' => array('thedata', 'newdata')), $this->_unitOfWork->getEntityChangeSet($entity)); $this->assertEquals(array('data' => array('thedata', 'newdata')), $this->_unitOfWork->getEntityChangeSet($entity));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment