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
36763dad
Commit
36763dad
authored
Jan 29, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A little progress on the UnitOfWork.
parent
0ac97e7a
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
196 additions
and
151 deletions
+196
-151
Collection.php
lib/Doctrine/Common/Collections/Collection.php
+19
-2
Connection.php
lib/Doctrine/DBAL/Connection.php
+2
-1
ActiveEntity.php
lib/Doctrine/ORM/ActiveEntity.php
+1
-0
Collection.php
lib/Doctrine/ORM/Collection.php
+23
-36
ObjectHydrator.php
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
+3
-3
AbstractCollectionPersister.php
lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php
+24
-14
AbstractEntityPersister.php
lib/Doctrine/ORM/Persisters/AbstractEntityPersister.php
+8
-29
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+89
-55
CmsUser.php
tests/Doctrine/Tests/Models/CMS/CmsUser.php
+11
-1
BasicCRUDTest.php
tests/Doctrine/Tests/ORM/Functional/BasicCRUDTest.php
+15
-7
ObjectHydratorTest.php
tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php
+0
-2
UnitOfWorkTest.php
tests/Doctrine/Tests/ORM/UnitOfWorkTest.php
+1
-1
No files found.
lib/Doctrine/Common/Collections/Collection.php
View file @
36763dad
...
@@ -9,6 +9,7 @@ namespace Doctrine\Common\Collections;
...
@@ -9,6 +9,7 @@ namespace Doctrine\Common\Collections;
use
\Countable
;
use
\Countable
;
use
\IteratorAggregate
;
use
\IteratorAggregate
;
use
\ArrayAccess
;
use
\ArrayAccess
;
use
\ArrayIterator
;
/**
/**
* A Collection is a wrapper around a php array and just like a php array a
* A Collection is a wrapper around a php array and just like a php array a
...
@@ -88,6 +89,22 @@ class Collection implements Countable, IteratorAggregate, ArrayAccess
...
@@ -88,6 +89,22 @@ class Collection implements Countable, IteratorAggregate, ArrayAccess
return
$removed
;
return
$removed
;
}
}
/**
* Removes the specified element from the collection, if it is found.
*
* @param mixed $element
* @return boolean
*/
public
function
removeElement
(
$element
)
{
$key
=
array_search
(
$element
,
$this
->
_data
,
true
);
if
(
$key
!==
false
)
{
unset
(
$this
->
_data
[
$key
]);
return
true
;
}
return
false
;
}
/**
/**
* @see containsKey()
* @see containsKey()
*/
*/
...
@@ -174,7 +191,7 @@ class Collection implements Countable, IteratorAggregate, ArrayAccess
...
@@ -174,7 +191,7 @@ class Collection implements Countable, IteratorAggregate, ArrayAccess
* Tests for the existance of an element that satisfies the given predicate.
* Tests for the existance of an element that satisfies the given predicate.
*
*
* @param function $func
* @param function $func
* @return boolean TRUE if the predicate is TRUE for at least one element, FALS
e
otherwise.
* @return boolean TRUE if the predicate is TRUE for at least one element, FALS
E
otherwise.
*/
*/
public
function
exists
(
Closure
$func
)
{
public
function
exists
(
Closure
$func
)
{
foreach
(
$this
->
_data
as
$key
=>
$element
)
foreach
(
$this
->
_data
as
$key
=>
$element
)
...
@@ -191,7 +208,7 @@ class Collection implements Countable, IteratorAggregate, ArrayAccess
...
@@ -191,7 +208,7 @@ class Collection implements Countable, IteratorAggregate, ArrayAccess
*/
*/
public
function
containsAll
(
$otherColl
)
public
function
containsAll
(
$otherColl
)
{
{
throw
new
Doctrine
_
Exception
(
"Not yet implemented."
);
throw
new
DoctrineException
(
"Not yet implemented."
);
}
}
/**
/**
...
...
lib/Doctrine/DBAL/Connection.php
View file @
36763dad
...
@@ -495,7 +495,7 @@ class Connection
...
@@ -495,7 +495,7 @@ class Connection
*/
*/
public
function
prepare
(
$statement
)
public
function
prepare
(
$statement
)
{
{
echo
$statement
;
echo
$statement
.
PHP_EOL
;
$this
->
connect
();
$this
->
connect
();
try
{
try
{
return
$this
->
_conn
->
prepare
(
$statement
);
return
$this
->
_conn
->
prepare
(
$statement
);
...
@@ -561,6 +561,7 @@ class Connection
...
@@ -561,6 +561,7 @@ class Connection
$this
->
connect
();
$this
->
connect
();
try
{
try
{
if
(
!
empty
(
$params
))
{
if
(
!
empty
(
$params
))
{
//var_dump($params);
$stmt
=
$this
->
prepare
(
$query
);
$stmt
=
$this
->
prepare
(
$query
);
$stmt
->
execute
(
$params
);
$stmt
->
execute
(
$params
);
return
$stmt
->
rowCount
();
return
$stmt
->
rowCount
();
...
...
lib/Doctrine/ORM/ActiveEntity.php
View file @
36763dad
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
* most method calls to the EntityManager.
* most method calls to the EntityManager.
*
*
* @since 2.0
* @since 2.0
* @todo Any takers for this one? Needs a rewrite.
*/
*/
class
Doctrine_ORM_ActiveEntity
class
Doctrine_ORM_ActiveEntity
{
{
...
...
lib/Doctrine/ORM/Collection.php
View file @
36763dad
...
@@ -21,11 +21,13 @@
...
@@ -21,11 +21,13 @@
namespace
Doctrine\ORM
;
namespace
Doctrine\ORM
;
use
Doctrine\ORM\Mapping\AssociationMapping
;
/**
/**
* A persistent collection wrapper.
* A persistent collection wrapper.
*
*
* A PersistentCollection represents a collection of e
ntities. Collections of
* A PersistentCollection represents a collection of e
lements that have persistent state.
* entities represent only the associations (links) to those entities.
*
Collections of
entities represent only the associations (links) to those entities.
* That means, if the collection is part of a many-many mapping and you remove
* That means, if the collection is part of a many-many mapping and you remove
* entities from the collection, only the links in the xref table are removed (on flush).
* entities from the collection, only the links in the xref table are removed (on flush).
* Similarly, if you remove entities from a collection that is part of a one-many
* Similarly, if you remove entities from a collection that is part of a one-many
...
@@ -104,13 +106,17 @@ final class Collection extends \Doctrine\Common\Collections\Collection
...
@@ -104,13 +106,17 @@ final class Collection extends \Doctrine\Common\Collections\Collection
*/
*/
private
$_hydrationFlag
;
private
$_hydrationFlag
;
/**
* The class descriptor of the owning entity.
*/
private
$_ownerClass
;
private
$_ownerClass
;
/**
/**
* Creates a new persistent collection.
* Creates a new persistent collection.
*/
*/
public
function
__construct
(
EntityManager
$em
,
$entityBaseType
,
$keyField
=
null
)
public
function
__construct
(
EntityManager
$em
,
$entityBaseType
,
array
$data
=
array
(),
$keyField
=
null
)
{
{
parent
::
__construct
(
$data
);
$this
->
_entityBaseType
=
$entityBaseType
;
$this
->
_entityBaseType
=
$entityBaseType
;
$this
->
_em
=
$em
;
$this
->
_em
=
$em
;
$this
->
_ownerClass
=
$em
->
getClassMetadata
(
$entityBaseType
);
$this
->
_ownerClass
=
$em
->
getClassMetadata
(
$entityBaseType
);
...
@@ -151,7 +157,7 @@ final class Collection extends \Doctrine\Common\Collections\Collection
...
@@ -151,7 +157,7 @@ final class Collection extends \Doctrine\Common\Collections\Collection
* @param object $entity
* @param object $entity
* @param AssociationMapping $relation
* @param AssociationMapping $relation
*/
*/
public
function
_setOwner
(
$entity
,
\Doctrine\ORM\Mapping\
AssociationMapping
$relation
)
public
function
_setOwner
(
$entity
,
AssociationMapping
$relation
)
{
{
$this
->
_owner
=
$entity
;
$this
->
_owner
=
$entity
;
$this
->
_association
=
$relation
;
$this
->
_association
=
$relation
;
...
@@ -180,7 +186,7 @@ final class Collection extends \Doctrine\Common\Collections\Collection
...
@@ -180,7 +186,7 @@ final class Collection extends \Doctrine\Common\Collections\Collection
}
}
/**
/**
* Removes an e
ntity
from the collection.
* Removes an e
lement
from the collection.
*
*
* @param mixed $key
* @param mixed $key
* @return boolean
* @return boolean
...
@@ -215,11 +221,11 @@ final class Collection extends \Doctrine\Common\Collections\Collection
...
@@ -215,11 +221,11 @@ final class Collection extends \Doctrine\Common\Collections\Collection
}
}
/**
/**
* Adds an e
ntry
to the collection.
* Adds an e
lement
to the collection.
*
*
* @param mixed $value
* @param mixed $value
* @param string $key
* @param string $key
* @return
boolean
* @return
TRUE
* @override
* @override
*/
*/
public
function
add
(
$value
)
public
function
add
(
$value
)
...
@@ -230,8 +236,8 @@ final class Collection extends \Doctrine\Common\Collections\Collection
...
@@ -230,8 +236,8 @@ final class Collection extends \Doctrine\Common\Collections\Collection
if
(
$this
->
_hydrationFlag
)
{
if
(
$this
->
_hydrationFlag
)
{
if
(
$this
->
_backRefFieldName
)
{
if
(
$this
->
_backRefFieldName
)
{
// set back reference to owner
// set back reference to owner
$this
->
_ownerClass
->
getReflectionProperty
(
$this
->
_ownerClass
->
getReflectionProperty
(
$this
->
_backRefFieldName
)
$this
->
_backRefFieldName
)
->
setValue
(
$value
,
$this
->
_owner
);
->
setValue
(
$value
,
$this
->
_owner
);
}
}
}
else
{
}
else
{
//TODO: Register collection as dirty with the UoW if necessary
//TODO: Register collection as dirty with the UoW if necessary
...
@@ -295,27 +301,6 @@ final class Collection extends \Doctrine\Common\Collections\Collection
...
@@ -295,27 +301,6 @@ final class Collection extends \Doctrine\Common\Collections\Collection
return
$this
->
_snapshot
;
return
$this
->
_snapshot
;
}
}
/**
* INTERNAL:
* Processes the difference of the last snapshot and the current data.
*
* an example:
* Snapshot with the objects 1, 2 and 4
* Current data with objects 2, 3 and 5
*
* The process would remove objects 1 and 4
*
* @return Doctrine_Collection
* @todo Move elsewhere
*/
public
function
processDiff
()
{
foreach
(
array_udiff
(
$this
->
_snapshot
,
$this
->
_data
,
array
(
$this
,
"_compareRecords"
))
as
$record
)
{
$record
->
delete
();
}
return
$this
;
}
/**
/**
* INTERNAL:
* INTERNAL:
* getDeleteDiff
* getDeleteDiff
...
@@ -324,7 +309,7 @@ final class Collection extends \Doctrine\Common\Collections\Collection
...
@@ -324,7 +309,7 @@ final class Collection extends \Doctrine\Common\Collections\Collection
*/
*/
public
function
getDeleteDiff
()
public
function
getDeleteDiff
()
{
{
return
array_udiff
(
$this
->
_snapshot
,
$this
->
_data
,
array
(
$this
,
"_compareRecords"
));
return
array_udiff
(
$this
->
_snapshot
,
$this
->
_data
,
array
(
$this
,
'_compareRecords'
));
}
}
/**
/**
...
@@ -334,7 +319,7 @@ final class Collection extends \Doctrine\Common\Collections\Collection
...
@@ -334,7 +319,7 @@ final class Collection extends \Doctrine\Common\Collections\Collection
*/
*/
public
function
getInsertDiff
()
public
function
getInsertDiff
()
{
{
return
array_udiff
(
$this
->
_data
,
$this
->
_snapshot
,
array
(
$this
,
"_compareRecords"
));
return
array_udiff
(
$this
->
_data
,
$this
->
_snapshot
,
array
(
$this
,
'_compareRecords'
));
}
}
/**
/**
...
@@ -377,8 +362,10 @@ final class Collection extends \Doctrine\Common\Collections\Collection
...
@@ -377,8 +362,10 @@ final class Collection extends \Doctrine\Common\Collections\Collection
private
function
_changed
()
private
function
_changed
()
{
{
/*if ( ! $this->_em->getUnitOfWork()->isCollectionScheduledForUpdate($this)) {
if
(
!
$this
->
_em
->
getUnitOfWork
()
->
isCollectionScheduledForUpdate
(
$this
))
{
$this->_em->getUnitOfWork()->scheduleCollectionUpdate($this);
//var_dump(get_class($this->_snapshot[0]));
}*/
//echo "NOT!";
//$this->_em->getUnitOfWork()->scheduleCollectionUpdate($this);
}
}
}
}
}
lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
View file @
36763dad
...
@@ -54,7 +54,7 @@ class ObjectHydrator extends AbstractHydrator
...
@@ -54,7 +54,7 @@ class ObjectHydrator extends AbstractHydrator
if
(
$this
->
_parserResult
->
isMixedQuery
())
{
if
(
$this
->
_parserResult
->
isMixedQuery
())
{
$result
=
array
();
$result
=
array
();
}
else
{
}
else
{
$result
=
new
\Doctrine\
ORM\Collection
(
$this
->
_em
,
$this
->
_rootEntityName
)
;
$result
=
new
\Doctrine\
Common\Collections\Collection
;
}
}
$cache
=
array
();
$cache
=
array
();
...
@@ -66,7 +66,7 @@ class ObjectHydrator extends AbstractHydrator
...
@@ -66,7 +66,7 @@ class ObjectHydrator extends AbstractHydrator
foreach
(
$this
->
_collections
as
$coll
)
{
foreach
(
$this
->
_collections
as
$coll
)
{
$coll
->
_takeSnapshot
();
$coll
->
_takeSnapshot
();
$coll
->
_setHydrationFlag
(
false
);
$coll
->
_setHydrationFlag
(
false
);
$this
->
_uow
->
addManagedCollection
(
$coll
);
//
$this->_uow->addManagedCollection($coll);
}
}
// Clean up
// Clean up
...
@@ -105,7 +105,7 @@ class ObjectHydrator extends AbstractHydrator
...
@@ -105,7 +105,7 @@ class ObjectHydrator extends AbstractHydrator
if
(
!
is_object
(
$coll
))
{
if
(
!
is_object
(
$coll
))
{
end
(
$coll
);
end
(
$coll
);
$this
->
_resultPointers
[
$dqlAlias
]
=&
$coll
[
key
(
$coll
)];
$this
->
_resultPointers
[
$dqlAlias
]
=&
$coll
[
key
(
$coll
)];
}
else
if
(
$coll
instanceof
\Doctrine\
ORM
\Collection
)
{
}
else
if
(
$coll
instanceof
\Doctrine\
Common\Collections
\Collection
)
{
if
(
count
(
$coll
)
>
0
)
{
if
(
count
(
$coll
)
>
0
)
{
$this
->
_resultPointers
[
$dqlAlias
]
=
$coll
->
last
();
$this
->
_resultPointers
[
$dqlAlias
]
=
$coll
->
last
();
}
}
...
...
lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php
View file @
36763dad
<?php
<?php
class
Doctrine_ORM_Persisters_AbstractCollectionPersister
namespace
Doctrine\ORM\Persisters
;
use
Doctrine\ORM\Collection
;
class
AbstractCollectionPersister
{
{
public
function
recreate
(
Doctrine_Collection
$coll
)
public
function
recreate
(
Doctrine_Collection
$coll
)
...
@@ -8,7 +12,6 @@ class Doctrine_ORM_Persisters_AbstractCollectionPersister
...
@@ -8,7 +12,6 @@ class Doctrine_ORM_Persisters_AbstractCollectionPersister
if
(
$coll
->
getRelation
()
->
isInverseSide
())
{
if
(
$coll
->
getRelation
()
->
isInverseSide
())
{
return
;
return
;
}
}
//...
//...
}
}
...
@@ -17,32 +20,39 @@ class Doctrine_ORM_Persisters_AbstractCollectionPersister
...
@@ -17,32 +20,39 @@ class Doctrine_ORM_Persisters_AbstractCollectionPersister
if
(
$coll
->
getRelation
()
->
isInverseSide
())
{
if
(
$coll
->
getRelation
()
->
isInverseSide
())
{
return
;
return
;
}
}
//...
if
(
$coll
->
getRelation
()
instanceof
Doctrine_Association_OneToManyMapping
)
{
//...
}
else
if
(
$coll
->
getRelation
()
instanceof
Doctrine_Association_ManyToManyMapping
)
{
//...
//...
}
}
}
/* collection update actions */
/* collection update actions */
public
function
deleteRows
()
public
function
deleteRows
(
Collection
$coll
)
{
//$collection->getDeleteDiff();
}
public
function
updateRows
(
Collection
$coll
)
{
{
}
}
public
function
updateRows
()
public
function
insertRows
(
Collection
$coll
)
{
//$collection->getInsertDiff();
}
protected
function
_getDeleteRowSql
()
{
{
}
}
p
ublic
function
insertRows
()
p
rotected
function
_getUpdateRowSql
()
{
{
}
}
protected
function
_getDeleteRowSql
()
{
}
}
}
?>
\ No newline at end of file
lib/Doctrine/ORM/Persisters/AbstractEntityPersister.php
View file @
36763dad
...
@@ -33,12 +33,7 @@ namespace Doctrine\ORM\Persisters;
...
@@ -33,12 +33,7 @@ namespace Doctrine\ORM\Persisters;
abstract
class
AbstractEntityPersister
abstract
class
AbstractEntityPersister
{
{
/**
/**
* The names of all the fields that are available on entities.
* Metadata object that describes the mapping of the mapped entity class.
*/
protected
$_fieldNames
=
array
();
/**
* Metadata object that descibes the mapping of the mapped entity class.
*
*
* @var Doctrine\ORM\Mapping\ClassMetadata
* @var Doctrine\ORM\Mapping\ClassMetadata
*/
*/
...
@@ -124,25 +119,13 @@ abstract class AbstractEntityPersister
...
@@ -124,25 +119,13 @@ abstract class AbstractEntityPersister
/**
/**
*
*
* @return
<type>
* @return
Doctrine\ORM\ClassMetadata
*/
*/
public
function
getClassMetadata
()
public
function
getClassMetadata
()
{
{
return
$this
->
_classMetadata
;
return
$this
->
_classMetadata
;
}
}
/**
* @todo Move to ClassMetadata?
*/
public
function
getFieldNames
()
{
if
(
$this
->
_fieldNames
)
{
return
$this
->
_fieldNames
;
}
$this
->
_fieldNames
=
$this
->
_classMetadata
->
getFieldNames
();
return
$this
->
_fieldNames
;
}
/**
/**
* Gets the name of the class in the entity hierarchy that owns the field with
* Gets the name of the class in the entity hierarchy that owns the field with
* the given name. The owning class is the one that defines the field.
* the given name. The owning class is the one that defines the field.
...
@@ -156,15 +139,10 @@ abstract class AbstractEntityPersister
...
@@ -156,15 +139,10 @@ abstract class AbstractEntityPersister
if
(
$this
->
_classMetadata
->
isInheritanceTypeNone
())
{
if
(
$this
->
_classMetadata
->
isInheritanceTypeNone
())
{
return
$this
->
_classMetadata
;
return
$this
->
_classMetadata
;
}
else
{
}
else
{
foreach
(
$this
->
_classMetadata
->
getParentClasses
()
as
$parentClass
)
{
$mapping
=
$this
->
_classMetadata
->
getFieldMapping
(
$fieldName
);
$parentClassMetadata
=
Doctrine_ORM_Mapping_ClassMetadataFactory
::
getInstance
()
return
$mapping
[
'inherited'
];
->
getMetadataFor
(
$parentClass
);
if
(
!
$parentClassMetadata
->
isInheritedField
(
$fieldName
))
{
return
$parentClassMetadata
;
}
}
}
}
throw
new
Doctrine
_
Exception
(
"Unable to find defining class of field '
$fieldName
'."
);
throw
new
DoctrineException
(
"Unable to find defining class of field '
$fieldName
'."
);
}
}
/**
/**
...
@@ -186,8 +164,9 @@ abstract class AbstractEntityPersister
...
@@ -186,8 +164,9 @@ abstract class AbstractEntityPersister
/**
/**
* Prepares all the entity data for insertion into the database.
* Prepares all the entity data for insertion into the database.
*
*
* @param object $entity
* @param array $array
* @param array $array
* @
return void
* @
param boolean $isInsert
*/
*/
protected
function
_prepareData
(
$entity
,
array
&
$result
,
$isInsert
=
false
)
protected
function
_prepareData
(
$entity
,
array
&
$result
,
$isInsert
=
false
)
{
{
...
...
lib/Doctrine/ORM/UnitOfWork.php
View file @
36763dad
This diff is collapsed.
Click to expand it.
tests/Doctrine/Tests/Models/CMS/CmsUser.php
View file @
36763dad
...
@@ -27,7 +27,7 @@ class CmsUser
...
@@ -27,7 +27,7 @@ class CmsUser
public
$name
;
public
$name
;
/**
/**
* @DoctrineOneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsPhonenumber",
* @DoctrineOneToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsPhonenumber",
mappedBy="user", cascade={"save"})
mappedBy="user", cascade={"save"
, "delete"
})
*/
*/
public
$phonenumbers
;
public
$phonenumbers
;
/**
/**
...
@@ -44,4 +44,14 @@ class CmsUser
...
@@ -44,4 +44,14 @@ class CmsUser
$this
->
phonenumbers
[]
=
$phone
;
$this
->
phonenumbers
[]
=
$phone
;
$phone
->
user
=
$this
;
$phone
->
user
=
$this
;
}
}
public
function
removePhonenumber
(
$index
)
{
if
(
isset
(
$this
->
phonenumbers
[
$index
]))
{
$ph
=
$this
->
phonenumbers
[
$index
];
unset
(
$this
->
phonenumbers
[
$index
]);
$ph
->
user
=
null
;
return
true
;
}
return
false
;
}
}
}
tests/Doctrine/Tests/ORM/Functional/BasicCRUDTest.php
View file @
36763dad
...
@@ -42,24 +42,32 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
...
@@ -42,24 +42,32 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
$em
->
flush
();
$em
->
flush
();
$this
->
assertTrue
(
$em
->
contains
(
$ph
));
$this
->
assertTrue
(
$em
->
contains
(
$ph
));
$this
->
assertTrue
(
$em
->
contains
(
$user
));
$this
->
assertTrue
(
$em
->
contains
(
$user
));
$this
->
assertTrue
(
$user
->
phonenumbers
instanceof
\Doctrine\ORM\Collection
);
// Update
// Update
name
$user
->
name
=
'guilherme'
;
$user
->
name
=
'guilherme'
;
$em
->
flush
();
$em
->
flush
();
$this
->
assertEquals
(
'guilherme'
,
$user
->
name
);
$this
->
assertEquals
(
'guilherme'
,
$user
->
name
);
// Add another phonenumber
$ph2
=
new
CmsPhonenumber
;
$ph2
->
phonenumber
=
"6789"
;
$user
->
addPhonenumber
(
$ph2
);
$em
->
flush
();
$this
->
assertTrue
(
$em
->
contains
(
$ph2
));
// Delete
// Delete
$em
->
delete
(
$user
);
$em
->
delete
(
$user
);
$this
->
assertTrue
(
$em
->
getUnitOfWork
()
->
isRegisteredRemoved
(
$user
));
$this
->
assertTrue
(
$em
->
getUnitOfWork
()
->
isRegisteredRemoved
(
$user
));
$this
->
assertTrue
(
$em
->
getUnitOfWork
()
->
isRegisteredRemoved
(
$ph
));
$this
->
assertTrue
(
$em
->
getUnitOfWork
()
->
isRegisteredRemoved
(
$ph2
));
$em
->
flush
();
$em
->
flush
();
$this
->
assertFalse
(
$em
->
getUnitOfWork
()
->
isRegisteredRemoved
(
$user
));
$this
->
assertFalse
(
$em
->
getUnitOfWork
()
->
isRegisteredRemoved
(
$user
));
$this
->
assertFalse
(
$em
->
getUnitOfWork
()
->
isRegisteredRemoved
(
$ph
));
$this
->
assertFalse
(
$em
->
getUnitOfWork
()
->
isRegisteredRemoved
(
$ph2
));
}
}
public
function
testMore
()
{
/*public function testMore() {
#echo PHP_EOL . "SECOND" . PHP_EOL;
/*$user = new CmsUser;
$user->name = 'jon';
$user->*/
$ph = new CmsPhonenumber;
$ph = new CmsPhonenumber;
$ph->phonenumber = 123456;
$ph->phonenumber = 123456;
...
@@ -67,6 +75,6 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
...
@@ -67,6 +75,6 @@ class BasicCRUDTest extends \Doctrine\Tests\OrmFunctionalTestCase {
$this->_em->save($ph);
$this->_em->save($ph);
$this->_em->flush();
$this->_em->flush();
}
}
*/
}
}
tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php
View file @
36763dad
...
@@ -53,7 +53,6 @@ class ObjectHydratorTest extends HydrationTest
...
@@ -53,7 +53,6 @@ class ObjectHydratorTest extends HydrationTest
$queryComponents
,
$tableAliasMap
));
$queryComponents
,
$tableAliasMap
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertTrue
(
$result
instanceof
\Doctrine\ORM\Collection
);
$this
->
assertTrue
(
$result
[
0
]
instanceof
\Doctrine\Tests\Models\CMS\CmsUser
);
$this
->
assertTrue
(
$result
[
0
]
instanceof
\Doctrine\Tests\Models\CMS\CmsUser
);
$this
->
assertTrue
(
$result
[
1
]
instanceof
\Doctrine\Tests\Models\CMS\CmsUser
);
$this
->
assertTrue
(
$result
[
1
]
instanceof
\Doctrine\Tests\Models\CMS\CmsUser
);
$this
->
assertEquals
(
1
,
$result
[
0
]
->
id
);
$this
->
assertEquals
(
1
,
$result
[
0
]
->
id
);
...
@@ -659,7 +658,6 @@ class ObjectHydratorTest extends HydrationTest
...
@@ -659,7 +658,6 @@ class ObjectHydratorTest extends HydrationTest
$queryComponents
,
$tableAliasMap
));
$queryComponents
,
$tableAliasMap
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertEquals
(
2
,
count
(
$result
));
$this
->
assertTrue
(
$result
instanceof
\Doctrine\ORM\Collection
);
$this
->
assertTrue
(
$result
[
0
]
instanceof
\Doctrine\Tests\Models\Forum\ForumCategory
);
$this
->
assertTrue
(
$result
[
0
]
instanceof
\Doctrine\Tests\Models\Forum\ForumCategory
);
$this
->
assertTrue
(
$result
[
1
]
instanceof
\Doctrine\Tests\Models\Forum\ForumCategory
);
$this
->
assertTrue
(
$result
[
1
]
instanceof
\Doctrine\Tests\Models\Forum\ForumCategory
);
$this
->
assertEquals
(
1
,
$result
[
0
]
->
getId
());
$this
->
assertEquals
(
1
,
$result
[
0
]
->
getId
());
...
...
tests/Doctrine/Tests/ORM/UnitOfWorkTest.php
View file @
36763dad
...
@@ -159,7 +159,7 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
...
@@ -159,7 +159,7 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
));
));
// Go
// Go
$this
->
_unitOfWork
->
compute
Entity
ChangeSets
(
array
(
$user1
,
$user2
));
$this
->
_unitOfWork
->
computeChangeSets
(
array
(
$user1
,
$user2
));
// Verify
// Verify
$user1ChangeSet
=
$this
->
_unitOfWork
->
getEntityChangeSet
(
$user1
);
$user1ChangeSet
=
$this
->
_unitOfWork
->
getEntityChangeSet
(
$user1
);
...
...
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