TYPO3 CMS  TYPO3_7-6
PageGeneratorTest.php
Go to the documentation of this file.
1 <?php
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 
19 
24 {
29 
34 
38  protected function setUp()
39  {
40  $this->pageGeneratorFixture = new PageGeneratorFixture();
41  $this->contentObjectRenderer = new ContentObjectRenderer();
42  }
43 
48  {
49  return [
50  'simple meta' => [
51  [
52  'author' => 'Markus Klein',
53  ],
54  false,
55  [
56  '<meta name="generator" content="TYPO3 CMS">',
57  '<meta name="author" content="Markus Klein">',
58  ]
59  ],
60  'simple meta xhtml' => [
61  [
62  'author' => 'Markus Klein',
63  ],
64  true,
65  [
66  '<meta name="generator" content="TYPO3 CMS" />',
67  '<meta name="author" content="Markus Klein" />',
68  ]
69  ],
70  'meta with nested stdWrap' => [
71  [
72  'author' => 'Markus ',
73  'author.' => ['stdWrap.' => ['wrap' => '|Klein']]
74  ],
75  false,
76  [
77  '<meta name="generator" content="TYPO3 CMS">',
78  '<meta name="author" content="Markus Klein">',
79  ]
80  ],
81  'httpEquivalent meta' => [
82  [
83  'X-UA-Compatible' => 'IE=edge,chrome=1',
84  'X-UA-Compatible.' => ['httpEquivalent' => 1]
85  ],
86  false,
87  [
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' => [
93  [
94  'X-UA-Compatible' => 'IE=edge,chrome=1',
95  'X-UA-Compatible.' => ['httpEquivalent' => 1]
96  ],
97  true,
98  [
99  '<meta name="generator" content="TYPO3 CMS" />',
100  '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />'
101  ]
102  ],
103  'httpEquivalent meta xhtml new notation' => [
104  [
105  'X-UA-Compatible' => 'IE=edge,chrome=1',
106  'X-UA-Compatible.' => ['attribute' => 'http-equiv']
107  ],
108  true,
109  [
110  '<meta name="generator" content="TYPO3 CMS" />',
111  '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />'
112  ]
113  ],
114  'refresh meta' => [
115  [
116  'refresh' => '10',
117  ],
118  false,
119  [
120  '<meta name="generator" content="TYPO3 CMS">',
121  '<meta http-equiv="refresh" content="10">',
122  ]
123  ],
124  'refresh meta new notation' => [
125  [
126  'refresh' => '10',
127  'refresh.' => ['attribute' => 'http-equiv']
128  ],
129  false,
130  [
131  '<meta name="generator" content="TYPO3 CMS">',
132  '<meta http-equiv="refresh" content="10">',
133  ]
134  ],
135  'refresh meta new notation wins form old' => [
136  [
137  'refresh' => '10',
138  'refresh.' => ['attribute' => 'http-equiv-new']
139  ],
140  false,
141  [
142  '<meta name="generator" content="TYPO3 CMS">',
143  '<meta http-equiv-new="refresh" content="10">',
144  ]
145  ],
146  'meta with dot' => [
147  [
148  'DC.author' => 'Markus Klein',
149  ],
150  false,
151  [
152  '<meta name="generator" content="TYPO3 CMS">',
153  '<meta name="DC.author" content="Markus Klein">',
154  ]
155  ],
156  'meta with colon' => [
157  [
158  'OG:title' => 'Magic Tests',
159  ],
160  false,
161  [
162  '<meta name="generator" content="TYPO3 CMS">',
163  '<meta name="OG:title" content="Magic Tests">',
164  ]
165  ],
166  'different attribute name' => [
167  [
168  'og:site_title' => 'My TYPO3 site',
169  'og:site_title.' => ['attribute' => 'property'],
170  ],
171  false,
172  [
173  '<meta name="generator" content="TYPO3 CMS">',
174  '<meta property="og:site_title" content="My TYPO3 site">',
175  ]
176  ],
177  'multi value attribute name' => [
178  [
179  'og:locale:alternate.' => [
180  'attribute' => 'property',
181  'value' => [
182  10 => 'nl_NL',
183  20 => 'de_DE',
184  ]
185  ],
186  ],
187  false,
188  [
189  '<meta name="generator" content="TYPO3 CMS">',
190  '<meta property="og:locale:alternate" content="nl_NL">',
191  '<meta property="og:locale:alternate" content="de_DE">',
192  ]
193  ],
194  'multi value attribute name (empty values are skipped)' => [
195  [
196  'og:locale:alternate.' => [
197  'attribute' => 'property',
198  'value' => [
199  10 => 'nl_NL',
200  20 => '',
201  30 => 'de_DE',
202  ]
203  ],
204  ],
205  false,
206  [
207  '<meta name="generator" content="TYPO3 CMS">',
208  '<meta property="og:locale:alternate" content="nl_NL">',
209  '<meta property="og:locale:alternate" content="de_DE">',
210  ]
211  ],
212  'meta with empty string value' => [
213  [
214  'custom:key' => '',
215  ],
216  false,
217  [
218  '<meta name="generator" content="TYPO3 CMS">',
219  ]
220  ],
221  'meta with 0 value' => [
222  [
223  'custom:key' => '0',
224  ],
225  false,
226  [
227  '<meta name="generator" content="TYPO3 CMS">',
228  '<meta name="custom:key" content="0">',
229  ]
230  ],
231  ];
232  }
233 
242  public function generateMetaTagHtmlGeneratesCorrectTags(array $typoScript, $xhtml, array $expectedTags)
243  {
244  $result = $this->pageGeneratorFixture->callGenerateMetaTagHtml($typoScript, $xhtml, $this->contentObjectRenderer);
245  $this->assertSame($expectedTags, $result);
246  }
247 
252  {
253  return [
254  'one simple search word' => [
255  ['test'],
256  false,
257  'test',
258  ],
259  'one simple search word with standalone words' => [
260  ['test'],
261  true,
262  '[[:space:]]test[[:space:]]',
263  ],
264  'two simple search words' => [
265  ['test', 'test2'],
266  false,
267  'test|test2',
268  ],
269  'two simple search words with standalone words' => [
270  ['test', 'test2'],
271  true,
272  '[[:space:]]test[[:space:]]|[[:space:]]test2[[:space:]]',
273  ],
274  'word with regex chars' => [
275  ['A \\ word with / a bunch of [] regex () chars .*'],
276  false,
277  'A \\\\ word with \\/ a bunch of \\[\\] regex \\(\\) chars \\.\\*',
278  ],
279  ];
280  }
281 
290  public function initializeSearchWordDataInTsfeBuildsCorrectRegex(array $searchWordGetParameters, $enableStandaloneSearchWords, $expectedRegex)
291  {
292  $_GET['sword_list'] = $searchWordGetParameters;
293 
294  $GLOBALS['TSFE'] = new \stdClass();
295  if ($enableStandaloneSearchWords) {
296  $GLOBALS['TSFE']->config = ['config' => ['sword_standAlone' => 1]];
297  }
298 
299  $this->pageGeneratorFixture->callInitializeSearchWordDataInTsfe();
300  $this->assertEquals($GLOBALS['TSFE']->sWordRegEx, $expectedRegex);
301  }
302 }
generateMetaTagHtmlGeneratesCorrectTags(array $typoScript, $xhtml, array $expectedTags)
initializeSearchWordDataInTsfeBuildsCorrectRegex(array $searchWordGetParameters, $enableStandaloneSearchWords, $expectedRegex)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']