2 namespace TYPO3\CMS\Core\Tests\Unit\Html
;
5 * This file is part of the TYPO3 CMS project.
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
18 * Testcase for \TYPO3\CMS\Core\Html\HtmlParser
20 * @author Nicole Cordes <typo3@cordes.co>
22 class HtmlParserTest
extends \TYPO3\CMS\Core\Tests\UnitTestCase
{
25 * @var \TYPO3\CMS\Core\Html\HtmlParser
27 protected $fixture = NULL;
29 public function setUp() {
30 $this->fixture
= new \TYPO3\CMS\Core\Html\
HtmlParser();
34 * Data provider for substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray
36 public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider() {
37 $template = '###SINGLEMARKER1###
38 <!-- ###FOO### begin -->
39 <!-- ###BAR### begin -->
41 <!-- ###BAR### end -->
42 <!-- ###FOOTER### begin -->
44 <!-- ###FOOTER### end -->
45 <!-- ###FOO### end -->';
62 'Single marker' => array(
65 '###SINGLEMARKER###' => 'Value 1'
72 'Subpart marker' => array(
75 '###SINGLEMARKER1###' => 'Value 1',
80 '###SINGLEMARKER2###' => 'Value 2.1'
83 '###SINGLEMARKER2###' => 'Value 2.2'
86 '###FOOTER###' => array(
88 '###SINGLEMARKER3###' => 'Value 3.1'
91 '###SINGLEMARKER3###' => 'Value 3.2'
102 'Subpart marker with wrap' => array(
105 'SINGLEMARKER1' => 'Value 1',
110 'SINGLEMARKER2' => 'Value 2.1'
113 'SINGLEMARKER2' => 'Value 2.2'
118 'SINGLEMARKER3' => 'Value 3.1'
121 'SINGLEMARKER3' => 'Value 3.2'
132 'Subpart marker with lower marker array keys' => array(
135 '###singlemarker1###' => 'Value 1',
136 '###foo###' => array(
138 '###bar###' => array(
140 '###singlemarker2###' => 'Value 2.1'
143 '###singlemarker2###' => 'Value 2.2'
146 '###footer###' => array(
148 '###singlemarker3###' => 'Value 3.1'
151 '###singlemarker3###' => 'Value 3.2'
162 'Subpart marker with unused markers' => array(
165 '###FOO###' => array(
167 '###BAR###' => array(
169 '###SINGLEMARKER2###' => 'Value 2.1'
172 '###FOOTER###' => array(
174 '###SINGLEMARKER3###' => 'Value 3.1'
193 'Subpart marker with empty subpart' => array(
196 '###SINGLEMARKER1###' => 'Value 1',
197 '###FOO###' => array(
199 '###BAR###' => array(
201 '###SINGLEMARKER2###' => 'Value 2.1'
204 '###SINGLEMARKER2###' => 'Value 2.2'
207 '###FOOTER###' => array()
229 * @dataProvider substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider
231 public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused, $expected) {
232 $this->assertSame($expected, $this->fixture
->substituteMarkerAndSubpartArrayRecursive($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused));
238 public function cDataWillRemainUnmodifiedDataProvider() {
240 'single-line CDATA' => array(
241 '/*<![CDATA[*/ <hello world> /*]]>*/',
242 '/*<![CDATA[*/ <hello world> /*]]>*/',
244 'multi-line CDATA #1' => array(
245 '/*<![CDATA[*/' . LF
. '<hello world> /*]]>*/',
246 '/*<![CDATA[*/' . LF
. '<hello world> /*]]>*/',
248 'multi-line CDATA #2' => array(
249 '/*<![CDATA[*/ <hello world>' . LF
. '/*]]>*/',
250 '/*<![CDATA[*/ <hello world>' . LF
. '/*]]>*/',
252 'multi-line CDATA #3' => array(
253 '/*<![CDATA[*/' . LF
. '<hello world>' . LF
. '/*]]>*/',
254 '/*<![CDATA[*/' . LF
. '<hello world>' . LF
. '/*]]>*/',
261 * @param string $source
262 * @param string $expected
263 * @dataProvider cDataWillRemainUnmodifiedDataProvider
265 public function xHtmlCleaningDoesNotModifyCDATA($source, $expected) {
266 $result = $this->fixture
->XHTML_clean($source);
267 $this->assertSame($expected, $result);