Browse Source

Added support for `fullBase` option in `::link()`.
Added test case for `fullBase`.

Huw Jones 8 years ago
parent
commit
c9c88f2283
2 changed files with 10 additions and 1 deletions
  1. 2 1
      src/View/Helper/HtmlHelper.php
  2. 8 0
      tests/TestCase/View/Helper/HtmlHelperTest.php

+ 2 - 1
src/View/Helper/HtmlHelper.php

@@ -346,7 +346,8 @@ class HtmlHelper extends Helper
     {
         $escapeTitle = true;
         if ($url !== null) {
-            $url = $this->Url->build($url);
+            $url = $this->Url->build($url, $options);
+            $options = array_diff_key($options, ['fullBase' => null]);
         } else {
             $url = $this->Url->build($title);
             $title = htmlspecialchars_decode($url, ENT_QUOTES);

+ 8 - 0
tests/TestCase/View/Helper/HtmlHelperTest.php

@@ -310,6 +310,14 @@ class HtmlHelperTest extends TestCase
         $result = $this->Html->link('say hello to 0123465-798', 'sms:0123465-798?body=hello "cakephp"');
         $expected = ['a' => ['href' => 'sms:0123465-798?body=hello "cakephp"'], 'say hello to 0123465-798', '/a'];
         $this->assertHtml($expected, $result);
+
+        $result = $this->Html->link('Home', '/', ['fullBase' => true]);
+        $expected = ['a' => ['href' => 'http://localhost/'], 'Home', '/a'];
+        $this->assertHtml($expected, $result);
+
+        $result = $this->Html->link('Home', '/', ['fullBase' => false]);
+        $expected = ['a' => ['href' => '/'], 'Home', '/a'];
+        $this->assertHtml($expected, $result);
     }
 
     /**