Skip to content

Commit a19ccbf

Browse files
authored
Merge pull request #382 from FriendsOfSymfony/functional-test-user-context
testing that user context request is handled correctly
2 parents af750bc + f7df0c3 commit a19ccbf

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the FOSHttpCacheBundle package.
5+
*
6+
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace FOS\HttpCacheBundle\Tests\Functional\EventListener;
13+
14+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
15+
16+
class UserContextListenerTest extends WebTestCase
17+
{
18+
public function testHashLookup()
19+
{
20+
$client = static::createClient();
21+
22+
$client->request('GET', '/_fos_user_context_hash', [], [], [
23+
'HTTP_ACCEPT' => 'application/vnd.fos.user-context-hash',
24+
]);
25+
$response = $client->getResponse();
26+
27+
$this->assertTrue($response->headers->has('X-User-Context-Hash'), 'X-User-Context-Hash header missing on the response');
28+
$this->assertEquals('max-age=60, public', $response->headers->get('Cache-Control'));
29+
}
30+
}

tests/Functional/Fixtures/app/config/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ fos_http_cache:
4242
- Cookie
4343
- Authorization
4444
role_provider: ~
45+
hash_cache_ttl: 60
4546
test:
4647
proxy_server:
4748
varnish:

tests/Functional/Fixtures/app/config/routing.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ test_logout:
4747
test_flash:
4848
path: /flash
4949
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\FlashMessageController::flashAction }
50+
51+
user_context_hash:
52+
path: /_fos_user_context_hash

0 commit comments

Comments
 (0)