TYPO3  7.6
AbstractPluginTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Unit\Plugin;
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  */
18 
22 class AbstractPluginTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
23 {
27  protected $abstractPlugin;
28 
32  protected $defaultPiVars;
33 
37  protected function setUp()
38  {
39  parent::setUp();
40 
41  // Allow objects until 100 levels deep when executing the stdWrap
42  $GLOBALS['TSFE'] = new \stdClass();
43  $GLOBALS['TSFE']->cObjectDepthCounter = 100;
44 
45  $this->abstractPlugin = new \TYPO3\CMS\Frontend\Plugin\AbstractPlugin();
46  $contentObjectRenderer = new ContentObjectRenderer();
47  $contentObjectRenderer->setContentObjectClassMap(array(
48  'TEXT' => TextContentObject::class,
49  ));
50  $this->abstractPlugin->cObj = $contentObjectRenderer;
51  $this->defaultPiVars = $this->abstractPlugin->piVars;
52  }
53 
60  {
61  return array(
62  'stdWrap on conf, non-recursive, stdWrap 1 level deep' => array(
63  array(
64  'abc' => 'DEF',
65  'abc.' => array(
66  'stdWrap.' => array(
67  'wrap' => 'test | test'
68  ),
69  ),
70  ),
71  array(
72  'abc' => 'testDEFtest',
73  'pointer' => '',
74  'mode' => '',
75  'sword' => '',
76  'sort' => '',
77  ),
78  ),
79  'stdWrap on conf, non-recursive, stdWrap 2 levels deep' => array(
80  array(
81  'xyz.' => array(
82  'stdWrap.' => array(
83  'cObject' => 'TEXT',
84  'cObject.' => array(
85  'data' => 'date:U',
86  'strftime' => '%Y',
87  ),
88  ),
89  ),
90  ),
91  array(
92  'xyz' => date('Y'),
93  'pointer' => '',
94  'mode' => '',
95  'sword' => '',
96  'sort' => '',
97  ),
98  ),
99  'stdWrap on conf, recursive' => array(
100  array(
101  'abc.' => array(
102  'def' => 'DEF',
103  'def.' => array(
104  'ghi' => '123',
105  'stdWrap.' => array(
106  'wrap' => 'test | test'
107  ),
108  ),
109  ),
110  ),
111  array(
112  'abc.' => array(
113  'def' => 'testDEFtest',
114  'def.' => array(
115  'ghi' => '123',
116  ),
117  ),
118  'pointer' => '',
119  'mode' => '',
120  'sword' => '',
121  'sort' => '',
122  ),
123  ),
124  );
125  }
126 
131  public function piSetPiVarDefaultsStdWrap($input, $expected)
132  {
133  $this->abstractPlugin->piVars = $this->defaultPiVars;
134 
135  $this->abstractPlugin->conf['_DEFAULT_PI_VARS.'] = $input;
136  $this->abstractPlugin->pi_setPiVarDefaults();
137  $this->assertEquals($expected, $this->abstractPlugin->piVars);
138  }
139 }