Skip to content

Commit 7452746

Browse files
committed
Add tag_expressions functional test (ref #120)
1 parent 166316c commit 7452746

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

Resources/doc/reference/configuration/tags.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ tag ``articles-123`` with the following configuration:
8181
match:
8282
path: ^/articles
8383
tags: [articles]
84-
tag_expressions: ["article-"~id]
84+
tag_expressions: ["'article-'~id"]
8585
8686
You can combine ``tags`` and ``tag_expression`` in one rule.

Tests/Functional/EventListener/CacheControlSubscriberTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function testIsCached()
1919
{
2020
$client = static::createClient();
2121

22-
$client->request('GET', '/cached');
22+
$client->request('GET', '/cached/42');
2323
$response = $client->getResponse();
2424
$this->assertEquals('public', $response->headers->get('Cache-Control'));
2525
}

Tests/Functional/EventListener/TagSubscriberTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public function testConfigurationTagsAreSet()
6363
{
6464
$client = static::createClient();
6565

66-
$client->request('GET', '/cached');
66+
$client->request('GET', '/cached/51');
6767
$response = $client->getResponse();
68-
$this->assertEquals('area', $response->headers->get('X-Cache-Tags'));
68+
$this->assertEquals('area,area-51', $response->headers->get('X-Cache-Tags'));
6969
}
7070

7171
public function testConfigurationTagsAreInvalidated()
@@ -76,11 +76,11 @@ public function testConfigurationTagsAreInvalidated()
7676
'fos_http_cache.cache_manager',
7777
'\FOS\HttpCacheBundle\CacheManager'
7878
)
79-
->shouldReceive('invalidateTags')->once()->with(array('area'))
79+
->shouldReceive('invalidateTags')->once()->with(array('area', 'area-51'))
8080
->shouldReceive('flush')->once()
8181
;
8282

83-
$client->request('POST', '/cached');
83+
$client->request('PUT', '/cached/51');
8484
}
8585

8686
protected function tearDown()

Tests/Functional/Fixtures/Controller/TestController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public function errorAction()
4747
return new Response('Forbidden', 403);
4848
}
4949

50-
public function contentAction()
50+
public function contentAction($id = null)
5151
{
52-
return new Response('content');
52+
return new Response('content ' . $id);
5353
}
5454
}

Tests/Functional/Fixtures/app/config/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ fos_http_cache:
2323
match:
2424
path: ^/cached
2525
tags: [area]
26+
tag_expressions: ["'area-'~id"]
2627
user_context:
2728
user_identifier_headers:
2829
- Cookie
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
test_list:
2-
pattern: /test/list
3-
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\TestController::listAction }
2+
pattern: /test/list
3+
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\TestController::listAction }
44
methods: [GET]
55

66
test_error:
7-
pattern: /test/error
8-
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\TestController::errorAction }
7+
pattern: /test/error
8+
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\TestController::errorAction }
99

1010
test_one:
11-
pattern: /test/{id}
12-
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\TestController::itemAction }
11+
pattern: /test/{id}
12+
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\TestController::itemAction }
1313
methods: [GET,POST]
1414

1515
test_cached:
16-
pattern: /cached
17-
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\TestController::contentAction }
16+
pattern: /cached/{id}
17+
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\TestController::contentAction }
18+
methods: [GET,PUT]
1819

1920
test_noncached:
2021
pattern: /noncached
21-
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\TestController::contentAction }
22+
defaults: { _controller: FOS\HttpCacheBundle\Tests\Functional\Fixtures\Controller\TestController::contentAction }
2223

2324
test_logout:
2425
pattern: /secured_area/logout

0 commit comments

Comments
 (0)