From 0b46b042b9deda463d45624bb2f86e4ba5319279 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 2 Feb 2013 11:35:48 +0530 Subject: [PATCH] Changed params for HtmlHelper::css() to be consistent with HtmlHelper::script(). Closes #3593 --- .../Test/Case/View/Helper/HtmlHelperTest.php | 45 ++++++++++++++++- lib/Cake/View/Helper/HtmlHelper.php | 48 +++++++++++++------ 2 files changed, 77 insertions(+), 16 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php index d28e074502e..f798a65ea42 100644 --- a/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php @@ -549,7 +549,7 @@ public function testCssLink() { $this->assertTags($result, $expected); CakePlugin::load('TestPlugin'); - $result = $this->Html->css('TestPlugin.style', null, array('plugin' => false)); + $result = $this->Html->css('TestPlugin.style', array('plugin' => false)); $expected['link']['href'] = 'preg:/.*css\/TestPlugin\.style\.css/'; $this->assertTags($result, $expected); CakePlugin::unload('TestPlugin'); @@ -596,6 +596,49 @@ public function testCssLink() { ->method('append') ->with('css', $this->matchesRegularExpression('/more_css_in_head.css/')); + $result = $this->Html->css('css_in_head', array('inline' => false)); + $this->assertNull($result); + + $result = $this->Html->css('more_css_in_head', array('inline' => false)); + $this->assertNull($result); + + $result = $this->Html->css('screen', array('rel' => 'import')); + $expected = array( + 'style' => array('type' => 'text/css'), + 'preg:/@import url\(.*css\/screen\.css\);/', + '/style' + ); + $this->assertTags($result, $expected); + } + +/** + * Test css link BC usage + * + * @return void + */ + public function testCssLinkBC() { + Configure::write('Asset.filter.css', false); + + CakePlugin::load('TestPlugin'); + $result = $this->Html->css('TestPlugin.style', null, array('plugin' => false)); + $expected = array( + 'link' => array( + 'rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => 'preg:/.*css\/TestPlugin\.style\.css/' + ) + ); + $this->assertTags($result, $expected); + CakePlugin::unload('TestPlugin'); + + $result = $this->Html->css('screen', 'import'); + $expected = array( + 'style' => array('type' => 'text/css'), + 'preg:/@import url\(.*css\/screen\.css\);/', + '/style' + ); + $this->assertTags($result, $expected); + $result = $this->Html->css('css_in_head', null, array('inline' => false)); $this->assertNull($result); diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 685c8c7e0c9..7f0074ba02e 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -384,30 +384,42 @@ public function link($title, $url = null, $options = array(), $confirmMessage = * * Add the stylesheet to the `$scripts_for_layout` layout var: * - * `$this->Html->css('styles.css', null, array('inline' => false));` + * `$this->Html->css('styles.css', array('inline' => false));` * * Add the stylesheet to a custom block: * - * `$this->Html->css('styles.css', null, array('block' => 'layoutCss'));` + * `$this->Html->css('styles.css', array('block' => 'layoutCss'));` * * ### Options * * - `inline` If set to false, the generated tag will be appended to the 'css' block, * and included in the `$scripts_for_layout` layout variable. Defaults to true. - * - `block` Set the name of the block link/style tag will be appended to. This overrides the `inline` - * option. + * - `block` Set the name of the block link/style tag will be appended to. + * This overrides the `inline` option. * - `plugin` False value will prevent parsing path as a plugin + * - `rel` Defaults to 'stylesheet'. If equal to 'import' the stylesheet will be imported. * * @param string|array $path The name of a CSS style sheet or an array containing names of * CSS stylesheets. If `$path` is prefixed with '/', the path will be relative to the webroot * of your application. Otherwise, the path will be relative to your CSS path, usually webroot/css. - * @param string $rel Rel attribute. Defaults to "stylesheet". If equal to 'import' the stylesheet will be imported. - * @param array $options Array of HTML attributes. + * @param array $options Array of options and HTML arguments. * @return string CSS or