[TASK] Remove version number from generator tag
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Unit / Page / PageGeneratorTest.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Unit\Page;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
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.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
18 use TYPO3\CMS\Frontend\Tests\Unit\Page\Fixtures\PageGeneratorFixture;
19
20 /**
21 * Test case
22 *
23 * @author Markus Klein <klein.t3@mfc-linz.at>
24 */
25 class PageGeneratorTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
26
27 /**
28 * @var PageGeneratorFixture
29 */
30 protected $pageGeneratorFixture;
31
32 /**
33 * @var ContentObjectRenderer
34 */
35 protected $contentObjectRenderer;
36
37 /**
38 * Set up the helper objects
39 */
40 protected function setUp() {
41 $this->pageGeneratorFixture = new PageGeneratorFixture();
42 $this->contentObjectRenderer = new ContentObjectRenderer();
43 }
44
45 /**
46 * @return array
47 */
48 public function generateMetaTagHtmlGeneratesCorrectTagsDataProvider() {
49 return array(
50 'simple meta' => array(
51 array(
52 'author' => 'Markus Klein',
53 ),
54 FALSE,
55 array(
56 '<meta name="generator" content="TYPO3 CMS">',
57 '<meta name="author" content="Markus Klein">',
58 )
59 ),
60 'simple meta xhtml' => array(
61 array(
62 'author' => 'Markus Klein',
63 ),
64 TRUE,
65 array(
66 '<meta name="generator" content="TYPO3 CMS" />',
67 '<meta name="author" content="Markus Klein" />',
68 )
69 ),
70 'meta with nested stdWrap' => array(
71 array(
72 'author' => 'Markus ',
73 'author.' => array('stdWrap.' => array('wrap' => '|Klein'))
74 ),
75 FALSE,
76 array(
77 '<meta name="generator" content="TYPO3 CMS">',
78 '<meta name="author" content="Markus Klein">',
79 )
80 ),
81 'httpEquivalent meta' => array(
82 array(
83 'X-UA-Compatible' => 'IE=edge,chrome=1',
84 'X-UA-Compatible.' => array('httpEquivalent' => 1)
85 ),
86 FALSE,
87 array(
88 '<meta name="generator" content="TYPO3 CMS">',
89 '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">'
90 )
91 ),
92 'httpEquivalent meta xhtml' => array(
93 array(
94 'X-UA-Compatible' => 'IE=edge,chrome=1',
95 'X-UA-Compatible.' => array('httpEquivalent' => 1)
96 ),
97 TRUE,
98 array(
99 '<meta name="generator" content="TYPO3 CMS" />',
100 '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />'
101 )
102 ),
103 'refresh meta' => array(
104 array(
105 'refresh' => '10',
106 ),
107 FALSE,
108 array(
109 '<meta name="generator" content="TYPO3 CMS">',
110 '<meta http-equiv="refresh" content="10">',
111 )
112 ),
113 'meta with dot' => array(
114 array(
115 'DC.author' => 'Markus Klein',
116 ),
117 FALSE,
118 array(
119 '<meta name="generator" content="TYPO3 CMS">',
120 '<meta name="DC.author" content="Markus Klein">',
121 )
122 ),
123 'meta with colon' => array(
124 array(
125 'OG:title' => 'Magic Tests',
126 ),
127 FALSE,
128 array(
129 '<meta name="generator" content="TYPO3 CMS">',
130 '<meta name="OG:title" content="Magic Tests">',
131 )
132 ),
133 );
134 }
135
136 /**
137 * @test
138 * @dataProvider generateMetaTagHtmlGeneratesCorrectTagsDataProvider
139 *
140 * @param array $typoScript
141 * @param bool $xhtml
142 * @param array $expectedTags
143 */
144 public function generateMetaTagHtmlGeneratesCorrectTags(array $typoScript, $xhtml, array $expectedTags) {
145 $result = $this->pageGeneratorFixture->callGenerateMetaTagHtml($typoScript, $xhtml, $this->contentObjectRenderer);
146 $this->assertSame($expectedTags, $result);
147 }
148
149 /**
150 * @return array
151 */
152 public function initializeSearchWordDataInTsfeBuildsCorrectRegexDataProvider() {
153 return array(
154 'one simple search word' => array(
155 array('test'),
156 FALSE,
157 'test',
158 ),
159 'one simple search word with standalone words' => array(
160 array('test'),
161 TRUE,
162 '[[:space:]]test[[:space:]]',
163 ),
164 'two simple search words' => array(
165 array('test', 'test2'),
166 FALSE,
167 'test|test2',
168 ),
169 'two simple search words with standalone words' => array(
170 array('test', 'test2'),
171 TRUE,
172 '[[:space:]]test[[:space:]]|[[:space:]]test2[[:space:]]',
173 ),
174 'word with regex chars' => array(
175 array('A \\ word with / a bunch of [] regex () chars .*'),
176 FALSE,
177 'A word with \\/ a bunch of \\[\\] regex \\(\\) chars \\.\\*',
178 ),
179 );
180 }
181
182 /**
183 * @test
184 * @dataProvider initializeSearchWordDataInTsfeBuildsCorrectRegexDataProvider
185 *
186 * @param array $searchWordGetParameters The values that should be loaded in the sword_list GET parameter.
187 * @param bool $enableStandaloneSearchWords If TRUE the sword_standAlone option will be enabled.
188 * @param string $expectedRegex The expected regex after processing the search words.
189 */
190 public function initializeSearchWordDataInTsfeBuildsCorrectRegex(array $searchWordGetParameters, $enableStandaloneSearchWords, $expectedRegex) {
191
192 $_GET['sword_list'] = $searchWordGetParameters;
193
194 $GLOBALS['TSFE'] = new \stdClass();
195 if ($enableStandaloneSearchWords) {
196 $GLOBALS['TSFE']->config = array('config' => array('sword_standAlone' => 1));
197 }
198
199 $this->pageGeneratorFixture->callInitializeSearchWordDataInTsfe();
200 $this->assertEquals($GLOBALS['TSFE']->sWordRegEx, $expectedRegex);
201 }
202 }