Skip to content

Commit 8651a82

Browse files
committed
Add test to ensure cache works
1 parent 4ae129b commit 8651a82

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

Response/RoutesResponse.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class RoutesResponse
2222
public function __construct($baseUrl, array $routes, $prefix, $host, $scheme)
2323
{
2424
$this->baseUrl = $baseUrl;
25-
$this->routes = $routes;
26-
$this->prefix = $prefix;
27-
$this->host = $host;
28-
$this->scheme = $scheme;
25+
$this->routes = $routes;
26+
$this->prefix = $prefix;
27+
$this->host = $host;
28+
$this->scheme = $scheme;
2929
}
3030

3131
public function getBase_url()

Tests/Controller/ControllerTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ public function testIndexAction()
3939
$this->assertEquals('{"base_url":"","routes":{"literal":{"tokens":[["text","\/homepage"]],"defaults":[],"requirements":[],"hosttokens":[]},"blog":{"tokens":[["variable","\/","[^\/]+?","slug"],["text","\/blog-post"]],"defaults":[],"requirements":[],"hosttokens":[["text","localhost"]]}},"prefix":"","host":"","scheme":""}', $response->getContent());
4040
}
4141

42+
public function testConfigCache()
43+
{
44+
$controller = new Controller(
45+
$this->getSerializer(),
46+
$this->getExtractor(array(
47+
'literal' => new ExtractedRoute(array(array('text', '/homepage')), array(), array()),
48+
))
49+
);
50+
51+
$response = $controller->indexAction($this->getRequest('/'), 'json');
52+
$this->assertEquals('{"base_url":"","routes":{"literal":{"tokens":[["text","\/homepage"]],"defaults":[],"requirements":[],"hosttokens":[]}},"prefix":"","host":"","scheme":""}', $response->getContent());
53+
54+
// second call should serve the cached content
55+
$response = $controller->indexAction($this->getRequest('/'), 'json');
56+
$this->assertEquals('{"base_url":"","routes":{"literal":{"tokens":[["text","\/homepage"]],"defaults":[],"requirements":[],"hosttokens":[]}},"prefix":"","host":"","scheme":""}', $response->getContent());
57+
}
58+
4259
/**
4360
* @dataProvider dataProviderForTestGenerateWithCallback
4461
*/

0 commit comments

Comments
 (0)