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
a5b31e95
Commit
a5b31e95
authored
Feb 09, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some new cache tests
parent
b3ad23bb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
CacheTestCase.php
tests/CacheTestCase.php
+48
-0
No files found.
tests/CacheTestCase.php
View file @
a5b31e95
...
...
@@ -113,6 +113,52 @@ class Doctrine_Cache_TestCase extends Doctrine_UnitTestCase
$a
=
$stmt
->
fetchAll
();
}
public
function
testAdapterStatementExecuteAddsQueriesToCache
()
{
$this
->
cache
->
setOption
(
'savePropability'
,
1
);
$driver
=
$this
->
cache
->
getDriver
();
$driver
->
deleteAll
();
$this
->
assertEqual
(
$driver
->
count
(),
0
);
$stmt
=
$this
->
dbh
->
prepare
(
'SELECT * FROM user WHERE id = ?'
);
$stmt
->
execute
(
array
(
1
));
$this
->
assertEqual
(
$driver
->
count
(),
1
);
}
public
function
testAppendStatsWritesQueriesToStatsFile
()
{
$this
->
cache
->
setOption
(
'addStatsPropability'
,
1
);
$data
=
array
(
1
,
2
,
3
);
$this
->
cache
->
add
(
'SELECT * FROM user'
);
$this
->
cache
->
add
(
array
(
'SELECT * FROM user WHERE id = ?'
,
array
(
1
)));
$this
->
cache
->
appendStats
();
$stats
=
$this
->
cache
->
readStats
();
$this
->
assertEqual
(
$stats
[
0
],
'SELECT * FROM user'
);
$this
->
assertEqual
(
$stats
[
1
],
array
(
'SELECT * FROM user WHERE id = ?'
,
array
(
1
)));
}
public
function
testCleanRemovesDriver
()
{
$this
->
cache
->
setOption
(
'cleanPropability'
,
1
);
$this
->
cache
->
add
(
'SELECT * FROM user'
);
$this
->
cache
->
add
(
array
(
'SELECT * FROM user WHERE id = ?'
,
array
(
1
)));
$this
->
cache
->
appendStats
();
$stats
=
$this
->
cache
->
readStats
();
$this
->
assertEqual
(
$stats
[
0
],
'SELECT * FROM user'
);
$this
->
assertEqual
(
$stats
[
1
],
array
(
'SELECT * FROM user WHERE id = ?'
,
array
(
1
)));
}
public
function
setUp
()
{
...
...
@@ -121,6 +167,8 @@ class Doctrine_Cache_TestCase extends Doctrine_UnitTestCase
if
(
!
isset
(
$this
->
cache
))
{
$this
->
cache
=
new
Doctrine_Cache
(
'Array'
);
$this
->
cache
->
setOption
(
'cacheFile'
,
false
);
$this
->
cache
->
setOption
(
'savePropability'
,
0
);
$this
->
dbh
->
setAdapter
(
new
Doctrine_Adapter_Mock
());
$this
->
dbh
->
addListener
(
$this
->
cache
);
}
...
...
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