Permalink
Browse files

Fixed pathPrefix for css and script methods

  • Loading branch information...
1 parent c0212a0 commit 316c6582ea5e0f6a45f9fc70b1cf72d0dcde5256 @jrbasso jrbasso committed May 28, 2013
Showing with 28 additions and 2 deletions.
  1. +26 −0 lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
  2. +2 −2 lib/Cake/View/Helper/HtmlHelper.php
@@ -408,6 +408,12 @@ public function testImageTag() {
$result = $this->Html->image('test.gif?one=two&three=four');
$this->assertTags($result, array('img' => array('src' => 'img/test.gif?one=two&three=four', 'alt' => '')));
+
+ $result = $this->Html->image('test.gif', array('pathPrefix' => '/my/custom/path/'));
+ $this->assertTags($result, array('img' => array('src' => '/my/custom/path/test.gif', 'alt' => '')));
+
+ $result = $this->Html->image('test.gif', array('pathPrefix' => 'http://cakephp.org/assets/img/'));
+ $this->assertTags($result, array('img' => array('src' => 'http://cakephp.org/assets/img/test.gif', 'alt' => '')));
}
/**
@@ -593,6 +599,14 @@ public function testCssLink() {
$expected['link']['href'] = 'preg:/http:\/\/.*\/screen\.css\?1234/';
$this->assertTags($result, $expected);
+ $result = $this->Html->css('cake.generic', array('pathPrefix' => '/my/custom/path/'));
+ $expected['link']['href'] = '/my/custom/path/cake.generic.css';
+ $this->assertTags($result, $expected);
+
+ $result = $this->Html->css('cake.generic', array('pathPrefix' => 'http://cakephp.org/assets/css/'));
+ $expected['link']['href'] = 'http://cakephp.org/assets/css/cake.generic.css';
+ $this->assertTags($result, $expected);
+
Configure::write('Asset.filter.css', 'css.php');
$result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*ccss\/cake\.generic\.css/';
@@ -926,6 +940,18 @@ public function testScript() {
);
$this->assertTags($result, $expected);
+ $result = $this->Html->script('foo2', array('pathPrefix' => '/my/custom/path/'));
+ $expected = array(
+ 'script' => array('type' => 'text/javascript', 'src' => '/my/custom/path/foo2.js')
+ );
+ $this->assertTags($result, $expected);
+
+ $result = $this->Html->script('foo3', array('pathPrefix' => 'http://cakephp.org/assets/js/'));
+ $expected = array(
+ 'script' => array('type' => 'text/javascript', 'src' => 'http://cakephp.org/assets/js/foo3.js')
+ );
+ $this->assertTags($result, $expected);
+
$result = $this->Html->script('foo');
$this->assertNull($result, 'Script returned upon duplicate inclusion %s');
@@ -445,7 +445,7 @@ public function css($path, $options = array()) {
$url = $path;
} else {
$url = $this->assetUrl($path, $options + array('pathPrefix' => Configure::read('App.cssBaseUrl'), 'ext' => '.css'));
- $options = array_diff_key($options, array('fullBase' => null));
+ $options = array_diff_key($options, array('fullBase' => null, 'pathPrefix' => null));
if (Configure::read('Asset.filter.css')) {
$pos = strpos($url, Configure::read('App.cssBaseUrl'));
@@ -546,7 +546,7 @@ public function script($url, $options = array()) {
if (strpos($url, '//') === false) {
$url = $this->assetUrl($url, $options + array('pathPrefix' => Configure::read('App.jsBaseUrl'), 'ext' => '.js'));
- $options = array_diff_key($options, array('fullBase' => null));
+ $options = array_diff_key($options, array('fullBase' => null, 'pathPrefix' => null));
if (Configure::read('Asset.filter.js')) {
$url = str_replace(Configure::read('App.jsBaseUrl'), 'cjs/', $url);

0 comments on commit 316c658

Please sign in to comment.