[FEATURE] 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']->cObjectDepthCounter = 100;
51
52 $this->abstractPlugin = new \TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
53 $this->abstractPlugin->cObj = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer();
54 $this->defaultPiVars = $this->abstractPlugin->piVars;
55 }
56
57 /**
58 * Tears down this testcase
59 */
60 public function tearDown() {
61 parent::tearDown();
62
63 $this->abstractPlugin = NULL;
64 }
65
66 /**
67 * Data provider for piSetPiVarDefaultsStdWrap
68 *
69 * @return array input-array with configuration and stdWrap, expected output-array in piVars
70 */
71 public function piSetPiVarDefaultsStdWrapProvider() {
72 return array(
73 'stdWrap on conf, non-recursive, stdWrap 1 level deep' => array(
74 array(
75 'abc' => 'DEF',
76 'abc.' => array(
77 'stdWrap.' => array(
78 'wrap' => 'test | test'
79 ),
80 ),
81 ),
82 array(
83 'abc' => 'testDEFtest',
84 'pointer' => '',
85 'mode' => '',
86 'sword' => '',
87 'sort' => '',
88 ),
89 ),
90 'stdWrap on conf, non-recursive, stdWrap 2 levels deep' => array(
91 array(
92 'xyz.' => array(
93 'stdWrap.' => array(
94 'cObject' => 'TEXT',
95 'cObject.' => array(
96 'data' => 'date:U',
97 'strftime' => '%Y',
98 ),
99 ),
100 ),
101 ),
102 array(
103 'xyz' => date('Y'),
104 'pointer' => '',
105 'mode' => '',
106 'sword' => '',
107 'sort' => '',
108 ),
109 ),
110 'stdWrap on conf, recursive' => array(
111 array(
112 'abc.' => array(
113 'def' => 'DEF',
114 'def.' => array(
115 'ghi' => '123',
116 'stdWrap.' => array(
117 'wrap' => 'test | test'
118 ),
119 ),
120 ),
121 ),
122 array(
123 'abc.' => array(
124 'def' => 'testDEFtest',
125 'def.' => array(
126 'ghi' => '123',
127 ),
128 ),
129 'pointer' => '',
130 'mode' => '',
131 'sword' => '',
132 'sort' => '',
133 ),
134 ),
135 );
136 }
137
138 /**
139 * @test
140 * @dataProvider piSetPiVarDefaultsStdWrapProvider
141 */
142 public function piSetPiVarDefaultsStdWrap($input, $expected) {
143 $this->abstractPlugin->piVars = $this->defaultPiVars;
144
145 $this->abstractPlugin->conf['_DEFAULT_PI_VARS.'] = $input;
146 $this->abstractPlugin->pi_setPiVarDefaults();
147 $this->assertEquals($expected, $this->abstractPlugin->piVars);
148 }
149
150 }
151
152 ?>