diff --git a/build/logs/clover.xml b/build/logs/clover.xml index edf1773..43c5c2f 100644 --- a/build/logs/clover.xml +++ b/build/logs/clover.xml @@ -1,6 +1,6 @@ - - + + @@ -66,7 +66,7 @@ - + @@ -154,38 +154,38 @@ - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -194,143 +194,156 @@ - + - - - - - + + + + - - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - + + - + + + - - - - + + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - + + + + + + + + + + - - - - - - + + + + + + + + + + + + - - - + + + + + + - - - - - - - - - + + + + + + + + + + + + @@ -338,6 +351,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -355,64 +401,80 @@ - + - - - - + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - - + + @@ -420,120 +482,119 @@ - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -547,29 +608,31 @@ - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - + + + + + + + @@ -759,6 +822,6 @@ - + diff --git a/composer.json b/composer.json index 8e85e46..d718bcb 100644 --- a/composer.json +++ b/composer.json @@ -16,16 +16,6 @@ "support": { "issues": "https://github.com/neilime/zf2-twb-bundle/issues" }, - "repositories":[ - { - "type": "package", - "package": { - "version": "dev-master", - "name": "twitter/bootstrap", - "source": {"url": "https://github.com/twitter/bootstrap.git","type": "git","reference": "master"} - } - } - ], "suggest": { "neilime/zf2-assets-bundle": "Bundling & caching Twitter Bootstrap assets", "twitter/bootstrap": "Twitter bootstrap assets" diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php index 2eccc2e..8aea250 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php @@ -1,93 +1,92 @@ %s'; +class TwbBundleFormCollection extends \Zend\Form\View\Helper\FormCollection { - /** - * @var string - */ - private static $fieldsetFormat = '
%s
'; + /** + * @var string + */ + private static $legendFormat = '%s'; - /** - * Attributes valid for the tag represented by this helper - * @var array - */ - protected $validTagAttributes = array( - 'disabled' => true - ); + /** + * @var string + */ + private static $fieldsetFormat = '%s'; - /** - * Render a collection by iterating through all fieldsets and elements - * @param \Zend\Form\ElementInterface $oElement - * @return string - */ - public function render(\Zend\Form\ElementInterface $oElement){ + /** + * Attributes valid for the tag represented by this helper + * @var array + */ + protected $validTagAttributes = array( + 'disabled' => true + ); - $oRenderer = $this->getView(); - if(!method_exists($oRenderer, 'plugin'))return ''; + /** + * Render a collection by iterating through all fieldsets and elements + * @param \Zend\Form\ElementInterface $oElement + * @return string + */ + public function render(\Zend\Form\ElementInterface $oElement) { + $oRenderer = $this->getView(); + if (!method_exists($oRenderer, 'plugin')) { + return ''; + } $bShouldWrap = $this->shouldWrap; - $sMarkup = ''; + $sMarkup = ''; $sElementLayout = $oElement->getOption('twb-layout'); - if($oElement instanceof \IteratorAggregate){ - $oElementHelper = $this->getElementHelper(); - $oFieldsetHelper = $this->getFieldsetHelper(); + if ($oElement instanceof \IteratorAggregate) { + $oElementHelper = $this->getElementHelper(); + $oFieldsetHelper = $this->getFieldsetHelper(); - foreach($oElement->getIterator() as $oElementOrFieldset){ + foreach ($oElement->getIterator() as $oElementOrFieldset) { $aOptions = $oElementOrFieldset->getOptions(); if ($sElementLayout && empty($aOptions['twb-layout'])) { $aOptions['twb-layout'] = $sElementLayout; $oElementOrFieldset->setOptions($aOptions); } - if ($oElementOrFieldset instanceof \Zend\Form\FieldsetInterface) { + if ($oElementOrFieldset instanceof \Zend\Form\FieldsetInterface) { $sMarkup .= $oFieldsetHelper($oElementOrFieldset); } elseif ($oElementOrFieldset instanceof \Zend\Form\ElementInterface) { $sMarkup .= $oElementHelper($oElementOrFieldset); } } - if ($oElement instanceof \Zend\Form\Element\Collection && $oElement->shouldCreateTemplate()) { + if ($oElement instanceof \Zend\Form\Element\Collection && $oElement->shouldCreateTemplate()) { $sMarkup .= $this->renderTemplate($oElement); } } - if($bShouldWrap) { - if(($sLabel = $oElement->getLabel())){ + if ($bShouldWrap) { + if (($sLabel = $oElement->getLabel())) { if (null !== ($oTranslator = $this->getTranslator())) { $sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain()); } $sMarkup = sprintf( - self::$legendFormat, - $this->createAttributesString($oElement->getLabelAttributes()?:array()), - $this->getEscapeHtmlHelper()->__invoke($sLabel) - ).$sMarkup; + self::$legendFormat, ($sAttributes = $this->createAttributesString($oElement->getLabelAttributes()? : array())) ? ' ' . $sAttributes : '', $this->getEscapeHtmlHelper()->__invoke($sLabel) + ) . $sMarkup; } //Set form layout class - if($sElementLayout){ - $sLayoutClass = 'form-'.$sElementLayout; + if ($sElementLayout) { + $sLayoutClass = 'form-' . $sElementLayout; if ($sElementClass = $oElement->getAttribute('class')) { if (!preg_match('/(\s|^)' . preg_quote($sLayoutClass, '/') . '(\s|$)/', $sElementClass)) { $oElement->setAttribute('class', trim($sElementClass . ' ' . $sLayoutClass)); } - } - else { + } else { $oElement->setAttribute('class', $sLayoutClass); } } $sMarkup = sprintf( - self::$fieldsetFormat, - $this->createAttributesString($oElement->getAttributes()), - $sMarkup + self::$fieldsetFormat, ($sAttributes = $this->createAttributesString($oElement->getAttributes())) ? ' ' . $sAttributes : '', $sMarkup ); } return $sMarkup; - } + } + } diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormElement.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormElement.php index d4017f2..d181735 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormElement.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormElement.php @@ -1,14 +1,14 @@ %s'; - /** * @var string */ @@ -37,36 +37,44 @@ class TwbBundleFormElement extends \Zend\Form\View\Helper\FormElement implements * @param \Zend\Form\ElementInterface $oElement * @return string */ - public function render(\Zend\Form\ElementInterface $oElement) - { + public function render(\Zend\Form\ElementInterface $oElement) { //Add form-controll class $sElementType = $oElement->getAttribute('type'); if (!in_array($sElementType, array('file', 'checkbox', 'radio', 'submit', 'multi_checkbox', 'static', 'button', 'reset'))) { if ($sElementClass = $oElement->getAttribute('class')) { - if (!preg_match('/(\s|^)form-control(\s|$)/', $sElementClass)) $oElement->setAttribute('class', trim($sElementClass . ' form-control')); - } else $oElement->setAttribute('class', 'form-control'); + if (!preg_match('/(\s|^)form-control(\s|$)/', $sElementClass)) { + $oElement->setAttribute('class', trim($sElementClass . ' form-control')); + } + } else { + $oElement->setAttribute('class', 'form-control'); + } } $sMarkup = $oElement instanceof \TwbBundle\Form\Element\StaticElement ? $this->getView()->formStatic()->render($oElement) : parent::render($oElement); //Addon prepend - if ($aAddOnPrepend = $oElement->getOption('add-on-prepend')) $sMarkup = $this->renderAddOn($aAddOnPrepend) . $sMarkup; + if ($aAddOnPrepend = $oElement->getOption('add-on-prepend')) { + $sMarkup = $this->renderAddOn($aAddOnPrepend) . $sMarkup; + } //Addon append - if ($aAddOnAppend = $oElement->getOption('add-on-append')) $sMarkup .= $this->renderAddOn($aAddOnAppend); + if ($aAddOnAppend = $oElement->getOption('add-on-append')) { + $sMarkup .= $this->renderAddOn($aAddOnAppend); + } if ($aAddOnAppend || $aAddOnPrepend) { $sSpecialClass = ''; //Input size if ($sElementClass = $oElement->getAttribute('class')) { - if (preg_match('/(\s|^)input-lg(\s|$)/', $sElementClass)) $sSpecialClass .= ' input-group-lg'; - elseif (preg_match('/(\s|^)input-sm(\s|$)/', $sElementClass)) $sSpecialClass .= ' input-group-sm'; + if (preg_match('/(\s|^)input-lg(\s|$)/', $sElementClass)) { + $sSpecialClass .= ' input-group-lg'; + } elseif (preg_match('/(\s|^)input-sm(\s|$)/', $sElementClass)) { + $sSpecialClass .= ' input-group-sm'; + } } return sprintf( - self::$inputGroupFormat, - trim($sSpecialClass), - $sMarkup + self::$inputGroupFormat, trim($sSpecialClass), $sMarkup ); } return $sMarkup; @@ -79,12 +87,17 @@ public function render(\Zend\Form\ElementInterface $oElement) * @throws \LogicException * @return string */ - protected function renderAddOn($aAddOnOptions) - { - if (empty($aAddOnOptions)) throw new \InvalidArgumentException('Addon options are empty'); - if ($aAddOnOptions instanceof \Zend\Form\ElementInterface) $aAddOnOptions = array('element' => $aAddOnOptions); - elseif (is_scalar($aAddOnOptions)) $aAddOnOptions = array('text' => $aAddOnOptions); - elseif (!is_array($aAddOnOptions)) throw new \InvalidArgumentException('Addon options expects an array or a scalar value, "' . gettype($aAddOnOptions) . '" given'); + protected function renderAddOn($aAddOnOptions) { + if (empty($aAddOnOptions)) { + throw new \InvalidArgumentException('Addon options are empty'); + } + if ($aAddOnOptions instanceof \Zend\Form\ElementInterface) { + $aAddOnOptions = array('element' => $aAddOnOptions); + } elseif (is_scalar($aAddOnOptions)) { + $aAddOnOptions = array('text' => $aAddOnOptions); + } elseif (!is_array($aAddOnOptions)) { + throw new \InvalidArgumentException('Addon options expects an array or a scalar value, "' . gettype($aAddOnOptions) . '" given'); + } $sMarkup = ''; $sAddonTagName = 'span'; @@ -100,20 +113,19 @@ protected function renderAddOn($aAddOnOptions) $sAddonClass .= ' input-group-addon'; } elseif (!empty($aAddOnOptions['element'])) { if ( - is_array($aAddOnOptions['element']) - || ($aAddOnOptions['element'] instanceof \Traversable && !($aAddOnOptions['element'] instanceof \Zend\Form\ElementInterface)) + is_array($aAddOnOptions['element']) || ($aAddOnOptions['element'] instanceof \Traversable && !($aAddOnOptions['element'] instanceof \Zend\Form\ElementInterface)) ) { $oFactory = new \Zend\Form\Factory(); $aAddOnOptions['element'] = $oFactory->create($aAddOnOptions['element']); } elseif (!($aAddOnOptions['element'] instanceof \Zend\Form\ElementInterface)) { throw new \LogicException(sprintf( - '"element" option expects an instanceof \Zend\Form\ElementInterface, "%s" given', is_object($aAddOnOptions['element']) ? get_class($aAddOnOptions['element']) : gettype($aAddOnOptions['element']) + '"element" option expects an instanceof \Zend\Form\ElementInterface, "%s" given', is_object($aAddOnOptions['element']) ? get_class($aAddOnOptions['element']) : gettype($aAddOnOptions['element']) )); } $aAddOnOptions['element']->setOptions(array_merge($aAddOnOptions['element']->getOptions(), array('disable-twb' => true))); $sMarkup .= $this->render($aAddOnOptions['element']); - if($aAddOnOptions['element'] instanceof \Zend\Form\Element\Button) { + if ($aAddOnOptions['element'] instanceof \Zend\Form\Element\Button) { $sAddonClass .= ' input-group-btn'; //Element contains dropdown, so add-on container must be a "div" if ($aAddOnOptions['element']->getOption('dropdown')) { @@ -130,24 +142,24 @@ protected function renderAddOn($aAddOnOptions) /** * Sets translator to use in helper * @see \Zend\I18n\Translator\TranslatorAwareInterface::setTranslator() - * @param \Zend\I18n\Translator\Translator $oTranslator : [optional] translator. Default is null, which sets no translator. + * @param \Zend\I18n\Translator\TranslatorInterface $oTranslator : [optional] translator. Default is null, which sets no translator. * @param string $sTextDomain : [optional] text domain Default is null, which skips setTranslatorTextDomain * @return \TwbBundle\Form\View\Helper\TwbBundleFormElement */ - public function setTranslator(\Zend\I18n\Translator\Translator $oTranslator = null, $sTextDomain = null) - { + public function setTranslator(\Zend\I18n\Translator\TranslatorInterface $oTranslator = null, $sTextDomain = null) { $this->translator = $oTranslator; - if (null !== $sTextDomain) $this->setTranslatorTextDomain($sTextDomain); + if (null !== $sTextDomain) { + $this->setTranslatorTextDomain($sTextDomain); + } return $this; } /** * Returns translator used in helper * @see \Zend\I18n\Translator\TranslatorAwareInterface::getTranslator() - * @return null|\Zend\I18n\Translator\Translator + * @return null|\Zend\I18n\Translator\TranslatorInterface */ - public function getTranslator() - { + public function getTranslator() { return $this->isTranslatorEnabled() ? $this->translator : null; } @@ -156,8 +168,7 @@ public function getTranslator() * @see \Zend\I18n\Translator\TranslatorAwareInterface::hasTranslator() * @return boolean */ - public function hasTranslator() - { + public function hasTranslator() { return !!$this->getTranslator(); } @@ -167,8 +178,7 @@ public function hasTranslator() * @param boolean $bEnabled * @return \TwbBundle\Form\View\Helper\TwbBundleFormElement */ - public function setTranslatorEnabled($bEnabled = true) - { + public function setTranslatorEnabled($bEnabled = true) { $this->translatorEnabled = !!$bEnabled; return $this; } @@ -178,8 +188,7 @@ public function setTranslatorEnabled($bEnabled = true) * @see \Zend\I18n\Translator\TranslatorAwareInterface::isTranslatorEnabled() * @return boolean */ - public function isTranslatorEnabled() - { + public function isTranslatorEnabled() { return $this->translatorEnabled; } @@ -189,8 +198,7 @@ public function isTranslatorEnabled() * @param string $sTextDomain * @return \TwbBundle\Form\View\Helper\TwbBundleFormElement */ - public function setTranslatorTextDomain($sTextDomain = 'default') - { + public function setTranslatorTextDomain($sTextDomain = 'default') { $this->translatorTextDomain = $sTextDomain; return $this; } @@ -200,8 +208,8 @@ public function setTranslatorTextDomain($sTextDomain = 'default') * @see \Zend\I18n\Translator\TranslatorAwareInterface::getTranslatorTextDomain() * @return string */ - public function getTranslatorTextDomain() - { + public function getTranslatorTextDomain() { return $this->translatorTextDomain; } + } diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormErrors.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormErrors.php index 798be9d..c25b896 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormErrors.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormErrors.php @@ -1,12 +1,9 @@ %s
  • '; protected $messageCloseString = '
'; @@ -14,24 +11,23 @@ class TwbBundleFormErrors extends ZendFormViewHelperAbstractHelper /** * Invoke as function - * - * @param ZendFormFormInterface $form - * @param string $message - * @param string $dismissable + * @param \Zend\Form\FormInterface $oForm + * @param string $sMessage + * @param string $bDismissable + * @return string|null */ - public function __invoke(ZendFormFormInterface $form = null, $message = null, $dismissable = false) - { - if (!$form) { + public function __invoke(\Zend\Form\FormInterface $oForm = null, $sMessage = null, $bDismissable = false) { + if (!$oForm) { return $this; } - if (!$message) { - $message = $this->defaultErrorText; + if (!$sMessage) { + $sMessage = $this->defaultErrorText; } - if ($form->hasValidated() && !$form->isValid()) { + if ($oForm->hasValidated() && !$oForm->isValid()) { - return $this->render($form, $message, $dismissable); + return $this->render($oForm, $sMessage, $bDismissable); } return null; @@ -39,51 +35,37 @@ public function __invoke(ZendFormFormInterface $form = null, $message = null, $d /** * Renders the error messages. - * - * @param ZendFormFormInterface $form - * - * return string + * @param \Zend\Form\FormInterface $oForm + * @return string */ - public function render(ZendFormFormInterface $form, $message, $dismissable = false) - { - $errorHtml = sprintf($this->messageOpenFormat, $message); + public function render(\Zend\Form\FormInterface $oForm, $sMessage, $bDismissable = false) { + $errorHtml = sprintf($this->messageOpenFormat, $sMessage); - $messagesArray = array(); + $sMessagesArray = array(); - foreach ($form->getMessages() as $fieldName => $messages) { - error_log(get_class($form->get($fieldName))); - foreach ($messages as $validatorName => $message) { - if ($form->get($fieldName)->getAttribute('id')) { - $messagesArray[] = sprintf( - '%s', - $form->get($fieldName)->getAttribute('id'), - $form->get($fieldName)->getLabel() . ': ' . $message + foreach ($oForm->getMessages() as $fieldName => $sMessages) { + foreach ($sMessages as $sMessage) { + if ($oForm->get($fieldName)->getAttribute('id')) { + $sMessagesArray[] = sprintf( + '%s', $oForm->get($fieldName)->getAttribute('id'), $oForm->get($fieldName)->getLabel() . ': ' . $sMessage ); } else { - $messagesArray[] = $form->get($fieldName)->getLabel() . ': ' . $message; + $sMessagesArray[] = $oForm->get($fieldName)->getLabel() . ': ' . $sMessage; } } } - $messageString = implode($this->messageSeparatorString, $messagesArray); - - $errorHtml = $errorHtml . $messageString . $this->messageCloseString; - - $errorHtml = $this->dangerAlert($errorHtml, $dismissable); - - return $errorHtml; + return $this->dangerAlert($errorHtml . implode($this->messageSeparatorString, $sMessagesArray) . $this->messageCloseString, $bDismissable); } /** * Creates and returns a "danger" alert. - * * @param string $content - * @param boolean $dismissable - * - * return string + * @param boolean $bDismissable + * @return string */ - public function dangerAlert($content, $dismissable = false) - { - return $this->getView()->alert($content, array('class' => 'alert-danger'), $dismissable); + public function dangerAlert($content, $bDismissable = false) { + return $this->getView()->alert($content, array('class' => 'alert-danger'), $bDismissable); } + } diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormRadio.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormRadio.php index ae957e6..3283a42 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormRadio.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormRadio.php @@ -1,90 +1,110 @@
'; - /** - * @var string - */ - private static $checkboxFormat = '
%s
'; +class TwbBundleFormRadio extends \Zend\Form\View\Helper\FormRadio { + + /** + * Separator for checkbox elements + * @var string + */ + protected $separator = '
'; + + /** + * @var string + */ + private static $checkboxFormat = '
%s
'; + + /** + * @see \Zend\Form\View\Helper\FormRadio::render() + * @param \Zend\Form\ElementInterface $oElement + * @return string + */ + public function render(\Zend\Form\ElementInterface $oElement) { + if ($oElement->getOption('disable-twb')) { + $sSeparator = $this->separator; + $this->separator = ''; + $sReturn = parent::render($oElement); + $this->separator = $sSeparator; + return $sReturn; + } + return sprintf(self::$checkboxFormat, parent::render($oElement)); + } - /** - * @see \Zend\Form\View\Helper\FormRadio::render() - * @param \Zend\Form\ElementInterface $oElement - * @return string - */ - public function render(\Zend\Form\ElementInterface $oElement){ - if($oElement->getOption('disable-twb')){ - $sSeparator = $this->separator; - $this->separator = ''; - $sReturn = parent::render($oElement); - $this->separator = $sSeparator; - return $sReturn; - } - return sprintf(self::$checkboxFormat,parent::render($oElement)); - } + /** + * @see \Zend\Form\View\Helper\FormMultiCheckbox::renderOptions() + * @param \Zend\Form\Element\MultiCheckbox $oElement + * @param array $aOptions + * @param array $aSelectedOptions + * @param array $aAttributes + * @return string + */ + protected function renderOptions(\Zend\Form\Element\MultiCheckbox $oElement, array $aOptions, array $aSelectedOptions, array $aAttributes) { + $iIterator = 0; + $aGlobalLabelAttributes = $oElement->getLabelAttributes()? : $this->labelAttributes; + $sMarkup = ''; + $oLabelHelper = $this->getLabelHelper(); + foreach ($aOptions as $key => $aOptionspec) { + if (is_scalar($aOptionspec)) { + $aOptionspec = array('label' => $aOptionspec, 'value' => $key); + } - /** - * @see \Zend\Form\View\Helper\FormMultiCheckbox::renderOptions() - * @param \Zend\Form\Element\MultiCheckbox $oElement - * @param array $aOptions - * @param array $aSelectedOptions - * @param array $aAttributes - * @return string - */ - protected function renderOptions(\Zend\Form\Element\MultiCheckbox $oElement, array $aOptions, array $aSelectedOptions,array $aAttributes){ - $iIterator = 0; - $aGlobalLabelAttributes = $oElement->getLabelAttributes()?:$this->labelAttributes; - $sMarkup = ''; - $oLabelHelper = $this->getLabelHelper(); - foreach($aOptions as $key => $aOptionspec){ - if(is_scalar($aOptionspec))$aOptionspec = array('label' => $aOptionspec,'value' => $key); + $iIterator++; + if ($iIterator > 1 && array_key_exists('id', $aAttributes)) { + unset($aAttributes['id']); + } - $iIterator++; - if($iIterator > 1 && array_key_exists('id', $aAttributes))unset($aAttributes['id']); + //Option attributes + $aInputAttributes = $aAttributes; + if (isset($aOptionspec['attributes'])) { + $aInputAttributes = \Zend\Stdlib\ArrayUtils::merge($aInputAttributes, $aOptionspec['attributes']); + } - //Option attributes - $aInputAttributes = $aAttributes; - if(isset($aOptionspec['attributes']))$aInputAttributes = array_merge($aInputAttributes, $aOptionspec['attributes']); + //Option value + $aInputAttributes['value'] = isset($aOptionspec['value']) ? $aOptionspec['value'] : ''; - //Option value - $aInputAttributes['value'] = isset($aOptionspec['value'])?$aOptionspec['value']:''; + //Selected option + if (in_array($aInputAttributes['value'], $aSelectedOptions)) { + $aInputAttributes['checked'] = true; + } elseif (isset($aOptionspec['selected'])) { + $aInputAttributes['checked'] = !!$aOptionspec['selected']; + } else { + $aInputAttributes['checked'] = isset($aInputAttributes['selected']) && $aInputAttributes['type'] !== 'radio' && $aInputAttributes['selected'] != false; + } - //Selected option - if(in_array($aInputAttributes['value'], $aSelectedOptions))$aInputAttributes['checked'] = true; - elseif(isset($aOptionspec['selected']))$aInputAttributes['checked'] = !!$aOptionspec['selected']; - else $aInputAttributes['checked'] = isset($aInputAttributes['selected']) && $aInputAttributes['type'] != 'radio' && $aInputAttributes['selected'] != false; + //Disabled option + if (isset($aOptionspec['disabled'])) { + $aInputAttributes['disabled'] = !!$aOptionspec['disabled']; + } else { + $aInputAttributes['disabled'] = isset($aInputAttributes['disabled']) && $aInputAttributes['disabled'] != false; + } - //Disabled option - if(isset($aOptionspec['disabled']))$aInputAttributes['disabled'] = !!$aOptionspec['disabled']; - else $aInputAttributes['disabled'] = isset($aInputAttributes['disabled']) && $aInputAttributes['disabled'] != false; + //Render option + $sOptionMarkup = sprintf('createAttributesString($aInputAttributes), $this->getInlineClosingBracket()); - //Render option - $sOptionMarkup = sprintf('createAttributesString($aInputAttributes),$this->getInlineClosingBracket()); + //Option label + $sLabel = isset($aOptionspec['label']) ? $aOptionspec['label'] : ''; + if ($sLabel) { + $aLabelAttributes = $aGlobalLabelAttributes; + if (isset($aOptionspec['label_attributes'])) { + $aLabelAttributes = isset($aLabelAttributes) ? array_merge($aLabelAttributes, $aOptionspec['label_attributes']) : $aOptionspec['label_attributes']; + } + if (null !== ($oTranslator = $this->getTranslator())) { + $sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain()); + } + switch ($this->getLabelPosition()) { + case self::LABEL_PREPEND: + $sOptionMarkup = sprintf($oLabelHelper->openTag($aLabelAttributes) . '%s%s' . $oLabelHelper->closeTag(), $this->getEscapeHtmlHelper()->__invoke($sLabel), $sOptionMarkup); + break; + case self::LABEL_APPEND: + default: + $sOptionMarkup = sprintf($oLabelHelper->openTag($aLabelAttributes) . '%s%s' . $oLabelHelper->closeTag(), $sOptionMarkup, $this->getEscapeHtmlHelper()->__invoke($sLabel)); + break; + } + } + $sMarkup .= ($sMarkup ? $this->getSeparator() : '') . $sOptionMarkup; + } + return $sMarkup; + } - //Option label - $sLabel = isset($aOptionspec['label'])?$aOptionspec['label']:''; - if($sLabel){ - $aLabelAttributes = $aGlobalLabelAttributes; - if(isset($aOptionspec['label_attributes']))$aLabelAttributes = isset($aLabelAttributes)?array_merge($aLabelAttributes,$aOptionspec['label_attributes']):$aOptionspec['label_attributes']; - if(null !== ($oTranslator = $this->getTranslator()))$sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain()); - switch($this->getLabelPosition()){ - case self::LABEL_PREPEND: - $sOptionMarkup = sprintf($oLabelHelper->openTag($aLabelAttributes).'%s%s'.$oLabelHelper->closeTag(), $this->getEscapeHtmlHelper()->__invoke($sLabel), $sOptionMarkup); - break; - case self::LABEL_APPEND: - default: - $sOptionMarkup = sprintf($oLabelHelper->openTag($aLabelAttributes).'%s%s'.$oLabelHelper->closeTag(), $sOptionMarkup, $this->getEscapeHtmlHelper()->__invoke($sLabel)); - break; - } - } - $sMarkup .= ($sMarkup?$this->getSeparator():'').$sOptionMarkup; - } - return $sMarkup; - } -} \ No newline at end of file +} diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php index 1073d5b..1275dd6 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php @@ -1,7 +1,8 @@ getAttribute('type'); + public function render(\Zend\Form\ElementInterface $oElement) { + $sElementType = $oElement->getAttribute('type'); - //Nothing to do for hidden elements which have no messages - if( $sElementType === 'hidden' && !$oElement->getMessages()) { - return parent::render($oElement); - } + //Nothing to do for hidden elements which have no messages + if ($sElementType === 'hidden' && !$oElement->getMessages()) { + return parent::render($oElement); + } //Retrieve expected layout $sLayout = $oElement->getOption('twb-layout'); @@ -44,38 +44,41 @@ public function render(\Zend\Form\ElementInterface $oElement) //Partial rendering if ($this->partial) { return $this->view->render($this->partial, array( - 'element' => $oElement, - 'label' => $this->renderLabel($oElement), - 'labelAttributes' => $this->labelAttributes, - 'labelPosition' => $this->labelPosition, - 'renderErrors' => $this->renderErrors, + 'element' => $oElement, + 'label' => $this->renderLabel($oElement), + 'labelAttributes' => $this->labelAttributes, + 'labelPosition' => $this->labelPosition, + 'renderErrors' => $this->renderErrors, )); } $sRowClass = ''; //Validation state - if (($sValidationState = $oElement->getOption('validation-state'))) $sRowClass .= ' has-' . $sValidationState; + if (($sValidationState = $oElement->getOption('validation-state'))) { + $sRowClass .= ' has-' . $sValidationState; + } //"has-error" validation state case - if (count($oElement->getMessages())){ - $sRowClass .= ' has-error'; - //Element have errors - if ($sInputErrorClass = $this->getInputErrorClass()) { - if ($sElementClass = $oElement->getAttribute('class')) { + if (count($oElement->getMessages())) { + $sRowClass .= ' has-error'; + //Element have errors + if ($sInputErrorClass = $this->getInputErrorClass()) { + if ($sElementClass = $oElement->getAttribute('class')) { if (!preg_match('/(\s|^)' . preg_quote($sInputErrorClass, '/') . '(\s|$)/', $sElementClass)) { $oElement->setAttribute('class', trim($sElementClass . ' ' . $sInputErrorClass)); } - } else $oElement->setAttribute('class', $sInputErrorClass); + } else { + $oElement->setAttribute('class', $sInputErrorClass); + } } } //Column size if ( - ($sColumSize = $oElement->getOption('column-size')) - && ( + ($sColumSize = $oElement->getOption('column-size')) && ( $sLayout !== \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL - ) + ) ) { $sRowClass .= ' col-' . $sColumSize; } @@ -87,17 +90,14 @@ public function render(\Zend\Form\ElementInterface $oElement) if (in_array($sElementType, array('checkbox')) && $sLayout !== \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL) { return $sElementContent . PHP_EOL; } - if (($sElementType === 'submit' || $sElementType === 'button' || $sElementType === 'reset') - && $sLayout === \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE - ) { + if (($sElementType === 'submit' || $sElementType === 'button' || $sElementType === 'reset') && $sLayout === \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE + ) { return $sElementContent . PHP_EOL; } return sprintf( - self::$formGroupFormat, - $sRowClass, - $sElementContent - ) . PHP_EOL; + self::$formGroupFormat, $sRowClass, $sElementContent + ) . PHP_EOL; } /** @@ -105,8 +105,7 @@ public function render(\Zend\Form\ElementInterface $oElement) * @param \Zend\Form\ElementInterface $oElement * @return string */ - protected function renderLabel(\Zend\Form\ElementInterface $oElement) - { + protected function renderLabel(\Zend\Form\ElementInterface $oElement) { if (($sLabel = $oElement->getLabel()) && ($oTranslator = $this->getTranslator())) { $sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain()); } @@ -119,8 +118,7 @@ protected function renderLabel(\Zend\Form\ElementInterface $oElement) * @throws \DomainException * @return string */ - protected function renderElement(\Zend\Form\ElementInterface $oElement) - { + protected function renderElement(\Zend\Form\ElementInterface $oElement) { //Retrieve expected layout $sLayout = $oElement->getOption('twb-layout'); @@ -132,7 +130,9 @@ protected function renderElement(\Zend\Form\ElementInterface $oElement) //Checkbox & radio elements are a special case, because label is rendered by their own helper if ($sElementType === 'checkbox') { - if (!$oElement->getLabelAttributes() && $this->labelAttributes) $oElement->setLabelAttributes($this->labelAttributes); + if (!$oElement->getLabelAttributes() && $this->labelAttributes) { + $oElement->setLabelAttributes($this->labelAttributes); + } //Render element input if ($sLayout !== \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL) { @@ -189,7 +189,7 @@ protected function renderElement(\Zend\Form\ElementInterface $oElement) switch ($sLayout) { case null: case \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE: - $sElementContent = $sLabelOpen . $sLabelContent . $sLabelClose . $this->getElementHelper()->render($oElement) . $this->renderHelpBlock($oElement); + $sElementContent = $sLabelOpen . $sLabelContent . $sLabelClose . $this->getElementHelper()->render($oElement) . $this->renderHelpBlock($oElement); //Render errors if ($this->renderErrors) { @@ -216,18 +216,12 @@ protected function renderElement(\Zend\Form\ElementInterface $oElement) // Checkbox elements are a special case. They don't need to render a label again if ($sElementType === 'checkbox') { return sprintf( - self::$horizontalLayoutFormat, - '', - $sClass, - $sElementContent + self::$horizontalLayoutFormat, '', $sClass, $sElementContent ); } return sprintf( - self::$horizontalLayoutFormat, - $sLabelOpen . $sLabelContent . $sLabelClose, - $sClass, - $sElementContent + self::$horizontalLayoutFormat, $sLabelOpen . $sLabelContent . $sLabelClose, $sClass, $sElementContent ); default: @@ -240,11 +234,10 @@ protected function renderElement(\Zend\Form\ElementInterface $oElement) * @param \Zend\Form\ElementInterface $oElement * @return string */ - protected function renderHelpBlock(\Zend\Form\ElementInterface $oElement) - { + protected function renderHelpBlock(\Zend\Form\ElementInterface $oElement) { return ($sHelpBlock = $oElement->getOption('help-block')) ? sprintf( - self::$helpBlockFormat, - $this->getEscapeHtmlHelper()->__invoke(($oTranslator = $this->getTranslator()) ? $oTranslator->translate($sHelpBlock, $this->getTranslatorTextDomain()) : $sHelpBlock) - ) : ''; + self::$helpBlockFormat, $this->getEscapeHtmlHelper()->__invoke(($oTranslator = $this->getTranslator()) ? $oTranslator->translate($sHelpBlock, $this->getTranslatorTextDomain()) : $sHelpBlock) + ) : ''; } + } diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php index c80e4d9..74a728c 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php @@ -1,448 +1,451 @@ expectedPath = __DIR__.DIRECTORY_SEPARATOR.'../../_files/expected-forms'.DIRECTORY_SEPARATOR; - $oViewHelperPluginManager = \TwbBundleTest\Bootstrap::getServiceManager()->get('view_helper_manager'); - $oRenderer = new \Zend\View\Renderer\PhpRenderer(); - $this->formHelper = $oViewHelperPluginManager->get('form')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); - } - - /** - * Test http://getbootstrap.com/css/#forms-example - */ - public function testBasicExample(){ - $oForm = new \Zend\Form\Form(); - $oForm->add(array( - 'name' => 'input-email', - 'attributes' => array( - 'type' => 'email', - 'placeholder' => 'Enter email', - 'id' => 'exampleInputEmail1' - ), - 'options' => array('label' => 'Email address') - ))->add(array( - 'name' => 'input-password', - 'attributes' => array( - 'type' => 'password', - 'placeholder' => 'Password', - 'id' => 'exampleInputPassword1' - ), - 'options' => array('label' => 'Password',) - ))->add(array( - 'name' => 'input-file', - 'attributes' => array( - 'type' => 'file', - 'id' => 'exampleInputFile' - ), - 'options' => array( - 'label' => 'File input', - 'help-block' => 'Example block-level help text here.' - ) - ))->add(array( - 'name' => 'input-checkbox', - 'type' => 'checkbox', - 'options' => array('label' => 'Check me out') - ))->add(array( - 'name' => 'button-submit', - 'type' => 'button', - 'attributes' => array('type' => 'submit'), - 'options' => array('label' => 'Submit') - )); - - //Test content - $this->assertStringEqualsFile($this->expectedPath.'basic-example.phtml',$this->formHelper->__invoke($oForm,null)); - } - - /** - * Test http://getbootstrap.com/css/#forms-inline - */ - public function testInlineForm(){ - $oForm = new \Zend\Form\Form(); - $oForm->add(array( - 'name' => 'input-email', - 'attributes' => array( - 'type' => 'email', - 'placeholder' => 'Enter email', - 'id' => 'exampleInputEmail2' - ), - 'options' => array('label' => 'Email address') - ))->add(array( - 'name' => 'input-password', - 'attributes' => array( - 'type' => 'password', - 'placeholder' => 'Password', - 'id' => 'exampleInputPassword2' - ), - 'options' => array('label' => 'Password') - ))->add(array( - 'name' => 'input-checkbox', - 'type' => 'checkbox', - 'options' => array('label' => 'Remember me') - ))->add(array( - 'name' => 'button-submit', - 'type' => 'button', - 'attributes' => array('type' => 'submit'), - 'options' => array('label' => 'Sign in') - )); - - //Test content - $this->assertStringEqualsFile($this->expectedPath.'inline-form.phtml',$this->formHelper->__invoke($oForm,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE)); - } - - /** - * Test http://getbootstrap.com/css/#forms-horizontal - */ - public function testHorizontalform(){ - $oForm = new \Zend\Form\Form(); - $oForm->add(array( - 'name' => 'input-email', - 'attributes' => array( - 'type' => 'email', - 'placeholder' => 'Enter email', - 'id' => 'inputEmail1' - ), - 'options' => array( +class TwbBundleFormsTest extends \PHPUnit_Framework_TestCase { + + /** + * @var string + */ + protected $expectedPath; + + /** + * @var \TwbBundle\Form\View\Helper\TwbBundleForm + */ + protected $formHelper; + + /** + * @see \PHPUnit_Framework_TestCase::setUp() + */ + public function setUp() { + $this->expectedPath = __DIR__ . DIRECTORY_SEPARATOR . '../../_files/expected-forms' . DIRECTORY_SEPARATOR; + $oViewHelperPluginManager = \TwbBundleTest\Bootstrap::getServiceManager()->get('view_helper_manager'); + $oRenderer = new \Zend\View\Renderer\PhpRenderer(); + $this->formHelper = $oViewHelperPluginManager->get('form')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); + } + + /** + * Test http://getbootstrap.com/css/#forms-example + */ + public function testBasicExample() { + $oForm = new \Zend\Form\Form(); + $oForm->add(array( + 'name' => 'input-email', + 'attributes' => array( + 'type' => 'email', + 'placeholder' => 'Enter email', + 'id' => 'exampleInputEmail1' + ), + 'options' => array('label' => 'Email address') + ))->add(array( + 'name' => 'input-password', + 'attributes' => array( + 'type' => 'password', + 'placeholder' => 'Password', + 'id' => 'exampleInputPassword1' + ), + 'options' => array('label' => 'Password',) + ))->add(array( + 'name' => 'input-file', + 'attributes' => array( + 'type' => 'file', + 'id' => 'exampleInputFile' + ), + 'options' => array( + 'label' => 'File input', + 'help-block' => 'Example block-level help text here.' + ) + ))->add(array( + 'name' => 'input-checkbox', + 'type' => 'checkbox', + 'options' => array('label' => 'Check me out') + ))->add(array( + 'name' => 'button-submit', + 'type' => 'button', + 'attributes' => array('type' => 'submit'), + 'options' => array('label' => 'Submit') + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'basic-example.phtml', $this->formHelper->__invoke($oForm, null)); + } + + /** + * Test http://getbootstrap.com/css/#forms-inline + */ + public function testInlineForm() { + $oForm = new \Zend\Form\Form(); + $oForm->add(array( + 'name' => 'input-email', + 'attributes' => array( + 'type' => 'email', + 'placeholder' => 'Enter email', + 'id' => 'exampleInputEmail2' + ), + 'options' => array('label' => 'Email address') + ))->add(array( + 'name' => 'input-password', + 'attributes' => array( + 'type' => 'password', + 'placeholder' => 'Password', + 'id' => 'exampleInputPassword2' + ), + 'options' => array('label' => 'Password') + ))->add(array( + 'name' => 'input-checkbox', + 'type' => 'checkbox', + 'options' => array('label' => 'Remember me') + ))->add(array( + 'name' => 'button-submit', + 'type' => 'button', + 'attributes' => array('type' => 'submit'), + 'options' => array('label' => 'Sign in') + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'inline-form.phtml', $this->formHelper->__invoke($oForm, \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE)); + } + + /** + * Test http://getbootstrap.com/css/#forms-horizontal + */ + public function testHorizontalform() { + $oForm = new \Zend\Form\Form(); + $oForm->add(array( + 'name' => 'input-email', + 'attributes' => array( + 'type' => 'email', + 'placeholder' => 'Enter email', + 'id' => 'inputEmail1' + ), + 'options' => array( 'label' => 'Email', 'column-size' => 'sm-10', 'label_attributes' => array('class' => 'col-sm-2') ) - ))->add(array( - 'name' => 'input-password', - 'attributes' => array( - 'type' => 'password', - 'placeholder' => 'Password', - 'id' => 'inputPassword1' - ), - 'options' => array('label' => 'Password','column-size' => 'sm-10','label_attributes' => array('class' => 'col-sm-2')) - ))->add(array( - 'name' => 'input-checkbox', - 'type' => 'checkbox', - 'options' => array('label' => 'Remember me','column-size' => 'sm-10 col-sm-offset-2') - ))->add(array( - 'name' => 'button-submit', - 'type' => 'button', - 'attributes' => array('type' => 'submit'), - 'options' => array('label' => 'Sign in','column-size' => 'sm-10 col-sm-offset-2') - )); - - //Test content - $this->assertStringEqualsFile($this->expectedPath.'horizontal-form.phtml',$this->formHelper->__invoke($oForm)); - } - - /** - * Test http://getbootstrap.com/css/#forms-controls - */ - public function testSupportedControlsform(){ - $oForm = new \Zend\Form\Form(); - $oForm->add(array( - 'name' => 'input-text', - 'attributes' => array( - 'type' => 'text', - 'placeholder' => 'Text input', - ) - ))->add(array( - 'name' => 'input-text-area', - 'type' => 'textarea', - 'attributes' => array( - 'row' => 3 - ) - ))->add(array( - 'name' => 'input-checkbox', - 'type' => 'checkbox', - 'options' => array('label' => 'Option one is this and that-be sure to include why it\'s great') - ))->add(array( - 'name' => 'optionsRadios', - 'type' => 'radio', - 'options' => array( - 'value_options' => array( - 'option1' => 'Option one is this and that-be sure to include why it\'s great', - 'optionsRadios2' => 'Option two can be something else and selecting it will deselect option one' - ) - ) - ))->add(array( - 'name' => 'optionsRadios', - 'type' => 'MultiCheckbox', - 'options' => array( - 'value_options' => array( - array('label' => '1','value' => 'option1', 'attributes' => array('id' => 'inlineCheckbox1')), - array('label' => '2','value' => 'option2', 'attributes' => array('id' => 'inlineCheckbox2')), - array('label' => '3','value' => 'option3', 'attributes' => array('id' => 'inlineCheckbox3')) - ) - ) - ))->add(array( - 'name' => 'optionsRadiosNoInline', - 'type' => 'MultiCheckbox', - 'options' => array( - 'value_options' => array( - array('label' => '1','value' => 'option1', 'attributes' => array('id' => 'noInlineCheckbox1')), - array('label' => '2','value' => 'option2', 'attributes' => array('id' => 'noInlineCheckbox2')), - array('label' => '3','value' => 'option3', 'attributes' => array('id' => 'noInlineCheckbox3')) - ), - 'inline' => false - ) - ))->add(array( - 'name' => 'select', - 'type' => 'select', - 'options' => array('value_options' => array(1,2,3,4,5)) - ))->add(array( - 'name' => 'multiple-select', - 'type' => 'select', - 'options' => array('value_options' => array(1,2,3,4,5)), - 'attributes' => array('multiple' => true) - )); - - //Test content - $this->assertStringEqualsFile($this->expectedPath.'supported-controls-form.phtml',$this->formHelper->__invoke($oForm,null)); - } - - /** - * Test http://getbootstrap.com/css/#forms-controls-static - */ - public function testStaticControlform(){ - $oForm = new \Zend\Form\Form(); - $oForm->add(array( - 'name' => 'static-element', - 'type' => '\TwbBundle\Form\Element\StaticElement', - 'attributes' => array('value' => 'email@example.com'), - 'options' => array('label' => 'Email','column-size' => 'lg-10','label_attributes' => array('class' => 'col-lg-2')) - ))->add(array( - 'name' => 'input-password', - 'attributes' => array( - 'type' => 'password', - 'placeholder' => 'Password', - 'id' => 'inputPassword' - ), - 'options' => array('label' => 'Password','column-size' => 'lg-10','label_attributes' => array('class' => 'col-lg-2')) - )); - - //Test content - $this->assertStringEqualsFile($this->expectedPath.'static-control-form.phtml',$this->formHelper->__invoke($oForm)); - } - - /** - * Test http://getbootstrap.com/css/#forms-control-states - */ - public function testControlStatesform(){ - $oForm = new \Zend\Form\Form(); - $oForm->add(array( - 'name' => 'input-text-disabled', - 'attributes' => array( - 'type' => 'text', - 'placeholder' => 'Disabled input here...', - 'id' => 'disabledInput' - ) - )); - - $oFieldset = new \Zend\Form\Fieldset('fieldset-disabled'); - $oForm->add($oFieldset->setAttributes(array('disabled' => true))->add(array( - 'name' => 'input-text-disabled', - 'attributes' => array( - 'type' => 'text', - 'placeholder' => 'Disabled input', - 'id' => 'disabledTextInput' - ), - 'options' => array('label' => 'Disabled input') - ))->add(array( - 'name' => 'disabled-select', - 'type' => 'select', - 'options' => array( - 'label' => 'Disabled select menu', - 'value_options' => array('' => 'Disabled select') - ), - 'attributes' => array('id' => 'disabled-select') - ))->add(array( - 'name' => 'input-checkbox', - 'type' => 'checkbox', - 'options' => array('label' => 'Can\'t check this') - ))->add(array( - 'name' => 'button-submit', - 'type' => 'button', - 'attributes' => array('type' => 'submit', 'class' => 'btn-primary'), - 'options' => array('label' => 'Submit') - ))); - - //Test content - $this->assertStringEqualsFile($this->expectedPath.'control-states-form.phtml',$this->formHelper->__invoke($oForm,null)); + ))->add(array( + 'name' => 'input-password', + 'attributes' => array( + 'type' => 'password', + 'placeholder' => 'Password', + 'id' => 'inputPassword1' + ), + 'options' => array('label' => 'Password', 'column-size' => 'sm-10', 'label_attributes' => array('class' => 'col-sm-2')) + ))->add(array( + 'name' => 'input-checkbox', + 'type' => 'checkbox', + 'options' => array('label' => 'Remember me', 'column-size' => 'sm-10 col-sm-offset-2') + ))->add(array( + 'name' => 'button-submit', + 'type' => 'button', + 'attributes' => array('type' => 'submit'), + 'options' => array('label' => 'Sign in', 'column-size' => 'sm-10 col-sm-offset-2') + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'horizontal-form.phtml', $this->formHelper->__invoke($oForm)); + } + + /** + * Test http://getbootstrap.com/css/#forms-controls + */ + public function testSupportedControlsform() { + $oForm = new \Zend\Form\Form(); + $oForm->add(array( + 'name' => 'input-text', + 'attributes' => array( + 'type' => 'text', + 'placeholder' => 'Text input', + ) + ))->add(array( + 'name' => 'input-text-area', + 'type' => 'textarea', + 'attributes' => array( + 'row' => 3 + ) + ))->add(array( + 'name' => 'input-checkbox', + 'type' => 'checkbox', + 'options' => array('label' => 'Option one is this and that-be sure to include why it\'s great') + ))->add(array( + 'name' => 'optionsRadios', + 'type' => 'radio', + 'options' => array( + 'value_options' => array( + 'option1' => 'Option one is this and that-be sure to include why it\'s great', + 'optionsRadios2' => 'Option two can be something else and selecting it will deselect option one' + ) + ) + ))->add(array( + 'name' => 'optionsRadios', + 'type' => 'MultiCheckbox', + 'options' => array( + 'value_options' => array( + array('label' => '1', 'value' => 'option1', 'attributes' => array('id' => 'inlineCheckbox1')), + array('label' => '2', 'value' => 'option2', 'attributes' => array('id' => 'inlineCheckbox2')), + array('label' => '3', 'value' => 'option3', 'attributes' => array('id' => 'inlineCheckbox3')) + ) + ) + ))->add(array( + 'name' => 'optionsRadiosNoInline', + 'type' => 'MultiCheckbox', + 'options' => array( + 'value_options' => array( + array('label' => '1', 'value' => 'option1', 'attributes' => array('id' => 'noInlineCheckbox1')), + array('label' => '2', 'value' => 'option2', 'attributes' => array('id' => 'noInlineCheckbox2')), + array('label' => '3', 'value' => 'option3', 'attributes' => array('id' => 'noInlineCheckbox3')) + ), + 'inline' => false + ) + ))->add(array( + 'name' => 'select', + 'type' => 'select', + 'options' => array('value_options' => array(1, 2, 3, 4, 5)) + ))->add(array( + 'name' => 'multiple-select', + 'type' => 'select', + 'options' => array('value_options' => array(1, 2, 3, 4, 5)), + 'attributes' => array('multiple' => true) + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'supported-controls-form.phtml', $this->formHelper->__invoke($oForm, null)); + } + + /** + * Test http://getbootstrap.com/css/#forms-controls-static + */ + public function testStaticControlform() { + $oForm = new \Zend\Form\Form(); + $oForm->add(array( + 'name' => 'static-element', + 'type' => '\TwbBundle\Form\Element\StaticElement', + 'attributes' => array('value' => 'email@example.com'), + 'options' => array('label' => 'Email', 'column-size' => 'lg-10', 'label_attributes' => array('class' => 'col-lg-2')) + ))->add(array( + 'name' => 'input-password', + 'attributes' => array( + 'type' => 'password', + 'placeholder' => 'Password', + 'id' => 'inputPassword' + ), + 'options' => array('label' => 'Password', 'column-size' => 'lg-10', 'label_attributes' => array('class' => 'col-lg-2')) + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'static-control-form.phtml', $this->formHelper->__invoke($oForm)); + } + + /** + * Test http://getbootstrap.com/css/#forms-control-states + */ + public function testControlStatesform() { + $oForm = new \Zend\Form\Form(); + $oForm->add(array( + 'name' => 'input-text-disabled', + 'attributes' => array( + 'type' => 'text', + 'placeholder' => 'Disabled input here...', + 'id' => 'disabledInput' + ) + )); + + $oFieldset = new \Zend\Form\Fieldset('fieldset-disabled'); + $oForm->add($oFieldset->setAttributes(array('disabled' => true))->add(array( + 'name' => 'input-text-disabled', + 'attributes' => array( + 'type' => 'text', + 'placeholder' => 'Disabled input', + 'id' => 'disabledTextInput' + ), + 'options' => array('label' => 'Disabled input') + ))->add(array( + 'name' => 'disabled-select', + 'type' => 'select', + 'options' => array( + 'label' => 'Disabled select menu', + 'value_options' => array('' => 'Disabled select') + ), + 'attributes' => array('id' => 'disabled-select') + ))->add(array( + 'name' => 'input-checkbox', + 'type' => 'checkbox', + 'options' => array('label' => 'Can\'t check this') + ))->add(array( + 'name' => 'button-submit', + 'type' => 'button', + 'attributes' => array('type' => 'submit', 'class' => 'btn-primary'), + 'options' => array('label' => 'Submit') + ))); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'control-states-form.phtml', $this->formHelper->__invoke($oForm, null)); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'control-states-form-horizontal.phtml', $this->formHelper->__invoke($oForm)); + } + + /** + * Test http://getbootstrap.com/css/#forms-validation + */ + public function testFormsValidation() { + $oForm = new \Zend\Form\Form(); + $oForm->add(array( + 'name' => 'input-text-success', + 'attributes' => array( + 'type' => 'text', + 'id' => 'inputSuccess' + ), + 'options' => array( + 'label' => 'Input with success', + 'validation-state' => 'success' + ) + ))->add(array( + 'name' => 'input-text-warning', + 'attributes' => array( + 'type' => 'text', + 'id' => 'inputWarning' + ), + 'options' => array( + 'label' => 'Input with warning', + 'validation-state' => 'warning' + ) + ))->add(array( + 'name' => 'input-text-error', + 'attributes' => array( + 'type' => 'text', + 'id' => 'inputError' + ), + 'options' => array( + 'label' => 'Input with error', + 'validation-state' => 'error' + ) + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'forms-validation.phtml', $this->formHelper->__invoke($oForm, null)); + } + + /** + * Test http://getbootstrap.com/css/#forms-control-sizes + */ + public function testFormsControlSizes() { + + //Height sizing + $oForm = new \Zend\Form\Form(); + $oForm->add(array( + 'name' => 'input-text-lg', + 'attributes' => array( + 'type' => 'text', + 'placeholder' => '.input-lg', + 'class' => 'input-lg' + ) + ))->add(array( + 'name' => 'input-text-default', + 'attributes' => array( + 'type' => 'text', + 'placeholder' => 'Default input' + ) + ))->add(array( + 'name' => 'input-text-sm', + 'attributes' => array( + 'type' => 'text', + 'placeholder' => '.input-sm', + 'class' => 'input-sm' + ) + ))->add(array( + 'name' => 'lg-select', + 'type' => 'select', + 'options' => array('value_options' => array('' => '.input-lg')), + 'attributes' => array('class' => 'input-lg') + ))->add(array( + 'name' => 'default-select', + 'type' => 'select', + 'options' => array('value_options' => array('' => 'Default select')) + ))->add(array( + 'name' => 'sm-select', + 'type' => 'select', + 'options' => array('value_options' => array('' => '.input-sm')), + 'attributes' => array('class' => 'input-sm') + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'forms-control-sizes-height.phtml', $this->formHelper->__invoke($oForm, null)); + + //Column sizing + $oForm = new \Zend\Form\Form(); + $oForm->add(array( + 'name' => 'input-text-col-lg-2', + 'attributes' => array( + 'type' => 'text', + 'placeholder' => '.col-lg-2' + ), + 'options' => array('column-size' => 'lg-2') + ))->add(array( + 'name' => 'input-text-col-lg-3', + 'attributes' => array( + 'type' => 'text', + 'placeholder' => '.col-lg-3' + ), + 'options' => array('column-size' => 'lg-3') + ))->add(array( + 'name' => 'input-text-col-lg-4', + 'attributes' => array( + 'type' => 'text', + 'placeholder' => '.col-lg-4' + ), + 'options' => array('column-size' => 'lg-4') + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'forms-control-sizes-column.phtml', $this->formHelper->__invoke($oForm, \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE)); + } + + /** + * Test http://getbootstrap.com/css/#forms-help-text + */ + public function testFormsHelpText() { + $oForm = new \Zend\Form\Form(); + $oForm->add(array( + 'name' => 'input-text', + 'attributes' => array('type' => 'text'), + 'options' => array( + 'help-block' => 'A block of help text that breaks onto a new line and may extend beyond one line.' + ) + )); //Test content - $this->assertStringEqualsFile($this->expectedPath.'control-states-form-horizontal.phtml',$this->formHelper->__invoke($oForm)); - } - - /** - * Test http://getbootstrap.com/css/#forms-validation - */ - public function testFormsValidation(){ - $oForm = new \Zend\Form\Form(); - $oForm->add(array( - 'name' => 'input-text-success', - 'attributes' => array( - 'type' => 'text', - 'id' => 'inputSuccess' - ), - 'options' => array( - 'label' => 'Input with success', - 'validation-state' => 'success' - ) - ))->add(array( - 'name' => 'input-text-warning', - 'attributes' => array( - 'type' => 'text', - 'id' => 'inputWarning' - ), - 'options' => array( - 'label' => 'Input with warning', - 'validation-state' => 'warning' - ) - ))->add(array( - 'name' => 'input-text-error', - 'attributes' => array( - 'type' => 'text', - 'id' => 'inputError' - ), - 'options' => array( - 'label' => 'Input with error', - 'validation-state' => 'error' - ) - )); - - //Test content - $this->assertStringEqualsFile($this->expectedPath.'forms-validation.phtml',$this->formHelper->__invoke($oForm,null)); - } - - /** - * Test http://getbootstrap.com/css/#forms-control-sizes - */ - public function testFormsControlSizes(){ - - //Height sizing - $oForm = new \Zend\Form\Form(); - $oForm->add(array( - 'name' => 'input-text-lg', - 'attributes' => array( - 'type' => 'text', - 'placeholder' => '.input-lg', - 'class' => 'input-lg' - ) - ))->add(array( - 'name' => 'input-text-default', - 'attributes' => array( - 'type' => 'text', - 'placeholder' => 'Default input' - ) - ))->add(array( - 'name' => 'input-text-sm', - 'attributes' => array( - 'type' => 'text', - 'placeholder' => '.input-sm', - 'class' => 'input-sm' - ) - ))->add(array( - 'name' => 'lg-select', - 'type' => 'select', - 'options' => array('value_options' => array('' => '.input-lg')), - 'attributes' => array('class' => 'input-lg') - ))->add(array( - 'name' => 'default-select', - 'type' => 'select', - 'options' => array('value_options' => array('' => 'Default select')) - ))->add(array( - 'name' => 'sm-select', - 'type' => 'select', - 'options' => array('value_options' => array('' => '.input-sm')), - 'attributes' => array('class' => 'input-sm') - )); - - //Test content - $this->assertStringEqualsFile($this->expectedPath.'forms-control-sizes-height.phtml',$this->formHelper->__invoke($oForm,null)); - - //Column sizing - $oForm = new \Zend\Form\Form(); - $oForm->add(array( - 'name' => 'input-text-col-lg-2', - 'attributes' => array( - 'type' => 'text', - 'placeholder' => '.col-lg-2' - ), - 'options' => array('column-size' => 'lg-2') - ))->add(array( - 'name' => 'input-text-col-lg-3', - 'attributes' => array( - 'type' => 'text', - 'placeholder' => '.col-lg-3' - ), - 'options' => array('column-size' => 'lg-3') - ))->add(array( - 'name' => 'input-text-col-lg-4', - 'attributes' => array( - 'type' => 'text', - 'placeholder' => '.col-lg-4' - ), - 'options' => array('column-size' => 'lg-4') - )); - - //Test content - $this->assertStringEqualsFile($this->expectedPath.'forms-control-sizes-column.phtml',$this->formHelper->__invoke($oForm,\TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE)); - } - - /** - * Test http://getbootstrap.com/css/#forms-help-text - */ - public function testFormsHelpText(){ - $oForm = new \Zend\Form\Form(); - $oForm->add(array( - 'name' => 'input-text', - 'attributes' => array('type' => 'text'), - 'options' => array( - 'help-block' => 'A block of help text that breaks onto a new line and may extend beyond one line.' - ) - )); - - //Test content - $this->assertStringEqualsFile($this->expectedPath.'forms-help-text.phtml',$this->formHelper->__invoke($oForm,null)); - } - - - /** - * Test errored input rendering - */ - public function testFormsErroredInput(){ - $oForm = new \Zend\Form\Form(); - $oElement = new \Zend\Form\Element\Text('input-text'); - $oForm->add($oElement - ->setMessages(array( - 'This is an error message', - 'This is an another one error message' - ))); - - //No form layout - $this->assertStringEqualsFile($this->expectedPath.'forms-no-layout-errored-input.phtml',$this->formHelper->__invoke($oForm,null)); - - //Horizontal form - $this->assertStringEqualsFile($this->expectedPath.'forms-horizontal-errored-input.phtml',$this->formHelper->__invoke($oForm)); - - //Horizontal form / input with label - $oElement - ->setOptions(array('column-size' => 'lg-10')) - ->setLabel('Input label') - ->setLabelAttributes(array('class' => 'col-lg-2')); - $this->assertStringEqualsFile($this->expectedPath.'forms-horizontal-errored-input-with-label.phtml',$this->formHelper->__invoke($oForm)); - } -} \ No newline at end of file + $this->assertStringEqualsFile($this->expectedPath . 'forms-help-text.phtml', $this->formHelper->__invoke($oForm, null)); + } + + /** + * Test errored input rendering + */ + public function testFormsErroredInput() { + $oForm = new \Zend\Form\Form(); + $oElement = new \Zend\Form\Element\Text('input-text'); + $oForm->add($oElement + ->setMessages(array( + 'This is an error message', + 'This is an another one error message' + ))); + + //No form layout + $this->assertStringEqualsFile($this->expectedPath . 'forms-no-layout-errored-input.phtml', $this->formHelper->__invoke($oForm, null)); + + //Horizontal form + $this->assertStringEqualsFile($this->expectedPath . 'forms-horizontal-errored-input.phtml', $this->formHelper->__invoke($oForm)); + + //Horizontal form / input with label + $oElement + ->setOptions(array('column-size' => 'lg-10')) + ->setLabel('Input label') + ->setLabelAttributes(array('class' => 'col-lg-2')); + $this->assertStringEqualsFile($this->expectedPath . 'forms-horizontal-errored-input-with-label.phtml', $this->formHelper->__invoke($oForm)); + } + +} diff --git a/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormCollectionTest.php b/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormCollectionTest.php index a7a0a63..dd99826 100644 --- a/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormCollectionTest.php +++ b/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormCollectionTest.php @@ -1,29 +1,36 @@ get('view_helper_manager'); - $oRenderer = new \Zend\View\Renderer\PhpRenderer(); - $this->formCollectionHelper = $oViewHelperPluginManager->get('formCollection')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); - } +class TwbBundleFormCollectionTest extends \PHPUnit_Framework_TestCase { + + /** + * @var \TwbBundle\Form\View\Helper\TwbBundleFormCollection + */ + protected $formCollectionHelper; + + /** + * @see \PHPUnit_Framework_TestCase::setUp() + */ + public function setUp() { + $oViewHelperPluginManager = \TwbBundleTest\Bootstrap::getServiceManager()->get('view_helper_manager'); + $oRenderer = new \Zend\View\Renderer\PhpRenderer(); + $this->formCollectionHelper = $oViewHelperPluginManager->get('formCollection')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); + } + + public function testRenderWithPluginFunctionUnavailable() { + $this->formCollectionHelper->setView(new \Zend\View\Renderer\FeedRenderer()); + $this->assertEquals('', $this->formCollectionHelper->render(new \Zend\Form\Element\Collection(null, array('label' => 'test-element')))); + } - public function testRenderWithShouldWrap(){ - $this->formCollectionHelper->setShouldWrap(true); - $this->assertEquals( - '
test-element
', - $this->formCollectionHelper->render(new \Zend\Form\Element(null,array('label' => 'test-element'))) - ); - } + public function testRenderWithShouldWrap() { + $this->formCollectionHelper->setShouldWrap(true); + $this->assertEquals( + '
test-element
', $this->formCollectionHelper->render(new \Zend\Form\Element\Collection(null, array('label' => 'test-element'))) + ); + } - public function testRenderWithShouldCreateTemplate(){ + public function testRenderWithShouldCreateTemplate() { $oElement = new \Zend\Form\Element('test'); $oForm = new \Zend\Form\Form(); $oForm->add(array( @@ -34,15 +41,13 @@ public function testRenderWithShouldCreateTemplate(){ 'target_element' => $oElement ) )); + $this->assertEquals( + '
', preg_replace('/<\/span>/', '', $this->formCollectionHelper->render($oForm->get('test-collection'))) + ); + } - $this->assertEquals( - '
'.PHP_EOL.'
', - preg_replace('/<\/span>/', '', $this->formCollectionHelper->render($oForm->get('test-collection'))) - ); - } - - public function testRenderInlineFieldsetWithAlreadyDefinedClass(){ - $oFieldset = new \Zend\Form\Fieldset('inline-fieldset',array('twb-layout' => \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE)); + public function testRenderInlineFieldsetWithAlreadyDefinedClass() { + $oFieldset = new \Zend\Form\Fieldset('inline-fieldset', array('twb-layout' => \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE)); $oFieldset->setAttributes(array('id' => 'inline-fieldset', 'class' => 'test-class')); $oFieldset->add(array( @@ -55,18 +60,17 @@ public function testRenderInlineFieldsetWithAlreadyDefinedClass(){ 'options' => array('label' => '') )); - $oCollection = new \Zend\Form\Element\Collection('inline-collection',array( - 'twb-layout' => \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE, - 'target_element' => $oFieldset + $oCollection = new \Zend\Form\Element\Collection('inline-collection', array( + 'twb-layout' => \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE )); - $oCollection->setAttributes(array('id' => 'inline-collection')); + $oCollection->add($oFieldset)->setAttributes(array('id' => 'inline-collection')); $oForm = new \Zend\Form\Form(); $oForm->add($oCollection); $this->assertStringEqualsFile( - __DIR__.DIRECTORY_SEPARATOR.'../../../../_files/expected-fieldsets/inline-fieldset.html', - $this->formCollectionHelper->__invoke($oForm->get('inline-collection'),false) - ); + __DIR__ . DIRECTORY_SEPARATOR . '../../../../_files/expected-fieldsets/inline-fieldset.html', $this->formCollectionHelper->__invoke($oForm->get('inline-collection'), false) + ); } -} \ No newline at end of file + +} diff --git a/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormElementTest.php b/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormElementTest.php index 999a7cf..2e1cf8a 100644 --- a/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormElementTest.php +++ b/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormElementTest.php @@ -1,89 +1,107 @@ get('view_helper_manager'); - $oRenderer = new \Zend\View\Renderer\PhpRenderer(); - $this->formElementHelper = $oViewHelperPluginManager->get('formElement')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRenderAddOnWithWrongTypeOption(){ - $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); - $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); - $oReflectionMethod->setAccessible(true); - $oReflectionMethod->invoke($this->formElementHelper,new \stdClass()); - } - - public function testRenderAddOnWithoutTranslator(){ - $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); - $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); - $oReflectionMethod->setAccessible(true); - - //Unset tranlator - $this->assertSame($this->formElementHelper,$this->formElementHelper->setTranslator(null)); - $this->assertFalse($this->formElementHelper->hasTranslator()); - - $this->assertEquals('test',$oReflectionMethod->invoke($this->formElementHelper,'test')); - - //Set translator - $this->assertSame($this->formElementHelper,$this->formElementHelper->setTranslator(\TwbBundleTest\Bootstrap::getServiceManager()->get('MVCTranslator'))); - $this->assertTrue($this->formElementHelper->hasTranslator()); - } - - public function testRenderAddOnWithElementAsArray(){ - $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); - $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); - $oReflectionMethod->setAccessible(true); - $this->assertEquals( - '', - $oReflectionMethod->invoke($this->formElementHelper,array('element' => array('name' => 'test-element'))) - ); - } - - /** - * @expectedException \LogicException - */ - public function testRenderAddOnWithWrongTypeElement(){ - $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); - $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); - $oReflectionMethod->setAccessible(true); - $oReflectionMethod->invoke($this->formElementHelper,array('element' => new \stdClass())); - } - - /** - * @expectedException \LogicException - */ - public function testRenderAddOnWithWrongTypeText(){ - $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); - $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); - $oReflectionMethod->setAccessible(true); - $oReflectionMethod->invoke($this->formElementHelper,array('text' => new \stdClass())); - } - - public function testSetTranslatorEnabled(){ - $this->assertSame($this->formElementHelper,$this->formElementHelper->setTranslatorEnabled(false)); - $this->assertFalse($this->formElementHelper->isTranslatorEnabled()); - - $this->assertSame($this->formElementHelper,$this->formElementHelper->setTranslatorEnabled(true)); - $this->assertTrue($this->formElementHelper->isTranslatorEnabled()); - } - - public function testSetTranslatorTextDomain(){ - $this->assertSame($this->formElementHelper,$this->formElementHelper->setTranslatorTextDomain('test')); - $this->assertEquals('test',$this->formElementHelper->getTranslatorTextDomain()); - - $this->assertSame($this->formElementHelper,$this->formElementHelper->setTranslatorTextDomain()); - $this->assertEquals('default',$this->formElementHelper->getTranslatorTextDomain()); - } -} \ No newline at end of file + +class TTwbBundleFormElementTest extends \PHPUnit_Framework_TestCase { + + /** + * @var \TwbBundle\Form\View\Helper\TwbBundleFormElement + */ + protected $formElementHelper; + + /** + * @see \PHPUnit_Framework_TestCase::setUp() + */ + public function setUp() { + $oViewHelperPluginManager = \TwbBundleTest\Bootstrap::getServiceManager()->get('view_helper_manager'); + $oRenderer = new \Zend\View\Renderer\PhpRenderer(); + $this->formElementHelper = $oViewHelperPluginManager->get('formElement')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testRenderAddOnWithEmptuOption() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); + $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); + $oReflectionMethod->setAccessible(true); + $oReflectionMethod->invoke($this->formElementHelper, ''); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testRenderAddOnWithWrongTypeOption() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); + $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); + $oReflectionMethod->setAccessible(true); + $oReflectionMethod->invoke($this->formElementHelper, new \stdClass()); + } + + public function testRenderAddOnWithoutTranslator() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); + $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); + $oReflectionMethod->setAccessible(true); + + //Unset tranlator + $this->assertSame($this->formElementHelper, $this->formElementHelper->setTranslator(null)); + $this->assertFalse($this->formElementHelper->hasTranslator()); + + $this->assertEquals('test', $oReflectionMethod->invoke($this->formElementHelper, 'test')); + + //Set translator + $this->assertSame($this->formElementHelper, $this->formElementHelper->setTranslator(\TwbBundleTest\Bootstrap::getServiceManager()->get('MVCTranslator'))); + $this->assertTrue($this->formElementHelper->hasTranslator()); + } + + public function testRenderAddOnWithElementAsArray() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); + $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); + $oReflectionMethod->setAccessible(true); + $this->assertEquals( + '', $oReflectionMethod->invoke($this->formElementHelper, array('element' => array('name' => 'test-element'))) + ); + } + + /** + * @expectedException \LogicException + */ + public function testRenderAddOnWithWrongTypeElement() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); + $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); + $oReflectionMethod->setAccessible(true); + $oReflectionMethod->invoke($this->formElementHelper, array('element' => new \stdClass())); + } + + /** + * @expectedException \LogicException + */ + public function testRenderAddOnWithWrongTypeText() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormElement'); + $oReflectionMethod = $oReflectionClass->getMethod('renderAddOn'); + $oReflectionMethod->setAccessible(true); + $oReflectionMethod->invoke($this->formElementHelper, array('text' => new \stdClass())); + } + + public function testSetTranslatorEnabled() { + $this->assertSame($this->formElementHelper, $this->formElementHelper->setTranslatorEnabled(false)); + $this->assertFalse($this->formElementHelper->isTranslatorEnabled()); + + $this->assertSame($this->formElementHelper, $this->formElementHelper->setTranslatorEnabled(true)); + $this->assertTrue($this->formElementHelper->isTranslatorEnabled()); + } + + public function testSetTranslatorWithTextDomain() { + $this->assertSame($this->formElementHelper, $this->formElementHelper->setTranslator($this->formElementHelper->getTranslator(), 'test')); + $this->assertEquals('test', $this->formElementHelper->getTranslatorTextDomain()); + } + + public function testSetTranslatorTextDomain() { + $this->assertSame($this->formElementHelper, $this->formElementHelper->setTranslatorTextDomain('test')); + $this->assertEquals('test', $this->formElementHelper->getTranslatorTextDomain()); + + $this->assertSame($this->formElementHelper, $this->formElementHelper->setTranslatorTextDomain()); + $this->assertEquals('default', $this->formElementHelper->getTranslatorTextDomain()); + } + +} diff --git a/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormRadioTest.php b/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormRadioTest.php index 1973ca2..6ceeb1c 100644 --- a/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormRadioTest.php +++ b/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormRadioTest.php @@ -1,29 +1,54 @@ -get('view_helper_manager'); - $oRenderer = new \Zend\View\Renderer\PhpRenderer(); - $this->formRadioHelper = $oViewHelperPluginManager->get('formRadio')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); - } - - public function testRenderOptionsWithPrependingLabel(){ - $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRadio'); - $oReflectionMethod = $oReflectionClass->getMethod('renderOptions'); - $oReflectionMethod->setAccessible(true); - - $this->formRadioHelper->setLabelPosition(\TwbBundle\Form\View\Helper\TwbBundleFormRadio::LABEL_PREPEND); - $this->assertEquals( - '', - $oReflectionMethod->invoke($this->formRadioHelper,new \Zend\Form\Element\MultiCheckbox(),array('test'),array('test'),array()) - ); - } -} \ No newline at end of file +get('view_helper_manager'); + $oRenderer = new \Zend\View\Renderer\PhpRenderer(); + $this->formRadioHelper = $oViewHelperPluginManager->get('formRadio')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); + } + + public function testRenderOptionsWithPrependingLabel() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRadio'); + $oReflectionMethod = $oReflectionClass->getMethod('renderOptions'); + $oReflectionMethod->setAccessible(true); + + $this->formRadioHelper->setLabelPosition(\TwbBundle\Form\View\Helper\TwbBundleFormRadio::LABEL_PREPEND); + $this->assertEquals( + '', $oReflectionMethod->invoke($this->formRadioHelper, new \Zend\Form\Element\Radio(), array('test'), array('test'), array()) + ); + } + + public function testRenderOptionsWithDefineAttributesId() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRadio'); + $oReflectionMethod = $oReflectionClass->getMethod('renderOptions'); + $oReflectionMethod->setAccessible(true); + + $this->formRadioHelper->setLabelPosition(\TwbBundle\Form\View\Helper\TwbBundleFormRadio::LABEL_PREPEND); + $this->assertEquals( + '
', $oReflectionMethod->invoke($this->formRadioHelper, new \Zend\Form\Element\Radio(), array('test1', 'test2'), array('test'), array('id' => 'test_id')) + ); + } + + public function testRenderOptionsWithOptionsSpecs() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRadio'); + $oReflectionMethod = $oReflectionClass->getMethod('renderOptions'); + $oReflectionMethod->setAccessible(true); + + $this->formRadioHelper->setLabelPosition(\TwbBundle\Form\View\Helper\TwbBundleFormRadio::LABEL_PREPEND); + $this->assertEquals( + '
', $oReflectionMethod->invoke($this->formRadioHelper, new \Zend\Form\Element\Radio(), array('test1', array('label' => 'test2', 'selected' => true, 'disabled' => true, 'label_attributes' => array('class' => 'test-label-class'), 'attributes' => array('class' => 'test-class'))), array('test'), array('id' => 'test_id', 'type' => 'radio')) + ); + } + +} diff --git a/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormRowTest.php b/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormRowTest.php index 8102ac1..ead6e8a 100644 --- a/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormRowTest.php +++ b/tests/TwbBundleTest/Form/View/Helper/TwbBundleFormRowTest.php @@ -1,108 +1,150 @@ get('view_helper_manager'); - $oRenderer = new \Zend\View\Renderer\PhpRenderer(); - $oRenderer->setResolver(\TwbBundleTest\Bootstrap::getServiceManager()->get('ViewResolver')); - $this->formRowHelper = $oViewHelperPluginManager->get('formRow')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); - $this->formRowHelper->setPartial(null); - } - - public function testRenderPartial(){ - $this->formRowHelper->setPartial('partial-row'); - $this->assertEquals('Partial Row : ',$this->formRowHelper->render(new \Zend\Form\Element('test-element'))); - } - - public function testRenderAddOnWithValidationStateAndDefinedLabelClass(){ - $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRow'); - $oReflectionMethod = $oReflectionClass->getMethod('renderElement'); - $oReflectionMethod->setAccessible(true); - - $oElement = new \Zend\Form\Element('test-element',array('validation-state' => 'warning')); - $oElement - ->setLabel('test-label') - ->setLabelAttributes(array('class' => 'test-label-class')); - - $this->assertEquals( - '', - $oReflectionMethod->invoke($this->formRowHelper,$oElement) - ); - } - - public function testRenderAddOnWithInlineLayoutAndDefinedLabelClass(){ - $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRow'); - $oReflectionMethod = $oReflectionClass->getMethod('renderElement'); - $oReflectionMethod->setAccessible(true); - - $oElement = new \Zend\Form\Element('test-element',array('twb-layout' => \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE)); - $oElement - ->setLabel('test-label') - ->setLabelAttributes(array('class' => 'test-label-class')); - - $this->assertEquals( - '', - $oReflectionMethod->invoke($this->formRowHelper,$oElement) - ); - } - - public function testRenderAddOnWithHorizontalLayoutAndDefinedLabelClass(){ - $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRow'); - $oReflectionMethod = $oReflectionClass->getMethod('renderElement'); - $oReflectionMethod->setAccessible(true); - - $oElement = new \Zend\Form\Element('test-element',array('twb-layout' => \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL)); - $oElement - ->setLabel('test-label') - ->setLabelAttributes(array('class' => 'test-label-class')); - - $this->assertEquals( - '
', - $oReflectionMethod->invoke($this->formRowHelper,$oElement) - ); - } - - /** - * @expectedException \DomainException - */ - public function testRenderAddOnWithWrongLayout(){ - $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRow'); - $oReflectionMethod = $oReflectionClass->getMethod('renderElement'); - $oReflectionMethod->setAccessible(true); - $oReflectionMethod->invoke($this->formRowHelper,new \Zend\Form\Element('test-element',array('label' => 'test-label','twb-layout' => 'wrong'))); - } - - public function testRenderErrorsWithInputErrorClass(){ - $this->formRowHelper->setInputErrorClass('input-error'); - $oElement = new \Zend\Form\Element\Text('input-text'); - $oElement->setAttribute('class', 'test-class'); - $oElement->setMessages(array( - 'This is an error message', - 'This is an another one error message' - )); - - //Test content - $this->assertEquals( - '
  • This is an error message
  • This is an another one error message
'.PHP_EOL, - $this->formRowHelper->__invoke($oElement) - ); - } - - public function testRenderHiddenElement(){ - $this->formRowHelper->setInputErrorClass('input-error'); - $oElement = new \Zend\Form\Element\Hidden('input-hidden'); - //Test content - $this->assertEquals( - '', - $this->formRowHelper->__invoke($oElement) - ); - } -} \ No newline at end of file + +class TwbBundleFormRowTest extends \PHPUnit_Framework_TestCase { + + /** + * @var string + */ + protected $expectedPath; + + /** + * @var \TwbBundle\Form\View\Helper\TwbBundleFormRow + */ + protected $formRowHelper; + + /** + * @see \PHPUnit_Framework_TestCase::setUp() + */ + public function setUp() { + $this->expectedPath = __DIR__ . DIRECTORY_SEPARATOR . '../../../../_files/expected-rows' . DIRECTORY_SEPARATOR; + $oViewHelperPluginManager = \TwbBundleTest\Bootstrap::getServiceManager()->get('view_helper_manager'); + $oRenderer = new \Zend\View\Renderer\PhpRenderer(); + $oRenderer->setResolver(\TwbBundleTest\Bootstrap::getServiceManager()->get('ViewResolver')); + $this->formRowHelper = $oViewHelperPluginManager->get('formRow')->setView($oRenderer->setHelperPluginManager($oViewHelperPluginManager)); + $this->formRowHelper->setPartial(null); + } + + public function testRenderPartial() { + $this->formRowHelper->setPartial('partial-row'); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'partial.phtml', $this->formRowHelper->render(new \Zend\Form\Element('test-element'))); + } + + public function testRenderAddOnWithValidationStateAndDefinedLabelClass() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRow'); + $oReflectionMethod = $oReflectionClass->getMethod('renderElement'); + $oReflectionMethod->setAccessible(true); + + $oElement = new \Zend\Form\Element('test-element', array('validation-state' => 'warning')); + $oElement + ->setLabel('test-label') + ->setLabelAttributes(array('class' => 'test-label-class')); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'add-on-validation-states.phtml', $oReflectionMethod->invoke($this->formRowHelper, $oElement)); + } + + public function testRenderAddOnWithInlineLayoutAndDefinedLabelClass() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRow'); + $oReflectionMethod = $oReflectionClass->getMethod('renderElement'); + $oReflectionMethod->setAccessible(true); + + $oElement = new \Zend\Form\Element('test-element', array('twb-layout' => \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE)); + $oElement + ->setLabel('test-label') + ->setLabelAttributes(array('class' => 'test-label-class')); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'add-on-inline-layout.phtml', $oReflectionMethod->invoke($this->formRowHelper, $oElement)); + } + + public function testRenderAddOnWithHorizontalLayoutAndDefinedLabelClass() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRow'); + $oReflectionMethod = $oReflectionClass->getMethod('renderElement'); + $oReflectionMethod->setAccessible(true); + + $oElement = new \Zend\Form\Element('test-element', array('twb-layout' => \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL)); + $oElement + ->setLabel('test-label') + ->setLabelAttributes(array('class' => 'test-label-class')); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'add-on-horizontal-layout.phtml', $oReflectionMethod->invoke($this->formRowHelper, $oElement)); + } + + /** + * @expectedException \DomainException + */ + public function testRenderAddOnWithWrongLayout() { + $oReflectionClass = new \ReflectionClass('\TwbBundle\Form\View\Helper\TwbBundleFormRow'); + $oReflectionMethod = $oReflectionClass->getMethod('renderElement'); + $oReflectionMethod->setAccessible(true); + $oReflectionMethod->invoke($this->formRowHelper, new \Zend\Form\Element('test-element', array('label' => 'test-label', 'twb-layout' => 'wrong'))); + } + + public function testRenderErrorsWithInputErrorClass() { + $this->formRowHelper->setInputErrorClass('input-error'); + $oElement = new \Zend\Form\Element\Text('input-text'); + $oElement->setAttribute('class', 'test-class'); + $oElement->setMessages(array( + 'This is an error message', + 'This is an another one error message' + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'errors-input-errors-class.phtml', $this->formRowHelper->__invoke($oElement)); + } + + public function testRenderErrorsWithoutInputErrorClass() { + $this->formRowHelper->setInputErrorClass('input-error'); + $oElement = new \Zend\Form\Element\Text('input-text'); + $oElement->setMessages(array( + 'This is an error message', + 'This is an another one error message' + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'errors-without-input-errors-class.phtml', $this->formRowHelper->__invoke($oElement)); + } + + public function testRenderHiddenElement() { + $this->formRowHelper->setInputErrorClass('input-error'); + $oElement = new \Zend\Form\Element\Hidden('input-hidden'); + //Test content + $this->assertEquals( + '', $this->formRowHelper->__invoke($oElement) + ); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'hidden-element.phtml', $this->formRowHelper->__invoke($oElement)); + } + + public function testRendeCheckboxWithDefinedLabelAttributes() { + $oElement = new \Zend\Form\Element\Checkbox('test-checkbox'); + $oElement->setLabel('Test checkobx'); + $this->formRowHelper->setLabelAttributes(array('class' => 'test-class')); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'checkobx-defined-label-attributes.phtml', $this->formRowHelper->__invoke($oElement)); + } + + public function testRendeRadiosWithHorizontalLayout() { + $oElement = new \Zend\Form\Element\Radio('test-radio', array( + 'twb-layout' => \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL, + 'label' => 'Test radio', + 'column-size' => 'sm-10', + 'label_attributes' => array('class' => 'col-sm-2'), + 'value_options' => array( + 'option1' => 'Option one', + 'option2' => 'Option two' + ) + )); + + //Test content + $this->assertStringEqualsFile($this->expectedPath . 'radio-horizontal-layout.phtml', $this->formRowHelper->__invoke($oElement)); + } + +} diff --git a/tests/TwbBundleTest/View/Helper/TwbBundleLabel.php b/tests/TwbBundleTest/View/Helper/TwbBundleLabelTest.php similarity index 100% rename from tests/TwbBundleTest/View/Helper/TwbBundleLabel.php rename to tests/TwbBundleTest/View/Helper/TwbBundleLabelTest.php diff --git a/tests/_files/expected-rows/add-on-horizontal-layout.phtml b/tests/_files/expected-rows/add-on-horizontal-layout.phtml new file mode 100644 index 0000000..853e83a --- /dev/null +++ b/tests/_files/expected-rows/add-on-horizontal-layout.phtml @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/tests/_files/expected-rows/add-on-inline-layout.phtml b/tests/_files/expected-rows/add-on-inline-layout.phtml new file mode 100644 index 0000000..e6269bf --- /dev/null +++ b/tests/_files/expected-rows/add-on-inline-layout.phtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/_files/expected-rows/add-on-validation-states.phtml b/tests/_files/expected-rows/add-on-validation-states.phtml new file mode 100644 index 0000000..903355e --- /dev/null +++ b/tests/_files/expected-rows/add-on-validation-states.phtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/_files/expected-rows/checkobx-defined-label-attributes.phtml b/tests/_files/expected-rows/checkobx-defined-label-attributes.phtml new file mode 100644 index 0000000..02bf0c0 --- /dev/null +++ b/tests/_files/expected-rows/checkobx-defined-label-attributes.phtml @@ -0,0 +1 @@ +
diff --git a/tests/_files/expected-rows/errors-input-errors-class.phtml b/tests/_files/expected-rows/errors-input-errors-class.phtml new file mode 100644 index 0000000..cfb29e2 --- /dev/null +++ b/tests/_files/expected-rows/errors-input-errors-class.phtml @@ -0,0 +1 @@ +
  • This is an error message
  • This is an another one error message
diff --git a/tests/_files/expected-rows/errors-without-input-errors-class.phtml b/tests/_files/expected-rows/errors-without-input-errors-class.phtml new file mode 100644 index 0000000..21cc812 --- /dev/null +++ b/tests/_files/expected-rows/errors-without-input-errors-class.phtml @@ -0,0 +1 @@ +
  • This is an error message
  • This is an another one error message
diff --git a/tests/_files/expected-rows/hidden-element.phtml b/tests/_files/expected-rows/hidden-element.phtml new file mode 100644 index 0000000..b285688 --- /dev/null +++ b/tests/_files/expected-rows/hidden-element.phtml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/tests/_files/expected-rows/partial.phtml b/tests/_files/expected-rows/partial.phtml new file mode 100644 index 0000000..d73333f --- /dev/null +++ b/tests/_files/expected-rows/partial.phtml @@ -0,0 +1 @@ +Partial Row : \ No newline at end of file diff --git a/tests/_files/expected-rows/radio-horizontal-layout.phtml b/tests/_files/expected-rows/radio-horizontal-layout.phtml new file mode 100644 index 0000000..73b9168 --- /dev/null +++ b/tests/_files/expected-rows/radio-horizontal-layout.phtml @@ -0,0 +1 @@ +
diff --git a/tests/_report/Module.php.html b/tests/_report/Module.php.html index 2917f2a..f7f529b 100644 --- a/tests/_report/Module.php.html +++ b/tests/_report/Module.php.html @@ -160,7 +160,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/index.dashboard.html b/tests/_report/index.dashboard.html index 26f255d..c224e03 100644 --- a/tests/_report/index.dashboard.html +++ b/tests/_report/index.dashboard.html @@ -52,7 +52,7 @@

Least Tested Methods

@@ -83,7 +83,7 @@

Least Tested Methods

min: 0 }, series: [{ - data: [0,0,0,0,0,0,0,0,0,0,0,17] + data: [0,0,0,0,0,0,0,0,0,0,0,18] }], }); @@ -111,7 +111,7 @@

Least Tested Methods

} }, series: [{ - data: [[100,2,"Module<\/a>"],[100,0,"StaticElement<\/a>"],[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,17,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,47,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"],[100,13,"TwbBundleAlert<\/a>"],[100,8,"TwbBundleBadge<\/a>"],[100,58,"TwbBundleDropDown<\/a>"],[100,9,"TwbBundleGlyphicon<\/a>"],[100,12,"TwbBundleLabel<\/a>"]], + data: [[100,2,"Module<\/a>"],[100,0,"StaticElement<\/a>"],[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,19,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,10,"TwbBundleFormErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,50,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"],[100,15,"TwbBundleAlert<\/a>"],[100,8,"TwbBundleBadge<\/a>"],[100,58,"TwbBundleDropDown<\/a>"],[100,9,"TwbBundleGlyphicon<\/a>"],[100,12,"TwbBundleLabel<\/a>"]], marker: { symbol: 'diamond' } diff --git a/tests/_report/index.html b/tests/_report/index.html index c8710b2..07764f2 100644 --- a/tests/_report/index.html +++ b/tests/_report/index.html @@ -47,19 +47,19 @@
100.00%
-
592 / 592
+
652 / 652
100.00%
-
38 / 38
+
41 / 41
100.00%
-
17 / 17
+
18 / 18
@@ -69,19 +69,19 @@
100.00%
-
588 / 588
+
648 / 648
100.00%
-
36 / 36
+
39 / 39
100.00%
-
16 / 16
+
17 / 17
@@ -117,7 +117,7 @@

Legend

High: 70% to 100%

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src.dashboard.html b/tests/_report/src.dashboard.html index 9e2a157..38ea719 100644 --- a/tests/_report/src.dashboard.html +++ b/tests/_report/src.dashboard.html @@ -53,7 +53,7 @@

Least Tested Methods

@@ -84,7 +84,7 @@

Least Tested Methods

min: 0 }, series: [{ - data: [0,0,0,0,0,0,0,0,0,0,0,16] + data: [0,0,0,0,0,0,0,0,0,0,0,17] }], }); @@ -112,7 +112,7 @@

Least Tested Methods

} }, series: [{ - data: [[100,0,"StaticElement<\/a>"],[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,17,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,47,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"],[100,13,"TwbBundleAlert<\/a>"],[100,8,"TwbBundleBadge<\/a>"],[100,58,"TwbBundleDropDown<\/a>"],[100,9,"TwbBundleGlyphicon<\/a>"],[100,12,"TwbBundleLabel<\/a>"]], + data: [[100,0,"StaticElement<\/a>"],[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,19,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,10,"TwbBundleFormErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,50,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"],[100,15,"TwbBundleAlert<\/a>"],[100,8,"TwbBundleBadge<\/a>"],[100,58,"TwbBundleDropDown<\/a>"],[100,9,"TwbBundleGlyphicon<\/a>"],[100,12,"TwbBundleLabel<\/a>"]], marker: { symbol: 'diamond' } diff --git a/tests/_report/src.html b/tests/_report/src.html index 616c516..2a14f18 100644 --- a/tests/_report/src.html +++ b/tests/_report/src.html @@ -48,19 +48,19 @@
100.00%
-
588 / 588
+
648 / 648
100.00%
-
36 / 36
+
39 / 39
100.00%
-
16 / 16
+
17 / 17
@@ -70,19 +70,19 @@
100.00%
-
588 / 588
+
648 / 648
100.00%
-
36 / 36
+
39 / 39
100.00%
-
16 / 16
+
17 / 17
@@ -96,7 +96,7 @@

Legend

High: 70% to 100%

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle.dashboard.html b/tests/_report/src_TwbBundle.dashboard.html index 3540bcc..a865279 100644 --- a/tests/_report/src_TwbBundle.dashboard.html +++ b/tests/_report/src_TwbBundle.dashboard.html @@ -54,7 +54,7 @@

Least Tested Methods

@@ -85,7 +85,7 @@

Least Tested Methods

min: 0 }, series: [{ - data: [0,0,0,0,0,0,0,0,0,0,0,16] + data: [0,0,0,0,0,0,0,0,0,0,0,17] }], }); @@ -113,7 +113,7 @@

Least Tested Methods

} }, series: [{ - data: [[100,0,"StaticElement<\/a>"],[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,17,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,47,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"],[100,13,"TwbBundleAlert<\/a>"],[100,8,"TwbBundleBadge<\/a>"],[100,58,"TwbBundleDropDown<\/a>"],[100,9,"TwbBundleGlyphicon<\/a>"],[100,12,"TwbBundleLabel<\/a>"]], + data: [[100,0,"StaticElement<\/a>"],[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,19,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,10,"TwbBundleFormErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,50,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"],[100,15,"TwbBundleAlert<\/a>"],[100,8,"TwbBundleBadge<\/a>"],[100,58,"TwbBundleDropDown<\/a>"],[100,9,"TwbBundleGlyphicon<\/a>"],[100,12,"TwbBundleLabel<\/a>"]], marker: { symbol: 'diamond' } diff --git a/tests/_report/src_TwbBundle.html b/tests/_report/src_TwbBundle.html index d93ca12..972d112 100644 --- a/tests/_report/src_TwbBundle.html +++ b/tests/_report/src_TwbBundle.html @@ -49,19 +49,19 @@
100.00%
-
588 / 588
+
648 / 648
100.00%
-
36 / 36
+
39 / 39
100.00%
-
16 / 16
+
17 / 17
@@ -71,19 +71,19 @@
100.00%
-
421 / 421
+
480 / 480
100.00%
-
23 / 23
+
26 / 26
100.00%
-
11 / 11
+
12 / 12
@@ -93,7 +93,7 @@
100.00%
-
167 / 167
+
168 / 168
@@ -119,7 +119,7 @@

Legend

High: 70% to 100%

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form.dashboard.html b/tests/_report/src_TwbBundle_Form.dashboard.html index 36308e3..8ff97f1 100644 --- a/tests/_report/src_TwbBundle_Form.dashboard.html +++ b/tests/_report/src_TwbBundle_Form.dashboard.html @@ -55,7 +55,7 @@

Least Tested Methods

@@ -86,7 +86,7 @@

Least Tested Methods

min: 0 }, series: [{ - data: [0,0,0,0,0,0,0,0,0,0,0,11] + data: [0,0,0,0,0,0,0,0,0,0,0,12] }], }); @@ -114,7 +114,7 @@

Least Tested Methods

} }, series: [{ - data: [[100,0,"StaticElement<\/a>"],[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,17,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,47,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"]], + data: [[100,0,"StaticElement<\/a>"],[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,19,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,10,"TwbBundleFormErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,50,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"]], marker: { symbol: 'diamond' } diff --git a/tests/_report/src_TwbBundle_Form.html b/tests/_report/src_TwbBundle_Form.html index 90416f6..e7a531a 100644 --- a/tests/_report/src_TwbBundle_Form.html +++ b/tests/_report/src_TwbBundle_Form.html @@ -50,19 +50,19 @@
100.00%
-
421 / 421
+
480 / 480
100.00%
-
23 / 23
+
26 / 26
100.00%
-
11 / 11
+
12 / 12
@@ -88,19 +88,19 @@
100.00%
-
421 / 421
+
480 / 480
100.00%
-
23 / 23
+
26 / 26
100.00%
-
10 / 10
+
11 / 11
@@ -114,7 +114,7 @@

Legend

High: 70% to 100%

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_Element.dashboard.html b/tests/_report/src_TwbBundle_Form_Element.dashboard.html index 325d94e..cfffa98 100644 --- a/tests/_report/src_TwbBundle_Form_Element.dashboard.html +++ b/tests/_report/src_TwbBundle_Form_Element.dashboard.html @@ -56,7 +56,7 @@

Least Tested Methods

diff --git a/tests/_report/src_TwbBundle_Form_Element.html b/tests/_report/src_TwbBundle_Form_Element.html index 1df6ece..8241765 100644 --- a/tests/_report/src_TwbBundle_Form_Element.html +++ b/tests/_report/src_TwbBundle_Form_Element.html @@ -87,7 +87,7 @@

Legend

High: 70% to 100%

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_Element_StaticElement.php.html b/tests/_report/src_TwbBundle_Form_Element_StaticElement.php.html index 2661d92..0e6a8ec 100644 --- a/tests/_report/src_TwbBundle_Form_Element_StaticElement.php.html +++ b/tests/_report/src_TwbBundle_Form_Element_StaticElement.php.html @@ -104,7 +104,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View.dashboard.html b/tests/_report/src_TwbBundle_Form_View.dashboard.html index 5ac2dad..ad8799c 100644 --- a/tests/_report/src_TwbBundle_Form_View.dashboard.html +++ b/tests/_report/src_TwbBundle_Form_View.dashboard.html @@ -56,7 +56,7 @@

Least Tested Methods

@@ -87,7 +87,7 @@

Least Tested Methods

min: 0 }, series: [{ - data: [0,0,0,0,0,0,0,0,0,0,0,10] + data: [0,0,0,0,0,0,0,0,0,0,0,11] }], }); @@ -115,7 +115,7 @@

Least Tested Methods

} }, series: [{ - data: [[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,17,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,47,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"]], + data: [[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,19,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,10,"TwbBundleFormErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,50,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"]], marker: { symbol: 'diamond' } diff --git a/tests/_report/src_TwbBundle_Form_View.html b/tests/_report/src_TwbBundle_Form_View.html index 9be033b..106d727 100644 --- a/tests/_report/src_TwbBundle_Form_View.html +++ b/tests/_report/src_TwbBundle_Form_View.html @@ -51,19 +51,19 @@
100.00%
-
421 / 421
+
480 / 480
100.00%
-
23 / 23
+
26 / 26
100.00%
-
10 / 10
+
11 / 11
@@ -73,19 +73,19 @@
100.00%
-
421 / 421
+
480 / 480
100.00%
-
23 / 23
+
26 / 26
100.00%
-
10 / 10
+
11 / 11
@@ -99,7 +99,7 @@

Legend

High: 70% to 100%

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper.dashboard.html b/tests/_report/src_TwbBundle_Form_View_Helper.dashboard.html index d59a870..0b09dfd 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper.dashboard.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper.dashboard.html @@ -57,7 +57,7 @@

Least Tested Methods

@@ -88,7 +88,7 @@

Least Tested Methods

min: 0 }, series: [{ - data: [0,0,0,0,0,0,0,0,0,0,0,10] + data: [0,0,0,0,0,0,0,0,0,0,0,11] }], }); @@ -116,7 +116,7 @@

Least Tested Methods

} }, series: [{ - data: [[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,17,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,47,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"]], + data: [[100,16,"TwbBundleForm<\/a>"],[100,30,"TwbBundleFormButton<\/a>"],[100,17,"TwbBundleFormCheckbox<\/a>"],[100,19,"TwbBundleFormCollection<\/a>"],[100,37,"TwbBundleFormElement<\/a>"],[100,0,"TwbBundleFormElementErrors<\/a>"],[100,10,"TwbBundleFormErrors<\/a>"],[100,5,"TwbBundleFormMultiCheckbox<\/a>"],[100,24,"TwbBundleFormRadio<\/a>"],[100,50,"TwbBundleFormRow<\/a>"],[100,1,"TwbBundleFormStatic<\/a>"]], marker: { symbol: 'diamond' } diff --git a/tests/_report/src_TwbBundle_Form_View_Helper.html b/tests/_report/src_TwbBundle_Form_View_Helper.html index 8c430b1..98c652c 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper.html @@ -52,19 +52,19 @@
100.00%
-
421 / 421
+
480 / 480
100.00%
-
23 / 23
+
26 / 26
100.00%
-
10 / 10
+
11 / 11
@@ -140,7 +140,7 @@
100.00%
-
46 / 46
+
48 / 48
@@ -162,7 +162,7 @@
100.00%
-
67 / 67
+
81 / 81
@@ -193,6 +193,28 @@
1 / 1
+ +
TwbBundleFormErrors.php +
+
+
+ +
100.00%
+
22 / 22
+
+
+
+ +
100.00%
+
3 / 3
+
+
+
+ +
100.00%
+
1 / 1
+ + TwbBundleFormMultiCheckbox.php
@@ -222,7 +244,7 @@
100.00%
-
42 / 42
+
57 / 57
@@ -244,7 +266,7 @@
100.00%
-
114 / 114
+
120 / 120
@@ -292,7 +314,7 @@

Legend

High: 70% to 100%

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleForm.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleForm.php.html index 5879184..1fa9e8b 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleForm.php.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleForm.php.html @@ -220,7 +220,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormButton.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormButton.php.html index 7113a0b..d270d02 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormButton.php.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormButton.php.html @@ -286,7 +286,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormCheckbox.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormCheckbox.php.html index 01f38e3..b9ef5f4 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormCheckbox.php.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormCheckbox.php.html @@ -154,45 +154,45 @@
22
*/
23
public function render(\Zend\Form\ElementInterface $oElement)
24
{ -
25
if (!$oElement instanceof \Zend\Form\Element\Checkbox) throw new \InvalidArgumentException(sprintf( +
25
if (!$oElement instanceof \Zend\Form\Element\Checkbox) throw new \InvalidArgumentException(sprintf(
26
'%s requires that the element is of type Zend\Form\Element\Checkbox',
27
__METHOD__
28
)); -
29
if (($sName = $oElement->getName()) !== 0 && empty($sName)) throw new \LogicException(sprintf( +
29
if (($sName = $oElement->getName()) !== 0 && empty($sName)) throw new \LogicException(sprintf(
30
'%s requires that the element has an assigned name; none discovered',
31
__METHOD__
32
));
33
-
34
$aAttributes = $oElement->getAttributes(); -
35
$aAttributes['name'] = $sName; -
36
$aAttributes['type'] = $this->getInputType(); -
37
$aAttributes['value'] = $oElement->getCheckedValue(); -
38
$sClosingBracket = $this->getInlineClosingBracket(); +
34
$aAttributes = $oElement->getAttributes(); +
35
$aAttributes['name'] = $sName; +
36
$aAttributes['type'] = $this->getInputType(); +
37
$aAttributes['value'] = $oElement->getCheckedValue(); +
38
$sClosingBracket = $this->getInlineClosingBracket();
39
-
40
if ($oElement->isChecked()) $aAttributes['checked'] = 'checked'; +
40
if ($oElement->isChecked()) $aAttributes['checked'] = 'checked';
41
42
//Render label and visible element -
43
if (($sLabel = $oElement->getLabel()) && ($oTranslator = $this->getTranslator())) $sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain()); -
44
$oLabelHelper = $this->getLabelHelper(); +
43
if (($sLabel = $oElement->getLabel()) && ($oTranslator = $this->getTranslator())) $sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain()); +
44
$oLabelHelper = $this->getLabelHelper();
45
-
46
$sElementContent = ''; -
47
if ($sLabel) $sElementContent .= $oLabelHelper->openTag($oElement->getLabelAttributes() ? : null); -
48
$sElementContent .= sprintf( -
49
'<input %s%s', -
50
$this->createAttributesString($aAttributes), +
46
$sElementContent = ''; +
47
if ($sLabel) $sElementContent .= $oLabelHelper->openTag($oElement->getLabelAttributes() ? : null); +
48
$sElementContent .= sprintf( +
49
'<input %s%s', +
50
$this->createAttributesString($aAttributes),
51
$sClosingBracket -
52
); -
53
if ($sLabel) $sElementContent .= $sLabel . $oLabelHelper->closeTag(); +
52
); +
53
if ($sLabel) $sElementContent .= $sLabel . $oLabelHelper->closeTag();
54
55
//Render hidden input -
56
if ($oElement->useHiddenElement()) $sElementContent = sprintf( -
57
'<input type="hidden" %s%s', -
58
$this->createAttributesString(array( -
59
'name' => $aAttributes['name'], -
60
'value' => $oElement->getUncheckedValue(), -
61
)), $sClosingBracket -
62
) . $sElementContent; -
63
return $oElement->getOption('disable-twb') ? $sElementContent : sprintf(self::$checkboxFormat, $sElementContent); +
56
if ($oElement->useHiddenElement()) $sElementContent = sprintf( +
57
'<input type="hidden" %s%s', +
58
$this->createAttributesString(array( +
59
'name' => $aAttributes['name'], +
60
'value' => $oElement->getUncheckedValue(), +
61
)), $sClosingBracket +
62
) . $sElementContent; +
63
return $oElement->getOption('disable-twb') ? $sElementContent : sprintf(self::$checkboxFormat, $sElementContent);
64
}
65
66
@@ -202,7 +202,7 @@
70
*/
71
protected function getLabelHelper()
72
{ -
73
if ($this->labelHelper) return $this->labelHelper; +
73
if ($this->labelHelper) return $this->labelHelper;
74
if (method_exists($this->view, 'plugin')) $this->labelHelper = $this->view->plugin('form_label');
75
if (!($this->labelHelper instanceof \Zend\Form\View\Helper\FormLabel)) $this->labelHelper = new \Zend\Form\View\Helper\FormLabel();
76
if ($this->hasTranslator()) $this->labelHelper->setTranslator($this->getTranslator(), $this->getTranslatorTextDomain()); @@ -219,7 +219,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormCollection.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormCollection.php.html index e0f5f8f..8b03312 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormCollection.php.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormCollection.php.html @@ -65,7 +65,7 @@
100.00%
-
46 / 46
+
48 / 48
@@ -82,30 +82,30 @@
100.00%
1 / 1
- 17 + 19
100.00%
-
46 / 46
+
48 / 48
-  render(\Zend\Form\ElementInterface $oElement) +  render(\Zend\Form\ElementInterface $oElement)
100.00%
1 / 1
- 17 + 19
100.00%
-
46 / 46
+
48 / 48
@@ -114,91 +114,97 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php
namespace TwbBundle\Form\View\Helper;
class TwbBundleFormCollection extends \Zend\Form\View\Helper\FormCollection{
namespace TwbBundle\Form\View\Helper;
/**
* @var string
*/
private static $legendFormat = '<legend %s>%s</legend>';
/**
* @var string
*/
private static $fieldsetFormat = '<fieldset %s>%s</fieldset>';
/**
* Attributes valid for the tag represented by this helper
* @var array
*/
protected $validTagAttributes = array(
'disabled' => true
);
/**
* Render a collection by iterating through all fieldsets and elements
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(\Zend\Form\ElementInterface $oElement){
$oRenderer = $this->getView();
if(!method_exists($oRenderer, 'plugin'))return '';
$sMarkup = '';
$sElementLayout = $oElement->getOption('twb-layout');
if($oElement instanceof \IteratorAggregate){
$oElementHelper = $this->getElementHelper();
$oFieldsetHelper = $this->getFieldsetHelper();
class TwbBundleFormCollection extends \Zend\Form\View\Helper\FormCollection {
/**
* @var string
*/
private static $legendFormat = '<legend%s>%s</legend>';
/**
* @var string
*/
private static $fieldsetFormat = '<fieldset%s>%s</fieldset>';
/**
* Attributes valid for the tag represented by this helper
* @var array
*/
protected $validTagAttributes = array(
'disabled' => true
);
/**
* Render a collection by iterating through all fieldsets and elements
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(\Zend\Form\ElementInterface $oElement) {
$oRenderer = $this->getView();
if (!method_exists($oRenderer, 'plugin')) {
return '';
}
$bShouldWrap = $this->shouldWrap;
foreach($oElement->getIterator() as $oElementOrFieldset){
$aOptions = $oElementOrFieldset->getOptions();
if ($sElementLayout && empty($aOptions['twb-layout'])) {
$aOptions['twb-layout'] = $sElementLayout;
$oElementOrFieldset->setOptions($aOptions);
}
if ($oElementOrFieldset instanceof \Zend\Form\FieldsetInterface) {
$sMarkup .= $oFieldsetHelper($oElementOrFieldset);
} elseif ($oElementOrFieldset instanceof \Zend\Form\ElementInterface) {
$sMarkup .= $oElementHelper($oElementOrFieldset);
}
}
if ($oElement instanceof \Zend\Form\Element\Collection && $oElement->shouldCreateTemplate()) {
$sMarkup .= $this->renderTemplate($oElement);
}
}
if($this->shouldWrap && ($sLabel = $oElement->getLabel())){
if (null !== ($oTranslator = $this->getTranslator())) {
$sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain());
}
$sMarkup = sprintf(
self::$legendFormat,
$this->createAttributesString($oElement->getLabelAttributes()?:array()),
$this->getEscapeHtmlHelper()->__invoke($sLabel)
).$sMarkup;
}
//Set form layout class
if($sElementLayout){
$sLayoutClass = 'form-'.$sElementLayout;
if ($sElementClass = $oElement->getAttribute('class')) {
if (!preg_match('/(\s|^)' . preg_quote($sLayoutClass, '/') . '(\s|$)/', $sElementClass)) {
$oElement->setAttribute('class', trim($sElementClass . ' ' . $sLayoutClass));
}
}
else {
$oElement->setAttribute('class', $sLayoutClass);
}
}
return sprintf(
self::$fieldsetFormat,
$this->createAttributesString($oElement->getAttributes()),
$sMarkup
);
}
}
$sMarkup = '';
$sElementLayout = $oElement->getOption('twb-layout');
if ($oElement instanceof \IteratorAggregate) {
$oElementHelper = $this->getElementHelper();
$oFieldsetHelper = $this->getFieldsetHelper();
foreach ($oElement->getIterator() as $oElementOrFieldset) {
$aOptions = $oElementOrFieldset->getOptions();
if ($sElementLayout && empty($aOptions['twb-layout'])) {
$aOptions['twb-layout'] = $sElementLayout;
$oElementOrFieldset->setOptions($aOptions);
}
if ($oElementOrFieldset instanceof \Zend\Form\FieldsetInterface) {
$sMarkup .= $oFieldsetHelper($oElementOrFieldset);
} elseif ($oElementOrFieldset instanceof \Zend\Form\ElementInterface) {
$sMarkup .= $oElementHelper($oElementOrFieldset);
}
}
if ($oElement instanceof \Zend\Form\Element\Collection && $oElement->shouldCreateTemplate()) {
$sMarkup .= $this->renderTemplate($oElement);
}
}
if ($bShouldWrap) {
if (($sLabel = $oElement->getLabel())) {
if (null !== ($oTranslator = $this->getTranslator())) {
$sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain());
}
$sMarkup = sprintf(
self::$legendFormat, ($sAttributes = $this->createAttributesString($oElement->getLabelAttributes()? : array())) ? ' ' . $sAttributes : '', $this->getEscapeHtmlHelper()->__invoke($sLabel)
) . $sMarkup;
}
//Set form layout class
if ($sElementLayout) {
$sLayoutClass = 'form-' . $sElementLayout;
if ($sElementClass = $oElement->getAttribute('class')) {
if (!preg_match('/(\s|^)' . preg_quote($sLayoutClass, '/') . '(\s|$)/', $sElementClass)) {
$oElement->setAttribute('class', trim($sElementClass . ' ' . $sLayoutClass));
}
} else {
$oElement->setAttribute('class', $sLayoutClass);
}
}
$sMarkup = sprintf(
self::$fieldsetFormat, ($sAttributes = $this->createAttributesString($oElement->getAttributes())) ? ' ' . $sAttributes : '', $sMarkup
);
}
return $sMarkup;
}
}
@@ -210,7 +216,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormElement.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormElement.php.html index 1e34ea6..7eebe9c 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormElement.php.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormElement.php.html @@ -65,7 +65,7 @@
100.00%
-
67 / 67
+
81 / 81
@@ -88,7 +88,7 @@
100.00%
-
67 / 67
+
81 / 81
@@ -105,11 +105,11 @@
100.00%
-
20 / 20
+
29 / 29
-  renderAddOn($aAddOnOptions) +  renderAddOn($aAddOnOptions)
@@ -122,11 +122,11 @@
100.00%
-
36 / 36
+
39 / 39
-  setTranslator(\Zend\I18n\Translator\Translator $oTranslator = null, $sTextDomain = null) +  setTranslator(\Zend\I18n\Translator\TranslatorInterface $oTranslator = null, $sTextDomain = null)
@@ -139,11 +139,11 @@
100.00%
-
3 / 3
+
5 / 5
-  getTranslator() +  getTranslator()
@@ -160,7 +160,7 @@ -  hasTranslator() +  hasTranslator()
@@ -177,7 +177,7 @@ -  setTranslatorEnabled($bEnabled = true) +  setTranslatorEnabled($bEnabled = true)
@@ -194,7 +194,7 @@ -  isTranslatorEnabled() +  isTranslatorEnabled()
@@ -211,7 +211,7 @@ -  setTranslatorTextDomain($sTextDomain = 'default') +  setTranslatorTextDomain($sTextDomain = 'default')
@@ -228,7 +228,7 @@ -  getTranslatorTextDomain() +  getTranslatorTextDomain()
@@ -250,20 +250,20 @@ - - - - - - - - - + + + + + + + + + - + @@ -288,173 +288,182 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php
namespace TwbBundle\Form\View\Helper;
class TwbBundleFormElement extends \Zend\Form\View\Helper\FormElement implements \Zend\I18n\Translator\TranslatorAwareInterface
{
/**
* @var string
*/
private static $addonFormat = '<%s class="%s">%s</%s>';
namespace TwbBundle\Form\View\Helper;
class TwbBundleFormElement extends \Zend\Form\View\Helper\FormElement implements \Zend\I18n\Translator\TranslatorAwareInterface {
/**
* @var string
*/
protected static $addonFormat = '<%s class="%s">%s</%s>';
/**
* @var string
*/
private static $inputGroupFormat = '<div class="input-group %s">%s</div>';
protected static $inputGroupFormat = '<div class="input-group %s">%s</div>';
/**
* Translator (optional)
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(\Zend\Form\ElementInterface $oElement)
{
//Add form-controll class
$sElementType = $oElement->getAttribute('type');
if (!in_array($sElementType, array('file', 'checkbox', 'radio', 'submit', 'multi_checkbox', 'static', 'button'))) {
if ($sElementClass = $oElement->getAttribute('class')) {
if (!preg_match('/(\s|^)form-control(\s|$)/', $sElementClass)) $oElement->setAttribute('class', trim($sElementClass . ' form-control'));
} else $oElement->setAttribute('class', 'form-control');
}
$sMarkup = $oElement instanceof \TwbBundle\Form\Element\StaticElement ? $this->getView()->formStatic()->render($oElement) : parent::render($oElement);
//Addon prepend
if ($aAddOnPrepend = $oElement->getOption('add-on-prepend')) $sMarkup = $this->renderAddOn($aAddOnPrepend) . $sMarkup;
public function render(\Zend\Form\ElementInterface $oElement) {
//Add form-controll class
$sElementType = $oElement->getAttribute('type');
if (!in_array($sElementType, array('file', 'checkbox', 'radio', 'submit', 'multi_checkbox', 'static', 'button', 'reset'))) {
if ($sElementClass = $oElement->getAttribute('class')) {
if (!preg_match('/(\s|^)form-control(\s|$)/', $sElementClass)) {
$oElement->setAttribute('class', trim($sElementClass . ' form-control'));
}
} else {
$oElement->setAttribute('class', 'form-control');
}
}
$sMarkup = $oElement instanceof \TwbBundle\Form\Element\StaticElement ? $this->getView()->formStatic()->render($oElement) : parent::render($oElement);
//Addon append
if ($aAddOnAppend = $oElement->getOption('add-on-append')) $sMarkup .= $this->renderAddOn($aAddOnAppend);
if ($aAddOnAppend || $aAddOnPrepend) {
$sSpecialClass = '';
//Input size
if ($sElementClass = $oElement->getAttribute('class')) {
if (preg_match('/(\s|^)input-lg(\s|$)/', $sElementClass)) $sSpecialClass .= ' input-group-lg';
elseif (preg_match('/(\s|^)input-sm(\s|$)/', $sElementClass)) $sSpecialClass .= ' input-group-sm';
}
return sprintf(
self::$inputGroupFormat,
trim($sSpecialClass),
$sMarkup
);
}
return $sMarkup;
}
/**
* Render addo-on markup
* @param string $aAddOnOptions
* @throws \InvalidArgumentException
* @throws \LogicException
* @return string
*/
protected function renderAddOn($aAddOnOptions)
{
if (empty($aAddOnOptions)) throw new \InvalidArgumentException('Addon options are empty');
if ($aAddOnOptions instanceof \Zend\Form\ElementInterface) $aAddOnOptions = array('element' => $aAddOnOptions);
elseif (is_scalar($aAddOnOptions)) $aAddOnOptions = array('text' => $aAddOnOptions);
elseif (!is_array($aAddOnOptions)) throw new \InvalidArgumentException('Addon options expects an array or a scalar value, "' . gettype($aAddOnOptions) . '" given');
$sMarkup = '';
$sAddonTagName = 'span';
$sAddonClass = '';
if (!empty($aAddOnOptions['text'])) {
if (!is_scalar($aAddOnOptions['text'])) {
throw new \LogicException('"text" option expects a scalar value, "' . gettype($aAddOnOptions['text']) . '" given');
} elseif (($oTranslator = $this->getTranslator())) {
$sMarkup .= $oTranslator->translate($aAddOnOptions['text'], $this->getTranslatorTextDomain());
} else {
$sMarkup .= $aAddOnOptions['text'];
}
$sAddonClass .= ' input-group-addon';
} elseif (!empty($aAddOnOptions['element'])) {
if (
is_array($aAddOnOptions['element'])
|| ($aAddOnOptions['element'] instanceof \Traversable && !($aAddOnOptions['element'] instanceof \Zend\Form\ElementInterface))
) {
$oFactory = new \Zend\Form\Factory();
$aAddOnOptions['element'] = $oFactory->create($aAddOnOptions['element']);
} elseif (!($aAddOnOptions['element'] instanceof \Zend\Form\ElementInterface)) {
throw new \LogicException(sprintf(
'"element" option expects an instanceof \Zend\Form\ElementInterface, "%s" given', is_object($aAddOnOptions['element']) ? get_class($aAddOnOptions['element']) : gettype($aAddOnOptions['element'])
));
//Addon prepend
if ($aAddOnPrepend = $oElement->getOption('add-on-prepend')) {
$sMarkup = $this->renderAddOn($aAddOnPrepend) . $sMarkup;
}
//Addon append
if ($aAddOnAppend = $oElement->getOption('add-on-append')) {
$sMarkup .= $this->renderAddOn($aAddOnAppend);
}
if ($aAddOnAppend || $aAddOnPrepend) {
$sSpecialClass = '';
//Input size
if ($sElementClass = $oElement->getAttribute('class')) {
if (preg_match('/(\s|^)input-lg(\s|$)/', $sElementClass)) {
$sSpecialClass .= ' input-group-lg';
} elseif (preg_match('/(\s|^)input-sm(\s|$)/', $sElementClass)) {
$sSpecialClass .= ' input-group-sm';
}
}
return sprintf(
self::$inputGroupFormat, trim($sSpecialClass), $sMarkup
);
}
return $sMarkup;
}
/**
* Render addo-on markup
* @param string $aAddOnOptions
* @throws \InvalidArgumentException
* @throws \LogicException
* @return string
*/
protected function renderAddOn($aAddOnOptions) {
if (empty($aAddOnOptions)) {
throw new \InvalidArgumentException('Addon options are empty');
}
if ($aAddOnOptions instanceof \Zend\Form\ElementInterface) {
$aAddOnOptions = array('element' => $aAddOnOptions);
} elseif (is_scalar($aAddOnOptions)) {
$aAddOnOptions = array('text' => $aAddOnOptions);
} elseif (!is_array($aAddOnOptions)) {
throw new \InvalidArgumentException('Addon options expects an array or a scalar value, "' . gettype($aAddOnOptions) . '" given');
}
$sMarkup = '';
$sAddonTagName = 'span';
$sAddonClass = '';
if (!empty($aAddOnOptions['text'])) {
if (!is_scalar($aAddOnOptions['text'])) {
throw new \LogicException('"text" option expects a scalar value, "' . gettype($aAddOnOptions['text']) . '" given');
} elseif (($oTranslator = $this->getTranslator())) {
$sMarkup .= $oTranslator->translate($aAddOnOptions['text'], $this->getTranslatorTextDomain());
} else {
$sMarkup .= $aAddOnOptions['text'];
}
$aAddOnOptions['element']->setOptions(array_merge($aAddOnOptions['element']->getOptions(), array('disable-twb' => true)));
$sMarkup .= $this->render($aAddOnOptions['element']);
if($aAddOnOptions['element'] instanceof \Zend\Form\Element\Button) {
$sAddonClass .= ' input-group-btn';
//Element contains dropdown, so add-on container must be a "div"
if ($aAddOnOptions['element']->getOption('dropdown')) {
$sAddonTagName = 'div';
}
} else {
$sAddonClass .= ' input-group-addon';
$sAddonClass .= ' input-group-addon';
} elseif (!empty($aAddOnOptions['element'])) {
if (
is_array($aAddOnOptions['element']) || ($aAddOnOptions['element'] instanceof \Traversable && !($aAddOnOptions['element'] instanceof \Zend\Form\ElementInterface))
) {
$oFactory = new \Zend\Form\Factory();
$aAddOnOptions['element'] = $oFactory->create($aAddOnOptions['element']);
} elseif (!($aAddOnOptions['element'] instanceof \Zend\Form\ElementInterface)) {
throw new \LogicException(sprintf(
'"element" option expects an instanceof \Zend\Form\ElementInterface, "%s" given', is_object($aAddOnOptions['element']) ? get_class($aAddOnOptions['element']) : gettype($aAddOnOptions['element'])
));
}
}
return sprintf(self::$addonFormat, $sAddonTagName, trim($sAddonClass), $sMarkup, $sAddonTagName);
}
/**
* Sets translator to use in helper
* @see \Zend\I18n\Translator\TranslatorAwareInterface::setTranslator()
* @param \Zend\I18n\Translator\Translator $oTranslator : [optional] translator. Default is null, which sets no translator.
* @param string $sTextDomain : [optional] text domain Default is null, which skips setTranslatorTextDomain
* @return \TwbBundle\Form\View\Helper\TwbBundleFormElement
*/
public function setTranslator(\Zend\I18n\Translator\Translator $oTranslator = null, $sTextDomain = null)
{
$this->translator = $oTranslator;
if (null !== $sTextDomain) $this->setTranslatorTextDomain($sTextDomain);
return $this;
}
/**
* Returns translator used in helper
* @see \Zend\I18n\Translator\TranslatorAwareInterface::getTranslator()
* @return null|\Zend\I18n\Translator\Translator
$aAddOnOptions['element']->setOptions(array_merge($aAddOnOptions['element']->getOptions(), array('disable-twb' => true)));
$sMarkup .= $this->render($aAddOnOptions['element']);
if ($aAddOnOptions['element'] instanceof \Zend\Form\Element\Button) {
$sAddonClass .= ' input-group-btn';
//Element contains dropdown, so add-on container must be a "div"
if ($aAddOnOptions['element']->getOption('dropdown')) {
$sAddonTagName = 'div';
}
} else {
$sAddonClass .= ' input-group-addon';
}
}
return sprintf(self::$addonFormat, $sAddonTagName, trim($sAddonClass), $sMarkup, $sAddonTagName);
}
/**
* Sets translator to use in helper
* @see \Zend\I18n\Translator\TranslatorAwareInterface::setTranslator()
* @param \Zend\I18n\Translator\TranslatorInterface $oTranslator : [optional] translator. Default is null, which sets no translator.
* @param string $sTextDomain : [optional] text domain Default is null, which skips setTranslatorTextDomain
* @return \TwbBundle\Form\View\Helper\TwbBundleFormElement
*/
public function getTranslator()
{
return $this->isTranslatorEnabled() ? $this->translator : null;
}
/**
* Checks if the helper has a translator
* @see \Zend\I18n\Translator\TranslatorAwareInterface::hasTranslator()
* @return boolean
*/
public function hasTranslator()
{
return !!$this->getTranslator();
}
/**
* Sets whether translator is enabled and should be used
* @see \Zend\I18n\Translator\TranslatorAwareInterface::setTranslatorEnabled()
* @param boolean $bEnabled
* @return \TwbBundle\Form\View\Helper\TwbBundleFormElement
*/
public function setTranslatorEnabled($bEnabled = true)
{
$this->translatorEnabled = !!$bEnabled;
return $this;
}
/**
* Returns whether translator is enabled and should be used
* @see \Zend\I18n\Translator\TranslatorAwareInterface::isTranslatorEnabled()
* @return boolean
public function setTranslator(\Zend\I18n\Translator\TranslatorInterface $oTranslator = null, $sTextDomain = null) {
$this->translator = $oTranslator;
if (null !== $sTextDomain) {
$this->setTranslatorTextDomain($sTextDomain);
}
return $this;
}
/**
* Returns translator used in helper
* @see \Zend\I18n\Translator\TranslatorAwareInterface::getTranslator()
* @return null|\Zend\I18n\Translator\TranslatorInterface
*/
public function getTranslator() {
return $this->isTranslatorEnabled() ? $this->translator : null;
}
/**
* Checks if the helper has a translator
* @see \Zend\I18n\Translator\TranslatorAwareInterface::hasTranslator()
* @return boolean
*/
public function hasTranslator() {
return !!$this->getTranslator();
}
/**
* Sets whether translator is enabled and should be used
* @see \Zend\I18n\Translator\TranslatorAwareInterface::setTranslatorEnabled()
* @param boolean $bEnabled
* @return \TwbBundle\Form\View\Helper\TwbBundleFormElement
*/
public function isTranslatorEnabled()
{
return $this->translatorEnabled;
public function setTranslatorEnabled($bEnabled = true) {
$this->translatorEnabled = !!$bEnabled;
return $this;
}
/**
* Set translation text domain
* @see \Zend\I18n\Translator\TranslatorAwareInterface::setTranslatorTextDomain()
* @param string $sTextDomain
* @return \TwbBundle\Form\View\Helper\TwbBundleFormElement
*/
public function setTranslatorTextDomain($sTextDomain = 'default')
{
$this->translatorTextDomain = $sTextDomain;
return $this;
}
/**
* Return the translation text domain
* @see \Zend\I18n\Translator\TranslatorAwareInterface::getTranslatorTextDomain()
* @return string
*/
public function getTranslatorTextDomain()
{
return $this->translatorTextDomain;
}
* Returns whether translator is enabled and should be used
* @see \Zend\I18n\Translator\TranslatorAwareInterface::isTranslatorEnabled()
* @return boolean
*/
public function isTranslatorEnabled() {
return $this->translatorEnabled;
}
/**
* Set translation text domain
* @see \Zend\I18n\Translator\TranslatorAwareInterface::setTranslatorTextDomain()
* @param string $sTextDomain
* @return \TwbBundle\Form\View\Helper\TwbBundleFormElement
*/
public function setTranslatorTextDomain($sTextDomain = 'default') {
$this->translatorTextDomain = $sTextDomain;
return $this;
}
/**
* Return the translation text domain
* @see \Zend\I18n\Translator\TranslatorAwareInterface::getTranslatorTextDomain()
* @return string
*/
public function getTranslatorTextDomain() {
return $this->translatorTextDomain;
}
}
@@ -466,7 +475,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormElementErrors.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormElementErrors.php.html index ee8543e..39d7ce6 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormElementErrors.php.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormElementErrors.php.html @@ -101,7 +101,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormErrors.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormErrors.php.html new file mode 100644 index 0000000..05bdca4 --- /dev/null +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormErrors.php.html @@ -0,0 +1,240 @@ + + + + + Code Coverage for C:\Users\neilime\Documents\NetBeansProjects\zf2-twb-bundle/src/TwbBundle/Form/View/Helper/TwbBundleFormErrors.php + + + + + + + +
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
+
+
+
100.00%
1 / 1
+
+
+
100.00%
3 / 3
CRAP
+
+
+
100.00%
22 / 22
TwbBundleFormErrors
+
+
+
100.00%
1 / 1
+
+
+
100.00%
3 / 3
10
+
+
+
100.00%
22 / 22
 __invoke(\Zend\Form\FormInterface $oForm = null, $sMessage = null, $bDismissable = false)
+
+
+
100.00%
1 / 1
5
+
+
+
100.00%
8 / 8
 render(\Zend\Form\FormInterface $oForm, $sMessage, $bDismissable = false)
+
+
+
100.00%
1 / 1
4
+
+
+
100.00%
13 / 13
 dangerAlert($content, $bDismissable = false)
+
+
+
100.00%
1 / 1
1
+
+
+
100.00%
1 / 1
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php
namespace TwbBundle\Form\View\Helper;
class TwbBundleFormErrors extends \Zend\Form\View\Helper\AbstractHelper {
protected $defaultErrorText = 'There were errors in the form submission';
protected $messageOpenFormat = '<h4>%s</h4><ul><li>';
protected $messageCloseString = '</li></ul>';
protected $messageSeparatorString = '</li><li>';
/**
* Invoke as function
* @param \Zend\Form\FormInterface $oForm
* @param string $sMessage
* @param string $bDismissable
* @return string|null
*/
public function __invoke(\Zend\Form\FormInterface $oForm = null, $sMessage = null, $bDismissable = false) {
if (!$oForm) {
return $this;
}
if (!$sMessage) {
$sMessage = $this->defaultErrorText;
}
if ($oForm->hasValidated() && !$oForm->isValid()) {
return $this->render($oForm, $sMessage, $bDismissable);
}
return null;
}
/**
* Renders the error messages.
* @param \Zend\Form\FormInterface $oForm
* @return string
*/
public function render(\Zend\Form\FormInterface $oForm, $sMessage, $bDismissable = false) {
$errorHtml = sprintf($this->messageOpenFormat, $sMessage);
$sMessagesArray = array();
foreach ($oForm->getMessages() as $fieldName => $sMessages) {
foreach ($sMessages as $sMessage) {
if ($oForm->get($fieldName)->getAttribute('id')) {
$sMessagesArray[] = sprintf(
'<a href="#%s">%s</a>', $oForm->get($fieldName)->getAttribute('id'), $oForm->get($fieldName)->getLabel() . ': ' . $sMessage
);
} else {
$sMessagesArray[] = $oForm->get($fieldName)->getLabel() . ': ' . $sMessage;
}
}
}
return $this->dangerAlert($errorHtml . implode($this->messageSeparatorString, $sMessagesArray) . $this->messageCloseString, $bDismissable);
}
/**
* Creates and returns a "danger" alert.
* @param string $content
* @param boolean $bDismissable
* @return string
*/
public function dangerAlert($content, $bDismissable = false) {
return $this->getView()->alert($content, array('class' => 'alert-danger'), $bDismissable);
}
}
+ +
+ + + + + diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormMultiCheckbox.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormMultiCheckbox.php.html index ec44107..886c100 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormMultiCheckbox.php.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormMultiCheckbox.php.html @@ -145,7 +145,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormRadio.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormRadio.php.html index 1da7c96..42977db 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormRadio.php.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormRadio.php.html @@ -65,7 +65,7 @@
100.00%
-
42 / 42
+
57 / 57
@@ -88,11 +88,11 @@
100.00%
-
42 / 42
+
57 / 57
-  render(\Zend\Form\ElementInterface $oElement) +  render(\Zend\Form\ElementInterface $oElement)
@@ -109,7 +109,7 @@ -  renderOptions(\Zend\Form\Element\MultiCheckbox $oElement, array $aOptions, array $aSelectedOptions,array $aAttributes) +  renderOptions(\Zend\Form\Element\MultiCheckbox $oElement, array $aOptions, array $aSelectedOptions, array $aAttributes)
@@ -122,7 +122,7 @@
100.00%
-
35 / 35
+
50 / 50
@@ -131,94 +131,115 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php
namespace TwbBundle\Form\View\Helper;
class TwbBundleFormRadio extends \Zend\Form\View\Helper\FormRadio{
/**
* Separator for checkbox elements
*
* @var string
*/
protected $separator = '</div><div class="radio">';
/**
* @var string
*/
private static $checkboxFormat = '<div class="radio">%s</div>';
/**
* @see \Zend\Form\View\Helper\FormRadio::render()
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(\Zend\Form\ElementInterface $oElement){
if($oElement->getOption('disable-twb')){
$sSeparator = $this->separator;
$this->separator = '';
$sReturn = parent::render($oElement);
$this->separator = $sSeparator;
return $sReturn;
}
return sprintf(self::$checkboxFormat,parent::render($oElement));
}
/**
* @see \Zend\Form\View\Helper\FormMultiCheckbox::renderOptions()
* @param \Zend\Form\Element\MultiCheckbox $oElement
* @param array $aOptions
* @param array $aSelectedOptions
* @param array $aAttributes
* @return string
*/
protected function renderOptions(\Zend\Form\Element\MultiCheckbox $oElement, array $aOptions, array $aSelectedOptions,array $aAttributes){
$iIterator = 0;
$aGlobalLabelAttributes = $oElement->getLabelAttributes()?:$this->labelAttributes;
$sMarkup = '';
$oLabelHelper = $this->getLabelHelper();
foreach($aOptions as $key => $aOptionspec){
if(is_scalar($aOptionspec))$aOptionspec = array('label' => $aOptionspec,'value' => $key);
$iIterator++;
if($iIterator > 1 && array_key_exists('id', $aAttributes))unset($aAttributes['id']);
//Option attributes
$aInputAttributes = $aAttributes;
if(isset($aOptionspec['attributes']))$aInputAttributes = array_merge($aInputAttributes, $aOptionspec['attributes']);
//Option value
$aInputAttributes['value'] = isset($aOptionspec['value'])?$aOptionspec['value']:'';
//Selected option
if(in_array($aInputAttributes['value'], $aSelectedOptions))$aInputAttributes['checked'] = true;
elseif(isset($aOptionspec['selected']))$aInputAttributes['checked'] = !!$aOptionspec['selected'];
else $aInputAttributes['checked'] = isset($aInputAttributes['selected']) && $aInputAttributes['type'] != 'radio' && $aInputAttributes['selected'] != false;
namespace TwbBundle\Form\View\Helper;
class TwbBundleFormRadio extends \Zend\Form\View\Helper\FormRadio {
/**
* Separator for checkbox elements
* @var string
*/
protected $separator = '</div><div class="radio">';
/**
* @var string
*/
private static $checkboxFormat = '<div class="radio">%s</div>';
/**
* @see \Zend\Form\View\Helper\FormRadio::render()
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(\Zend\Form\ElementInterface $oElement) {
if ($oElement->getOption('disable-twb')) {
$sSeparator = $this->separator;
$this->separator = '';
$sReturn = parent::render($oElement);
$this->separator = $sSeparator;
return $sReturn;
}
return sprintf(self::$checkboxFormat, parent::render($oElement));
}
/**
* @see \Zend\Form\View\Helper\FormMultiCheckbox::renderOptions()
* @param \Zend\Form\Element\MultiCheckbox $oElement
* @param array $aOptions
* @param array $aSelectedOptions
* @param array $aAttributes
* @return string
*/
protected function renderOptions(\Zend\Form\Element\MultiCheckbox $oElement, array $aOptions, array $aSelectedOptions, array $aAttributes) {
$iIterator = 0;
$aGlobalLabelAttributes = $oElement->getLabelAttributes()? : $this->labelAttributes;
$sMarkup = '';
$oLabelHelper = $this->getLabelHelper();
foreach ($aOptions as $key => $aOptionspec) {
if (is_scalar($aOptionspec)) {
$aOptionspec = array('label' => $aOptionspec, 'value' => $key);
}
$iIterator++;
if ($iIterator > 1 && array_key_exists('id', $aAttributes)) {
unset($aAttributes['id']);
}
//Option attributes
$aInputAttributes = $aAttributes;
if (isset($aOptionspec['attributes'])) {
$aInputAttributes = \Zend\Stdlib\ArrayUtils::merge($aInputAttributes, $aOptionspec['attributes']);
}
//Disabled option
if(isset($aOptionspec['disabled']))$aInputAttributes['disabled'] = !!$aOptionspec['disabled'];
else $aInputAttributes['disabled'] = isset($aInputAttributes['disabled']) && $aInputAttributes['disabled'] != false;
//Render option
$sOptionMarkup = sprintf('<input %s%s',$this->createAttributesString($aInputAttributes),$this->getInlineClosingBracket());
//Option label
$sLabel = isset($aOptionspec['label'])?$aOptionspec['label']:'';
if($sLabel){
$aLabelAttributes = $aGlobalLabelAttributes;
if(isset($aOptionspec['label_attributes']))$aLabelAttributes = isset($aLabelAttributes)?array_merge($aLabelAttributes,$aOptionspec['label_attributes']):$aOptionspec['label_attributes'];
if(null !== ($oTranslator = $this->getTranslator()))$sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain());
switch($this->getLabelPosition()){
case self::LABEL_PREPEND:
$sOptionMarkup = sprintf($oLabelHelper->openTag($aLabelAttributes).'%s%s'.$oLabelHelper->closeTag(), $this->getEscapeHtmlHelper()->__invoke($sLabel), $sOptionMarkup);
break;
case self::LABEL_APPEND:
default:
$sOptionMarkup = sprintf($oLabelHelper->openTag($aLabelAttributes).'%s%s'.$oLabelHelper->closeTag(), $sOptionMarkup, $this->getEscapeHtmlHelper()->__invoke($sLabel));
break;
}
}
$sMarkup .= ($sMarkup?$this->getSeparator():'').$sOptionMarkup;
}
return $sMarkup;
}
//Option value
$aInputAttributes['value'] = isset($aOptionspec['value']) ? $aOptionspec['value'] : '';
//Selected option
if (in_array($aInputAttributes['value'], $aSelectedOptions)) {
$aInputAttributes['checked'] = true;
} elseif (isset($aOptionspec['selected'])) {
$aInputAttributes['checked'] = !!$aOptionspec['selected'];
} else {
$aInputAttributes['checked'] = isset($aInputAttributes['selected']) && $aInputAttributes['type'] !== 'radio' && $aInputAttributes['selected'] != false;
}
//Disabled option
if (isset($aOptionspec['disabled'])) {
$aInputAttributes['disabled'] = !!$aOptionspec['disabled'];
} else {
$aInputAttributes['disabled'] = isset($aInputAttributes['disabled']) && $aInputAttributes['disabled'] != false;
}
//Render option
$sOptionMarkup = sprintf('<input %s%s', $this->createAttributesString($aInputAttributes), $this->getInlineClosingBracket());
//Option label
$sLabel = isset($aOptionspec['label']) ? $aOptionspec['label'] : '';
if ($sLabel) {
$aLabelAttributes = $aGlobalLabelAttributes;
if (isset($aOptionspec['label_attributes'])) {
$aLabelAttributes = isset($aLabelAttributes) ? array_merge($aLabelAttributes, $aOptionspec['label_attributes']) : $aOptionspec['label_attributes'];
}
if (null !== ($oTranslator = $this->getTranslator())) {
$sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain());
}
switch ($this->getLabelPosition()) {
case self::LABEL_PREPEND:
$sOptionMarkup = sprintf($oLabelHelper->openTag($aLabelAttributes) . '%s%s' . $oLabelHelper->closeTag(), $this->getEscapeHtmlHelper()->__invoke($sLabel), $sOptionMarkup);
break;
case self::LABEL_APPEND:
default:
$sOptionMarkup = sprintf($oLabelHelper->openTag($aLabelAttributes) . '%s%s' . $oLabelHelper->closeTag(), $sOptionMarkup, $this->getEscapeHtmlHelper()->__invoke($sLabel));
break;
}
}
$sMarkup .= ($sMarkup ? $this->getSeparator() : '') . $sOptionMarkup;
}
return $sMarkup;
}
}
@@ -230,7 +251,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormRow.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormRow.php.html index 8c7f59b..1216f3f 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormRow.php.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormRow.php.html @@ -65,7 +65,7 @@
100.00%
-
114 / 114
+
120 / 120
@@ -82,34 +82,34 @@
100.00%
4 / 4
- 47 + 50
100.00%
-
114 / 114
+
120 / 120
-  render(\Zend\Form\ElementInterface $oElement) +  render(\Zend\Form\ElementInterface $oElement)
100.00%
1 / 1
- 15 + 17
100.00%
-
39 / 39
+
41 / 41
-  renderLabel(\Zend\Form\ElementInterface $oElement) +  renderLabel(\Zend\Form\ElementInterface $oElement)
@@ -126,24 +126,24 @@ -  renderElement(\Zend\Form\ElementInterface $oElement) +  renderElement(\Zend\Form\ElementInterface $oElement)
100.00%
1 / 1
- 26 + 27
100.00%
-
67 / 67
+
72 / 72
-  renderHelpBlock(\Zend\Form\ElementInterface $oElement) +  renderHelpBlock(\Zend\Form\ElementInterface $oElement)
@@ -156,7 +156,7 @@
100.00%
-
4 / 4
+
3 / 3
@@ -165,242 +165,248 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php
namespace TwbBundle\Form\View\Helper;
class TwbBundleFormRow extends \Zend\Form\View\Helper\FormRow
{
/**
* @var string
*/
private static $formGroupFormat = '<div class="form-group %s">%s</div>';
/**
* @var string
*/
private static $horizontalLayoutFormat = '%s<div class="%s">%s</div>';
/**
* @var string
*/
private static $helpBlockFormat = '<p class="help-block">%s</p>';
/**
* The class that is added to element that have errors
* @var string
*/
protected $inputErrorClass = '';
/**
* @see \Zend\Form\View\Helper\FormRow::render()
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(\Zend\Form\ElementInterface $oElement)
{
$sElementType = $oElement->getAttribute('type');
namespace TwbBundle\Form\View\Helper;
class TwbBundleFormRow extends \Zend\Form\View\Helper\FormRow {
/**
* @var string
*/
private static $formGroupFormat = '<div class="form-group %s">%s</div>';
/**
* @var string
*/
private static $horizontalLayoutFormat = '%s<div class="%s">%s</div>';
/**
* @var string
*/
private static $helpBlockFormat = '<p class="help-block">%s</p>';
/**
* The class that is added to element that have errors
* @var string
*/
protected $inputErrorClass = '';
/**
* @see \Zend\Form\View\Helper\FormRow::render()
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
public function render(\Zend\Form\ElementInterface $oElement) {
$sElementType = $oElement->getAttribute('type');
//Nothing to do for hidden elements which have no messages
if( $sElementType === 'hidden' && !$oElement->getMessages()) {
if ($sElementType === 'hidden' && !$oElement->getMessages()) {
return parent::render($oElement);
}
//Retrieve expected layout
$sLayout = $oElement->getOption('twb-layout');
$sLayout = $oElement->getOption('twb-layout');
//Partial rendering
if ($this->partial) {
if ($this->partial) {
return $this->view->render($this->partial, array(
'element' => $oElement,
'label' => $this->renderLabel($oElement),
'labelAttributes' => $this->labelAttributes,
'labelPosition' => $this->labelPosition,
'renderErrors' => $this->renderErrors,
'element' => $oElement,
'label' => $this->renderLabel($oElement),
'labelAttributes' => $this->labelAttributes,
'labelPosition' => $this->labelPosition,
'renderErrors' => $this->renderErrors,
));
}
$sRowClass = '';
$sRowClass = '';
//Validation state
if (($sValidationState = $oElement->getOption('validation-state'))) $sRowClass .= ' has-' . $sValidationState;
//"has-error" validation state case
if (count($oElement->getMessages())){
$sRowClass .= ' has-error';
//Element have errors
if ($sInputErrorClass = $this->getInputErrorClass()) {
if ($sElementClass = $oElement->getAttribute('class')) {
if (!preg_match('/(\s|^)' . preg_quote($sInputErrorClass, '/') . '(\s|$)/', $sElementClass)) {
$oElement->setAttribute('class', trim($sElementClass . ' ' . $sInputErrorClass));
}
} else $oElement->setAttribute('class', $sInputErrorClass);
}
}
//Column size
if (
($sColumSize = $oElement->getOption('column-size'))
&& (
$sLayout !== \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL
)
) {
$sRowClass .= ' col-' . $sColumSize;
}
//Render element
$sElementContent = $this->renderElement($oElement);
if (($sValidationState = $oElement->getOption('validation-state'))) {
$sRowClass .= ' has-' . $sValidationState;
}
//"has-error" validation state case
if (count($oElement->getMessages())) {
$sRowClass .= ' has-error';
//Element have errors
if ($sInputErrorClass = $this->getInputErrorClass()) {
if ($sElementClass = $oElement->getAttribute('class')) {
if (!preg_match('/(\s|^)' . preg_quote($sInputErrorClass, '/') . '(\s|$)/', $sElementClass)) {
$oElement->setAttribute('class', trim($sElementClass . ' ' . $sInputErrorClass));
}
} else {
$oElement->setAttribute('class', $sInputErrorClass);
}
}
}
//Column size
if (
($sColumSize = $oElement->getOption('column-size')) && (
$sLayout !== \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL
)
) {
$sRowClass .= ' col-' . $sColumSize;
}
//Render form row
if (in_array($sElementType, array('checkbox')) && $sLayout !== \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL) {
return $sElementContent . PHP_EOL;
}
if ($sElementType === 'submit' && $sLayout === \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE) {
return $sElementContent . PHP_EOL;
//Render element
$sElementContent = $this->renderElement($oElement);
//Render form row
if (in_array($sElementType, array('checkbox')) && $sLayout !== \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL) {
return $sElementContent . PHP_EOL;
}
return sprintf(
self::$formGroupFormat,
$sRowClass,
$sElementContent
) . PHP_EOL;
}
/**
* Render element's label
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
protected function renderLabel(\Zend\Form\ElementInterface $oElement)
{
if (($sLabel = $oElement->getLabel()) && ($oTranslator = $this->getTranslator())) {
$sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain());
}
return $sLabel;
}
/**
* Render element
* @param \Zend\Form\ElementInterface $oElement
* @throws \DomainException
* @return string
*/
protected function renderElement(\Zend\Form\ElementInterface $oElement)
{
if (($sElementType === 'submit' || $sElementType === 'button' || $sElementType === 'reset') && $sLayout === \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE
) {
return $sElementContent . PHP_EOL;
}
return sprintf(
self::$formGroupFormat, $sRowClass, $sElementContent
) . PHP_EOL;
}
/**
* Render element's label
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
protected function renderLabel(\Zend\Form\ElementInterface $oElement) {
if (($sLabel = $oElement->getLabel()) && ($oTranslator = $this->getTranslator())) {
$sLabel = $oTranslator->translate($sLabel, $this->getTranslatorTextDomain());
}
return $sLabel;
}
/**
* Render element
* @param \Zend\Form\ElementInterface $oElement
* @throws \DomainException
* @return string
*/
protected function renderElement(\Zend\Form\ElementInterface $oElement) {
//Retrieve expected layout
$sLayout = $oElement->getOption('twb-layout');
$sLayout = $oElement->getOption('twb-layout');
//Render label
$sLabelOpen = $sLabelClose = $sLabelContent = '';
if ($sLabelContent = $this->renderLabel($oElement)) {
$sLabelOpen = $sLabelClose = $sLabelContent = $sElementType = '';
if ($sLabelContent = $this->renderLabel($oElement)) {
//Multicheckbox elements have to be handled differently as the HTML standard does not allow nested labels. The semantic way is to group them inside a fieldset
$sElementType = $oElement->getAttribute('type');
$sElementType = $oElement->getAttribute('type');
//Checkbox & radio elements are a special case, because label is rendered by their own helper
if ($sElementType === 'checkbox') {
if (!$oElement->getLabelAttributes() && $this->labelAttributes) $oElement->setLabelAttributes($this->labelAttributes);
//Render element input
if ($sLayout !== \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL) {
return $this->getElementHelper()->render($oElement);
}
}
//Button element is a special case, because label is always rendered inside it
elseif ($oElement instanceof \Zend\Form\Element\Button) {
$sLabelContent = '';
} else {
$aLabelAttributes = $oElement->getLabelAttributes() ? : $this->labelAttributes;
//Validation state
if ($oElement->getOption('validation-state') || count($oElement->getMessages())) {
if (empty($aLabelAttributes['class'])) {
$aLabelAttributes['class'] = 'control-label';
} elseif (!preg_match('/(\s|^)control-label(\s|$)/', $aLabelAttributes['class'])) {
$aLabelAttributes['class'] = trim($aLabelAttributes['class'] . ' control-label');
}
}
$oLabelHelper = $this->getLabelHelper();
switch ($sLayout) {
//Hide label for "inline" layout
case \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE:
if (empty($aLabelAttributes['class'])) {
$aLabelAttributes['class'] = 'sr-only';
} elseif (!preg_match('/(\s|^)sr-only(\s|$)/', $aLabelAttributes['class'])) {
$aLabelAttributes['class'] = trim($aLabelAttributes['class'] . ' sr-only');
}
break;
case \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL:
if (empty($aLabelAttributes['class'])) {
$aLabelAttributes['class'] = 'control-label';
} else {
if (!preg_match('/(\s|^)control-label(\s|$)/', $aLabelAttributes['class'])) {
$aLabelAttributes['class'] = trim($aLabelAttributes['class'] . ' control-label');
}
}
break;
}
if ($aLabelAttributes) {
$oElement->setLabelAttributes($aLabelAttributes);
}
$sLabelOpen = $oLabelHelper->openTag($oElement->getAttribute('id') ? $oElement : $aLabelAttributes);
$sLabelClose = $oLabelHelper->closeTag();
$sLabelContent = $this->getEscapeHtmlHelper()->__invoke($sLabelContent);
}
}
switch ($sLayout) {
case null:
case \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE:
$sElementContent = $sLabelOpen . $sLabelContent . $sLabelClose . $this->getElementHelper()->render($oElement) . $this->renderHelpBlock($oElement);
//Render errors
if ($this->renderErrors) {
$sElementContent .= $this->getElementErrorsHelper()->render($oElement);
}
return $sElementContent;
case \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL:
$sElementContent = $this->getElementHelper()->render($oElement) . $this->renderHelpBlock($oElement);
if ($sElementType === 'checkbox') {
if (!$oElement->getLabelAttributes() && $this->labelAttributes) {
$oElement->setLabelAttributes($this->labelAttributes);
}
//Render element input
if ($sLayout !== \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL) {
return $this->getElementHelper()->render($oElement);
}
$sLabelContent = '';
}
//Button element is a special case, because label is always rendered inside it
elseif ($oElement instanceof \Zend\Form\Element\Button) {
$sLabelContent = '';
} else {
$aLabelAttributes = $oElement->getLabelAttributes() ? : $this->labelAttributes;
//Validation state
if ($oElement->getOption('validation-state') || count($oElement->getMessages())) {
if (empty($aLabelAttributes['class'])) {
$aLabelAttributes['class'] = 'control-label';
} elseif (!preg_match('/(\s|^)control-label(\s|$)/', $aLabelAttributes['class'])) {
$aLabelAttributes['class'] = trim($aLabelAttributes['class'] . ' control-label');
}
}
$oLabelHelper = $this->getLabelHelper();
switch ($sLayout) {
//Hide label for "inline" layout
case \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE:
if (empty($aLabelAttributes['class'])) {
$aLabelAttributes['class'] = 'sr-only';
} elseif (!preg_match('/(\s|^)sr-only(\s|$)/', $aLabelAttributes['class'])) {
$aLabelAttributes['class'] = trim($aLabelAttributes['class'] . ' sr-only');
}
break;
case \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL:
if (empty($aLabelAttributes['class'])) {
$aLabelAttributes['class'] = 'control-label';
} else {
if (!preg_match('/(\s|^)control-label(\s|$)/', $aLabelAttributes['class'])) {
$aLabelAttributes['class'] = trim($aLabelAttributes['class'] . ' control-label');
}
}
break;
}
if ($aLabelAttributes) {
$oElement->setLabelAttributes($aLabelAttributes);
}
$sLabelOpen = $oLabelHelper->openTag($oElement->getAttribute('id') ? $oElement : $aLabelAttributes);
$sLabelClose = $oLabelHelper->closeTag();
$sLabelContent = $this->getEscapeHtmlHelper()->__invoke($sLabelContent);
}
}
switch ($sLayout) {
case null:
case \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_INLINE:
$sElementContent = $sLabelOpen . $sLabelContent . $sLabelClose . $this->getElementHelper()->render($oElement) . $this->renderHelpBlock($oElement);
//Render errors
if ($this->renderErrors) {
$sElementContent .= $this->getElementErrorsHelper()->render($oElement);
}
return $sElementContent;
//Render errors
if ($this->renderErrors) {
$sElementContent .= $this->getElementErrorsHelper()->render($oElement);
}
$sClass = '';
//Column size
if ($sColumSize = $oElement->getOption('column-size')) {
$sClass .= ' col-' . $sColumSize;
}
return sprintf(
self::$horizontalLayoutFormat,
$sLabelOpen . $sLabelContent . $sLabelClose,
$sClass,
$sElementContent
);
default:
throw new \DomainException('Layout "' . $sLayout . '" is not valid');
}
}
/**
* Render element's help block
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
protected function renderHelpBlock(\Zend\Form\ElementInterface $oElement)
{
return ($sHelpBlock = $oElement->getOption('help-block')) ? sprintf(
self::$helpBlockFormat,
$this->getEscapeHtmlHelper()->__invoke(($oTranslator = $this->getTranslator()) ? $oTranslator->translate($sHelpBlock, $this->getTranslatorTextDomain()) : $sHelpBlock)
) : '';
}
}
case \TwbBundle\Form\View\Helper\TwbBundleForm::LAYOUT_HORIZONTAL:
$sElementContent = $this->getElementHelper()->render($oElement) . $this->renderHelpBlock($oElement);
//Render errors
if ($this->renderErrors) {
$sElementContent .= $this->getElementErrorsHelper()->render($oElement);
}
$sClass = '';
//Column size
if ($sColumSize = $oElement->getOption('column-size')) {
$sClass .= ' col-' . $sColumSize;
}
// Checkbox elements are a special case. They don't need to render a label again
if ($sElementType === 'checkbox') {
return sprintf(
self::$horizontalLayoutFormat, '', $sClass, $sElementContent
);
}
return sprintf(
self::$horizontalLayoutFormat, $sLabelOpen . $sLabelContent . $sLabelClose, $sClass, $sElementContent
);
default:
throw new \DomainException('Layout "' . $sLayout . '" is not valid');
}
}
/**
* Render element's help block
* @param \Zend\Form\ElementInterface $oElement
* @return string
*/
protected function renderHelpBlock(\Zend\Form\ElementInterface $oElement) {
return ($sHelpBlock = $oElement->getOption('help-block')) ? sprintf(
self::$helpBlockFormat, $this->getEscapeHtmlHelper()->__invoke(($oTranslator = $this->getTranslator()) ? $oTranslator->translate($sHelpBlock, $this->getTranslatorTextDomain()) : $sHelpBlock)
) : '';
}
}
@@ -412,7 +418,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormStatic.php.html b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormStatic.php.html index 0af4c70..f461ffb 100644 --- a/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormStatic.php.html +++ b/tests/_report/src_TwbBundle_Form_View_Helper_TwbBundleFormStatic.php.html @@ -140,7 +140,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_View.dashboard.html b/tests/_report/src_TwbBundle_View.dashboard.html index 59c7bde..87ac6f4 100644 --- a/tests/_report/src_TwbBundle_View.dashboard.html +++ b/tests/_report/src_TwbBundle_View.dashboard.html @@ -55,7 +55,7 @@

Least Tested Methods

@@ -114,7 +114,7 @@

Least Tested Methods

} }, series: [{ - data: [[100,13,"TwbBundleAlert<\/a>"],[100,8,"TwbBundleBadge<\/a>"],[100,58,"TwbBundleDropDown<\/a>"],[100,9,"TwbBundleGlyphicon<\/a>"],[100,12,"TwbBundleLabel<\/a>"]], + data: [[100,15,"TwbBundleAlert<\/a>"],[100,8,"TwbBundleBadge<\/a>"],[100,58,"TwbBundleDropDown<\/a>"],[100,9,"TwbBundleGlyphicon<\/a>"],[100,12,"TwbBundleLabel<\/a>"]], marker: { symbol: 'diamond' } diff --git a/tests/_report/src_TwbBundle_View.html b/tests/_report/src_TwbBundle_View.html index 44dfcdf..7a2acae 100644 --- a/tests/_report/src_TwbBundle_View.html +++ b/tests/_report/src_TwbBundle_View.html @@ -50,7 +50,7 @@
100.00%
-
167 / 167
+
168 / 168
@@ -72,7 +72,7 @@
100.00%
-
167 / 167
+
168 / 168
@@ -98,7 +98,7 @@

Legend

High: 70% to 100%

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_View_Helper.dashboard.html b/tests/_report/src_TwbBundle_View_Helper.dashboard.html index 4e120bf..c82481a 100644 --- a/tests/_report/src_TwbBundle_View_Helper.dashboard.html +++ b/tests/_report/src_TwbBundle_View_Helper.dashboard.html @@ -56,7 +56,7 @@

Least Tested Methods

@@ -115,7 +115,7 @@

Least Tested Methods

} }, series: [{ - data: [[100,13,"TwbBundleAlert<\/a>"],[100,8,"TwbBundleBadge<\/a>"],[100,58,"TwbBundleDropDown<\/a>"],[100,9,"TwbBundleGlyphicon<\/a>"],[100,12,"TwbBundleLabel<\/a>"]], + data: [[100,15,"TwbBundleAlert<\/a>"],[100,8,"TwbBundleBadge<\/a>"],[100,58,"TwbBundleDropDown<\/a>"],[100,9,"TwbBundleGlyphicon<\/a>"],[100,12,"TwbBundleLabel<\/a>"]], marker: { symbol: 'diamond' } diff --git a/tests/_report/src_TwbBundle_View_Helper.html b/tests/_report/src_TwbBundle_View_Helper.html index 8253646..1ff5783 100644 --- a/tests/_report/src_TwbBundle_View_Helper.html +++ b/tests/_report/src_TwbBundle_View_Helper.html @@ -51,7 +51,7 @@
100.00%
-
167 / 167
+
168 / 168
@@ -73,7 +73,7 @@
100.00%
-
18 / 18
+
19 / 19
@@ -187,7 +187,7 @@

Legend

High: 70% to 100%

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_View_Helper_TwbBundleAlert.php.html b/tests/_report/src_TwbBundle_View_Helper_TwbBundleAlert.php.html index 799f215..d910c0d 100644 --- a/tests/_report/src_TwbBundle_View_Helper_TwbBundleAlert.php.html +++ b/tests/_report/src_TwbBundle_View_Helper_TwbBundleAlert.php.html @@ -64,7 +64,7 @@
100.00%
-
18 / 18
+
19 / 19
@@ -81,13 +81,13 @@
100.00%
2 / 2
- 13 + 15
100.00%
-
18 / 18
+
19 / 19
@@ -98,17 +98,17 @@
100.00%
1 / 1
- 2 + 4
100.00%
-
2 / 2
+
3 / 3
-  render($sAlertMessage, $aAlertAttributes = null, $bDismissable = false) +  render($sAlertMessage, $aAlertAttributes = null, $bDismissable = false)
@@ -150,40 +150,42 @@
19
* @return string|\TwbBundle\View\Helper\TwbBundleAlert
20
*/
21
public function __invoke($sAlertMessage = null, $aAlertAttributes = null, $bDismissable = false){ -
22
if(!$sAlertMessage)return $this; -
23
return $this->render($sAlertMessage,$aAlertAttributes,$bDismissable); -
24
} -
25
-
26
/** -
27
* Retrieve alert markup -
28
* @param string $sAlertMessage -
29
* @param string|array $aAlertAttributes : [optionnal] if string, alert class -
30
* @param boolean $bDismissable -
31
* @throws \InvalidArgumentException -
32
* @return string -
33
*/ -
34
public function render($sAlertMessage, $aAlertAttributes = null, $bDismissable = false){ -
35
if(!is_scalar($sAlertMessage))throw new \InvalidArgumentException('Alert message expects a scalar value, "'.gettype($sAlertMessage).'" given'); -
36
if(empty($aAlertAttributes))$aAlertAttributes = array('class' => 'alert'); -
37
elseif(is_string($aAlertAttributes))$aAlertAttributes = array('class' => $aAlertAttributes); -
38
elseif(!is_array($aAlertAttributes))throw new \InvalidArgumentException('Alert attributes expects a string or an array, "'.gettype($aAlertAttributes).'" given'); -
39
elseif(empty($aAlertAttributes['class']))throw new \InvalidArgumentException('Alert "class" attribute is empty'); -
40
elseif(!is_string($aAlertAttributes['class']))throw new \InvalidArgumentException('Alert "class" attribute expects string, "'.gettype($aAlertAttributes).'" given'); -
41
-
42
if(!preg_match('/(\s|^)alert(\s|$)/',$aAlertAttributes['class']))$aAlertAttributes['class'] .= ' alert'; -
43
if(null !== ($oTranslator = $this->getTranslator()))$sAlertMessage = $oTranslator->translate($sAlertMessage, $this->getTranslatorTextDomain()); -
44
-
45
if($bDismissable){ -
46
$sAlertMessage .= self::$dismissButtonFormat; -
47
if(!preg_match('/(\s|^)alert-dismissable(\s|$)/',$aAlertAttributes['class']))$aAlertAttributes['class'] .= ' alert-dismissable'; -
48
} -
49
-
50
return sprintf( -
51
self::$alertFormat, -
52
$this->createAttributesString($aAlertAttributes), -
53
$sAlertMessage -
54
); -
55
} +
22
if($sAlertMessage === null) return $this; +
23
if($sAlertMessage === '' || $sAlertMessage === false) return ''; +
24
return $this->render($sAlertMessage,$aAlertAttributes,$bDismissable); +
25
} +
26
+
27
/** +
28
* Retrieve alert markup +
29
* @param string $sAlertMessage +
30
* @param string|array $aAlertAttributes : [optionnal] if string, alert class +
31
* @param boolean $bDismissable +
32
* @throws \InvalidArgumentException +
33
* @return string +
34
*/ +
35
public function render($sAlertMessage, $aAlertAttributes = null, $bDismissable = false){ +
36
if(!is_scalar($sAlertMessage))throw new \InvalidArgumentException('Alert message expects a scalar value, "'.gettype($sAlertMessage).'" given'); +
37
if(empty($aAlertAttributes))$aAlertAttributes = array('class' => 'alert'); +
38
elseif(is_string($aAlertAttributes))$aAlertAttributes = array('class' => $aAlertAttributes); +
39
elseif(!is_array($aAlertAttributes))throw new \InvalidArgumentException('Alert attributes expects a string or an array, "'.gettype($aAlertAttributes).'" given'); +
40
elseif(empty($aAlertAttributes['class']))throw new \InvalidArgumentException('Alert "class" attribute is empty'); +
41
elseif(!is_string($aAlertAttributes['class']))throw new \InvalidArgumentException('Alert "class" attribute expects string, "'.gettype($aAlertAttributes).'" given'); +
42
+
43
if(!preg_match('/(\s|^)alert(\s|$)/',$aAlertAttributes['class']))$aAlertAttributes['class'] .= ' alert'; +
44
if(null !== ($oTranslator = $this->getTranslator()))$sAlertMessage = $oTranslator->translate($sAlertMessage, $this->getTranslatorTextDomain()); +
45
+
46
if($bDismissable){ +
47
$sAlertMessage = self::$dismissButtonFormat . $sAlertMessage; +
48
if(!preg_match('/(\s|^)alert-dismissable(\s|$)/',$aAlertAttributes['class']))$aAlertAttributes['class'] .= ' alert-dismissable'; +
49
} +
50
+
51
return sprintf( +
52
self::$alertFormat, +
53
$this->createAttributesString($aAlertAttributes), +
54
$sAlertMessage +
55
); +
56
} +
57
} @@ -195,7 +197,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_View_Helper_TwbBundleBadge.php.html b/tests/_report/src_TwbBundle_View_Helper_TwbBundleBadge.php.html index a82a178..fb75949 100644 --- a/tests/_report/src_TwbBundle_View_Helper_TwbBundleBadge.php.html +++ b/tests/_report/src_TwbBundle_View_Helper_TwbBundleBadge.php.html @@ -182,7 +182,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_View_Helper_TwbBundleDropdown.php.html b/tests/_report/src_TwbBundle_View_Helper_TwbBundleDropdown.php.html index 9a2affb..9765b1e 100644 --- a/tests/_report/src_TwbBundle_View_Helper_TwbBundleDropdown.php.html +++ b/tests/_report/src_TwbBundle_View_Helper_TwbBundleDropdown.php.html @@ -446,7 +446,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_View_Helper_TwbBundleGlyphicon.php.html b/tests/_report/src_TwbBundle_View_Helper_TwbBundleGlyphicon.php.html index 374df72..0b00449 100644 --- a/tests/_report/src_TwbBundle_View_Helper_TwbBundleGlyphicon.php.html +++ b/tests/_report/src_TwbBundle_View_Helper_TwbBundleGlyphicon.php.html @@ -198,7 +198,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/_report/src_TwbBundle_View_Helper_TwbBundleLabel.php.html b/tests/_report/src_TwbBundle_View_Helper_TwbBundleLabel.php.html index 95c38fe..b73aef0 100644 --- a/tests/_report/src_TwbBundle_View_Helper_TwbBundleLabel.php.html +++ b/tests/_report/src_TwbBundle_View_Helper_TwbBundleLabel.php.html @@ -197,7 +197,7 @@

Legend

Dead Code

- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Thu Jan 16 22:17:42 CET 2014. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.5 and PHPUnit 3.7.28 at Sun Mar 16 19:52:14 CET 2014.

diff --git a/tests/phpunit.xml.dist b/tests/phpunit.xml similarity index 100% rename from tests/phpunit.xml.dist rename to tests/phpunit.xml