Removing Dispatcher::$here, it wasn't really used outside of a cached() which had a param that it just ignored. Making Dispatcher::cached() pay attention to its parameter.

Updating tests.
This commit is contained in:
mark_story 2011-03-02 21:52:25 -05:00
parent af16b13e5f
commit a6abd61f3f
2 changed files with 16 additions and 27 deletions

View file

@ -37,14 +37,6 @@ App::import('Controller', 'Controller', false);
*/
class Dispatcher {
/**
* Current URL
*
* @var string
* @access public
*/
public $here = false;
/**
* The request object
*
@ -91,9 +83,7 @@ class Dispatcher {
* 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;
}
@ -260,12 +250,11 @@ class Dispatcher {
/**
* 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));

View file

@ -1424,7 +1424,7 @@ class DispatcherTest extends CakeTestCase {
$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);
@ -1433,7 +1433,7 @@ class DispatcherTest extends CakeTestCase {
$this->assertEqual($result, $expected);
$filename = $this->__cachePath($dispatcher->here);
$filename = $this->__cachePath($request->here);
unlink($filename);
$request = new CakeRequest('test_cached_pages/index');
@ -1446,7 +1446,7 @@ class DispatcherTest extends CakeTestCase {
$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);
@ -1454,7 +1454,7 @@ class DispatcherTest extends CakeTestCase {
$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');
@ -1464,7 +1464,7 @@ class DispatcherTest extends CakeTestCase {
$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);
@ -1472,7 +1472,7 @@ class DispatcherTest extends CakeTestCase {
$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');
@ -1482,7 +1482,7 @@ class DispatcherTest extends CakeTestCase {
$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);
@ -1490,7 +1490,7 @@ class DispatcherTest extends CakeTestCase {
$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');
@ -1500,7 +1500,7 @@ class DispatcherTest extends CakeTestCase {
$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);
@ -1508,7 +1508,7 @@ class DispatcherTest extends CakeTestCase {
$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');
@ -1518,7 +1518,7 @@ class DispatcherTest extends CakeTestCase {
$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);
@ -1526,7 +1526,7 @@ class DispatcherTest extends CakeTestCase {
$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);