Commit 6fd0f223 authored by Fabien Potencier's avatar Fabien Potencier

merged branch igorw/http-cache-terminate (PR #322)

Commits
-------

16872871 Call terminate() after sending the response in HttpCache

Discussion
----------

Call terminate() after sending the response in HttpCache
parents 6ad4c16a 16872871
......@@ -32,6 +32,8 @@ class HttpCache extends BaseHttpCache
$request = Request::createFromGlobals();
}
$this->handle($request)->send();
$response = $this->handle($request);
$response->send();
$this->terminate($request, $response);
}
}
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Silex\Tests\Provider;
use Silex\Application;
use Silex\Provider\HttpCacheServiceProvider;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* HttpCacheProvider test cases.
*
* @author Igor Wiedler <igor@wiedler.ch>
*/
class HttpCacheServiceProviderTest extends \PHPUnit_Framework_TestCase
{
public function testRegister()
{
$app = new Application();
$app->register(new HttpCacheServiceProvider(), array(
'http_cache.cache_dir' => sys_get_temp_dir().'/silex_http_cache_'.uniqid(),
));
$this->assertInstanceOf('Silex\HttpCache', $app['http_cache']);
return $app;
}
/**
* @depends testRegister
*/
public function testRunCallsShutdown($app)
{
$finished = false;
$app->get('/', function () use ($app, &$finished) {
$app->finish(function () use (&$finished) {
$finished = true;
});
return new UnsendableResponse('will do something after finish');
});
$request = Request::create('/');
$app['http_cache']->run($request);
$this->assertTrue($finished);
}
}
class UnsendableResponse extends Response
{
public function send()
{
// do nothing
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment