Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Fix override of runBare() in functional test #3421

Open
wants to merge 1 commit into
base: 8.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

60 changes: 20 additions & 40 deletions Neos.FluidAdaptor/Tests/Functional/View/StandaloneViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Tests\FunctionalTestCase;
use Neos\FluidAdaptor\Core\ViewHelper\Exception\WrongEnctypeException;
use Neos\FluidAdaptor\Tests\Functional\View\Fixtures\View\StandaloneView;
use Neos\FluidAdaptor\View\Exception\InvalidTemplateResourceException;
use Neos\FluidAdaptor\View\StandaloneView;
use Psr\Http\Message\ServerRequestFactoryInterface;
use TYPO3Fluid\Fluid\Core\Parser\UnknownNamespaceException;

Expand All @@ -25,26 +25,6 @@
*/
class StandaloneViewTest extends FunctionalTestCase
{
/**
* @var string
*/
protected $standaloneViewNonce = '42';

/**
* Every testcase should run *twice*. First, it is run in *uncached* way, second,
* it is run *cached*. To make sure that the first run is always uncached, the
* $standaloneViewNonce is initialized to some random value which is used inside
* an overridden version of StandaloneView::createIdentifierForFile.
*/
public function runBare(): void
{
$this->standaloneViewNonce = uniqid('', true);
parent::runBare();
$numberOfAssertions = $this->getNumAssertions();
parent::runBare();
$this->addToAssertionCount($numberOfAssertions);
}

/**
* @test
*/
Expand All @@ -53,7 +33,7 @@ public function inlineTemplateIsEvaluatedCorrectly(): void
$httpRequest = $this->objectManager->get(ServerRequestFactoryInterface::class)->createServerRequest('GET', 'http://localhost');
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);

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

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

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

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

$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
$standaloneView = new StandaloneView($actionRequest);
$standaloneView->render();
}

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

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

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

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

$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
$standaloneView = new StandaloneView($actionRequest);
$standaloneView->assign('name', 'Karsten');
$standaloneView->assign('name', 'Robert');
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplate.txt');
Expand All @@ -157,7 +137,7 @@ public function templatePathAndFilenameIsLoaded(): void
*/
public function variablesAreEscapedByDefault(): void
{
$standaloneView = new StandaloneView(null, $this->standaloneViewNonce);
$standaloneView = new StandaloneView(null);
$standaloneView->assign('name', 'Sebastian <script>alert("dangerous");</script>');
$standaloneView->setTemplateSource('Hello {name}.');

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

Expand All @@ -185,7 +165,7 @@ public function variablesAreNotEscapedIfEscapingIsDisabled(): void
*/
public function variablesCanBeNested()
{
$standaloneView = new StandaloneView(null, $this->standaloneViewNonce);
$standaloneView = new StandaloneView(null);
$standaloneView->assign('type', 'thing');
$standaloneView->assign('flavor', 'yellow');
$standaloneView->assign('config', ['thing' => ['value' => ['yellow' => 'Okayish']]]);
Expand All @@ -205,7 +185,7 @@ public function partialWithDefaultLocationIsUsedIfNoPartialPathIsSetExplicitly()
$actionRequest = ActionRequest::fromHttpRequest($httpRequest);
$actionRequest->setFormat('txt');

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

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

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

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

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

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

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

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

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

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

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

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

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

$standaloneView = new StandaloneView($actionRequest, $this->standaloneViewNonce);
$standaloneView = new StandaloneView($actionRequest);
$standaloneView->assign('name', 'Karsten');
$standaloneView->assign('name', 'Robert');
$standaloneView->setTemplatePathAndFilename(__DIR__ . '/Fixtures/TestTemplateWithFormField.txt');
Expand Down
Loading