Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
PSDI Army
yii2
Commits
83872ff8
Commit
83872ff8
authored
Aug 16, 2014
by
DaSourcerer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CacheFilter test coverage
parent
a5b6c19d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
HttpCacheTest.php
tests/unit/framework/filters/HttpCacheTest.php
+71
-0
No files found.
tests/unit/framework/filters/HttpCacheTest.php
0 → 100644
View file @
83872ff8
<?php
namespace
yiiunit\framework\filters
;
use
Yii
;
use
yii\filters\HttpCache
;
/**
* @group filters
*/
class
HttpCacheTest
extends
\yiiunit\TestCase
{
protected
function
setUp
()
{
parent
::
setUp
();
$_SERVER
[
'SCRIPT_FILENAME'
]
=
"/index.php"
;
$_SERVER
[
'SCRIPT_NAME'
]
=
"/index.php"
;
$this
->
mockWebApplication
();
}
public
function
testDisabled
()
{
$httpCache
=
new
HttpCache
;
$this
->
assertTrue
(
$httpCache
->
beforeAction
(
null
));
$httpCache
->
enabled
=
false
;
$this
->
assertTrue
(
$httpCache
->
beforeAction
(
null
));
}
/**
* @covers HttpCache::validateCache
*/
public
function
testValidateCache
()
{
$httpCache
=
new
HttpCache
;
$method
=
new
\ReflectionMethod
(
$httpCache
,
'validateCache'
);
$method
->
setAccessible
(
true
);
$this
->
assertFalse
(
$method
->
invoke
(
$httpCache
,
null
,
null
));
$_SERVER
[
'HTTP_IF_MODIFIED_SINCE'
]
=
'Thu, 01 Jan 1970 00:00:00 GMT'
;
$this
->
assertTrue
(
$method
->
invoke
(
$httpCache
,
0
,
null
));
$this
->
assertFalse
(
$method
->
invoke
(
$httpCache
,
1
,
null
));
$_SERVER
[
'HTTP_IF_NONE_MATCH'
]
=
'"foo"'
;
$this
->
assertTrue
(
$method
->
invoke
(
$httpCache
,
0
,
'"foo"'
));
$this
->
assertTrue
(
$method
->
invoke
(
$httpCache
,
1
,
'"foo"'
));
$this
->
assertFalse
(
$method
->
invoke
(
$httpCache
,
null
,
null
));
}
/**
* @covers HttpCache::generateEtag
*/
public
function
testGenerateEtag
()
{
$httpCache
=
new
HttpCache
;
$httpCache
->
etagSeed
=
function
(
$action
,
$params
)
{
return
''
;
};
$httpCache
->
beforeAction
(
null
);
$response
=
Yii
::
$app
->
getResponse
();
$this
->
assertTrue
(
$response
->
getHeaders
()
->
offsetExists
(
'ETag'
));
$etag
=
$response
->
getHeaders
()
->
get
(
'ETag'
);
$this
->
assertStringStartsWith
(
'"'
,
$etag
);
$this
->
assertStringEndsWith
(
'"'
,
$etag
);
}
}
\ No newline at end of file
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