From 648d01e2e6c24f237d03102fa48b716ae059716b Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 20 Apr 2008 12:02:58 +0000 Subject: [PATCH] Adding test cases for HtmlHelper::charset() git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6705 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/html.php | 17 ++++------------- .../tests/cases/libs/view/helpers/html.test.php | 9 +++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index b01333ad8..3fdbdfc70 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -219,15 +219,12 @@ class HtmlHelper extends AppHelper { } elseif (isset($attributes['type']) && isset($types[$attributes['type']])) { $type = $types[$attributes['type']]; } - } else { - if ($url !== null) { - $inline = $url; - } + } elseif ($url !== null) { + $inline = $url; } - $attributes = array_merge($type, $attributes); - $out = null; + if (isset($attributes['link'])) { if (isset($attributes['rel']) && $attributes['rel'] === 'icon') { $out = sprintf($this->tags['metalink'], $attributes['link'], $this->_parseAttributes($attributes, array('link'))); @@ -254,13 +251,7 @@ class HtmlHelper extends AppHelper { * @return string A meta tag containing the specified character set. */ function charset($charset = null) { - if (is_null($charset)) { - $charset = strtolower(Configure::read('App.encoding')); - if (!$charset) { - $charset = 'utf-8'; - } - } - + $charset = current(array_filter(array($charset, strtolower(Configure::read('App.encoding')), 'utf-8'))); return $this->output(sprintf($this->tags['charset'], $charset)); } /** diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index 854bca6f4..43e995b6b 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -141,6 +141,15 @@ class HtmlHelperTest extends UnitTestCase { Configure::write('Asset.filter.css', false); } + function testCharsetTag() { + Configure::write('App.encoding', null); + $this->assertPattern('/charset=utf-8"/', $this->Html->charset()); + + Configure::write('App.encoding', 'ISO-8859-1'); + $this->assertPattern('/charset=iso-8859-1"/', $this->Html->charset()); + $this->assertPattern('/charset=UTF-7"/', $this->Html->charset('UTF-7')); + } + function testBreadcrumb() { $this->Html->addCrumb('First', '#first'); $this->Html->addCrumb('Second', '#second');