Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug #1351: CClientScript::registerMetaTag() now allows to register mu…

…ltiple meta tags with the same set of attributes
  • Loading branch information...
commit 10ea135c0f05f5620f79015b48710710eb4ec9e7 2 parents 920813e + be6a0f0
@samdark samdark authored
View
1  CHANGELOG
@@ -15,6 +15,7 @@ Version 1.1.13 work in progress
- Bug #1181: Fixed can read but not save binary data e.g. BYTEA on PostgreSQL (karmakaze)
- Bug #1249: CHttpRequest::sendFile() outputs malformed file content in some specific circumstances (andyhu)
- Bug #1330: SQLite column default value was incorrect for column of type string and DEFAULT NULL (cebe)
+- Bug #1351: CClientScript::registerMetaTag() now allows to register multiple meta tags with the same set of attributes (klimov-paul)
- Bug #1364: Empty CHtml::$errorCss cause class attribute rendering errors (creocoder)
- Enh #117: Added CPhpMessageSource::$extensionPaths to allow extensions, that do not have a base class to use as category prefix, to register message source (rcoelho, cebe)
- Enh #291: CFormatter::formatDate and formatDateTime now also accept strings in strtotime() format (francis_tm, cebe)
View
4 framework/web/CClientScript.php
@@ -632,7 +632,7 @@ public function registerScript($id,$script,$position=null)
* Registers a meta tag that will be inserted in the head section (right before the title element) of the resulting page.
*
* <b>Note:</b>
- * Meta tags with same attributes will be rendered more then once if called with different values.
+ * Each call of this method will cause a rendering of new meta tag, even if their attributes are equal.
*
* <b>Example:</b>
* <pre>
@@ -653,7 +653,7 @@ public function registerMetaTag($content,$name=null,$httpEquiv=null,$options=arr
if($httpEquiv!==null)
$options['http-equiv']=$httpEquiv;
$options['content']=$content;
- $this->metaTags[serialize($options)]=$options;
+ $this->metaTags[]=$options;
$params=func_get_args();
$this->recordCachingAction('clientScript','registerMetaTag',$params);
return $this;
View
260 tests/framework/web/CClientScriptTest.php
@@ -7,105 +7,167 @@
*/
class CClientScriptTest extends CTestCase
{
- /**
- * @var CClientScript
- */
- private $_clientScript;
-
- public function setUp()
- {
- $this->_clientScript = new CClientScript();
- $this->_clientScript->setCoreScriptUrl("assets/12345");
- $this->_clientScript->registerCoreScript('jquery');
- $this->_clientScript->registerCoreScript('yii');
- }
-
- /* Test Script Getters */
-
- public function testGetCoreScriptUrl()
- {
- $this->assertEquals('assets/12345', $this->_clientScript->getCoreScriptUrl());
- }
-
-
- public function providerGetPackageBaseUrl()
- {
- return array(
- array('jquery', 'assets/12345'),
- array('yii', 'assets/12345')
- );
- }
-
- /**
- * @dataProvider providerGetPackageBaseUrl
- *
- * @param string $name
- * @param string $assertion
- */
- public function testGetPackageBaseUrl($name, $assertion)
- {
- $this->assertEquals($assertion,$this->_clientScript->getPackageBaseUrl($name));
- }
-
- /* Test Script Registers */
-
- public function providerCoreScripts()
- {
- return array(
- array('jquery', array('js'=>array('jquery.js'))),
- array('yiitab', array('js'=>array('jquery.yiitab.js'), 'depends'=>array('jquery'))),
- array('yiiactiveform', array('js'=>array('jquery.yiiactiveform.js'), 'depends'=>array('jquery')))
+ /**
+ * @var CClientScript
+ */
+ private $_clientScript;
+
+ public function setUp()
+ {
+ $this->_clientScript = new CClientScript();
+ $this->_clientScript->setCoreScriptUrl("assets/12345");
+ $this->_clientScript->registerCoreScript('jquery');
+ $this->_clientScript->registerCoreScript('yii');
+ }
+
+ /* Test Script Getters */
+
+ public function testGetCoreScriptUrl()
+ {
+ $this->assertEquals('assets/12345', $this->_clientScript->getCoreScriptUrl());
+ }
+
+
+ public function providerGetPackageBaseUrl()
+ {
+ return array(
+ array('jquery', 'assets/12345'),
+ array('yii', 'assets/12345')
+ );
+ }
+
+ /**
+ * @dataProvider providerGetPackageBaseUrl
+ *
+ * @param string $name
+ * @param string $assertion
+ */
+ public function testGetPackageBaseUrl($name, $assertion)
+ {
+ $this->assertEquals($assertion,$this->_clientScript->getPackageBaseUrl($name));
+ }
+
+ /* Test Script Registers */
+
+ public function providerCoreScripts()
+ {
+ return array(
+ array('jquery', array('js'=>array('jquery.js'))),
+ array('yiitab', array('js'=>array('jquery.yiitab.js'), 'depends'=>array('jquery'))),
+ array('yiiactiveform', array('js'=>array('jquery.yiiactiveform.js'), 'depends'=>array('jquery')))
- );
- }
- /**
- * @dataProvider providerCoreScripts
- *
- * @param string $name
- * @param array $assertion
- */
- public function testRegisterCoreScript($name, $assertion)
- {
- $returnedClientScript = $this->_clientScript->registerCoreScript($name);
- $this->assertEquals($assertion, $returnedClientScript->corePackages[$name]);
- }
-
- /**
- * @dataProvider providerCoreScripts
- *
- * @param string $name
- * @param array $assertion
- */
- public function testRegisterPackage($name, $assertion)
- {
- $returnedClientScript = $this->_clientScript->registerPackage($name);
- $this->assertEquals($assertion, $returnedClientScript->corePackages[$name]);
- }
-
- public function providerRegisterCss()
- {
- return array(
- array('myCssDiv', 'float:right;', '', array('myCssDiv'=>array('float:right;', ''))),
- array('myCssDiv', 'float:right;', 'screen', array('myCssDiv'=>array('float:right;', 'screen')))
- );
- }
-
- /**
- * @dataProvider providerRegisterCss
- *
- * @param string $id
- * @param string $css
- * @param string $media
- * @param array $assertion
- */
- public function testRegisterCss($id, $css, $media, $assertion)
- {
- $returnedClientScript = $this->_clientScript->registerCss($id, $css, $media);
- $this->assertAttributeEquals($assertion, 'css', $returnedClientScript);
- }
+ );
+ }
+ /**
+ * @dataProvider providerCoreScripts
+ *
+ * @param string $name
+ * @param array $assertion
+ */
+ public function testRegisterCoreScript($name, $assertion)
+ {
+ $returnedClientScript = $this->_clientScript->registerCoreScript($name);
+ $this->assertEquals($assertion, $returnedClientScript->corePackages[$name]);
+ }
+
+ /**
+ * @dataProvider providerCoreScripts
+ *
+ * @param string $name
+ * @param array $assertion
+ */
+ public function testRegisterPackage($name, $assertion)
+ {
+ $returnedClientScript = $this->_clientScript->registerPackage($name);
+ $this->assertEquals($assertion, $returnedClientScript->corePackages[$name]);
+ }
+
+ public function providerRegisterCss()
+ {
+ return array(
+ array('myCssDiv', 'float:right;', '', array('myCssDiv'=>array('float:right;', ''))),
+ array('myCssDiv', 'float:right;', 'screen', array('myCssDiv'=>array('float:right;', 'screen')))
+ );
+ }
+
+ /**
+ * @dataProvider providerRegisterCss
+ *
+ * @param string $id
+ * @param string $css
+ * @param string $media
+ * @param array $assertion
+ */
+ public function testRegisterCss($id, $css, $media, $assertion)
+ {
+ $returnedClientScript = $this->_clientScript->registerCss($id, $css, $media);
+ $this->assertAttributeEquals($assertion, 'css', $returnedClientScript);
+ }
- /* Test Script Renderers */
-
-}
+ public function providerRegisterMetaTag()
+ {
+ $data = array();
+
+ // Simple:
+ $metaTagData = array(
+ 'name'=>'testMetaTagName',
+ 'http-equiv'=>false,
+ 'content'=>'testMetaTagContent',
+ );
+ $assertion = array(
+ $metaTagData
+ );
+ $data[] = array($metaTagData['content'],$metaTagData['name'],$metaTagData['http-equiv'],array(),$assertion);
+
+ // Http Equiv:
+ $metaTagData = array(
+ 'name'=>'testMetaTagHttpEquiv',
+ 'http-equiv'=>true,
+ 'content'=>'testMetaTagHttpEquivContent',
+ );
+ $assertion = array(
+ $metaTagData
+ );
+ $data[] = array($metaTagData['content'],$metaTagData['name'],$metaTagData['http-equiv'],array(),$assertion);
+
+ return $data;
+ }
-?>
+ /**
+ * @dataProvider providerRegisterMetaTag
+ *
+ * @param string $content
+ * @param string $name
+ * @param boolean $httpEquiv
+ * @param array $options
+ * @param array $assertion
+ */
+ public function testRegisterMetaTag($content,$name,$httpEquiv,$options,$assertion)
+ {
+ $returnedClientScript = $this->_clientScript->registerMetaTag($content,$name,$httpEquiv,$options);
+ $this->assertAttributeEquals($assertion, 'metaTags', $returnedClientScript);
+ }
+
+ /**
+ * @depends testRegisterMetaTag
+ */
+ public function testRegisterDuplicatingMetaTag() {
+ $content='Test meta tag content';
+ $name='test_meta_tag_name';
+ $this->_clientScript->registerMetaTag($content,$name);
+ $this->_clientScript->registerMetaTag($content,$name);
+
+ $metaTagData=array(
+ 'name'=>$name,
+ 'content'=>$content,
+ );
+ $assertion=array(
+ $metaTagData,
+ $metaTagData
+ );
+ $this->assertAttributeEquals($assertion, 'metaTags', $this->_clientScript);
+ }
+
+ /* Test Script Renderers */
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.