Permalink
Browse files

Added test cases showing usage of 'full_base' key for url generation.…

… Refs #1256
  • Loading branch information...
1 parent d1403b0 commit 81ce6f40b9f78d8e092d8672ad3bcbd5288412fb @ADmad ADmad committed Nov 4, 2010
Showing with 24 additions and 8 deletions.
  1. +10 −8 cake/tests/cases/libs/router.test.php
  2. +14 −0 cake/tests/cases/libs/view/helpers/paginator.test.php
View
18 cake/tests/cases/libs/router.test.php
@@ -74,6 +74,8 @@ function testReturnedInstanceReference() {
function testFullBaseURL() {
$this->assertPattern('/^http(s)?:\/\//', Router::url('/', true));
$this->assertPattern('/^http(s)?:\/\//', Router::url(null, true));
+ $this->assertPattern('/^http(s)?:\/\//', Router::url(array('full_base' => true)));
+ $this->assertIdentical(FULL_BASE_URL . '/', Router::url(array('full_base' => true)));
}
/**
@@ -1702,8 +1704,8 @@ function testParsingWithTrailingPeriodAndParseExtensions() {
function testParsingWithPatternOnAction() {
Router::reload();
Router::connect(
- '/blog/:action/*',
- array('controller' => 'blog_posts'),
+ '/blog/:action/*',
+ array('controller' => 'blog_posts'),
array('action' => 'other|actions')
);
$result = Router::parse('/blog/other');
@@ -1725,7 +1727,7 @@ function testParsingWithPatternOnAction() {
'named' => array()
);
$this->assertEqual($expected, $result);
-
+
$result = Router::url(array('controller' => 'blog_posts', 'action' => 'foo'));
$this->assertEqual('/blog_posts/foo', $result);
@@ -2535,20 +2537,20 @@ function testMatchWithPatterns() {
*/
function testPatternOnAction() {
$route =& new CakeRoute(
- '/blog/:action/*',
- array('controller' => 'blog_posts'),
+ '/blog/:action/*',
+ array('controller' => 'blog_posts'),
array('action' => 'other|actions')
);
$result = $route->match(array('controller' => 'blog_posts', 'action' => 'foo'));
$this->assertFalse($result);
-
+
$result = $route->match(array('controller' => 'blog_posts', 'action' => 'actions'));
$this->assertTrue($result);
-
+
$result = $route->parse('/blog/other');
$expected = array('controller' => 'blog_posts', 'action' => 'other', 'pass' => array(), 'named' => array());
$this->assertEqual($expected, $result);
-
+
$result = $route->parse('/blog/foobar');
$this->assertFalse($result);
}
View
14 cake/tests/cases/libs/view/helpers/paginator.test.php
@@ -21,6 +21,10 @@
Mock::generate('JsHelper', 'PaginatorMockJsHelper');
+if (!defined('FULL_BASE_URL')) {
+ define('FULL_BASE_URL', 'http://cakephp.org');
+}
+
/**
* PaginatorHelperTest class
*
@@ -1718,6 +1722,16 @@ function testFirstAndLast() {
'/span',
);
$this->assertTags($result, $expected);
+
+ $this->Paginator->options(array('url' => array('full_base' => true)));
+ $result = $this->Paginator->first();
+
+ $expected = array(
+ '<span',
+ array('a' => array('href' => FULL_BASE_URL . '/index/page:1/sort:Client.name/direction:DESC')), '&lt;&lt; first', '/a',
+ '/span',
+ );
+ $this->assertTags($result, $expected);
}
/**

0 comments on commit 81ce6f4

Please sign in to comment.