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
f2213c4d
Commit
f2213c4d
authored
May 10, 2010
by
Christian Heinrich
Committed by
Roman S. Borschel
May 11, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed #DDC-578
Also added a new testcase
parent
f9b53c6b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
10 deletions
+28
-10
ProxyFactory.php
lib/Doctrine/ORM/Proxy/ProxyFactory.php
+5
-1
ForumEntry.php
tests/Doctrine/Tests/Models/Forum/ForumEntry.php
+4
-0
ProxyClassGeneratorTest.php
tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php
+19
-9
No files found.
lib/Doctrine/ORM/Proxy/ProxyFactory.php
View file @
f2213c4d
...
...
@@ -164,7 +164,11 @@ class ProxyFactory
}
if
(
$method
->
isPublic
()
&&
!
$method
->
isFinal
()
&&
!
$method
->
isStatic
())
{
$methods
.=
PHP_EOL
.
' public function '
.
$method
->
getName
()
.
'('
;
$methods
.=
PHP_EOL
.
' public function '
;
if
(
$method
->
returnsReference
())
{
$methods
.=
'&'
;
}
$methods
.=
$method
->
getName
()
.
'('
;
$firstParam
=
true
;
$parameterString
=
$argumentString
=
''
;
...
...
tests/Doctrine/Tests/Models/Forum/ForumEntry.php
View file @
f2213c4d
...
...
@@ -18,5 +18,9 @@ class ForumEntry
* @Column(type="string", length=50)
*/
public
$topic
;
public
function
&
getTopicByReference
()
{
return
$this
->
topic
;
}
}
tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php
View file @
f2213c4d
...
...
@@ -28,7 +28,7 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
* @var \Doctrine\ORM\Proxy\ProxyFactory
*/
private
$_proxyFactory
;
protected
function
setUp
()
{
parent
::
setUp
();
...
...
@@ -39,7 +39,7 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
// SUT
$this
->
_proxyFactory
=
new
ProxyFactory
(
$this
->
_emMock
,
__DIR__
.
'/generated'
,
'Proxies'
,
true
);
}
protected
function
tearDown
()
{
foreach
(
new
\DirectoryIterator
(
__DIR__
.
'/generated'
)
as
$file
)
{
...
...
@@ -55,14 +55,14 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
$proxyClass
=
'Proxies\DoctrineTestsModelsECommerceECommerceFeatureProxy'
;
$persister
=
$this
->
_getMockPersister
();
$this
->
_uowMock
->
setEntityPersister
(
'Doctrine\Tests\Models\ECommerce\ECommerceFeature'
,
$persister
);
$proxy
=
$this
->
_proxyFactory
->
getProxy
(
'Doctrine\Tests\Models\ECommerce\ECommerceFeature'
,
$identifier
);
$persister
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'load'
)
->
with
(
$this
->
equalTo
(
$identifier
),
$this
->
isInstanceOf
(
$proxyClass
))
->
will
(
$this
->
returnValue
(
new
\stdClass
()));
// fake return of entity instance
$proxy
->
getDescription
();
}
...
...
@@ -87,14 +87,24 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
$persister
=
$this
->
_getMockPersister
();
$this
->
_uowMock
->
setEntityPersister
(
'Doctrine\Tests\Models\ECommerce\ECommerceFeature'
,
$persister
);
$proxy
=
$this
->
_proxyFactory
->
getProxy
(
'Doctrine\Tests\Models\ECommerce\ECommerceFeature'
,
null
);
$method
=
new
\ReflectionMethod
(
get_class
(
$proxy
),
'setProduct'
);
$params
=
$method
->
getParameters
();
$this
->
assertEquals
(
1
,
count
(
$params
));
$this
->
assertEquals
(
'Doctrine\Tests\Models\ECommerce\ECommerceProduct'
,
$params
[
0
]
->
getClass
()
->
getName
());
}
/**
* Test that the proxy behaves in regard to methods like &foo() correctly
*/
public
function
testProxyRespectsMethodsWhichReturnValuesByReference
()
{
$proxy
=
$this
->
_proxyFactory
->
getProxy
(
'Doctrine\Tests\Models\Forum\ForumEntry'
,
null
);
$method
=
new
\ReflectionMethod
(
get_class
(
$proxy
),
'getTopicByReference'
);
$this
->
assertTrue
(
$method
->
returnsReference
());
}
public
function
testCreatesAssociationProxyAsSubclassOfTheOriginalOne
()
{
$proxyClass
=
'Proxies\DoctrineTestsModelsECommerceECommerceFeatureProxy'
;
...
...
@@ -122,7 +132,7 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
$this
->
_proxyFactory
->
generateProxyClasses
(
array
(
$classMetadata
));
$classCode
=
file_get_contents
(
dirname
(
__FILE__
)
.
"/generated/"
.
$proxyName
.
".php"
);
$this
->
assertNotContains
(
"class DoctrineOrmTestEntityProxy extends
\\\\
DoctrineOrmTestEntity"
,
$classCode
);
$this
->
assertContains
(
"class DoctrineOrmTestEntityProxy extends
\\
DoctrineOrmTestEntity"
,
$classCode
);
}
...
...
@@ -153,7 +163,7 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase
$this
->
setExpectedException
(
'Doctrine\ORM\Proxy\ProxyException'
);
new
ProxyFactory
(
$this
->
_getTestEntityManager
(),
__DIR__
.
'/generated'
,
null
);
}
protected
function
_getMockPersister
()
{
$persister
=
$this
->
getMock
(
'Doctrine\ORM\Persisters\BasicEntityPersister'
,
array
(
'load'
),
array
(),
''
,
false
);
...
...
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