From 7bea96f53450e8af318570b634658d7d1b5c7ffe Mon Sep 17 00:00:00 2001 From: Rachman Chavik Date: Wed, 19 Nov 2014 10:54:56 +0700 Subject: [PATCH 1/2] Add test for css() and script() with the same resource identifier --- .../Test/Case/View/Helper/HtmlHelperTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php index f7e2351f2..873f6a955 100644 --- a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php @@ -899,6 +899,22 @@ class HtmlHelperTest extends CakeTestCase { CakePlugin::unload('TestPlugin'); } +/** + * Resource names must be treated differently for css() and script() + * + * @return void + */ + public function testBufferedCssAndScriptWithIdenticalResourceName() { + $this->View->expects($this->at(0)) + ->method('append') + ->with('css', $this->stringContains('test.min.css')); + $this->View->expects($this->at(1)) + ->method('append') + ->with('script', $this->stringContains('test.min.js')); + $this->Html->css('test.min', array('inline' => false)); + $this->Html->script('test.min', array('inline' => false)); + } + /** * test timestamp enforcement for script tags. * From a37e007d9fcf208cc6e2a3b796a07760ee5f8821 Mon Sep 17 00:00:00 2001 From: Rachman Chavik Date: Wed, 19 Nov 2014 10:56:15 +0700 Subject: [PATCH 2/2] BC fix for css() and script() with identical resource names --- lib/Cake/View/Helper/HtmlHelper.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 4786fc306..6dfed4068 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -449,11 +449,11 @@ class HtmlHelper extends AppHelper { return; } - if ($options['once'] && isset($this->_includedAssets[$path])) { + if ($options['once'] && isset($this->_includedAssets[__METHOD__][$path])) { return ''; } unset($options['once']); - $this->_includedAssets[$path] = true; + $this->_includedAssets[__METHOD__][$path] = true; if (strpos($path, '//') !== false) { $url = $path; @@ -552,10 +552,10 @@ class HtmlHelper extends AppHelper { } return null; } - if ($options['once'] && isset($this->_includedAssets[$url])) { + if ($options['once'] && isset($this->_includedAssets[__METHOD__][$url])) { return null; } - $this->_includedAssets[$url] = true; + $this->_includedAssets[__METHOD__][$url] = true; if (strpos($url, '//') === false) { $url = $this->assetUrl($url, $options + array('pathPrefix' => Configure::read('App.jsBaseUrl'), 'ext' => '.js'));