From d0c73d0650dfe6ea59d6e61bfe5e31ca1e178dc9 Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski <matthias@binarypark.org> Date: Tue, 12 Mar 2013 14:56:59 +0100 Subject: [PATCH 1/3] added tests and fixed typos --- src/Helper/HeadMeta.php | 4 +-- test/Helper/HeadMetaTest.php | 57 +++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/Helper/HeadMeta.php b/src/Helper/HeadMeta.php index f433a17e..66e51b9b 100644 --- a/src/Helper/HeadMeta.php +++ b/src/Helper/HeadMeta.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_View */ @@ -187,7 +187,7 @@ public function setCharset($charset) * Determine if item is valid * * @param mixed $item - * @return boolean + * @return bool */ protected function isValid($item) { diff --git a/test/Helper/HeadMetaTest.php b/test/Helper/HeadMetaTest.php index 18f3357b..cbd6e759 100644 --- a/test/Helper/HeadMetaTest.php +++ b/test/Helper/HeadMetaTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_View */ @@ -475,6 +475,61 @@ public function testOverloadingSetPropertyOverwritesMetaTagStack() $this->view->doctype('XHTML1_RDFA'); $this->_testOverloadSet('property'); } + + /** + * @issue 3751 + */ + public function testItempropIsSupportedWithHtml5Doctype() + { + $this->view->doctype('HTML5'); + $this->helper->__invoke('HeadMeta with Microdata', 'description', 'itemprop'); + $this->assertEquals('<meta itemprop="description" content="HeadMeta with Microdata">', + $this->helper->toString() + ); + } + + /** + * @issue 3751 + */ + public function testItempropIsNotSupportedByDefaultDoctype() + { + try { + $this->helper->__invoke('HeadMeta with Microdata', 'description', 'itemprop'); + $this->fail('meta itemprop attribute should not be supported on default doctype'); + } catch (ViewException $e) { + $this->assertContains('Invalid value passed', $e->getMessage()); + } + } + + /** + * @issue 3751 + * @depends testItempropIsSupportedWithHtml5Doctype + */ + public function testOverloadingAppendItempropAppendsMetaTagToStack() + { + $this->view->doctype('HTML5'); + $this->_testOverloadAppend('itemprop'); + } + + /** + * @issue 3751 + * @depends testItempropIsSupportedWithHtml5Doctype + */ + public function testOverloadingPrependItempropPrependsMetaTagToStack() + { + $this->view->doctype('HTML5'); + $this->_testOverloadPrepend('itemprop'); + } + + /** + * @issue 3751 + * @depends testItempropIsSupportedWithHtml5Doctype + */ + public function testOverloadingSetItempropOverwritesMetaTagStack() + { + $this->view->doctype('HTML5'); + $this->_testOverloadSet('itemprop'); + } /** * @group ZF-11835 From f9b87996f2fd751a7a449f1dc6fe50e2201826f1 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney <matthew@zend.com> Date: Tue, 12 Mar 2013 12:37:15 -0500 Subject: [PATCH 2/3] [zendframework/zf2#4011] CS fixes - Replace tabs with spaces - Remove unnecessary annotations - Fix other CS/consistency issues as found --- src/Helper/HeadMeta.php | 47 ++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/Helper/HeadMeta.php b/src/Helper/HeadMeta.php index 66e51b9b..63eed6f6 100644 --- a/src/Helper/HeadMeta.php +++ b/src/Helper/HeadMeta.php @@ -5,7 +5,6 @@ * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_View */ namespace Zend\View\Helper; @@ -18,8 +17,6 @@ * Zend_Layout_View_Helper_HeadMeta * * @see http://www.w3.org/TR/xhtml1/dtds.html - * @package Zend_View - * @subpackage Helper */ class HeadMeta extends Placeholder\Container\AbstractStandalone { @@ -94,8 +91,8 @@ protected function normalizeType($type) return 'http-equiv'; case 'Property': return 'property'; - case 'Itemprop': - return 'itemprop'; + case 'Itemprop': + return 'itemprop'; default: throw new Exception\DomainException(sprintf( 'Invalid type "%s" passed to normalizeType', @@ -128,7 +125,11 @@ protected function normalizeType($type) */ public function __call($method, $args) { - if (preg_match('/^(?P<action>set|(pre|ap)pend|offsetSet)(?P<type>Name|HttpEquiv|Property|Itemprop)$/', $method, $matches)) { + if (preg_match( + '/^(?P<action>set|(pre|ap)pend|offsetSet)(?P<type>Name|HttpEquiv|Property|Itemprop)$/', + $method, + $matches) + ) { $action = $matches['action']; $type = $this->normalizeType($matches['type']); $argc = count($args); @@ -174,10 +175,10 @@ public function __call($method, $args) */ public function setCharset($charset) { - $item = new stdClass; - $item->type = 'charset'; - $item->charset = $charset; - $item->content = null; + $item = new stdClass; + $item->type = 'charset'; + $item->charset = $charset; + $item->content = null; $item->modifiers = array(); $this->set($item); return $this; @@ -193,27 +194,29 @@ protected function isValid($item) { if ((!$item instanceof stdClass) || !isset($item->type) - || !isset($item->modifiers)) - { + || !isset($item->modifiers) + ) { return false; } if (!isset($item->content) - && (! $this->view->plugin('doctype')->isHtml5() - || (! $this->view->plugin('doctype')->isHtml5() && $item->type !== 'charset'))) { + && (! $this->view->plugin('doctype')->isHtml5() + || (! $this->view->plugin('doctype')->isHtml5() && $item->type !== 'charset')) + ) { + return false; + } + + // <meta itemprop= ... /> is only supported with doctype html + if (! $this->view->plugin('doctype')->isHtml5() + && $item->type === 'itemprop' + ) { return false; } - - // <meta itemprop= ... /> is only supported with doctype html - if (! $this->view->plugin('doctype')->isHtml5() - && $item->type === 'itemprop'){ - - return false; - } // <meta property= ... /> is only supported with doctype RDFa if (!$this->view->plugin('doctype')->isRdfa() - && $item->type === 'property') { + && $item->type === 'property' + ) { return false; } From 04febadf43b1dadd77dadd8721bd370d5f45ae86 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney <matthew@zend.com> Date: Tue, 12 Mar 2013 12:37:46 -0500 Subject: [PATCH 3/3] [zendframework/zf2#4011] CS fixes - indentation, trailing spaces --- src/Helper/HeadMeta.php | 2 +- test/Helper/HeadMetaTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Helper/HeadMeta.php b/src/Helper/HeadMeta.php index 63eed6f6..fc6d9a51 100644 --- a/src/Helper/HeadMeta.php +++ b/src/Helper/HeadMeta.php @@ -205,7 +205,7 @@ protected function isValid($item) ) { return false; } - + // <meta itemprop= ... /> is only supported with doctype html if (! $this->view->plugin('doctype')->isHtml5() && $item->type === 'itemprop' diff --git a/test/Helper/HeadMetaTest.php b/test/Helper/HeadMetaTest.php index 7ad7d839..b78eeda5 100644 --- a/test/Helper/HeadMetaTest.php +++ b/test/Helper/HeadMetaTest.php @@ -463,8 +463,8 @@ public function testOverloadingSetPropertyOverwritesMetaTagStack() $this->view->doctype('XHTML1_RDFA'); $this->_testOverloadSet('property'); } - - /** + + /** * @issue 3751 */ public function testItempropIsSupportedWithHtml5Doctype()