Skip to content
Permalink
Browse files

Add tests for new UrlHelper methods.

  • Loading branch information...
ADmad committed Mar 6, 2016
1 parent 1704ab4 commit 35dc0c6dc6966bcc0f1b8df81df26415283ed42b
Showing with 55 additions and 0 deletions.
  1. +55 −0 tests/TestCase/View/Helper/UrlHelperTest.php
@@ -251,6 +251,61 @@ public function testAssetTimestampPluginsAndThemes()
$this->assertRegExp('#/test_theme/js/non_existant.js\?$#', $result, 'No error on missing file');
}
/**
* 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().
*

0 comments on commit 35dc0c6

Please sign in to comment.
You can’t perform that action at this time.