TYPO3 CMS  TYPO3_7-6
PostProcessorTest.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 
26 
31 {
35  protected $singletonInstances = [];
36 
40  protected $elementProphecy;
41 
46 
51 
55  protected function setUp()
56  {
57  parent::setUp();
58  $this->elementProphecy = $this->prophesize(Element::class);
59  $this->objectManagerProphecy = $this->prophesize(ObjectManager::class);
60  $this->controllerContextProphecy = $this->prophesize(ControllerContext::class);
61  }
62 
66  protected function tearDown()
67  {
68  parent::tearDown();
69  unset($this->elementProphecy);
70  unset($this->objectManagerProphecy);
71  unset($this->controllerContextProphecy);
72  }
73 
78  {
79  $typoScript = [
80  10 => $this->getUniqueId('postprocess'),
81  20 => PostProcessorWithoutFormPrefixFixture::class
82  ];
83 
84  $this->objectManagerProphecy
85  ->get(Argument::cetera())
86  ->will(function ($arguments) {
87  return new $arguments[0]($arguments[1], $arguments[2]);
88  });
89 
90  $subject = $this->createSubject($typoScript);
91  $this->assertEquals('processedWithoutPrefix', $subject->process());
92  }
93 
98  {
99  $typoScript = [
100  10 => $this->getUniqueId('postprocess'),
101  20 => PostProcessorWithFormPrefixFixture::class
102  ];
103 
104  $this->objectManagerProphecy
105  ->get(Argument::cetera())
106  ->will(function ($arguments) {
107  return new $arguments[0]($arguments[1], $arguments[2]);
108  });
109 
110  $subject = $this->createSubject($typoScript);
111  $this->assertEquals('processedWithPrefix', $subject->process());
112  }
113 
118  {
119  $typoScript = [
120  10 => $this->getUniqueId('postprocess'),
121  20 => PostProcessorWithoutInterfaceFixture::class
122  ];
123 
124  $this->objectManagerProphecy
125  ->get(Argument::cetera())
126  ->will(function ($arguments) {
127  return new $arguments[0]($arguments[1], $arguments[2]);
128  });
129 
130  $subject = $this->createSubject($typoScript);
131  $this->assertEquals('', $subject->process());
132  }
133 
138  protected function createSubject(array $typoScript)
139  {
140  $subject = $this->getAccessibleMock(
141  PostProcessor::class,
142  ['__none'],
143  [$this->elementProphecy->reveal(), $typoScript]
144  );
145  $subject->_set('controllerContext', $this->controllerContextProphecy->reveal());
146  $subject->_set('objectManager', $this->objectManagerProphecy->reveal());
147  return $subject;
148  }
149 }
$singletonInstances
tearDown()
processFindsClassSpecifiedByTypoScriptWithoutFormPrefix()
processFindsClassSpecifiedByTypoScriptWithFormPrefix()
$objectManagerProphecy
processReturnsEmptyStringIfSpecifiedPostProcessorDoesNotImplementTheInterface()
$elementProphecy
createSubject(array $typoScript)
$controllerContextProphecy
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)
setUp()