Skip to content

Commit

Permalink
Add test for the ability to not only cache HTTP 200 and GET method
Browse files Browse the repository at this point in the history
  • Loading branch information
alquerci committed Oct 25, 2018
1 parent 31c2460 commit 94a850d
Show file tree
Hide file tree
Showing 13 changed files with 418 additions and 19 deletions.
14 changes: 14 additions & 0 deletions test/functional/cache203Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$app = 'cache203';
$successStatusCode = 203;

include __DIR__.'/cacheTest.php';
68 changes: 68 additions & 0 deletions test/functional/cache404NoDebugTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$app = 'cache';
$debug = false;

if (!include __DIR__.'/../bootstrap/functional.php')
{
return;
}

$b = new sfTestBrowser();

// Test for 404 support
$b->
get('/cache/error404')->
with('request')->begin()->
isParameter('module', 'cache')->
isParameter('action', 'error404')->
end()->
with('response')->begin()->
isStatusCode(404)->
checkElement('body', '/Error 404/')->
end()->
with('view_cache')->begin()->
isCached(true, true)->
end()->

setHttpHeader('If-Modified-Since', $b->getResponse()->getHttpHeader('Last-Modified'))->

get('/cache/error404')->
with('response')->begin()->
isStatusCode(304)->
matches('/^$/')-> // Response content is empty.
end()
;

// Test for 404 support without layout
$b->
restart()->
get('/cache/error404WithoutLayout')->
with('request')->begin()->
isParameter('module', 'cache')->
isParameter('action', 'error404WithoutLayout')->
end()->
with('response')->begin()->
isStatusCode(404)->
checkElement('body', '/Error 404/')->
end()->
with('view_cache')->begin()->
isCached(true)->
end()->

setHttpHeader('If-Modified-Since', $b->getResponse()->getHttpHeader('Last-Modified'))->

get('/cache/error404WithoutLayout')->
with('response')->begin()->
isStatusCode(404)->
checkElement('body', '/Error 404/')->
end()
;
Loading

0 comments on commit 94a850d

Please sign in to comment.