Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Showing difference between renderer url and router match methods.

- Adding tests to prove behavior using empty array as first parameter
  differs.

- Adding documentation for renderer handlers.

Refs #973.
  • Loading branch information...
commit cdbf4566591b5a2ec09a920ad9e019d6e059d32f 1 parent 7c659c4
@davidpersson davidpersson authored
View
16 template/view/Renderer.php
@@ -183,6 +183,22 @@ public function __construct(array $config = array()) {
/**
* Sets the default output handlers for string template inputs.
*
+ * The default handlers available are:
+ * - `url`: Allows generating escaped and routed URLs using `Router::match()`. Note that
+ * all falsey values, which includes an empty array, will result in `'/'` being
+ * returned. For empty arrays this behavior is slightly different from using
+ * `Router::match()` directly.
+ * - `path`: Generates an asset path.
+ * - `options`: Converts a set of parameters to HTML attributes into a string.
+ * - `title`: Returns the escaped title.
+ * - `value`: Returns an escaped value.
+ * - `scripts`: Returns a markup string of styles from context.
+ * - `styles`: Returns a markup string of scripts from context.
+ * - `head`
+ *
+ * @see lithium\net\http\Router::match()
+ * @see lithium\net\http\Media::asset()
+ * @see lithium\template\Helper::_attributes()
* @return void
*/
protected function _init() {
View
9 tests/cases/net/http/RouterTest.php
@@ -361,6 +361,15 @@ public function testRouteMatchAbsoluteUrl() {
$this->assertIdentical($base . '/login', $result);
}
+ public function testEmptyUrlMatching() {
+ $result = Router::match('');
+ $expected = '/';
+ $this->assertIdentical($expected, $result);
+
+ $this->expectException('/No parameter match found for URL/');
+ Router::match(array());
+ }
+
/**
* Tests getting routes using `Router::get()`, and checking to see if the routes returned match
* the routes connected.
View
4 tests/cases/template/view/RendererTest.php
@@ -262,6 +262,10 @@ public function testHandlers() {
$absolute = $this->subject->url('Posts::foo', array('absolute' => true));
$this->assertEqual('http://foo.local/posts/foo', $absolute);
+ $this->assertEqual('/', $this->subject->url(array()));
+ $this->assertEqual('/', $this->subject->url(''));
+ $this->assertEqual('/', $this->subject->url(null));
+
$this->assertEmpty(trim($this->subject->scripts()));
$this->assertEqual('foobar', trim($this->subject->scripts('foobar')));
$this->assertEqual('foobar', trim($this->subject->scripts()));
Please sign in to comment.
Something went wrong with that request. Please try again.