Skip to content

Commit 1ba400b

Browse files
authored
Merge pull request #3421 from kdambekalns/task/drop-runbare-override
TASK: Fix override of runBare() in functional test
2 parents e7c80d7 + 9a0380e commit 1ba400b

File tree

2 files changed

+20
-80
lines changed

2 files changed

+20
-80
lines changed

Neos.FluidAdaptor/Tests/Functional/View/Fixtures/View/StandaloneView.php

Lines changed: 0 additions & 40 deletions
This file was deleted.

Neos.FluidAdaptor/Tests/Functional/View/StandaloneViewTest.php

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use Neos\Flow\Mvc\ActionRequest;
1616
use Neos\Flow\Tests\FunctionalTestCase;
1717
use Neos\FluidAdaptor\Core\ViewHelper\Exception\WrongEnctypeException;
18-
use Neos\FluidAdaptor\Tests\Functional\View\Fixtures\View\StandaloneView;
1918
use Neos\FluidAdaptor\View\Exception\InvalidTemplateResourceException;
19+
use Neos\FluidAdaptor\View\StandaloneView;
2020
use Psr\Http\Message\ServerRequestFactoryInterface;
2121
use TYPO3Fluid\Fluid\Core\Parser\UnknownNamespaceException;
2222

@@ -25,26 +25,6 @@
2525
*/
2626
class StandaloneViewTest extends FunctionalTestCase
2727
{
28-
/**
29-
* @var string
30-
*/
31-
protected $standaloneViewNonce = '42';
32-
33-
/**
34-
* Every testcase should run *twice*. First, it is run in *uncached* way, second,
35-
* it is run *cached*. To make sure that the first run is always uncached, the
36-
* $standaloneViewNonce is initialized to some random value which is used inside
37-
* an overridden version of StandaloneView::createIdentifierForFile.
38-
*/
39-
public function runBare(): void
40-
{
41-
$this->standaloneViewNonce = uniqid('', true);
42-
parent::runBare();
43-
$numberOfAssertions = $this->getNumAssertions();
44-
parent::runBare();
45-
$this->addToAssertionCount($numberOfAssertions);
46-
}
47-
4828
/**
4929
* @test
5030
*/
@@ -53,7 +33,7 @@ public function inlineTemplateIsEvaluatedCorrectly(): void
5333
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
5434
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
5535

56-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
36+
$standaloneView = new StandaloneView($actionRequest);
5737
$standaloneView->assign('foo', 'bar');
5838
$standaloneView->setTemplateSource('This is my cool {foo} template!');
5939

@@ -70,7 +50,7 @@ public function renderSectionIsEvaluatedCorrectly(): void
7050
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
7151
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
7252

73-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
53+
$standaloneView = new StandaloneView($actionRequest);
7454
$standaloneView->assign('foo', 'bar');
7555
$standaloneView->setTemplateSource('Around stuff... <f:section name="innerSection">test {foo}</f:section> after it');
7656

@@ -88,7 +68,7 @@ public function renderThrowsExceptionIfNeitherTemplateSourceNorTemplatePathAndFi
8868
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
8969
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
9070

91-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
71+
$standaloneView = new StandaloneView($actionRequest);
9272
$standaloneView->render();
9373
}
9474

@@ -101,7 +81,7 @@ public function renderThrowsExceptionSpecifiedTemplatePathAndFilenameDoesNotExis
10181
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
10282
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
10383

104-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
84+
$standaloneView = new StandaloneView($actionRequest);
10585
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/NonExistingTemplate.txt');
10686
$standaloneView->render();
10787
}
@@ -115,7 +95,7 @@ public function renderThrowsExceptionIfWrongEnctypeIsSetForFormUpload(): void
11595
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
11696
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
11797

118-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
98+
$standaloneView = new StandaloneView($actionRequest);
11999
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithFormUpload.txt');
120100
$standaloneView->render();
121101
}
@@ -129,7 +109,7 @@ public function renderThrowsExceptionIfSpecifiedTemplatePathAndFilenamePointsToA
129109
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
130110
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
131111

132-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
112+
$standaloneView = new StandaloneView($actionRequest);
133113
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures');
134114
$standaloneView->render();
135115
}
@@ -142,7 +122,7 @@ public function templatePathAndFilenameIsLoaded(): void
142122
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
143123
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
144124

145-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
125+
$standaloneView = new StandaloneView($actionRequest);
146126
$standaloneView->assign('name', 'Karsten');
147127
$standaloneView->assign('name', 'Robert');
148128
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplate.txt');
@@ -157,7 +137,7 @@ public function templatePathAndFilenameIsLoaded(): void
157137
*/
158138
public function variablesAreEscapedByDefault(): void
159139
{
160-
$standaloneView = new StandaloneView(null, $this->standaloneViewNonce);
140+
$standaloneView = new StandaloneView(null);
161141
$standaloneView->assign('name', 'Sebastian <script>alert("dangerous");</script>');
162142
$standaloneView->setTemplateSource('Hello {name}.');
163143

@@ -171,7 +151,7 @@ public function variablesAreEscapedByDefault(): void
171151
*/
172152
public function variablesAreNotEscapedIfEscapingIsDisabled(): void
173153
{
174-
$standaloneView = new StandaloneView(null, $this->standaloneViewNonce);
154+
$standaloneView = new StandaloneView(null);
175155
$standaloneView->assign('name', 'Sebastian <script>alert("dangerous");</script>');
176156
$standaloneView->setTemplateSource('{escapingEnabled=false}Hello {name}.');
177157

@@ -185,7 +165,7 @@ public function variablesAreNotEscapedIfEscapingIsDisabled(): void
185165
*/
186166
public function variablesCanBeNested()
187167
{
188-
$standaloneView = new StandaloneView(null, $this->standaloneViewNonce);
168+
$standaloneView = new StandaloneView(null);
189169
$standaloneView->assign('type', 'thing');
190170
$standaloneView->assign('flavor', 'yellow');
191171
$standaloneView->assign('config', ['thing' => ['value' => ['yellow' => 'Okayish']]]);
@@ -205,7 +185,7 @@ public function partialWithDefaultLocationIsUsedIfNoPartialPathIsSetExplicitly()
205185
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
206186
$actionRequest->setFormat('txt');
207187

208-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
188+
$standaloneView = new StandaloneView($actionRequest);
209189
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithPartial.txt');
210190

211191
$expected = 'This is a test template. Hello Robert.';
@@ -222,7 +202,7 @@ public function explicitPartialPathIsUsed(): void
222202
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
223203
$actionRequest->setFormat('txt');
224204

225-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
205+
$standaloneView = new StandaloneView($actionRequest);
226206
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithPartial.txt');
227207
$standaloneView->setPartialRootPath(__DIR__ . '/Fixtures/SpecialPartialsDirectory');
228208

@@ -240,7 +220,7 @@ public function layoutWithDefaultLocationIsUsedIfNoLayoutPathIsSetExplicitly():
240220
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
241221
$actionRequest->setFormat('txt');
242222

243-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
223+
$standaloneView = new StandaloneView($actionRequest);
244224
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithLayout.txt');
245225

246226
$expected = 'Hey HEY HO';
@@ -256,7 +236,7 @@ public function explicitLayoutPathIsUsed(): void
256236
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
257237
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
258238
$actionRequest->setFormat('txt');
259-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
239+
$standaloneView = new StandaloneView($actionRequest);
260240
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithLayout.txt');
261241
$standaloneView->setLayoutRootPath(__DIR__ . '/Fixtures/SpecialLayouts');
262242

@@ -274,7 +254,7 @@ public function viewThrowsExceptionWhenUnknownViewHelperIsCalled(): void
274254
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
275255
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
276256
$actionRequest->setFormat('txt');
277-
$standaloneView = new Fixtures\View\StandaloneView($actionRequest, $this->standaloneViewNonce);
257+
$standaloneView = new StandaloneView($actionRequest);
278258
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithUnknownViewHelper.txt');
279259
$standaloneView->setLayoutRootPath(__DIR__ . '/Fixtures/SpecialLayouts');
280260

@@ -289,7 +269,7 @@ public function xmlNamespacesCanBeIgnored(): void
289269
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
290270
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
291271
$actionRequest->setFormat('txt');
292-
$standaloneView = new Fixtures\View\StandaloneView($actionRequest, $this->standaloneViewNonce);
272+
$standaloneView = new StandaloneView($actionRequest);
293273
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithCustomNamespaces.txt');
294274
$standaloneView->setLayoutRootPath(__DIR__ . '/Fixtures/SpecialLayouts');
295275

@@ -312,7 +292,7 @@ public function interceptorsWorkInPartialRenderedInStandaloneSection(): void
312292
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
313293
$actionRequest->setFormat('html');
314294

315-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
295+
$standaloneView = new StandaloneView($actionRequest);
316296
$standaloneView->assign('hack', '<h1>HACK</h1>');
317297
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/NestedRenderingConfiguration/TemplateWithSection.txt');
318298

@@ -324,7 +304,7 @@ public function interceptorsWorkInPartialRenderedInStandaloneSection(): void
324304
$templateCache = $this->objectManager->get(CacheManager::class)->getCache('Fluid_TemplateCache');
325305
$templateCache->remove($partialCacheIdentifier);
326306

327-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
307+
$standaloneView = new StandaloneView($actionRequest);
328308
$standaloneView->assign('hack', '<h1>HACK</h1>');
329309
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/NestedRenderingConfiguration/TemplateWithSection.txt');
330310

@@ -366,7 +346,7 @@ public function formViewHelpersOutsideOfFormWork(): void
366346
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
367347
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
368348

369-
$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
349+
$standaloneView = new StandaloneView($actionRequest);
370350
$standaloneView->assign('name', 'Karsten');
371351
$standaloneView->assign('name', 'Robert');
372352
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithFormField.txt');

0 commit comments

Comments
 (0)