failing test to reproduce session problem
This commit is contained in:
parent
26fc4e683f
commit
89ed756462
@ -43,6 +43,14 @@ class SessionController implements ContainerAwareInterface
|
||||
return new Response(sprintf('Welcome back %s, nice to meet you.', $name));
|
||||
}
|
||||
|
||||
public function cacheableAction()
|
||||
{
|
||||
$response = new Response('all good');
|
||||
$response->setSharedMaxAge(100);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function logoutAction(Request $request)
|
||||
{
|
||||
$request->getSession()->invalidate();
|
||||
|
@ -2,6 +2,10 @@ session_welcome:
|
||||
path: /session
|
||||
defaults: { _controller: TestBundle:Session:welcome }
|
||||
|
||||
session_cacheable:
|
||||
path: /cacheable
|
||||
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SessionController::cacheableAction }
|
||||
|
||||
session_welcome_name:
|
||||
path: /session/{name}
|
||||
defaults: { _controller: TestBundle:Session:welcome }
|
||||
|
@ -126,6 +126,22 @@ class SessionTest extends WebTestCase
|
||||
$this->assertContains('Welcome back client2, nice to meet you.', $crawler2->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getConfigs
|
||||
*/
|
||||
public function testCorrectCacheControlHeadersForCacheableAction($config, $insulate)
|
||||
{
|
||||
$client = $this->createClient(array('test_case' => 'Session', 'root_config' => $config));
|
||||
if ($insulate) {
|
||||
$client->insulate();
|
||||
}
|
||||
|
||||
$client->request('GET', '/cacheable');
|
||||
|
||||
$response = $client->getResponse();
|
||||
$this->assertSame('public, s-maxage=100', $response->headers->get('cache-control'));
|
||||
}
|
||||
|
||||
public function getConfigs()
|
||||
{
|
||||
return array(
|
||||
|
@ -54,8 +54,6 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
++$this->usageIndex;
|
||||
|
||||
return $this->storage->start();
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,11 @@ final class SessionBagProxy implements SessionBagInterface
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
if (!isset($this->data[$this->bag->getStorageKey()])) {
|
||||
return true;
|
||||
}
|
||||
++$this->usageIndex;
|
||||
|
||||
return empty($this->data[$this->bag->getStorageKey()]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user