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
0b9a2e0c
Commit
0b9a2e0c
authored
Jul 16, 2009
by
piccoloprincipe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] working implementation of reference proxies
parent
9dba60a5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
113 additions
and
1 deletion
+113
-1
AllTests.php
tests/Doctrine/Tests/ORM/AllTests.php
+2
-1
GeneratorTest.php
tests/Doctrine/Tests/ORM/DynamicProxy/GeneratorTest.php
+72
-0
AllTests.php
tests/Doctrine/Tests/ORM/Functional/AllTests.php
+1
-0
DynamicProxyTest.php
tests/Doctrine/Tests/ORM/Functional/DynamicProxyTest.php
+38
-0
No files found.
tests/Doctrine/Tests/ORM/AllTests.php
View file @
0b9a2e0c
...
...
@@ -32,6 +32,7 @@ class AllTests
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\EntityManagerTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\CommitOrderCalculatorTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\QueryBuilderTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\DynamicProxy\GeneratorTest'
);
$suite
->
addTest
(
Query\AllTests
::
suite
());
$suite
->
addTest
(
Hydration\AllTests
::
suite
());
...
...
@@ -48,4 +49,4 @@ class AllTests
if
(
PHPUnit_MAIN_METHOD
==
'Orm_AllTests::main'
)
{
AllTests
::
main
();
}
\ No newline at end of file
}
tests/Doctrine/Tests/ORM/DynamicProxy/GeneratorTest.php
0 → 100644
View file @
0b9a2e0c
<?php
namespace
Doctrine\Tests\ORM\DynamicProxy
;
use
Doctrine\ORM\DynamicProxy\Generator
;
use
Doctrine\Tests\Mocks\ConnectionMock
;
use
Doctrine\Tests\Mocks\EntityManagerMock
;
use
Doctrine\Tests\Models\ECommerce\ECommerceCart
;
use
Doctrine\Tests\Models\ECommerce\ECommerceCustomer
;
use
Doctrine\Tests\Models\ECommerce\ECommerceFeature
;
use
Doctrine\Tests\Models\ECommerce\ECommerceShipping
;
require_once
__DIR__
.
'/../../TestInit.php'
;
/**
* Test the proxy generator. Its work is generating on-the-fly subclasses of a given model, which implement the Proxy pattern.
*/
class
GeneratorTest
extends
\Doctrine\Tests\OrmTestCase
{
private
$_connectionMock
;
private
$_emMock
;
private
$_generator
;
protected
function
setUp
()
{
parent
::
setUp
();
// SUT
$this
->
_connectionMock
=
new
ConnectionMock
(
array
(),
new
\Doctrine\Tests\Mocks\DriverMock
());
$this
->
_emMock
=
EntityManagerMock
::
create
(
$this
->
_connectionMock
);
$this
->
_generator
=
new
Generator
(
$this
->
_emMock
,
__DIR__
.
'/generated'
);
}
protected
function
tearDown
()
{
foreach
(
new
\DirectoryIterator
(
__DIR__
.
'/generated'
)
as
$file
)
{
if
(
strstr
(
$file
->
getFilename
(),
'.php'
))
{
unlink
(
$file
->
getPathname
());
}
}
}
public
function
testCreatesASubclassOfTheOriginalOne
()
{
$proxyClass
=
$this
->
_generator
->
generateReferenceProxyClass
(
'Doctrine\Tests\Models\ECommerce\ECommerceFeature'
);
$this
->
assertTrue
(
is_subclass_of
(
$proxyClass
,
'\Doctrine\Tests\Models\ECommerce\ECommerceFeature'
));
}
public
function
testCanGuessADefaultTempFolder
()
{
$generator
=
new
Generator
(
$this
->
_emMock
);
$proxyClass
=
$generator
->
generateReferenceProxyClass
(
'Doctrine\Tests\Models\ECommerce\ECommerceShipping'
);
$this
->
assertTrue
(
is_subclass_of
(
$proxyClass
,
'\Doctrine\Tests\Models\ECommerce\ECommerceShipping'
));
}
public
function
testAllowsClassesWithAConstructor
()
{
$proxyClass
=
$this
->
_generator
->
generateReferenceProxyClass
(
'Doctrine\Tests\Models\ECommerce\ECommerceCart'
);
$this
->
assertTrue
(
is_subclass_of
(
$proxyClass
,
'\Doctrine\Tests\Models\ECommerce\ECommerceCart'
));
}
public
function
_testGenerateProxiesWhichForwardsToTheModelWithTheGivenIdentifier
()
{
$feature
=
new
ECommerceFeature
;
$feature
->
setDescription
(
'An interesting feature'
);
$this
->
_emMock
->
save
(
$feature
);
$id
=
$feature
->
getId
();
$this
->
_emMock
->
clear
();
$proxy
=
$this
->
_generator
->
generateReferenceProxyClass
(
'Doctrine\Tests\Models\ECommerce\ECommerceFeature'
,
1
);
$this
->
assertEquals
(
'An interesting feature'
,
$proxy
->
getDescription
());
}
}
tests/Doctrine/Tests/ORM/Functional/AllTests.php
View file @
0b9a2e0c
...
...
@@ -34,6 +34,7 @@ class AllTests
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\OneToOneSelfReferentialAssociationTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\OneToManySelfReferentialAssociationTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\ManyToManySelfReferentialAssociationTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\DynamicProxyTest'
);
return
$suite
;
}
...
...
tests/Doctrine/Tests/ORM/Functional/DynamicProxyTest.php
0 → 100644
View file @
0b9a2e0c
<?php
namespace
Doctrine\Tests\ORM\Functional
;
use
Doctrine\ORM\DynamicProxy\Factory
;
use
Doctrine\ORM\DynamicProxy\Generator
;
use
Doctrine\Tests\Models\ECommerce\ECommerceProduct
;
require_once
__DIR__
.
'/../../TestInit.php'
;
/**
* Tests the generation of a proxy object for lazy loading.
*/
class
DynamicProxyTest
extends
\Doctrine\Tests\OrmFunctionalTestCase
{
private
$product
;
protected
function
setUp
()
{
$this
->
useModelSet
(
'ecommerce'
);
parent
::
setUp
();
$this
->
_factory
=
new
Factory
(
$this
->
_em
,
new
Generator
(
$this
->
_em
));
}
public
function
testLazyLoadsFieldValuesFromDatabase
()
{
$product
=
new
ECommerceProduct
();
$product
->
setName
(
'Doctrine Cookbook'
);
$this
->
_em
->
save
(
$product
);
$id
=
$product
->
getId
();
$this
->
_em
->
flush
();
$this
->
_em
->
clear
();
$productProxy
=
$this
->
_factory
->
getReferenceProxy
(
'Doctrine\Tests\Models\ECommerce\ECommerceProduct'
,
array
(
'id'
=>
$id
));
$this
->
assertEquals
(
'Doctrine Cookbook'
,
$productProxy
->
getName
());
}
}
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