1760849b4fa2261a81f0901e1ca4a58a106f1ddb
[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 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
17 use TYPO3\CMS\Frontend\Tests\Unit\Page\Fixtures\PageGeneratorFixture;
18
19 /**
20 * Test case
21 *
22 * @author Markus Klein <klein.t3@mfc-linz.at>
23 */
24 class PageGeneratorTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
25
26 /**
27 * @var PageGeneratorFixture
28 */
29 protected $pageGeneratorFixture;
30
31 /**
32 * @var ContentObjectRenderer
33 */
34 protected $contentObjectRenderer;
35
36 /**
37 * Set up the helper objects
38 */
39 protected function setUp() {
40 $this->pageGeneratorFixture = new PageGeneratorFixture();
41 $this->contentObjectRenderer = new ContentObjectRenderer();
42 }
43
44 /**
45 * @return array
46 */
47 public function generateMetaTagHtmlGeneratesCorrectTagsDataProvider() {
48 return array(
49 'simple meta' => array(
50 array(
51 'author' => 'Markus Klein',
52 ),
53 FALSE,
54 array(
55 '<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS">',
56 '<meta name="author" content="Markus Klein">',
57 )
58 ),
59 'simple meta xhtml' => array(
60 array(
61 'author' => 'Markus Klein',
62 ),
63 TRUE,
64 array(
65 '<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS" />',
66 '<meta name="author" content="Markus Klein" />',
67 )
68 ),
69 'meta with nested stdWrap' => array(
70 array(
71 'author' => 'Markus ',
72 'author.' => array('stdWrap.' => array('wrap' => '|Klein'))
73 ),
74 FALSE,
75 array(
76 '<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS">',
77 '<meta name="author" content="Markus Klein">',
78 )
79 ),
80 'httpEquivalent meta' => array(
81 array(
82 'X-UA-Compatible' => 'IE=edge,chrome=1',
83 'X-UA-Compatible.' => array('httpEquivalent' => 1)
84 ),
85 FALSE,
86 array(
87 '<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS">',
88 '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">'
89 )
90 ),
91 'httpEquivalent meta xhtml' => array(
92 array(
93 'X-UA-Compatible' => 'IE=edge,chrome=1',
94 'X-UA-Compatible.' => array('httpEquivalent' => 1)
95 ),
96 TRUE,
97 array(
98 '<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS" />',
99 '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />'
100 )
101 ),
102 'refresh meta' => array(
103 array(
104 'refresh' => '10',
105 ),
106 FALSE,
107 array(
108 '<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS">',
109 '<meta http-equiv="refresh" content="10">',
110 )
111 ),
112 'meta with dot' => array(
113 array(
114 'DC.author' => 'Markus Klein',
115 ),
116 FALSE,
117 array(
118 '<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS">',
119 '<meta name="DC.author" content="Markus Klein">',
120 )
121 ),
122 'meta with colon' => array(
123 array(
124 'OG:title' => 'Magic Tests',
125 ),
126 FALSE,
127 array(
128 '<meta name="generator" content="TYPO3 ' . TYPO3_branch . ' CMS">',
129 '<meta name="OG:title" content="Magic Tests">',
130 )
131 ),
132 );
133 }
134
135 /**
136 * @test
137 * @dataProvider generateMetaTagHtmlGeneratesCorrectTagsDataProvider
138 *
139 * @param array $typoScript
140 * @param bool $xhtml
141 * @param array $expectedTags
142 */
143 public function generateMetaTagHtmlGeneratesCorrectTags(array $typoScript, $xhtml, array $expectedTags) {
144 $result = $this->pageGeneratorFixture->callGenerateMetaTagHtml($typoScript, $xhtml, $this->contentObjectRenderer);
145 $this->assertSame($expectedTags, $result);
146 }
147 }