[BUGFIX] Follow-up: Add stdWrap for _DEFAULT_PI_VARS
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Unit / Plugin / AbstractPluginTest.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Unit\Plugin;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Stefan Neufeind <info (at) speedpartner.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * Testcase for TYPO3\CMS\Frontend\Plugin\AbstractPlugin
28 *
29 * @author Stefan Neufeind <info (at) speedpartner.de>
30 */
31 class AbstractPluginTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
32
33 /**
34 * @var \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
35 */
36 protected $abstractPlugin;
37
38 /**
39 * @var array
40 */
41 protected $defaultPiVars;
42
43 /**
44 * Sets up this testcase
45 */
46 public function setUp() {
47 parent::setUp();
48
49 // Allow objects until 100 levels deep when executing the stdWrap
50 $GLOBALS['TSFE'] = new \stdClass();
51 $GLOBALS['TSFE']->cObjectDepthCounter = 100;
52
53 $this->abstractPlugin = new \TYPO3\CMS\Frontend\Plugin\AbstractPlugin();
54 $this->abstractPlugin->cObj = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer();
55 $this->defaultPiVars = $this->abstractPlugin->piVars;
56 }
57
58 /**
59 * Tears down this testcase
60 */
61 public function tearDown() {
62 parent::tearDown();
63
64 $this->abstractPlugin = NULL;
65 }
66
67 /**
68 * Data provider for piSetPiVarDefaultsStdWrap
69 *
70 * @return array input-array with configuration and stdWrap, expected output-array in piVars
71 */
72 public function piSetPiVarDefaultsStdWrapProvider() {
73 return array(
74 'stdWrap on conf, non-recursive, stdWrap 1 level deep' => array(
75 array(
76 'abc' => 'DEF',
77 'abc.' => array(
78 'stdWrap.' => array(
79 'wrap' => 'test | test'
80 ),
81 ),
82 ),
83 array(
84 'abc' => 'testDEFtest',
85 'pointer' => '',
86 'mode' => '',
87 'sword' => '',
88 'sort' => '',
89 ),
90 ),
91 'stdWrap on conf, non-recursive, stdWrap 2 levels deep' => array(
92 array(
93 'xyz.' => array(
94 'stdWrap.' => array(
95 'cObject' => 'TEXT',
96 'cObject.' => array(
97 'data' => 'date:U',
98 'strftime' => '%Y',
99 ),
100 ),
101 ),
102 ),
103 array(
104 'xyz' => date('Y'),
105 'pointer' => '',
106 'mode' => '',
107 'sword' => '',
108 'sort' => '',
109 ),
110 ),
111 'stdWrap on conf, recursive' => array(
112 array(
113 'abc.' => array(
114 'def' => 'DEF',
115 'def.' => array(
116 'ghi' => '123',
117 'stdWrap.' => array(
118 'wrap' => 'test | test'
119 ),
120 ),
121 ),
122 ),
123 array(
124 'abc.' => array(
125 'def' => 'testDEFtest',
126 'def.' => array(
127 'ghi' => '123',
128 ),
129 ),
130 'pointer' => '',
131 'mode' => '',
132 'sword' => '',
133 'sort' => '',
134 ),
135 ),
136 );
137 }
138
139 /**
140 * @test
141 * @dataProvider piSetPiVarDefaultsStdWrapProvider
142 */
143 public function piSetPiVarDefaultsStdWrap($input, $expected) {
144 $this->abstractPlugin->piVars = $this->defaultPiVars;
145
146 $this->abstractPlugin->conf['_DEFAULT_PI_VARS.'] = $input;
147 $this->abstractPlugin->pi_setPiVarDefaults();
148 $this->assertEquals($expected, $this->abstractPlugin->piVars);
149 }
150
151 }
152
153 ?>