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
be0088f0
Commit
be0088f0
authored
Jul 21, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Fix and test for result cache.
parent
49434b03
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
2 deletions
+67
-2
AbstractQuery.php
lib/Doctrine/ORM/AbstractQuery.php
+7
-2
AllTests.php
tests/Doctrine/Tests/ORM/Functional/AllTests.php
+1
-0
ResultCacheTest.php
tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php
+59
-0
No files found.
lib/Doctrine/ORM/AbstractQuery.php
View file @
be0088f0
...
...
@@ -443,7 +443,12 @@ abstract class AbstractQuery
if
(
$cached
===
false
)
{
// Cache miss.
$result
=
$this
->
_doExecute
(
$params
);
$stmt
=
$this
->
_doExecute
(
$params
);
$result
=
$this
->
_em
->
getHydrator
(
$this
->
_hydrationMode
)
->
hydrateAll
(
$stmt
,
$this
->
_resultSetMapping
,
$this
->
_hints
);
$cacheDriver
->
save
(
$hash
,
serialize
(
$result
),
$this
->
_resultCacheTTL
);
return
$result
;
...
...
@@ -467,7 +472,7 @@ abstract class AbstractQuery
/**
* Prepares the given parameters for execution in an SQL statement.
*
* Note to inheritors: This method must return a numerically, continously indexed array,
* Note to inheritors: This method must return a numerically, contin
u
ously indexed array,
* starting with index 0 where the values (the parameter values) are in the order
* in which the parameters appear in the SQL query.
*
...
...
tests/Doctrine/Tests/ORM/Functional/AllTests.php
View file @
be0088f0
...
...
@@ -25,6 +25,7 @@ class AllTests
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\ClassTableInheritanceTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\DetachedEntityTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\QueryCacheTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\ResultCacheTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\QueryTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\OneToOneUnidirectionalAssociationTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\OneToOneBidirectionalAssociationTest'
);
...
...
tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php
0 → 100644
View file @
be0088f0
<?php
namespace
Doctrine\Tests\ORM\Functional
;
use
Doctrine\Tests\Models\CMS\CmsUser
;
use
Doctrine\Common\Cache\ArrayCache
;
require_once
__DIR__
.
'/../../TestInit.php'
;
/**
* ResultCacheTest
*
* @author robo
*/
class
ResultCacheTest
extends
\Doctrine\Tests\OrmFunctionalTestCase
{
protected
function
setUp
()
{
$this
->
useModelSet
(
'cms'
);
parent
::
setUp
();
}
public
function
testQueryCache
()
{
$user
=
new
CmsUser
;
$user
->
name
=
'Roman'
;
$user
->
username
=
'romanb'
;
$user
->
status
=
'dev'
;
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$query
=
$this
->
_em
->
createQuery
(
'select ux from Doctrine\Tests\Models\CMS\CmsUser ux'
);
$cache
=
new
ArrayCache
;
$query
->
setResultCache
(
$cache
);
$this
->
assertEquals
(
0
,
$cache
->
count
());
$initialQueryCount
=
$this
->
_em
->
getConnection
()
->
getQueryCount
();
$users
=
$query
->
getResultList
();
$this
->
assertEquals
(
$initialQueryCount
+
1
,
$this
->
_em
->
getConnection
()
->
getQueryCount
());
$this
->
assertEquals
(
1
,
$cache
->
count
());
$this
->
assertEquals
(
1
,
count
(
$users
));
$this
->
assertEquals
(
'Roman'
,
$users
[
0
]
->
name
);
$this
->
_em
->
clear
();
$query2
=
$this
->
_em
->
createQuery
(
'select ux from Doctrine\Tests\Models\CMS\CmsUser ux'
);
$query2
->
setResultCache
(
$cache
);
$users
=
$query2
->
getResultList
();
$this
->
assertEquals
(
$initialQueryCount
+
1
,
$this
->
_em
->
getConnection
()
->
getQueryCount
());
$this
->
assertEquals
(
1
,
$cache
->
count
());
$this
->
assertEquals
(
1
,
count
(
$users
));
$this
->
assertEquals
(
'Roman'
,
$users
[
0
]
->
name
);
}
}
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