-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid double escaped entities in labels
- Loading branch information
Showing
2 changed files
with
213 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
212 changes: 212 additions & 0 deletions
212
tests/TestSuite/TwbsHelper/Form/View/Helper/FormLabelTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
<?php | ||
|
||
namespace TestSuite\TwbsHelper\Form\View\Helper; | ||
|
||
class FormLabelTest extends \TestSuite\TwbsHelper\AbstractViewHelperTestCase | ||
{ | ||
/** | ||
* @var \TwbsHelper\Form\View\Helper\FormLabel | ||
*/ | ||
protected $helper = 'formLabel'; | ||
|
||
/** | ||
* @dataProvider dataProviderRenderLabels | ||
*/ | ||
public function testRenderWithLabel($element, string $expected) | ||
{ | ||
$this->assertEquals( | ||
$expected, | ||
$this->helper->__invoke($element) | ||
); | ||
} | ||
|
||
public function dataProviderRenderLabels(): array | ||
{ | ||
return [ | ||
[ | ||
new \Laminas\Form\Element\Text( | ||
'test_one', | ||
[ | ||
'label' => 'Without special chars', | ||
] | ||
), | ||
'<label class="form-label" for="test_one">Without special chars</label>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\Text( | ||
'test_one', | ||
[ | ||
'label' => 'With special chars < > &', | ||
] | ||
), | ||
'<label class="form-label" for="test_one">With special chars < > &</label>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\Text( | ||
'test_one', | ||
[ | ||
'label' => 'With special chars < > &', | ||
] | ||
), | ||
'<label class="form-label" for="test_one">With special chars &lt; &gt; &amp;</label>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\Text( | ||
'test_one', | ||
[ | ||
'label' => 'With a quote\'', | ||
] | ||
), | ||
'<label class="form-label" for="test_one">With a quote'</label>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\MultiCheckbox( | ||
'test_one', | ||
[ | ||
'label' => 'Without special chars', | ||
] | ||
), | ||
'<div class="form-label"> | ||
Without special chars | ||
</div>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\MultiCheckbox( | ||
'test_one', | ||
[ | ||
'label' => 'With special chars < > &', | ||
] | ||
), | ||
'<div class="form-label"> | ||
With special chars < > & | ||
</div>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\MultiCheckbox( | ||
'test_one', | ||
[ | ||
'label' => 'With special chars < > &', | ||
] | ||
), | ||
'<div class="form-label"> | ||
With special chars &lt; &gt; &amp; | ||
</div>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\MultiCheckbox( | ||
'test_one', | ||
[ | ||
'label' => 'With a quote\'', | ||
] | ||
), | ||
'<div class="form-label"> | ||
With a quote' | ||
</div>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\Text( | ||
'test_one', | ||
[ | ||
'label' => 'Without special chars', | ||
'label_options' => [ | ||
'disable_html_escape' => true, | ||
], | ||
] | ||
), | ||
'<label class="form-label" for="test_one">Without special chars</label>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\Text( | ||
'test_one', | ||
[ | ||
'label' => 'With special chars < > &', | ||
'label_options' => [ | ||
'disable_html_escape' => true, | ||
], | ||
] | ||
), | ||
'<label class="form-label" for="test_one">With special chars < > &</label>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\Text( | ||
'test_one', | ||
[ | ||
'label' => 'With special chars < > &', | ||
'label_options' => [ | ||
'disable_html_escape' => true, | ||
], | ||
] | ||
), | ||
'<label class="form-label" for="test_one">With special chars < > &</label>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\Text( | ||
'test_one', | ||
[ | ||
'label' => 'With a quote\'', | ||
'label_options' => [ | ||
'disable_html_escape' => true, | ||
], | ||
] | ||
), | ||
'<label class="form-label" for="test_one">With a quote\'</label>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\MultiCheckbox( | ||
'test_one', | ||
[ | ||
'label' => 'Without special chars', | ||
'label_options' => [ | ||
'disable_html_escape' => true, | ||
], | ||
] | ||
), | ||
'<div class="form-label"> | ||
Without special chars | ||
</div>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\MultiCheckbox( | ||
'test_one', | ||
[ | ||
'label' => 'With special chars < > &', | ||
'label_options' => [ | ||
'disable_html_escape' => true, | ||
], | ||
] | ||
), | ||
'<div class="form-label"> | ||
With special chars < > & | ||
</div>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\MultiCheckbox( | ||
'test_one', | ||
[ | ||
'label' => 'With special chars < > &', | ||
'label_options' => [ | ||
'disable_html_escape' => true, | ||
], | ||
] | ||
), | ||
'<div class="form-label"> | ||
With special chars < > & | ||
</div>' | ||
], | ||
[ | ||
new \Laminas\Form\Element\MultiCheckbox( | ||
'test_one', | ||
[ | ||
'label' => 'With a quote\'', | ||
'label_options' => [ | ||
'disable_html_escape' => true, | ||
], | ||
] | ||
), | ||
'<div class="form-label"> | ||
With a quote\' | ||
</div>' | ||
], | ||
]; | ||
} | ||
} |