From a0e040f04c8dd7841d042eb13ce0305241d33ec8 Mon Sep 17 00:00:00 2001 From: Alexander Zamponi Date: Sat, 28 Jan 2017 19:38:20 +0100 Subject: [PATCH 1/3] Changed line endings from windows to linux in test files. Changed line endings from PHP_EOL to \n in library. --- .../Form/View/Helper/TwbBundleForm.php | 2 +- .../View/Helper/TwbBundleFormCollection.php | 4 +- .../Form/View/Helper/TwbBundleFormRow.php | 4 +- .../View/Helper/TwbBundleDropdown.php | 2 +- .../TwbBundleAlertsTest.php | 10 ++--- .../TwbBundleBadgesTest.php | 4 +- .../TwbBundleButtonsDropdownsTest.php | 34 +++++++-------- .../TwbBundleButtonsTest.php | 42 +++++++++---------- .../TwbBundleGlyphiconsTest.php | 14 +++---- .../TwbBundleInputGroupsTest.php | 28 ++++++------- .../TwbBundleLabelsTest.php | 12 +++--- 11 files changed, 78 insertions(+), 78 deletions(-) diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleForm.php b/src/TwbBundle/Form/View/Helper/TwbBundleForm.php index 2031e5f..b2e739f 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleForm.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleForm.php @@ -67,7 +67,7 @@ public function render(FormInterface $oForm, $sFormLayout = self::LAYOUT_HORIZON $oForm->setAttribute('role', 'form'); } - return $this->openTag($oForm) . PHP_EOL . $this->renderElements($oForm, $sFormLayout) . $this->closeTag(); + return $this->openTag($oForm) . "\n" . $this->renderElements($oForm, $sFormLayout) . $this->closeTag(); } /** diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php index 580ff4d..39b06d5 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormCollection.php @@ -57,13 +57,13 @@ public function render(ElementInterface $oElement) $sMarkup .= $oFieldsetHelper($oElementOrFieldset); } elseif ($oElementOrFieldset instanceof \Zend\Form\ElementInterface) { if ($oElementOrFieldset->getOption('twb-row-open')) { - $sMarkup .= '
' . PHP_EOL; + $sMarkup .= '
' . "\n"; } $sMarkup .= $oElementHelper($oElementOrFieldset); if ($oElementOrFieldset->getOption('twb-row-close')) { - $sMarkup .= '
' . PHP_EOL; + $sMarkup .= '
' . "\n"; } } } diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php index e70e180..53cc2ca 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php @@ -100,7 +100,7 @@ public function render(ElementInterface $oElement, $sLabelPosition = null) case $sElementType === 'checkbox' && $sLayout !== TwbBundleForm::LAYOUT_HORIZONTAL && !$oElement->getOption('form-group'): // All "button" elements in inline form case in_array($sElementType, array('submit', 'button', 'reset'), true) && $sLayout === TwbBundleForm::LAYOUT_INLINE: - return $sElementContent . PHP_EOL; + return $sElementContent . "\n"; default: // Render element into form group return $this->renderElementFormGroup($sElementContent, $this->getRowClassFromElement($oElement)); @@ -153,7 +153,7 @@ public function renderElementFormGroup($sElementContent, $sRowClass) if (!is_string($sRowClass)) { throw new \InvalidArgumentException('Argument "$sRowClass" expects a string, "' . (is_object($sRowClass) ? get_class($sRowClass) : gettype($sRowClass)) . '" given'); } - return sprintf(self::$formGroupFormat, $sRowClass, $sElementContent) . PHP_EOL; + return sprintf(self::$formGroupFormat, $sRowClass, $sElementContent) . "\n"; } /** diff --git a/src/TwbBundle/View/Helper/TwbBundleDropdown.php b/src/TwbBundle/View/Helper/TwbBundleDropdown.php index 7fa423c..ab3665f 100644 --- a/src/TwbBundle/View/Helper/TwbBundleDropdown.php +++ b/src/TwbBundle/View/Helper/TwbBundleDropdown.php @@ -228,7 +228,7 @@ public function renderListItems(array $aDropdownOptions) $aItemOptions['type'] = self::TYPE_ITEM_LINK; } } - $sItems .= $this->renderItem($aItemOptions) . PHP_EOL; + $sItems .= $this->renderItem($aItemOptions) . "\n"; } return sprintf( diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleAlertsTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleAlertsTest.php index fd2ec37..82643e2 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleAlertsTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleAlertsTest.php @@ -32,16 +32,16 @@ public function testExamples(){ $sContent = ''; //Success - $sContent .= $this->alertHelper->__invoke('Well done! You successfully read this important alert message.','alert-success').PHP_EOL; + $sContent .= $this->alertHelper->__invoke('Well done! You successfully read this important alert message.','alert-success')."\n"; //Info - $sContent .= $this->alertHelper->__invoke('Heads up! This alert needs your attention, but it\'s not super important.','alert-info').PHP_EOL; + $sContent .= $this->alertHelper->__invoke('Heads up! This alert needs your attention, but it\'s not super important.','alert-info')."\n"; //Warning - $sContent .= $this->alertHelper->__invoke('Warning! Best check yo self, you\'re not looking too good.','alert-warning').PHP_EOL; + $sContent .= $this->alertHelper->__invoke('Warning! Best check yo self, you\'re not looking too good.','alert-warning')."\n"; //Danger - $sContent .= $this->alertHelper->__invoke('Oh snap! Change a few things up and try submitting again.','alert-danger').PHP_EOL; + $sContent .= $this->alertHelper->__invoke('Oh snap! Change a few things up and try submitting again.','alert-danger')."\n"; $this->assertStringEqualsFile($this->expectedPath.'alerts-examples.phtml',$sContent); } @@ -51,7 +51,7 @@ public function testExamples(){ */ public function testDismissableAlerts(){ - $sContent = $this->alertHelper->__invoke('Warning! Best check yo self, you\'re not looking too good.',null,true).PHP_EOL; + $sContent = $this->alertHelper->__invoke('Warning! Best check yo self, you\'re not looking too good.',null,true)."\n"; $this->assertStringEqualsFile($this->expectedPath.'alerts-dismissable.phtml',$sContent); } diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleBadgesTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleBadgesTest.php index f7972b2..b049f75 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleBadgesTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleBadgesTest.php @@ -29,10 +29,10 @@ public function testBadges(){ $sContent = ''; //Default - $sContent .= $this->badgeHelper->__invoke('42').PHP_EOL; + $sContent .= $this->badgeHelper->__invoke('42')."\n"; //Pull-right - $sContent .= $this->badgeHelper->__invoke('3',array('class' => 'pull-right')).PHP_EOL; + $sContent .= $this->badgeHelper->__invoke('3',array('class' => 'pull-right'))."\n"; $this->assertStringEqualsFile($this->expectedPath.'badges.phtml',$sContent); } diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleButtonsDropdownsTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleButtonsDropdownsTest.php index 46b4f86..cc37b77 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleButtonsDropdownsTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleButtonsDropdownsTest.php @@ -38,27 +38,27 @@ public function testSingleButtonDropdowns() { $sContent = ''; $oButton = new \Zend\Form\Element\Button('default', array('label' => 'Default', 'dropdown' => $aDropDownOptions)); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('primary', array('label' => 'Primary', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-primary'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('success', array('label' => 'Success', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-success'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('info', array('label' => 'Info', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-info'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('warning', array('label' => 'Warning', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-warning'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('danger', array('label' => 'Danger', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-danger'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'dropdowns-single.phtml', $sContent); @@ -76,27 +76,27 @@ public function testSplitButtonDropdowns() { $sContent = ''; $oButton = new \Zend\Form\Element\Button('default', array('label' => 'Default', 'dropdown' => $aDropDownOptions)); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('primary', array('label' => 'Primary', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-primary'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('success', array('label' => 'Success', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-success'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('info', array('label' => 'Info', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-info'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('warning', array('label' => 'Warning', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-warning'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('danger', array('label' => 'Danger', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-danger'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'dropdowns-split.phtml', $sContent); @@ -115,17 +115,17 @@ public function testDropdownsSizing() { //Large $oButton = new \Zend\Form\Element\Button('large-button-default', array('label' => 'Large button', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-lg'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Small $oButton = new \Zend\Form\Element\Button('small-button-default', array('label' => 'Small button', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-sm'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Extra small $oButton = new \Zend\Form\Element\Button('extra-small-button-default', array('label' => 'Extra small button', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-xs'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'dropdowns-sizing.phtml', $sContent); @@ -144,12 +144,12 @@ public function testDropup() { $sContent = ''; $oButton = new \Zend\Form\Element\Button('default', array('label' => 'Dropup', 'dropdown' => $aDropDownOptions)); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $aDropDownOptions['list_attributes'] = array('class' => 'pull-right'); $oButton = new \Zend\Form\Element\Button('primary', array('label' => 'Right dropup', 'dropdown' => $aDropDownOptions)); $oButton->setAttribute('class', 'btn-primary'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'dropup.phtml', $sContent); diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleButtonsTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleButtonsTest.php index f84164c..3283953 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleButtonsTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleButtonsTest.php @@ -34,31 +34,31 @@ public function setUp() { public function testButtonsOptions() { $sContent = ''; $oButton = new \Zend\Form\Element\Button('default', array('label' => 'Default')); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('primary', array('label' => 'Primary')); $oButton->setAttribute('class', 'btn-primary'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('success', array('label' => 'Success')); $oButton->setAttribute('class', 'btn-success'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('info', array('label' => 'Info')); $oButton->setAttribute('class', 'btn-info'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('warning', array('label' => 'Warning')); $oButton->setAttribute('class', 'btn-warning'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('danger', array('label' => 'Danger')); $oButton->setAttribute('class', 'btn-danger'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('link', array('label' => 'Link')); $oButton->setAttribute('class', 'btn-link'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'options.phtml', $sContent); @@ -73,46 +73,46 @@ public function testButtonsSizes() { //Large $oButton = new \Zend\Form\Element\Button('large-button-primary', array('label' => 'Large button')); $oButton->setAttribute('class', 'btn-primary btn-lg'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('large-button-default', array('label' => 'Large button')); $oButton->setAttribute('class', 'btn-lg'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Default $oButton = new \Zend\Form\Element\Button('button-primary', array('label' => 'Default button')); $oButton->setAttribute('class', 'btn-primary'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('button-default', array('label' => 'Default button')); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Small $oButton = new \Zend\Form\Element\Button('small-button-primary', array('label' => 'Small button')); $oButton->setAttribute('class', 'btn-primary btn-sm'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('small-button-default', array('label' => 'Small button')); $oButton->setAttribute('class', 'btn-sm'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Extra small $oButton = new \Zend\Form\Element\Button('extra-small-button-primary', array('label' => 'Extra small button')); $oButton->setAttribute('class', 'btn-primary btn-xs'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('extra-small-button-default', array('label' => 'Extra small button')); $oButton->setAttribute('class', 'btn-xs'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Block level $oButton = new \Zend\Form\Element\Button('block-level-button-primary', array('label' => 'Block level button')); $oButton->setAttribute('class', 'btn-primary btn-block'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('block-level-button-default', array('label' => 'Block level button')); $oButton->setAttribute('class', 'btn-block'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'sizes.phtml', $sContent); @@ -128,13 +128,13 @@ public function testButtonsActive() { $oButton->setAttributes(array( 'class' => 'btn-primary btn-lg active', )); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('large-button-default-active', array('label' => 'Button')); $oButton->setAttributes(array( 'class' => 'btn-lg active', )); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'active.phtml', $sContent); @@ -151,14 +151,14 @@ public function testButtonsDisabled() { 'class' => 'btn-primary btn-lg', 'disabled' => true )); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $oButton = new \Zend\Form\Element\Button('large-button-default-disabled', array('label' => 'Button')); $oButton->setAttributes(array( 'class' => 'btn-lg', 'disabled' => true )); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'disabled.phtml', $sContent); diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleGlyphiconsTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleGlyphiconsTest.php index 013031a..72ceb42 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleGlyphiconsTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleGlyphiconsTest.php @@ -52,32 +52,32 @@ public function testExamples() { $sContent = ''; //Align left - $sContent .= $this->formButtonHelper->__invoke(new \Zend\Form\Element\Button('align-left', array('glyphicon' => 'align-left'))) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke(new \Zend\Form\Element\Button('align-left', array('glyphicon' => 'align-left'))) . "\n"; //Align center - $sContent .= $this->formButtonHelper->__invoke(new \Zend\Form\Element\Button('align-left', array('glyphicon' => 'align-center'))) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke(new \Zend\Form\Element\Button('align-left', array('glyphicon' => 'align-center'))) . "\n"; //Align right - $sContent .= $this->formButtonHelper->__invoke(new \Zend\Form\Element\Button('align-left', array('glyphicon' => 'align-right'))) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke(new \Zend\Form\Element\Button('align-left', array('glyphicon' => 'align-right'))) . "\n"; //Large $oButton = new \Zend\Form\Element\Button('large-button-default', array('label' => 'Star', 'glyphicon' => 'star')); $oButton->setAttribute('class', 'btn-lg'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Default $oButton = new \Zend\Form\Element\Button('button-default', array('label' => 'Star', 'glyphicon' => 'star')); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Small $oButton = new \Zend\Form\Element\Button('small-button-default', array('label' => 'Star', 'glyphicon' => 'star')); $oButton->setAttribute('class', 'btn-sm'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; //Extra small $oButton = new \Zend\Form\Element\Button('extra-small-button-default', array('label' => 'Star', 'glyphicon' => 'star')); $oButton->setAttribute('class', 'btn-xs'); - $sContent .= $this->formButtonHelper->__invoke($oButton) . PHP_EOL; + $sContent .= $this->formButtonHelper->__invoke($oButton) . "\n"; $this->assertStringEqualsFile($this->expectedPath . 'examples.phtml', $sContent); } diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleInputGroupsTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleInputGroupsTest.php index 35b6d63..65568ec 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleInputGroupsTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleInputGroupsTest.php @@ -36,13 +36,13 @@ public function testBasicExample() { $oInput = new \Zend\Form\Element\Text('input-prepend', array('add-on-prepend' => '@')); $oInput->setAttribute('placeholder', 'Username'); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; $oInput = new \Zend\Form\Element\Text('input-append', array('add-on-append' => '.00')); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; $oInput = new \Zend\Form\Element\Text('input-append-prepend', array('add-on-prepend' => '$', 'add-on-append' => '.00')); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'input-groups-basic.phtml', $sContent); @@ -57,17 +57,17 @@ public function testSizing() { //Large $oInput = new \Zend\Form\Element\Text('input-prepend', array('add-on-prepend' => '@')); $oInput->setAttributes(array('placeholder' => 'Username', 'class' => 'input-lg')); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Default $oInput = new \Zend\Form\Element\Text('input-prepend', array('add-on-prepend' => '@')); $oInput->setAttribute('placeholder', 'Username'); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Small $oInput = new \Zend\Form\Element\Text('input-prepend', array('add-on-prepend' => '@')); $oInput->setAttributes(array('placeholder' => 'Username', 'class' => 'input-sm')); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'input-groups-sizing.phtml', $sContent); @@ -81,11 +81,11 @@ public function testCheckboxesAndRadioAddons() { //Checkbox $oInput = new \Zend\Form\Element\Text('input-username', array('add-on-prepend' => new \Zend\Form\Element\Checkbox('checkbox'))); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Radio $oInput = new \Zend\Form\Element\Text('input-username', array('add-on-prepend' => new \Zend\Form\Element\Radio('radio', array('value_options' => array(1 => ''))))); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'input-groups-checkboxes-radios.phtml', $sContent); @@ -99,11 +99,11 @@ public function testButtonAddons() { //Prepend $oInput = new \Zend\Form\Element\Text('input-username', array('add-on-prepend' => new \Zend\Form\Element\Button('prepend-button', array('label' => 'Go!')))); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Append $oInput = new \Zend\Form\Element\Text('input-username', array('add-on-append' => new \Zend\Form\Element\Button('append-button', array('label' => 'Go!')))); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'input-groups-buttons.phtml', $sContent); @@ -125,11 +125,11 @@ public function testButtonsWithDropdowns() { //Prepend $oInput = new \Zend\Form\Element\Text('input-username', array('add-on-prepend' => new \Zend\Form\Element\Button('prepend-button', $aButtonOptions))); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Append $oInput = new \Zend\Form\Element\Text('input-username', array('add-on-append' => new \Zend\Form\Element\Button('append-button', $aButtonOptions))); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'input-groups-buttons-dropdowns.phtml', $sContent); @@ -152,11 +152,11 @@ public function testSegmentedButtons() { //Prepend $oInput = new \Zend\Form\Element\Text('input-username', array('add-on-prepend' => new \Zend\Form\Element\Button('prepend-button', $aButtonOptions))); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Append $oInput = new \Zend\Form\Element\Text('input-username', array('add-on-append' => new \Zend\Form\Element\Button('append-button', $aButtonOptions))); - $sContent .= $this->formElementHelper->__invoke($oInput) . PHP_EOL; + $sContent .= $this->formElementHelper->__invoke($oInput) . "\n"; //Test content $this->assertStringEqualsFile($this->expectedPath . 'input-groups-buttons-segmented.phtml', $sContent); diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleLabelsTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleLabelsTest.php index 67fc0d9..7290d2b 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleLabelsTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleLabelsTest.php @@ -29,22 +29,22 @@ public function testAvailableVariations(){ $sContent = ''; //Default - $sContent .= $this->labelHelper->__invoke('Default','label-default').PHP_EOL; + $sContent .= $this->labelHelper->__invoke('Default','label-default')."\n"; //Primary - $sContent .= $this->labelHelper->__invoke('Primary','label-primary').PHP_EOL; + $sContent .= $this->labelHelper->__invoke('Primary','label-primary')."\n"; //Success - $sContent .= $this->labelHelper->__invoke('Success','label-success').PHP_EOL; + $sContent .= $this->labelHelper->__invoke('Success','label-success')."\n"; //Info - $sContent .= $this->labelHelper->__invoke('Info','label-info').PHP_EOL; + $sContent .= $this->labelHelper->__invoke('Info','label-info')."\n"; //Warning - $sContent .= $this->labelHelper->__invoke('Warning','label-warning').PHP_EOL; + $sContent .= $this->labelHelper->__invoke('Warning','label-warning')."\n"; //Danger - $sContent .= $this->labelHelper->__invoke('Danger','label-danger').PHP_EOL; + $sContent .= $this->labelHelper->__invoke('Danger','label-danger')."\n"; //Test content file_put_contents($this->expectedPath.'available-variations.phtml',$sContent); From 87ec981c742e82461d3cd28abb6f39a1184961be Mon Sep 17 00:00:00 2001 From: Alexander Zamponi Date: Sat, 28 Jan 2017 19:45:27 +0100 Subject: [PATCH 2/3] Added the ability to show the label for each element in an inline form. --- src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php | 10 ++++++---- .../BootstrapBasedTests/TwbBundleFormsTest.php | 10 +++++++++- tests/_files/expected-forms/inline-form.phtml | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php index 53cc2ca..5a93ac8 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php @@ -216,10 +216,12 @@ protected function renderElement(ElementInterface $oElement, $sLabelPosition = n //Hide label for "inline" layout case TwbBundleForm::LAYOUT_INLINE: if ($sElementType !== 'checkbox') { - if (empty($aLabelAttributes['class'])) { - $aLabelAttributes['class'] = 'sr-only'; - } elseif (!preg_match('/(\s|^)sr-only(\s|$)/', $aLabelAttributes['class'])) { - $aLabelAttributes['class'] = trim($aLabelAttributes['class'] . ' sr-only'); + if ($sElementType !== 'checkbox') { + if (empty($aLabelAttributes['class']) && empty($aLabelAttributes['showLabel']) ) { + $aLabelAttributes['class'] = 'sr-only'; + } elseif (empty($aLabelAttributes['showLabel']) && !preg_match('/(\s|^)sr-only(\s|$)/', $aLabelAttributes['class'])) { + $aLabelAttributes['class'] = trim($aLabelAttributes['class'] . ' sr-only'); + } } } break; diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php index 36f7f09..8629572 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php @@ -90,7 +90,15 @@ public function testInlineForm() 'placeholder' => 'Enter email', 'id' => 'exampleInputEmail2' ), - 'options' => array('label' => 'Email address') + 'options' => array('label' => 'Email address', 'label_attributes' => [ 'showLabel' => false ],) + ))->add(array( + 'name' => 'input-email2', + 'attributes' => array( + 'type' => 'email2', + 'placeholder' => 'Enter email2', + 'id' => 'exampleInputEmail2a' + ), + 'options' => array('label' => 'Email address2', 'label_attributes' => [ 'showLabel' => true ],) ))->add(array( 'name' => 'input-password', 'attributes' => array( diff --git a/tests/_files/expected-forms/inline-form.phtml b/tests/_files/expected-forms/inline-form.phtml index fdf17b8..d16cb1e 100644 --- a/tests/_files/expected-forms/inline-form.phtml +++ b/tests/_files/expected-forms/inline-form.phtml @@ -1,5 +1,6 @@
+
From ed42211cf1fac0e25a8a30c548e56262636252fb Mon Sep 17 00:00:00 2001 From: Alexander Zamponi Date: Sun, 29 Jan 2017 18:24:01 +0100 Subject: [PATCH 3/3] Fixed the showLabel location and changed the readme --- src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php | 4 ++-- .../TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php index 5a93ac8..a57b5fb 100644 --- a/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php +++ b/src/TwbBundle/Form/View/Helper/TwbBundleFormRow.php @@ -217,9 +217,9 @@ protected function renderElement(ElementInterface $oElement, $sLabelPosition = n case TwbBundleForm::LAYOUT_INLINE: if ($sElementType !== 'checkbox') { if ($sElementType !== 'checkbox') { - if (empty($aLabelAttributes['class']) && empty($aLabelAttributes['showLabel']) ) { + if (empty($aLabelAttributes['class']) && empty($oElement->getOption('showLabel'))) { $aLabelAttributes['class'] = 'sr-only'; - } elseif (empty($aLabelAttributes['showLabel']) && !preg_match('/(\s|^)sr-only(\s|$)/', $aLabelAttributes['class'])) { + } elseif (empty($oElement->getOption('showLabel')) && !preg_match('/(\s|^)sr-only(\s|$)/', $aLabelAttributes['class'])) { $aLabelAttributes['class'] = trim($aLabelAttributes['class'] . ' sr-only'); } } diff --git a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php index 8629572..9dd6cf5 100644 --- a/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php +++ b/tests/TwbBundleTest/BootstrapBasedTests/TwbBundleFormsTest.php @@ -90,7 +90,7 @@ public function testInlineForm() 'placeholder' => 'Enter email', 'id' => 'exampleInputEmail2' ), - 'options' => array('label' => 'Email address', 'label_attributes' => [ 'showLabel' => false ],) + 'options' => array('label' => 'Email address', 'showLabel' => false) ))->add(array( 'name' => 'input-email2', 'attributes' => array( @@ -98,7 +98,7 @@ public function testInlineForm() 'placeholder' => 'Enter email2', 'id' => 'exampleInputEmail2a' ), - 'options' => array('label' => 'Email address2', 'label_attributes' => [ 'showLabel' => true ],) + 'options' => array('label' => 'Email address2', 'showLabel' => true) ))->add(array( 'name' => 'input-password', 'attributes' => array(