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
0a9876b2
Commit
0a9876b2
authored
Jan 15, 2010
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-248] Fixed and some more unrelated tests.
parent
d060a48c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
9 deletions
+43
-9
ClassMetadata.php
lib/Doctrine/ORM/Mapping/ClassMetadata.php
+15
-5
OneToManyBidirectionalAssociationTest.php
.../ORM/Functional/OneToManyBidirectionalAssociationTest.php
+28
-4
No files found.
lib/Doctrine/ORM/Mapping/ClassMetadata.php
View file @
0a9876b2
...
...
@@ -358,13 +358,23 @@ class ClassMetadata extends ClassMetadataInfo
{
// Restore ReflectionClass and properties
$this
->
reflClass
=
new
\ReflectionClass
(
$this
->
name
);
foreach
(
$this
->
fieldNames
as
$field
)
{
$this
->
reflFields
[
$field
]
=
$this
->
reflClass
->
getProperty
(
$field
);
$this
->
reflFields
[
$field
]
->
setAccessible
(
true
);
foreach
(
$this
->
fieldMappings
as
$field
=>
$mapping
)
{
if
(
isset
(
$mapping
[
'inherited'
]))
{
$reflField
=
new
\ReflectionProperty
(
$mapping
[
'inherited'
],
$field
);
}
else
{
$reflField
=
$this
->
reflClass
->
getProperty
(
$field
);
}
$reflField
->
setAccessible
(
true
);
$this
->
reflFields
[
$field
]
=
$reflField
;
}
foreach
(
$this
->
associationMappings
as
$field
=>
$mapping
)
{
$this
->
reflFields
[
$field
]
=
$this
->
reflClass
->
getProperty
(
$field
);
$this
->
reflFields
[
$field
]
->
setAccessible
(
true
);
if
(
isset
(
$this
->
inheritedAssociationFields
[
$field
]))
{
$reflField
=
new
\ReflectionProperty
(
$this
->
inheritedAssociationFields
[
$field
],
$field
);
}
else
{
$reflField
=
$this
->
reflClass
->
getProperty
(
$field
);
}
$reflField
->
setAccessible
(
true
);
$this
->
reflFields
[
$field
]
=
$reflField
;
}
//$this->prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
...
...
tests/Doctrine/Tests/ORM/Functional/OneToManyBidirectionalAssociationTest.php
View file @
0a9876b2
...
...
@@ -87,15 +87,15 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public
function
testLazyLoadsObjectsOnTheOwningSide
()
{
$this
->
_createFixture
();
$metadata
=
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\Models\ECommerce\ECommerceProduct'
);
$metadata
->
getAssociationMapping
(
'features'
)
->
fetchMode
=
AssociationMapping
::
FETCH_LAZY
;
$query
=
$this
->
_em
->
createQuery
(
'select p from Doctrine\Tests\Models\ECommerce\ECommerceProduct p'
);
$result
=
$query
->
getResult
();
$product
=
$result
[
0
];
$features
=
$product
->
getFeatures
();
$this
->
assertFalse
(
$features
->
isInitialized
());
$this
->
assertTrue
(
$features
[
0
]
instanceof
ECommerceFeature
);
$this
->
assertTrue
(
$features
->
isInitialized
());
$this
->
assertSame
(
$product
,
$features
[
0
]
->
getProduct
());
$this
->
assertEquals
(
'Model writing tutorial'
,
$features
[
0
]
->
getDescription
());
$this
->
assertTrue
(
$features
[
1
]
instanceof
ECommerceFeature
);
...
...
@@ -106,15 +106,39 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public
function
testLazyLoadsObjectsOnTheInverseSide
()
{
$this
->
_createFixture
();
$metadata
=
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\Models\ECommerce\ECommerceFeature'
);
$metadata
->
getAssociationMapping
(
'product'
)
->
fetchMode
=
AssociationMapping
::
FETCH_LAZY
;
$query
=
$this
->
_em
->
createQuery
(
'select f from Doctrine\Tests\Models\ECommerce\ECommerceFeature f'
);
$features
=
$query
->
getResult
();
$product
=
$features
[
0
]
->
getProduct
();
$this
->
assertTrue
(
$product
instanceof
\Doctrine\ORM\Proxy\Proxy
);
$this
->
assertTrue
(
$product
instanceof
ECommerceProduct
);
$this
->
assertFalse
(
$product
->
__isInitialized__
);
$this
->
assertSame
(
'Doctrine Cookbook'
,
$product
->
getName
());
$this
->
assertTrue
(
$product
->
__isInitialized__
);
}
public
function
testLazyLoadsObjectsOnTheInverseSide2
()
{
//$this->_em->getConnection()->getConfiguration()->setSqlLogger(new \Doctrine\DBAL\Logging\EchoSqlLogger);
$this
->
_createFixture
();
$query
=
$this
->
_em
->
createQuery
(
'select f,p from Doctrine\Tests\Models\ECommerce\ECommerceFeature f join f.product p'
);
$features
=
$query
->
getResult
();
$product
=
$features
[
0
]
->
getProduct
();
$this
->
assertFalse
(
$product
instanceof
\Doctrine\ORM\Proxy\Proxy
);
$this
->
assertTrue
(
$product
instanceof
ECommerceProduct
);
$this
->
assertSame
(
'Doctrine Cookbook'
,
$product
->
getName
());
$this
->
assertFalse
(
$product
->
getFeatures
()
->
isInitialized
());
// This would trigger lazy-load
//$this->assertEquals(2, $product->getFeatures()->count());
//$this->assertTrue($product->getFeatures()->contains($features[0]));
//$this->assertTrue($product->getFeatures()->contains($features[1]));
//$this->_em->getConnection()->getConfiguration()->setSqlLogger(null);
}
public
function
testJoinFromOwningSide
()
...
...
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