Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
7297ac7b
Commit
7297ac7b
authored
Jul 19, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Addressed #2363.
parent
82be4bf0
Changes
25
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
193 additions
and
227 deletions
+193
-227
EntityManager.php
lib/Doctrine/ORM/EntityManager.php
+18
-12
PersistentCollection.php
lib/Doctrine/ORM/PersistentCollection.php
+2
-2
StandardEntityPersister.php
lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
+1
-1
ResultSetMapping.php
lib/Doctrine/ORM/Query/ResultSetMapping.php
+1
-1
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+68
-88
BasicFunctionalTest.php
tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php
+19
-45
ClassTableInheritanceTest.php
...ctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php
+8
-8
DetachedEntityTest.php
tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php
+1
-1
LifecycleCallbackTest.php
...s/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php
+1
-1
OptimisticTest.php
.../Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php
+3
-3
ManyToManyBidirectionalAssociationTest.php
...ORM/Functional/ManyToManyBidirectionalAssociationTest.php
+4
-4
ManyToManySelfReferentialAssociationTest.php
...M/Functional/ManyToManySelfReferentialAssociationTest.php
+4
-4
ManyToManyUnidirectionalAssociationTest.php
...RM/Functional/ManyToManyUnidirectionalAssociationTest.php
+4
-4
NativeQueryTest.php
tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php
+1
-1
OneToManyBidirectionalAssociationTest.php
.../ORM/Functional/OneToManyBidirectionalAssociationTest.php
+5
-5
OneToManySelfReferentialAssociationTest.php
...RM/Functional/OneToManySelfReferentialAssociationTest.php
+5
-5
OneToOneBidirectionalAssociationTest.php
...s/ORM/Functional/OneToOneBidirectionalAssociationTest.php
+4
-4
OneToOneSelfReferentialAssociationTest.php
...ORM/Functional/OneToOneSelfReferentialAssociationTest.php
+3
-3
OneToOneUnidirectionalAssociationTest.php
.../ORM/Functional/OneToOneUnidirectionalAssociationTest.php
+3
-3
QueryCacheTest.php
tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php
+1
-1
QueryTest.php
tests/Doctrine/Tests/ORM/Functional/QueryTest.php
+4
-4
ReferenceProxyTest.php
tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php
+3
-2
SingleTableInheritanceTest.php
...trine/Tests/ORM/Functional/SingleTableInheritanceTest.php
+7
-7
InsertPerformanceTest.php
.../Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php
+1
-1
UnitOfWorkTest.php
tests/Doctrine/Tests/ORM/UnitOfWorkTest.php
+22
-17
No files found.
lib/Doctrine/ORM/EntityManager.php
View file @
7297ac7b
...
...
@@ -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
->
_unitOfWork
->
save
(
$object
);
$this
->
_unitOfWork
->
persist
(
$object
);
if
(
$this
->
_flushMode
==
self
::
FLUSHMODE_IMMEDIATE
)
{
$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
delet
e
(
$entity
)
public
function
remov
e
(
$entity
)
{
$this
->
_errorIfClosed
();
$this
->
_unitOfWork
->
delet
e
(
$entity
);
$this
->
_unitOfWork
->
remov
e
(
$entity
);
if
(
$this
->
_flushMode
==
self
::
FLUSHMODE_IMMEDIATE
)
{
$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.
*
* @param object $entity
...
...
@@ -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.
* @return boolean
...
...
@@ -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
* @return boolean TRUE if this EntityManager currently manages the given entity
...
...
@@ -485,7 +491,7 @@ class EntityManager
public
function
contains
(
$entity
)
{
return
$this
->
_unitOfWork
->
isInIdentityMap
(
$entity
)
&&
!
$this
->
_unitOfWork
->
is
RegisteredRemoved
(
$entity
);
!
$this
->
_unitOfWork
->
is
ScheduledForDelete
(
$entity
);
}
/**
...
...
lib/Doctrine/ORM/PersistentCollection.php
View file @
7297ac7b
...
...
@@ -199,7 +199,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
{
//TODO: delete entity if shouldDeleteOrphans
/*if ($this->_association->isOneToMany() && $this->_association->shouldDeleteOrphans()) {
$this->_em->
delet
e($removed);
$this->_em->
remov
e($removed);
}*/
$removed
=
parent
::
remove
(
$key
);
if
(
$removed
)
{
...
...
@@ -377,7 +377,7 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection
//TODO: If oneToMany() && shouldDeleteOrphan() delete entities
/*if ($this->_association->isOneToMany() && $this->_association->shouldDeleteOrphans()) {
foreach ($this->_data as $entity) {
$this->_em->
delet
e($entity);
$this->_em->
remov
e($entity);
}
}*/
parent
::
clear
();
...
...
lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
View file @
7297ac7b
...
...
@@ -351,7 +351,7 @@ class StandardEntityPersister
// Special case: One-one self-referencing of the same class.
if
(
$newVal
!==
null
&&
$assocMapping
->
sourceEntityName
==
$assocMapping
->
targetEntityName
)
{
$oid
=
spl_object_hash
(
$newVal
);
$isScheduledForInsert
=
$uow
->
is
RegisteredNew
(
$newVal
);
$isScheduledForInsert
=
$uow
->
is
ScheduledForInsert
(
$newVal
);
if
(
isset
(
$this
->
_queuedInserts
[
$oid
])
||
$isScheduledForInsert
)
{
// The associated entity $newVal is not yet persisted, so we must
// set $newVal = null, in order to insert a null value and schedule an
...
...
lib/Doctrine/ORM/Query/ResultSetMapping.php
View file @
7297ac7b
lib/Doctrine/ORM/UnitOfWork.php
View file @
7297ac7b
...
...
@@ -58,7 +58,7 @@ class UnitOfWork implements PropertyChangedListener
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.
*/
const
STATE_NEW
=
2
;
...
...
@@ -66,7 +66,6 @@ class UnitOfWork implements PropertyChangedListener
/**
* A detached entity is an instance with a persistent identity that is not
* (or no longer) associated with an EntityManager (and a UnitOfWork).
* This means it is no longer in the identity map.
*/
const
STATE_DETACHED
=
3
;
...
...
@@ -88,7 +87,7 @@ class UnitOfWork implements PropertyChangedListener
private
$_identityMap
=
array
();
/**
* Map of all identifiers. Keys are object ids.
* Map of all identifiers. Keys are object ids
(spl_object_hash)
.
*
* @var array
*/
...
...
@@ -96,15 +95,18 @@ class UnitOfWork implements PropertyChangedListener
/**
* 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.
*
Note that PHPs "copy-on-write" behavior helps a lot with memory usag
e.
* Keys are object ids
(spl_object_hash). This is used for calculating changesets
*
at commit tim
e.
*
* @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
();
/**
* 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.
*
* @var array
...
...
@@ -113,6 +115,7 @@ class UnitOfWork implements PropertyChangedListener
/**
* The states of entities in this UnitOfWork.
* Keys are object ids (spl_object_hash).
*
* @var array
*/
...
...
@@ -121,6 +124,9 @@ class UnitOfWork implements PropertyChangedListener
/**
* Map of entities that are scheduled for dirty checking at commit time.
* This is only used if automatic dirty checking is disabled.
* Keys are object ids (spl_object_hash).
*
* @var array
*/
private
$_scheduledForDirtyCheck
=
array
();
...
...
@@ -164,7 +170,7 @@ class UnitOfWork implements PropertyChangedListener
*
* @var array
*/
private
$_collectionCreations
=
array
();
//
private $_collectionCreations = array();
/**
* All collection updates.
...
...
@@ -355,26 +361,25 @@ class UnitOfWork implements PropertyChangedListener
* If automatic dirty checking is disabled, only those changesets will be
* computed that have been scheduled through scheduleForDirtyCheck().
*/
public
function
computeChangeSets
(
array
$entities
=
null
)
public
function
computeChangeSets
()
{
$entitySet
=
array
();
$newEntities
=
array
();
if
(
$entities
!==
null
)
{
foreach
(
$entities
as
$entity
)
{
$entitySet
[
get_class
(
$entity
)][]
=
$entity
;
}
$newEntities
=
$entities
;
}
else
{
$entitySet
=
$this
->
_identityMap
;
$newEntities
=
$this
->
_entityInsertions
;
}
$entityInsertions
=
$this
->
_entityInsertions
;
// Compute changes for NEW entities first. This must always happen.
foreach
(
$newEntities
as
$entity
)
{
$this
->
_computeEntityChanges
(
$this
->
_em
->
getClassMetadata
(
get_class
(
$entity
)),
$entity
);
// Compute changes for INSERTed entities first. This must always happen.
foreach
(
$entityInsertions
as
$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
)
{
$class
=
$this
->
_em
->
getClassMetadata
(
$className
);
...
...
@@ -388,8 +393,9 @@ class UnitOfWork implements PropertyChangedListener
$this
->
_scheduledForDirtyCheck
[
$className
]
:
$entities
;
foreach
(
$entitiesToProcess
as
$entity
)
{
// Only MANAGED entities are processed here.
if
(
$this
->
getEntityState
(
$entity
)
==
self
::
STATE_MANAGED
)
{
// Only MANAGED entities that are NOT INSERTED are processed here.
$oid
=
spl_object_hash
(
$entity
);
if
(
isset
(
$this
->
_entityStates
[
$oid
])
&&
!
isset
(
$entityInsertions
[
$oid
]))
{
$this
->
_computeEntityChanges
(
$class
,
$entity
);
// Look for changes in associations of the entity
foreach
(
$class
->
associationMappings
as
$assoc
)
{
...
...
@@ -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.
*
* @param object $entity
* @todo Rename to scheduleForInsert().
*/
public
function
registerNew
(
$entity
)
public
function
scheduleForInsert
(
$entity
)
{
$oid
=
spl_object_hash
(
$entity
);
...
...
@@ -839,9 +844,8 @@ class UnitOfWork implements PropertyChangedListener
*
* @param object $entity
* @return boolean
* @todo Rename to isScheduledForInsert().
*/
public
function
is
RegisteredNew
(
$entity
)
public
function
is
ScheduledForInsert
(
$entity
)
{
return
isset
(
$this
->
_entityInsertions
[
spl_object_hash
(
$entity
)]);
}
...
...
@@ -850,9 +854,8 @@ class UnitOfWork implements PropertyChangedListener
* Registers a dirty entity.
*
* @param object $entity
* @todo Rename to scheduleForUpdate().
*/
public
function
registerDirty
(
$entity
)
public
function
scheduleForUpdate
(
$entity
)
{
$oid
=
spl_object_hash
(
$entity
);
if
(
!
isset
(
$this
->
_entityIdentifiers
[
$oid
]))
{
...
...
@@ -887,9 +890,8 @@ class UnitOfWork implements PropertyChangedListener
*
* @param object $entity
* @return boolean
* @todo Rename to isScheduledForUpdate().
*/
public
function
is
RegisteredDirty
(
$entity
)
public
function
is
ScheduledForUpdate
(
$entity
)
{
return
isset
(
$this
->
_entityUpdates
[
spl_object_hash
(
$entity
)]);
}
...
...
@@ -897,9 +899,9 @@ class UnitOfWork implements PropertyChangedListener
/**
* Registers a deleted entity.
*
* @
todo Rename to scheduleForDelete().
* @
param object $entity
*/
public
function
registerDeleted
(
$entity
)
public
function
scheduleForDelete
(
$entity
)
{
$oid
=
spl_object_hash
(
$entity
);
if
(
!
$this
->
isInIdentityMap
(
$entity
))
{
...
...
@@ -928,9 +930,8 @@ class UnitOfWork implements PropertyChangedListener
*
* @param object $entity
* @return boolean
* @todo Rename to isScheduledForDelete().
*/
public
function
is
RegisteredRemoved
(
$entity
)
public
function
is
ScheduledForDelete
(
$entity
)
{
return
isset
(
$this
->
_entityDeletions
[
spl_object_hash
(
$entity
)]);
}
...
...
@@ -951,12 +952,12 @@ class UnitOfWork implements PropertyChangedListener
}
/**
*
*
Checks whether an entity is scheduled for insertion, update or deletion.
*
* @param $entity
* @return
unknown_type
* @return
boolean
*/
public
function
isEntity
Register
ed
(
$entity
)
public
function
isEntity
Schedul
ed
(
$entity
)
{
$oid
=
spl_object_hash
(
$entity
);
return
isset
(
$this
->
_entityInsertions
[
$oid
])
||
...
...
@@ -1110,28 +1111,10 @@ class UnitOfWork implements PropertyChangedListener
*
* @param object $entity The entity to save.
*/
public
function
save
(
$entity
)
public
function
persist
(
$entity
)
{
$insertNow
=
array
();
$visited
=
array
();
$this
->
_doSave
(
$entity
,
$visited
,
$insertNow
);
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
);
}
$this
->
_doPersist
(
$entity
,
$visited
);
}
/**
...
...
@@ -1144,7 +1127,7 @@ class UnitOfWork implements PropertyChangedListener
* @param array $insertNow The entities that must be immediately inserted because of
* post-insert ID generation.
*/
private
function
_do
Save
(
$entity
,
array
&
$visited
,
array
&
$insertNow
)
private
function
_do
Persist
(
$entity
,
array
&
$visited
)
{
$oid
=
spl_object_hash
(
$entity
);
if
(
isset
(
$visited
[
$oid
]))
{
...
...
@@ -1170,11 +1153,8 @@ class UnitOfWork implements PropertyChangedListener
}
$idGen
=
$class
->
idGenerator
;
if
(
$idGen
->
isPostInsertGenerator
())
{
$insertNow
[
$oid
]
=
$entity
;
}
else
{
if
(
!
$idGen
->
isPostInsertGenerator
())
{
$idValue
=
$idGen
->
generate
(
$this
->
_em
,
$entity
);
$this
->
_entityStates
[
$oid
]
=
self
::
STATE_MANAGED
;
if
(
!
$idGen
instanceof
\Doctrine\ORM\Id\Assigned
)
{
$this
->
_entityIdentifiers
[
$oid
]
=
array
(
$idValue
);
$class
->
setIdentifierValues
(
$entity
,
$idValue
);
...
...
@@ -1182,24 +1162,26 @@ class UnitOfWork implements PropertyChangedListener
$this
->
_entityIdentifiers
[
$oid
]
=
$idValue
;
}
}
$this
->
registerNew
(
$entity
);
$this
->
_entityStates
[
$oid
]
=
self
::
STATE_MANAGED
;
$this
->
scheduleForInsert
(
$entity
);
break
;
case
self
::
STATE_DETACHED
:
throw
DoctrineException
::
updateMe
(
"Behavior of save() for a detached entity "
.
"is not yet defined."
);
case
self
::
STATE_DELETED
:
// Entity becomes managed again
if
(
$this
->
is
RegisteredRemoved
(
$entity
))
{
if
(
$this
->
is
ScheduledForDelete
(
$entity
))
{
unset
(
$this
->
_entityDeletions
[
$oid
]);
}
else
{
//FIXME: There's more to think of here...
$this
->
registerNew
(
$entity
);
$this
->
scheduleForInsert
(
$entity
);
}
break
;
default
:
throw
DoctrineException
::
updateMe
(
"Encountered invalid entity state."
);
}
$this
->
_cascade
Save
(
$entity
,
$visited
,
$insertNow
);
$this
->
_cascade
Persist
(
$entity
,
$visited
);
}
/**
...
...
@@ -1207,10 +1189,10 @@ class UnitOfWork implements PropertyChangedListener
*
* @param object $entity
*/
public
function
delet
e
(
$entity
)
public
function
remov
e
(
$entity
)
{
$visited
=
array
();
$this
->
_do
Delet
e
(
$entity
,
$visited
);
$this
->
_do
Remov
e
(
$entity
,
$visited
);
}
/**
...
...
@@ -1222,7 +1204,7 @@ class UnitOfWork implements PropertyChangedListener
* @param object $entity The entity to delete.
* @param array $visited The map of the already visited entities.
*/
private
function
_do
Delet
e
(
$entity
,
array
&
$visited
)
private
function
_do
Remov
e
(
$entity
,
array
&
$visited
)
{
$oid
=
spl_object_hash
(
$entity
);
if
(
isset
(
$visited
[
$oid
]))
{
...
...
@@ -1244,14 +1226,14 @@ class UnitOfWork implements PropertyChangedListener
if
(
$this
->
_evm
->
hasListeners
(
Events
::
preDelete
))
{
$this
->
_evm
->
dispatchEvent
(
Events
::
preDelete
,
new
LifecycleEventArgs
(
$entity
));
}
$this
->
registerDeleted
(
$entity
);
$this
->
scheduleForDelete
(
$entity
);
break
;
case
self
::
STATE_DETACHED
:
throw
DoctrineException
::
updateMe
(
"A detached entity can't be deleted."
);
default
:
throw
DoctrineException
::
updateMe
(
"Encountered invalid entity state."
);
}
$this
->
_cascade
Delet
e
(
$entity
,
$visited
);
$this
->
_cascade
Remov
e
(
$entity
,
$visited
);
}
/**
...
...
@@ -1361,7 +1343,7 @@ class UnitOfWork implements PropertyChangedListener
* @param array $visited
* @param array $insertNow
*/
private
function
_cascade
Save
(
$entity
,
array
&
$visited
,
array
&
$insertNow
)
private
function
_cascade
Persist
(
$entity
,
array
&
$visited
)
{
$class
=
$this
->
_em
->
getClassMetadata
(
get_class
(
$entity
));
foreach
(
$class
->
associationMappings
as
$assocMapping
)
{
...
...
@@ -1371,10 +1353,10 @@ class UnitOfWork implements PropertyChangedListener
$relatedEntities
=
$class
->
reflFields
[
$assocMapping
->
sourceFieldName
]
->
getValue
(
$entity
);
if
((
$relatedEntities
instanceof
Collection
||
is_array
(
$relatedEntities
)))
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
$this
->
_do
Save
(
$relatedEntity
,
$visited
,
$insertNow
);
$this
->
_do
Persist
(
$relatedEntity
,
$visited
);
}
}
else
if
(
$relatedEntities
!==
null
)
{
$this
->
_do
Save
(
$relatedEntities
,
$visited
,
$insertNow
);
$this
->
_do
Persist
(
$relatedEntities
,
$visited
);
}
}
}
...
...
@@ -1385,7 +1367,7 @@ class UnitOfWork implements PropertyChangedListener
* @param object $entity
* @param array $visited
*/
private
function
_cascade
Delet
e
(
$entity
,
array
&
$visited
)
private
function
_cascade
Remov
e
(
$entity
,
array
&
$visited
)
{
$class
=
$this
->
_em
->
getClassMetadata
(
get_class
(
$entity
));
foreach
(
$class
->
associationMappings
as
$assocMapping
)
{
...
...
@@ -1396,10 +1378,10 @@ class UnitOfWork implements PropertyChangedListener
->
getValue
(
$entity
);
if
(
$relatedEntities
instanceof
Collection
||
is_array
(
$relatedEntities
))
{
foreach
(
$relatedEntities
as
$relatedEntity
)
{
$this
->
_do
Delet
e
(
$relatedEntity
,
$visited
);
$this
->
_do
Remov
e
(
$relatedEntity
,
$visited
);
}
}
else
if
(
$relatedEntities
!==
null
)
{
$this
->
_do
Delet
e
(
$relatedEntities
,
$visited
);
$this
->
_do
Remov
e
(
$relatedEntities
,
$visited
);
}
}
}
...
...
@@ -1429,7 +1411,7 @@ class UnitOfWork implements PropertyChangedListener
$this
->
_entityUpdates
=
array
();
$this
->
_entityDeletions
=
array
();
$this
->
_collectionDeletions
=
array
();
$this
->
_collectionCreations
=
array
();
//
$this->_collectionCreations = array();
$this
->
_collectionUpdates
=
array
();
$this
->
_commitOrderCalculator
->
clear
();
}
...
...
@@ -1574,8 +1556,6 @@ class UnitOfWork implements PropertyChangedListener
/**
* INTERNAL:
* For internal purposes only.
*
* Sets a property value of the original data array of an entity.
*
* @param string $oid
...
...
tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php
View file @
7297ac7b
...
...
@@ -25,7 +25,9 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user
->
name
=
'Roman'
;
$user
->
username
=
'romanb'
;
$user
->
status
=
'developer'
;
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$this
->
assertTrue
(
is_numeric
(
$user
->
id
));
$this
->
assertTrue
(
$this
->
_em
->
contains
(
$user
));
...
...
@@ -56,14 +58,14 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertTrue
(
$this
->
_em
->
contains
(
$ph2
));
// Delete
$this
->
_em
->
delet
e
(
$user
);
$this
->
assertTrue
(
$this
->
_em
->
getUnitOfWork
()
->
is
RegisteredRemoved
(
$user
));
$this
->
assertTrue
(
$this
->
_em
->
getUnitOfWork
()
->
is
RegisteredRemoved
(
$ph
));
$this
->
assertTrue
(
$this
->
_em
->
getUnitOfWork
()
->
is
RegisteredRemoved
(
$ph2
));
$this
->
_em
->
remov
e
(
$user
);
$this
->
assertTrue
(
$this
->
_em
->
getUnitOfWork
()
->
is
ScheduledForDelete
(
$user
));
$this
->
assertTrue
(
$this
->
_em
->
getUnitOfWork
()
->
is
ScheduledForDelete
(
$ph
));
$this
->
assertTrue
(
$this
->
_em
->
getUnitOfWork
()
->
is
ScheduledForDelete
(
$ph2
));
$this
->
_em
->
flush
();
$this
->
assertFalse
(
$this
->
_em
->
getUnitOfWork
()
->
is
RegisteredRemoved
(
$user
));
$this
->
assertFalse
(
$this
->
_em
->
getUnitOfWork
()
->
is
RegisteredRemoved
(
$ph
));
$this
->
assertFalse
(
$this
->
_em
->
getUnitOfWork
()
->
is
RegisteredRemoved
(
$ph2
));
$this
->
assertFalse
(
$this
->
_em
->
getUnitOfWork
()
->
is
ScheduledForDelete
(
$user
));
$this
->
assertFalse
(
$this
->
_em
->
getUnitOfWork
()
->
is
ScheduledForDelete
(
$ph
));
$this
->
assertFalse
(
$this
->
_em
->
getUnitOfWork
()
->
is
ScheduledForDelete
(
$ph2
));
}
public
function
testOneToManyAssociationModification
()
...
...
@@ -81,7 +83,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user
->
addPhonenumber
(
$ph1
);
$user
->
addPhonenumber
(
$ph2
);
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
//$this->assertTrue($user->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
...
...
@@ -111,7 +113,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user
->
address
=
$address
;
// inverse side
$address
->
user
=
$user
;
// owning side!
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
// Check that the foreign key has been set
...
...
@@ -133,8 +135,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user
->
groups
[]
=
$group
;
$group
->
users
[]
=
$user
;
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
save
(
$group
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
...
...
@@ -163,7 +164,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$group
->
users
[]
=
$user
;
}
$this
->
_em
->
save
(
$user
);
// Saves the user, 'cause of post-insert ID
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
...
...
@@ -189,7 +190,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user
->
name
=
'Guilherme'
;
$user
->
username
=
'gblanco'
;
$user
->
status
=
'developer'
;
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$query
=
$this
->
_em
->
createQuery
(
"select u from Doctrine\Tests\Models\CMS\CmsUser u"
);
...
...
@@ -226,7 +227,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user
->
name
=
'Guilherme'
;
$user
->
username
=
'gblanco'
;
$user
->
status
=
'developer'
;
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$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
$user
->
name
=
'Guilherme'
;
$user
->
username
=
'gblanco'
;
$user
->
status
=
'developer'
;
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$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
$user
->
addGroup
(
$group1
);
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
save
(
$group1
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
@@ -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"
);
$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
tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php
View file @
7297ac7b
...
...
@@ -25,14 +25,14 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$person
=
new
CompanyPerson
;
$person
->
setName
(
'Roman S. Borschel'
);
$this
->
_em
->
save
(
$person
);
$this
->
_em
->
persist
(
$person
);
$employee
=
new
CompanyEmployee
;
$employee
->
setName
(
'Roman S. Borschel'
);
$employee
->
setSalary
(
100000
);
$employee
->
setDepartment
(
'IT'
);
$this
->
_em
->
save
(
$employee
);
$this
->
_em
->
persist
(
$employee
);
$employee
->
setName
(
'Guilherme Blanco'
);
$this
->
_em
->
flush
();
...
...
@@ -86,13 +86,13 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$manager
->
setSalary
(
100000
);
$manager
->
setDepartment
(
'IT'
);
$manager
->
setTitle
(
'CTO'
);
$this
->
_em
->
save
(
$manager
);
$this
->
_em
->
persist
(
$manager
);
$this
->
_em
->
flush
();
$manager
->
setName
(
'Roman B.'
);
$manager
->
setSalary
(
119000
);
$manager
->
setTitle
(
'CEO'
);
$this
->
_em
->
save
(
$manager
);
$this
->
_em
->
persist
(
$manager
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
@@ -119,8 +119,8 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertSame
(
$manager
,
$wife
->
getSpouse
());
$this
->
assertSame
(
$wife
,
$manager
->
getSpouse
());
$this
->
_em
->
save
(
$manager
);
$this
->
_em
->
save
(
$wife
);
$this
->
_em
->
persist
(
$manager
);
$this
->
_em
->
persist
(
$wife
);
$this
->
_em
->
flush
();
...
...
@@ -155,8 +155,8 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertEquals
(
1
,
count
(
$person2
->
getFriends
()));
$this
->
_em
->
save
(
$person1
);
$this
->
_em
->
save
(
$person2
);
$this
->
_em
->
persist
(
$person1
);
$this
->
_em
->
persist
(
$person2
);
$this
->
_em
->
flush
();
...
...
tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php
View file @
7297ac7b
...
...
@@ -24,7 +24,7 @@ class DetachedEntityTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user
->
name
=
'Roman'
;
$user
->
username
=
'romanb'
;
$user
->
status
=
'dev'
;
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php
View file @
7297ac7b
...
...
@@ -21,7 +21,7 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
{
$entity
=
new
LifecycleCallbackTestEntity
;
$entity
->
value
=
'hello'
;
$this
->
_em
->
save
(
$entity
);
$this
->
_em
->
persist
(
$entity
);
$this
->
_em
->
flush
();
$this
->
assertTrue
(
$entity
->
preSaveCallbackInvoked
);
...
...
tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php
View file @
7297ac7b
...
...
@@ -37,7 +37,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
$test
=
new
OptimisticJoinedChild
();
$test
->
name
=
'child'
;
$test
->
whatever
=
'whatever'
;
$this
->
_em
->
save
(
$test
);
$this
->
_em
->
persist
(
$test
);
$this
->
_em
->
flush
();
$this
->
assertEquals
(
1
,
$test
->
version
);
...
...
@@ -66,7 +66,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
{
$test
=
new
OptimisticJoinedParent
();
$test
->
name
=
'parent'
;
$this
->
_em
->
save
(
$test
);
$this
->
_em
->
persist
(
$test
);
$this
->
_em
->
flush
();
$this
->
assertEquals
(
1
,
$test
->
version
);
...
...
@@ -95,7 +95,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
{
$test
=
new
OptimisticStandard
();
$test
->
name
=
'test'
;
$this
->
_em
->
save
(
$test
);
$this
->
_em
->
persist
(
$test
);
$this
->
_em
->
flush
();
$this
->
assertEquals
(
1
,
$test
->
version
);
...
...
tests/Doctrine/Tests/ORM/Functional/ManyToManyBidirectionalAssociationTest.php
View file @
7297ac7b
...
...
@@ -38,7 +38,7 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
{
$this
->
firstProduct
->
addCategory
(
$this
->
firstCategory
);
$this
->
firstProduct
->
addCategory
(
$this
->
secondCategory
);
$this
->
_em
->
save
(
$this
->
firstProduct
);
$this
->
_em
->
persist
(
$this
->
firstProduct
);
$this
->
_em
->
flush
();
$this
->
assertForeignKeysContain
(
$this
->
firstProduct
->
getId
(),
...
...
@@ -51,7 +51,7 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
{
$this
->
firstProduct
->
addCategory
(
$this
->
firstCategory
);
$this
->
firstProduct
->
addCategory
(
$this
->
secondCategory
);
$this
->
_em
->
save
(
$this
->
firstProduct
);
$this
->
_em
->
persist
(
$this
->
firstProduct
);
$this
->
firstProduct
->
removeCategory
(
$this
->
firstCategory
);
$this
->
_em
->
flush
();
...
...
@@ -102,8 +102,8 @@ class ManyToManyBidirectionalAssociationTest extends AbstractManyToManyAssociati
$this
->
firstProduct
->
addCategory
(
$this
->
secondCategory
);
$this
->
secondProduct
->
addCategory
(
$this
->
firstCategory
);
$this
->
secondProduct
->
addCategory
(
$this
->
secondCategory
);
$this
->
_em
->
save
(
$this
->
firstProduct
);
$this
->
_em
->
save
(
$this
->
secondProduct
);
$this
->
_em
->
persist
(
$this
->
firstProduct
);
$this
->
_em
->
persist
(
$this
->
secondProduct
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/ManyToManySelfReferentialAssociationTest.php
View file @
7297ac7b
...
...
@@ -38,7 +38,7 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia
{
$this
->
firstProduct
->
addRelated
(
$this
->
firstRelated
);
$this
->
firstProduct
->
addRelated
(
$this
->
secondRelated
);
$this
->
_em
->
save
(
$this
->
firstProduct
);
$this
->
_em
->
persist
(
$this
->
firstProduct
);
$this
->
_em
->
flush
();
$this
->
assertForeignKeysContain
(
$this
->
firstProduct
->
getId
(),
...
...
@@ -51,7 +51,7 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia
{
$this
->
firstProduct
->
addRelated
(
$this
->
firstRelated
);
$this
->
firstProduct
->
addRelated
(
$this
->
secondRelated
);
$this
->
_em
->
save
(
$this
->
firstProduct
);
$this
->
_em
->
persist
(
$this
->
firstProduct
);
$this
->
firstProduct
->
removeRelated
(
$this
->
firstRelated
);
$this
->
_em
->
flush
();
...
...
@@ -91,8 +91,8 @@ class ManyToManySelfReferentialAssociationTest extends AbstractManyToManyAssocia
$this
->
firstProduct
->
addRelated
(
$this
->
secondRelated
);
$this
->
secondProduct
->
addRelated
(
$this
->
firstRelated
);
$this
->
secondProduct
->
addRelated
(
$this
->
secondRelated
);
$this
->
_em
->
save
(
$this
->
firstProduct
);
$this
->
_em
->
save
(
$this
->
secondProduct
);
$this
->
_em
->
persist
(
$this
->
firstProduct
);
$this
->
_em
->
persist
(
$this
->
secondProduct
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/ManyToManyUnidirectionalAssociationTest.php
View file @
7297ac7b
...
...
@@ -38,7 +38,7 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
{
$this
->
firstCart
->
addProduct
(
$this
->
firstProduct
);
$this
->
firstCart
->
addProduct
(
$this
->
secondProduct
);
$this
->
_em
->
save
(
$this
->
firstCart
);
$this
->
_em
->
persist
(
$this
->
firstCart
);
$this
->
_em
->
flush
();
$this
->
assertForeignKeysContain
(
$this
->
firstCart
->
getId
(),
$this
->
firstProduct
->
getId
());
...
...
@@ -49,7 +49,7 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
{
$this
->
firstCart
->
addProduct
(
$this
->
firstProduct
);
$this
->
firstCart
->
addProduct
(
$this
->
secondProduct
);
$this
->
_em
->
save
(
$this
->
firstCart
);
$this
->
_em
->
persist
(
$this
->
firstCart
);
$this
->
firstCart
->
removeProduct
(
$this
->
firstProduct
);
$this
->
_em
->
flush
();
...
...
@@ -64,8 +64,8 @@ class ManyToManyUnidirectionalAssociationTest extends AbstractManyToManyAssociat
$this
->
firstCart
->
addProduct
(
$this
->
secondProduct
);
$this
->
secondCart
->
addProduct
(
$this
->
firstProduct
);
$this
->
secondCart
->
addProduct
(
$this
->
secondProduct
);
$this
->
_em
->
save
(
$this
->
firstCart
);
$this
->
_em
->
save
(
$this
->
secondCart
);
$this
->
_em
->
persist
(
$this
->
firstCart
);
$this
->
_em
->
persist
(
$this
->
secondCart
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php
View file @
7297ac7b
...
...
@@ -25,7 +25,7 @@ class NativeQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user
->
name
=
'Roman'
;
$user
->
username
=
'romanb'
;
$user
->
status
=
'dev'
;
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$rsm
=
new
ResultSetMapping
;
...
...
tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php
View file @
7297ac7b
...
...
@@ -31,7 +31,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public
function
testSavesAOneToManyAssociationWithCascadeSaveSet
()
{
$this
->
product
->
addFeature
(
$this
->
firstFeature
);
$this
->
product
->
addFeature
(
$this
->
secondFeature
);
$this
->
_em
->
save
(
$this
->
product
);
$this
->
_em
->
persist
(
$this
->
product
);
$this
->
_em
->
flush
();
$this
->
assertFeatureForeignKeyIs
(
$this
->
product
->
getId
(),
$this
->
firstFeature
);
...
...
@@ -40,7 +40,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public
function
testSavesAnEmptyCollection
()
{
$this
->
_em
->
save
(
$this
->
product
);
$this
->
_em
->
persist
(
$this
->
product
);
$this
->
_em
->
flush
();
$this
->
assertEquals
(
0
,
count
(
$this
->
product
->
getFeatures
()));
...
...
@@ -48,7 +48,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public
function
testDoesNotSaveAnInverseSideSet
()
{
$this
->
product
->
brokenAddFeature
(
$this
->
firstFeature
);
$this
->
_em
->
save
(
$this
->
product
);
$this
->
_em
->
persist
(
$this
->
product
);
$this
->
_em
->
flush
();
$this
->
assertFeatureForeignKeyIs
(
null
,
$this
->
firstFeature
);
...
...
@@ -58,7 +58,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
{
$this
->
product
->
addFeature
(
$this
->
firstFeature
);
$this
->
product
->
addFeature
(
$this
->
secondFeature
);
$this
->
_em
->
save
(
$this
->
product
);
$this
->
_em
->
persist
(
$this
->
product
);
$this
->
product
->
removeFeature
(
$this
->
firstFeature
);
$this
->
_em
->
flush
();
...
...
@@ -71,7 +71,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
{
$this
->
product
->
addFeature
(
$this
->
firstFeature
);
$this
->
product
->
addFeature
(
$this
->
secondFeature
);
$this
->
_em
->
save
(
$this
->
product
);
$this
->
_em
->
persist
(
$this
->
product
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/OneToManySelfReferentialAssociationTest.php
View file @
7297ac7b
...
...
@@ -30,7 +30,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
public
function
testSavesAOneToManyAssociationWithCascadeSaveSet
()
{
$this
->
parent
->
addChild
(
$this
->
firstChild
);
$this
->
parent
->
addChild
(
$this
->
secondChild
);
$this
->
_em
->
save
(
$this
->
parent
);
$this
->
_em
->
persist
(
$this
->
parent
);
$this
->
_em
->
flush
();
...
...
@@ -40,7 +40,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
public
function
testSavesAnEmptyCollection
()
{
$this
->
_em
->
save
(
$this
->
parent
);
$this
->
_em
->
persist
(
$this
->
parent
);
$this
->
_em
->
flush
();
$this
->
assertEquals
(
0
,
count
(
$this
->
parent
->
getChildren
()));
...
...
@@ -48,7 +48,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
public
function
testDoesNotSaveAnInverseSideSet
()
{
$this
->
parent
->
brokenAddChild
(
$this
->
firstChild
);
$this
->
_em
->
save
(
$this
->
parent
);
$this
->
_em
->
persist
(
$this
->
parent
);
$this
->
_em
->
flush
();
$this
->
assertForeignKeyIs
(
null
,
$this
->
firstChild
);
...
...
@@ -58,7 +58,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
{
$this
->
parent
->
addChild
(
$this
->
firstChild
);
$this
->
parent
->
addChild
(
$this
->
secondChild
);
$this
->
_em
->
save
(
$this
->
parent
);
$this
->
_em
->
persist
(
$this
->
parent
);
$this
->
parent
->
removeChild
(
$this
->
firstChild
);
$this
->
_em
->
flush
();
...
...
@@ -71,7 +71,7 @@ class OneToManySelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunctio
{
$this
->
parent
->
addChild
(
$this
->
firstChild
);
$this
->
parent
->
addChild
(
$this
->
secondChild
);
$this
->
_em
->
save
(
$this
->
parent
);
$this
->
_em
->
persist
(
$this
->
parent
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/OneToOneBidirectionalAssociationTest.php
View file @
7297ac7b
...
...
@@ -28,7 +28,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public
function
testSavesAOneToOneAssociationWithCascadeSaveSet
()
{
$this
->
customer
->
setCart
(
$this
->
cart
);
$this
->
_em
->
save
(
$this
->
customer
);
$this
->
_em
->
persist
(
$this
->
customer
);
$this
->
_em
->
flush
();
$this
->
assertCartForeignKeyIs
(
$this
->
customer
->
getId
());
...
...
@@ -36,7 +36,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public
function
testDoesNotSaveAnInverseSideSet
()
{
$this
->
customer
->
brokenSetCart
(
$this
->
cart
);
$this
->
_em
->
save
(
$this
->
customer
);
$this
->
_em
->
persist
(
$this
->
customer
);
$this
->
_em
->
flush
();
$this
->
assertCartForeignKeyIs
(
null
);
...
...
@@ -45,7 +45,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public
function
testRemovesOneToOneAssociation
()
{
$this
->
customer
->
setCart
(
$this
->
cart
);
$this
->
_em
->
save
(
$this
->
customer
);
$this
->
_em
->
persist
(
$this
->
customer
);
$this
->
customer
->
removeCart
();
$this
->
_em
->
flush
();
...
...
@@ -88,7 +88,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
$cart
->
setPayment
(
'paypal'
);
$customer
->
setCart
(
$cart
);
$this
->
_em
->
save
(
$customer
);
$this
->
_em
->
persist
(
$customer
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/OneToOneSelfReferentialAssociationTest.php
View file @
7297ac7b
...
...
@@ -30,7 +30,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
public
function
testSavesAOneToOneAssociationWithCascadeSaveSet
()
{
$this
->
customer
->
setMentor
(
$this
->
mentor
);
$this
->
_em
->
save
(
$this
->
customer
);
$this
->
_em
->
persist
(
$this
->
customer
);
$this
->
_em
->
flush
();
$this
->
assertForeignKeyIs
(
$this
->
mentor
->
getId
());
...
...
@@ -39,7 +39,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
public
function
testRemovesOneToOneAssociation
()
{
$this
->
customer
->
setMentor
(
$this
->
mentor
);
$this
->
_em
->
save
(
$this
->
customer
);
$this
->
_em
->
persist
(
$this
->
customer
);
$this
->
customer
->
removeMentor
();
$this
->
_em
->
flush
();
...
...
@@ -55,7 +55,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
$mentor
->
setName
(
'Obi-wan Kenobi'
);
$customer
->
setMentor
(
$mentor
);
$this
->
_em
->
save
(
$customer
);
$this
->
_em
->
persist
(
$customer
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/OneToOneUnidirectionalAssociationTest.php
View file @
7297ac7b
...
...
@@ -29,7 +29,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public
function
testSavesAOneToOneAssociationWithCascadeSaveSet
()
{
$this
->
product
->
setShipping
(
$this
->
shipping
);
$this
->
_em
->
save
(
$this
->
product
);
$this
->
_em
->
persist
(
$this
->
product
);
$this
->
_em
->
flush
();
$this
->
assertForeignKeyIs
(
$this
->
shipping
->
getId
());
...
...
@@ -38,7 +38,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public
function
testRemovesOneToOneAssociation
()
{
$this
->
product
->
setShipping
(
$this
->
shipping
);
$this
->
_em
->
save
(
$this
->
product
);
$this
->
_em
->
persist
(
$this
->
product
);
$this
->
product
->
removeShipping
();
$this
->
_em
->
flush
();
...
...
@@ -81,7 +81,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
$shipping
->
setDays
(
'1'
);
$product
->
setShipping
(
$shipping
);
$this
->
_em
->
save
(
$product
);
$this
->
_em
->
persist
(
$product
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php
View file @
7297ac7b
...
...
@@ -25,7 +25,7 @@ class QueryCacheTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user
->
name
=
'Roman'
;
$user
->
username
=
'romanb'
;
$user
->
status
=
'dev'
;
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
...
...
tests/Doctrine/Tests/ORM/Functional/QueryTest.php
View file @
7297ac7b
...
...
@@ -26,7 +26,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user
->
name
=
'Guilherme'
;
$user
->
username
=
'gblanco'
;
$user
->
status
=
'developer'
;
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
@@ -77,9 +77,9 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$article2
->
text
=
"This is an introduction to Symfony 2."
;
$user
->
addArticle
(
$article2
);
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
save
(
$article1
);
$this
->
_em
->
save
(
$article2
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
persist
(
$article1
);
$this
->
_em
->
persist
(
$article2
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/Functional/ReferenceProxyTest.php
View file @
7297ac7b
...
...
@@ -27,12 +27,13 @@ class ReferenceProxyTest extends \Doctrine\Tests\OrmFunctionalTestCase
{
$product
=
new
ECommerceProduct
();
$product
->
setName
(
'Doctrine Cookbook'
);
$this
->
_em
->
save
(
$product
);
$id
=
$product
->
getId
();
$this
->
_em
->
persist
(
$product
);
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$id
=
$product
->
getId
();
$productProxy
=
$this
->
_factory
->
getReferenceProxy
(
'Doctrine\Tests\Models\ECommerce\ECommerceProduct'
,
array
(
'id'
=>
$id
));
$this
->
assertEquals
(
'Doctrine Cookbook'
,
$productProxy
->
getName
());
}
...
...
tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php
View file @
7297ac7b
...
...
@@ -29,32 +29,32 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$parent
=
new
ParentEntity
;
$parent
->
setData
(
'foobar'
);
$this
->
_em
->
save
(
$parent
);
$this
->
_em
->
persist
(
$parent
);
$child
=
new
ChildEntity
;
$child
->
setData
(
'thedata'
);
$child
->
setNumber
(
1234
);
$this
->
_em
->
save
(
$child
);
$this
->
_em
->
persist
(
$child
);
$relatedEntity
=
new
RelatedEntity
;
$relatedEntity
->
setName
(
'theRelatedOne'
);
$relatedEntity
->
setOwner
(
$child
);
$this
->
_em
->
save
(
$relatedEntity
);
$this
->
_em
->
persist
(
$relatedEntity
);
$this
->
_em
->
flush
();
$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
();
$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
[
1
]
->
getId
()));
$this
->
assertTrue
(
$entities
[
0
]
instanceof
ParentEntity
);
$this
->
assertTrue
(
$entities
[
1
]
instanceof
ChildEntity
);
$this
->
assertEquals
(
'foobar'
,
$entities
[
0
]
->
getData
());
$this
->
assertEquals
(
'thedata'
,
$entities
[
1
]
->
getData
());
$this
->
assertEquals
(
1234
,
$entities
[
1
]
->
getNumber
());
...
...
tests/Doctrine/Tests/ORM/Performance/InsertPerformanceTest.php
View file @
7297ac7b
...
...
@@ -37,7 +37,7 @@ class InsertPerformanceTest extends \Doctrine\Tests\OrmPerformanceTestCase
$user
->
status
=
'user'
;
$user
->
username
=
'user'
.
$i
;
$user
->
name
=
'Mr.Smith-'
.
$i
;
$this
->
_em
->
save
(
$user
);
$this
->
_em
->
persist
(
$user
);
if
((
$i
%
$batchSize
)
==
0
)
{
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
...
...
tests/Doctrine/Tests/ORM/UnitOfWorkTest.php
View file @
7297ac7b
...
...
@@ -40,9 +40,9 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
{
$user
=
new
ForumUser
();
$user
->
username
=
'romanb'
;
$this
->
assertFalse
(
$this
->
_unitOfWork
->
is
RegisteredRemoved
(
$user
));
$this
->
_unitOfWork
->
registerDeleted
(
$user
);
$this
->
assertFalse
(
$this
->
_unitOfWork
->
is
RegisteredRemoved
(
$user
));
$this
->
assertFalse
(
$this
->
_unitOfWork
->
is
ScheduledForDelete
(
$user
));
$this
->
_unitOfWork
->
scheduleForDelete
(
$user
);
$this
->
assertFalse
(
$this
->
_unitOfWork
->
is
ScheduledForDelete
(
$user
));
}
...
...
@@ -60,28 +60,29 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
// Test
$user
=
new
ForumUser
();
$user
->
username
=
'romanb'
;
$this
->
_unitOfWork
->
save
(
$user
);
$this
->
_unitOfWork
->
persist
(
$user
);
// 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
->
getDeletes
()));
$this
->
assert
Tru
e
(
$this
->
_unitOfWork
->
isInIdentityMap
(
$user
));
$this
->
assert
Fals
e
(
$this
->
_unitOfWork
->
isInIdentityMap
(
$user
));
// should no longer be scheduled for insert
$this
->
assertFalse
(
$this
->
_unitOfWork
->
isRegisteredNew
(
$user
));
// should have an id
$this
->
assertTrue
(
is_numeric
(
$user
->
id
));
$this
->
assertTrue
(
$this
->
_unitOfWork
->
isScheduledForInsert
(
$user
));
// Now lets check whether a subsequent commit() does anything
$userPersister
->
reset
();
// Test
$this
->
_unitOfWork
->
commit
();
// shouldnt do anything
$this
->
_unitOfWork
->
commit
();
// Check.
Verify that nothing happened.
$this
->
assertEquals
(
0
,
count
(
$userPersister
->
getInserts
()));
// Check.
$this
->
assertEquals
(
1
,
count
(
$userPersister
->
getInserts
()));
$this
->
assertEquals
(
0
,
count
(
$userPersister
->
getUpdates
()));
$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
$user
->
username
=
'romanb'
;
$avatar
=
new
ForumAvatar
();
$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
(
$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
->
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
->
getDeletes
()));
}
...
...
@@ -130,13 +133,15 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
$entity
=
new
NotifyChangedEntity
;
$entity
->
setData
(
'thedata'
);
$this
->
_unitOfWork
->
save
(
$entity
);
$this
->
_unitOfWork
->
persist
(
$entity
);
$this
->
_unitOfWork
->
commit
();
$this
->
assertTrue
(
$this
->
_unitOfWork
->
isInIdentityMap
(
$entity
));
$entity
->
setData
(
'newdata'
);
$this
->
assertTrue
(
$this
->
_unitOfWork
->
is
RegisteredDirty
(
$entity
));
$this
->
assertTrue
(
$this
->
_unitOfWork
->
is
ScheduledForUpdate
(
$entity
));
$this
->
assertEquals
(
array
(
'data'
=>
array
(
'thedata'
,
'newdata'
)),
$this
->
_unitOfWork
->
getEntityChangeSet
(
$entity
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment