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
a1b01060
Commit
a1b01060
authored
May 03, 2017
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CS (alignment, imports, short array syntax, list assignments)
parent
00f13ca3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
41 deletions
+34
-41
QueryCacheProfileTest.php
tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php
+34
-41
No files found.
tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php
View file @
a1b01060
...
...
@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Cache;
use
Doctrine\DBAL\Cache\QueryCacheProfile
;
use
Doctrine\Tests\DbalTestCase
;
use
PDO
;
class
QueryCacheProfileTest
extends
DbalTestCase
{
...
...
@@ -21,44 +22,44 @@ class QueryCacheProfileTest extends DbalTestCase
public
function
testShouldUseTheGivenCacheKeyIfPresent
()
{
$query
=
'SELECT * FROM foo WHERE bar = ?'
;
$params
=
array
(
666
)
;
$types
=
array
(
\PDO
::
PARAM_INT
)
;
$params
=
[
666
]
;
$types
=
[
PDO
::
PARAM_INT
]
;
$connectionParams
=
array
(
'dbname'
=>
'database_name'
,
'user'
=>
'database_user'
,
'dbname'
=>
'database_name'
,
'user'
=>
'database_user'
,
'password'
=>
'database_password'
,
'host'
=>
'database_host'
,
'driver'
=>
'database_driver'
'host'
=>
'database_host'
,
'driver'
=>
'database_driver'
);
$generatedKeys
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
list
(
$cacheKey
)
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
$query
,
$params
,
$types
,
$connectionParams
);
$this
->
assertEquals
(
self
::
CACHE_KEY
,
$
generatedKeys
[
0
]
,
'The returned cache key should match the given one'
);
$this
->
assertEquals
(
self
::
CACHE_KEY
,
$
cacheKey
,
'The returned cache key should match the given one'
);
}
public
function
testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven
()
{
$query
=
'SELECT * FROM foo WHERE bar = ?'
;
$params
=
array
(
666
)
;
$types
=
array
(
\PDO
::
PARAM_INT
)
;
$params
=
[
666
]
;
$types
=
[
PDO
::
PARAM_INT
]
;
$connectionParams
=
array
(
'dbname'
=>
'database_name'
,
'user'
=>
'database_user'
,
'dbname'
=>
'database_name'
,
'user'
=>
'database_user'
,
'password'
=>
'database_password'
,
'host'
=>
'database_host'
,
'driver'
=>
'database_driver'
'host'
=>
'database_host'
,
'driver'
=>
'database_driver'
);
$this
->
queryCacheProfile
=
$this
->
queryCacheProfile
->
setCacheKey
(
null
);
$generatedKeys
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
list
(
$cacheKey
)
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
$query
,
$params
,
$types
,
...
...
@@ -67,86 +68,78 @@ class QueryCacheProfileTest extends DbalTestCase
$this
->
assertNotEquals
(
self
::
CACHE_KEY
,
$
generatedKeys
[
0
]
,
$
cacheKey
,
'The returned cache key should be generated automatically'
);
$this
->
assertNotEmpty
(
$
generatedKeys
[
0
]
,
'The generated cache key should not be empty'
);
$this
->
assertNotEmpty
(
$
cacheKey
,
'The generated cache key should not be empty'
);
}
public
function
testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferentConnections
()
{
$query
=
'SELECT * FROM foo WHERE bar = ?'
;
$params
=
array
(
666
)
;
$types
=
array
(
\PDO
::
PARAM_INT
)
;
$params
=
[
666
]
;
$types
=
[
PDO
::
PARAM_INT
]
;
$connectionParams
=
array
(
'dbname'
=>
'database_name'
,
'user'
=>
'database_user'
,
'dbname'
=>
'database_name'
,
'user'
=>
'database_user'
,
'password'
=>
'database_password'
,
'host'
=>
'database_host'
,
'driver'
=>
'database_driver'
'host'
=>
'database_host'
,
'driver'
=>
'database_driver'
);
$this
->
queryCacheProfile
=
$this
->
queryCacheProfile
->
setCacheKey
(
null
);
$generatedKeys
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
list
(
$firstCacheKey
)
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
$query
,
$params
,
$types
,
$connectionParams
);
$firstCacheKey
=
$generatedKeys
[
0
];
$connectionParams
[
'host'
]
=
'a_different_host'
;
$generatedKeys
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
list
(
$secondCacheKey
)
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
$query
,
$params
,
$types
,
$connectionParams
);
$secondCacheKey
=
$generatedKeys
[
0
];
$this
->
assertNotEquals
(
$firstCacheKey
,
$secondCacheKey
,
'Cache keys should be different'
);
}
public
function
testShouldGenerateSameKeysIfNoneOfTheParamsChanges
()
{
$query
=
'SELECT * FROM foo WHERE bar = ?'
;
$params
=
array
(
666
)
;
$types
=
array
(
\PDO
::
PARAM_INT
)
;
$params
=
[
666
]
;
$types
=
[
PDO
::
PARAM_INT
]
;
$connectionParams
=
array
(
'dbname'
=>
'database_name'
,
'user'
=>
'database_user'
,
'dbname'
=>
'database_name'
,
'user'
=>
'database_user'
,
'password'
=>
'database_password'
,
'host'
=>
'database_host'
,
'driver'
=>
'database_driver'
'host'
=>
'database_host'
,
'driver'
=>
'database_driver'
);
$this
->
queryCacheProfile
=
$this
->
queryCacheProfile
->
setCacheKey
(
null
);
$generatedKeys
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
list
(
$firstCacheKey
)
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
$query
,
$params
,
$types
,
$connectionParams
);
$firstCacheKey
=
$generatedKeys
[
0
];
$generatedKeys
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
list
(
$secondCacheKey
)
=
$this
->
queryCacheProfile
->
generateCacheKeys
(
$query
,
$params
,
$types
,
$connectionParams
);
$secondCacheKey
=
$generatedKeys
[
0
];
$this
->
assertEquals
(
$firstCacheKey
,
$secondCacheKey
,
'Cache keys should be the same'
);
}
}
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