Browse Source

Add tests for new UrlHelper methods.

ADmad 10 years ago
parent
commit
35dc0c6dc6
1 changed files with 55 additions and 0 deletions
  1. 55 0
      tests/TestCase/View/Helper/UrlHelperTest.php

+ 55 - 0
tests/TestCase/View/Helper/UrlHelperTest.php

@@ -252,6 +252,61 @@ class UrlHelperTest extends TestCase
     }
 
     /**
+     * test script()
+     *
+     * @return void
+     */
+    public function testScript()
+    {
+        Router::connect('/:controller/:action/*');
+
+        $this->Helper->webroot = '';
+        $result = $this->Helper->script(
+            [
+                'controller' => 'js',
+                'action' => 'post',
+                '_ext' => 'js'
+            ],
+            ['fullBase' => true]
+        );
+        $this->assertEquals(Router::fullBaseUrl() . '/js/post.js', $result);
+    }
+
+    /**
+     * test image()
+     *
+     * @return void
+     */
+    public function testImage()
+    {
+        $result = $this->Helper->image('foo.jpg');
+        $this->assertEquals('img/foo.jpg', $result);
+
+        $result = $this->Helper->image('foo.jpg', ['fullBase' => true]);
+        $this->assertEquals(Router::fullBaseUrl() . '/img/foo.jpg', $result);
+
+        $result = $this->Helper->image('dir/sub dir/my image.jpg');
+        $this->assertEquals('img/dir/sub%20dir/my%20image.jpg', $result);
+
+        $result = $this->Helper->image('foo.jpg?one=two&three=four');
+        $this->assertEquals('img/foo.jpg?one=two&three=four', $result);
+
+        $result = $this->Helper->image('dir/big+tall/image.jpg');
+        $this->assertEquals('img/dir/big%2Btall/image.jpg', $result);
+    }
+
+    /**
+     * test css
+     *
+     * @return void
+     */
+    public function testCss()
+    {
+        $result = $this->Helper->css('style');
+        $this->assertEquals('css/style.css', $result);
+    }
+
+    /**
      * Test generating paths with webroot().
      *
      * @return void