Skip to content

Commit

Permalink
Removing Dispatcher::$here, it wasn't really used outside of a cached…
Browse files Browse the repository at this point in the history
…() which had a param that it just ignored. Making Dispatcher::cached() pay attention to its parameter.

Updating tests.
  • Loading branch information
markstory committed Mar 3, 2011
1 parent af16b13 commit a6abd61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
19 changes: 4 additions & 15 deletions cake/libs/dispatcher.php
Expand Up @@ -37,14 +37,6 @@
*/
class Dispatcher {

/**
* Current URL
*
* @var string
* @access public
*/
public $here = false;

/**
* The request object
*
Expand Down Expand Up @@ -91,9 +83,7 @@ public function __construct($url = null, $base = false) {
* are encountered.
*/
public function dispatch(CakeRequest $request, $additionalParams = array()) {
$this->here = $request->here;

if ($this->asset($request->url) || $this->cached($request->url)) {
if ($this->asset($request->url) || $this->cached($request->here)) {
return;
}

Expand Down Expand Up @@ -260,12 +250,11 @@ protected function _loadRoutes() {
/**
* Outputs cached dispatch view cache
*
* @param string $url Requested URL
* @param string $path Requested URL path
*/
public function cached($url) {
public function cached($path) {
if (Configure::read('Cache.check') === true) {
$path = $this->here;
if ($this->here == '/') {
if ($path == '/') {
$path = 'home';
}
$path = strtolower(Inflector::slug($path));
Expand Down
24 changes: 12 additions & 12 deletions cake/tests/cases/libs/dispatcher.test.php
Expand Up @@ -1424,7 +1424,7 @@ public function testFullPageCachingDispatch() {
$out = ob_get_clean();

ob_start();
$dispatcher->cached($request);
$dispatcher->cached($request->here);
$cached = ob_get_clean();

$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
Expand All @@ -1433,7 +1433,7 @@ public function testFullPageCachingDispatch() {

$this->assertEqual($result, $expected);

$filename = $this->__cachePath($dispatcher->here);
$filename = $this->__cachePath($request->here);
unlink($filename);

$request = new CakeRequest('test_cached_pages/index');
Expand All @@ -1446,15 +1446,15 @@ public function testFullPageCachingDispatch() {
$out = ob_get_clean();

ob_start();
$dispatcher->cached($request);
$dispatcher->cached($request->here);
$cached = ob_get_clean();

$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);

$this->assertEqual($result, $expected);
$filename = $this->__cachePath($dispatcher->here);
$filename = $this->__cachePath($request->here);
unlink($filename);

$request = new CakeRequest('TestCachedPages/index');
Expand All @@ -1464,15 +1464,15 @@ public function testFullPageCachingDispatch() {
$out = ob_get_clean();

ob_start();
$dispatcher->cached($request);
$dispatcher->cached($request->here);
$cached = ob_get_clean();

$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);

$this->assertEqual($result, $expected);
$filename = $this->__cachePath($dispatcher->here);
$filename = $this->__cachePath($request->here);
unlink($filename);

$request = new CakeRequest('TestCachedPages/test_nocache_tags');
Expand All @@ -1482,15 +1482,15 @@ public function testFullPageCachingDispatch() {
$out = ob_get_clean();

ob_start();
$dispatcher->cached($request);
$dispatcher->cached($request->here);
$cached = ob_get_clean();

$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);

$this->assertEqual($result, $expected);
$filename = $this->__cachePath($dispatcher->here);
$filename = $this->__cachePath($request->here);
unlink($filename);

$request = new CakeRequest('test_cached_pages/view/param/param');
Expand All @@ -1500,15 +1500,15 @@ public function testFullPageCachingDispatch() {
$out = ob_get_clean();

ob_start();
$dispatcher->cached($request);
$dispatcher->cached($request->here);
$cached = ob_get_clean();

$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);

$this->assertEqual($result, $expected);
$filename = $this->__cachePath($dispatcher->here);
$filename = $this->__cachePath($request->here);
unlink($filename);

$request = new CakeRequest('test_cached_pages/view/foo:bar/value:goo');
Expand All @@ -1518,15 +1518,15 @@ public function testFullPageCachingDispatch() {
$out = ob_get_clean();

ob_start();
$dispatcher->cached($request);
$dispatcher->cached($request->here);
$cached = ob_get_clean();

$result = str_replace(array("\t", "\r\n", "\n"), "", $out);
$cached = preg_replace('/<!--+[^<>]+-->/', '', $cached);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $cached);

$this->assertEqual($result, $expected);
$filename = $this->__cachePath($dispatcher->here);
$filename = $this->__cachePath($request->here);
$this->assertTrue(file_exists($filename));

unlink($filename);
Expand Down

0 comments on commit a6abd61

Please sign in to comment.