Skip to content
Snippets Groups Projects
Commit 3d35dfd8 authored by Benjamin Franzke's avatar Benjamin Franzke Committed by Oliver Bartsch
Browse files

[BUGFIX] Allow service aliases in ContentDataProcessor

Fetch services from the DI container and perform post-creations
checks instead of checking class_exists and therefore exclude
possible service aliases defined in DI.

Releases: master
Resolves: #95855
Resolves: #92910
Change-Id: Ic85485edc7604a92bdf72d147ad47fe79954500e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72029


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
parent 9a7da081
Branches
Tags
No related merge requests found
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
namespace TYPO3\CMS\Frontend\ContentObject; namespace TYPO3\CMS\Frontend\ContentObject;
use Psr\Container\ContainerInterface;
use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
...@@ -23,6 +24,13 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; ...@@ -23,6 +24,13 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
*/ */
class ContentDataProcessor class ContentDataProcessor
{ {
private ContainerInterface $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
/** /**
* Check for the availability of processors, defined in TypoScript, and use them for data processing * Check for the availability of processors, defined in TypoScript, and use them for data processing
* *
...@@ -42,22 +50,9 @@ class ContentDataProcessor ...@@ -42,22 +50,9 @@ class ContentDataProcessor
$processorKeys = ArrayUtility::filterAndSortByNumericKeys($processors); $processorKeys = ArrayUtility::filterAndSortByNumericKeys($processors);
foreach ($processorKeys as $key) { foreach ($processorKeys as $key) {
$className = $processors[$key]; $dataProcessor = $this->getDataProcessor($processors[$key]);
if (!class_exists($className)) {
throw new \UnexpectedValueException('Processor class name "' . $className . '" does not exist!', 1427455378);
}
if (!in_array(DataProcessorInterface::class, class_implements($className) ?: [], true)) {
throw new \UnexpectedValueException(
'Processor with class name "' . $className . '" ' .
'must implement interface "' . DataProcessorInterface::class . '"',
1427455377
);
}
$processorConfiguration = $processors[$key . '.'] ?? []; $processorConfiguration = $processors[$key . '.'] ?? [];
$variables = $dataProcessor->process(
$variables = GeneralUtility::makeInstance($className)->process(
$cObject, $cObject,
$configuration, $configuration,
$processorConfiguration, $processorConfiguration,
...@@ -68,4 +63,38 @@ class ContentDataProcessor ...@@ -68,4 +63,38 @@ class ContentDataProcessor
return $variables; return $variables;
} }
private function getDataProcessor(string $serviceName): DataProcessorInterface
{
if (!$this->container->has($serviceName)) {
// assume serviceName is the class name if it is not available in the container
return $this->instantiateDataProcessor($serviceName);
}
$dataProcessor = $this->container->get($serviceName);
if (!$dataProcessor instanceof DataProcessorInterface) {
throw new \UnexpectedValueException(
'Processor with service name "' . $serviceName . '" ' .
'must implement interface "' . DataProcessorInterface::class . '"',
1635927108
);
}
return $dataProcessor;
}
private function instantiateDataProcessor(string $className): DataProcessorInterface
{
if (!class_exists($className)) {
throw new \UnexpectedValueException('Processor class or service name "' . $className . '" does not exist!', 1427455378);
}
if (!in_array(DataProcessorInterface::class, class_implements($className) ?: [], true)) {
throw new \UnexpectedValueException(
'Processor with class name "' . $className . '" ' .
'must implement interface "' . DataProcessorInterface::class . '"',
1427455377
);
}
return GeneralUtility::makeInstance($className);
}
} }
...@@ -18,6 +18,9 @@ services: ...@@ -18,6 +18,9 @@ services:
version: '11.5' version: '11.5'
message: 'Injection of "%service_id%" breaks subrequests. Please use the PSR-7 request attribute "frontend.controller".' message: 'Injection of "%service_id%" breaks subrequests. Please use the PSR-7 request attribute "frontend.controller".'
TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor:
public: true
TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer: TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer:
public: true public: true
shared: false shared: false
......
...@@ -17,6 +17,10 @@ declare(strict_types=1); ...@@ -17,6 +17,10 @@ declare(strict_types=1);
namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject; namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Container\ContainerInterface;
use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor; use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Fixtures\DataProcessorFixture; use TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Fixtures\DataProcessorFixture;
...@@ -27,21 +31,32 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; ...@@ -27,21 +31,32 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
*/ */
class ContentDataProcessorTest extends UnitTestCase class ContentDataProcessorTest extends UnitTestCase
{ {
use ProphecyTrait;
protected ContentDataProcessor $contentDataProcessor; protected ContentDataProcessor $contentDataProcessor;
/**
* @var ObjectProphecy|ContainerInterface
*/
protected ObjectProphecy $containerProphecy;
/** /**
* Set up * Set up
*/ */
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->contentDataProcessor = new ContentDataProcessor(); $this->containerProphecy = $this->prophesize(ContainerInterface::class);
$this->containerProphecy->has(Argument::any())->willReturn(false);
$this->contentDataProcessor = new ContentDataProcessor(
$this->containerProphecy->reveal()
);
} }
/** /**
* @test * @test
*/ */
public function throwsExceptionIfProcessorClassDoesNotExist(): void public function throwsExceptionIfProcessorDoesNotExist(): void
{ {
$this->expectException(\UnexpectedValueException::class); $this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1427455378); $this->expectExceptionCode(1427455378);
...@@ -75,7 +90,7 @@ class ContentDataProcessorTest extends UnitTestCase ...@@ -75,7 +90,7 @@ class ContentDataProcessorTest extends UnitTestCase
/** /**
* @test * @test
*/ */
public function processorIsCalled(): void public function processorClassIsCalled(): void
{ {
$contentObjectRendererStub = new ContentObjectRenderer(); $contentObjectRendererStub = new ContentObjectRenderer();
$config = [ $config = [
...@@ -90,4 +105,44 @@ class ContentDataProcessorTest extends UnitTestCase ...@@ -90,4 +105,44 @@ class ContentDataProcessorTest extends UnitTestCase
$this->contentDataProcessor->process($contentObjectRendererStub, $config, $variables) $this->contentDataProcessor->process($contentObjectRendererStub, $config, $variables)
); );
} }
/**
* @test
*/
public function throwsExceptionIfProcessorServiceDoesNotImplementInterface(): void
{
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionCode(1635927108);
$contentObjectRendererStub = new ContentObjectRenderer();
$this->containerProphecy->has(static::class)->willReturn(true);
$this->containerProphecy->get(static::class)->willReturn($this);
$config = [
'dataProcessing.' => [
'10' => static::class,
],
];
$variables = [];
$this->contentDataProcessor->process($contentObjectRendererStub, $config, $variables);
}
/**
* @test
*/
public function processorServiceIsCalled(): void
{
$contentObjectRendererStub = new ContentObjectRenderer();
$this->containerProphecy->has('dataProcessorFixture')->willReturn(true);
$this->containerProphecy->get('dataProcessorFixture')->willReturn(new DataProcessorFixture());
$config = [
'dataProcessing.' => [
'10' => 'dataProcessorFixture',
'10.' => ['foo' => 'bar'],
],
];
$variables = [];
self::assertSame(
['foo' => 'bar'],
$this->contentDataProcessor->process($contentObjectRendererStub, $config, $variables)
);
}
} }
...@@ -22,6 +22,7 @@ use PHPUnit\Framework\MockObject\MockObject; ...@@ -22,6 +22,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use Prophecy\Argument; use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophecy\ObjectProphecy;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\NullLogger; use Psr\Log\NullLogger;
use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Cache\CacheManager;
...@@ -54,6 +55,7 @@ use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication; ...@@ -54,6 +55,7 @@ use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
use TYPO3\CMS\Frontend\ContentObject\AbstractContentObject; use TYPO3\CMS\Frontend\ContentObject\AbstractContentObject;
use TYPO3\CMS\Frontend\ContentObject\CaseContentObject; use TYPO3\CMS\Frontend\ContentObject\CaseContentObject;
use TYPO3\CMS\Frontend\ContentObject\ContentContentObject; use TYPO3\CMS\Frontend\ContentObject\ContentContentObject;
use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayContentObject; use TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayContentObject;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayInternalContentObject; use TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayInternalContentObject;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectGetImageResourceHookInterface; use TYPO3\CMS\Frontend\ContentObject\ContentObjectGetImageResourceHookInterface;
...@@ -393,6 +395,9 @@ class ContentObjectRendererTest extends UnitTestCase ...@@ -393,6 +395,9 @@ class ContentObjectRendererTest extends UnitTestCase
self::assertTrue( self::assertTrue(
is_subclass_of($className, AbstractContentObject::class) is_subclass_of($className, AbstractContentObject::class)
); );
if ($objectName === 'FLUIDTEMPLATE') {
GeneralUtility::addInstance(ContentDataProcessor::class, new ContentDataProcessor($this->prophesize(ContainerInterface::class)->reveal()));
}
$object = $this->subject->getContentObject($objectName); $object = $this->subject->getContentObject($objectName);
self::assertInstanceOf($className, $object); self::assertInstanceOf($className, $object);
} }
......
...@@ -22,6 +22,7 @@ use Prophecy\Argument; ...@@ -22,6 +22,7 @@ use Prophecy\Argument;
use Prophecy\Doubler\Generator\Node\ReturnTypeNode; use Prophecy\Doubler\Generator\Node\ReturnTypeNode;
use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophecy\ObjectProphecy;
use Psr\Container\ContainerInterface;
use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\TypoScript\TemplateService; use TYPO3\CMS\Core\TypoScript\TemplateService;
...@@ -29,6 +30,7 @@ use TYPO3\CMS\Core\TypoScript\TypoScriptService; ...@@ -29,6 +30,7 @@ use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Request; use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject; use TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
...@@ -61,6 +63,11 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -61,6 +63,11 @@ class FluidTemplateContentObjectTest extends UnitTestCase
*/ */
protected ObjectProphecy $contentObjectRenderer; protected ObjectProphecy $contentObjectRenderer;
/**
* @var ContentDataProcessor
*/
protected ContentDataProcessor $contentDataProcessor;
/** /**
* @var StandaloneView|MockObject * @var StandaloneView|MockObject
*/ */
...@@ -77,7 +84,9 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -77,7 +84,9 @@ class FluidTemplateContentObjectTest extends UnitTestCase
protected function setUp(): void protected function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->contentDataProcessor = new ContentDataProcessor($this->prophesize(ContainerInterface::class)->reveal());
$this->contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $this->contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$this->subject = $this->getAccessibleMock( $this->subject = $this->getAccessibleMock(
FluidTemplateContentObject::class, FluidTemplateContentObject::class,
['initializeStandaloneViewInstance'], ['initializeStandaloneViewInstance'],
...@@ -109,6 +118,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -109,6 +118,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
public function constructSetsContentObjectRenderer(): void public function constructSetsContentObjectRenderer(): void
{ {
$contentObjectRenderer = new ContentObjectRenderer(); $contentObjectRenderer = new ContentObjectRenderer();
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer); $subject = new FluidTemplateContentObject($contentObjectRenderer);
self::assertEquals($contentObjectRenderer, $subject->getContentObjectRenderer()); self::assertEquals($contentObjectRenderer, $subject->getContentObjectRenderer());
} }
...@@ -150,6 +160,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -150,6 +160,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$standAloneView->render(Argument::cetera())->willReturn(''); $standAloneView->render(Argument::cetera())->willReturn('');
$standAloneView->renderSection(Argument::cetera())->willReturn(''); $standAloneView->renderSection(Argument::cetera())->willReturn('');
GeneralUtility::addInstance(StandaloneView::class, $standAloneView->reveal()); GeneralUtility::addInstance(StandaloneView::class, $standAloneView->reveal());
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$subject->render($configuration); $subject->render($configuration);
...@@ -168,6 +179,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -168,6 +179,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('file', $configuration)->willReturn('EXT:core/bar.html'); $contentObjectRenderer->stdWrapValue('file', $configuration)->willReturn('EXT:core/bar.html');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
...@@ -197,6 +209,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -197,6 +209,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(7); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(7);
$contentObjectRenderer->cObjGetSingle('FILE', ['file' => Environment::getPublicPath() . '/foo/bar.html'], 'template')->willReturn('baz'); $contentObjectRenderer->cObjGetSingle('FILE', ['file' => Environment::getPublicPath() . '/foo/bar.html'], 'template')->willReturn('baz');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->assignMultiple(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->assignMultiple(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -225,6 +238,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -225,6 +238,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('templateName', $configuration)->willReturn('foo'); $contentObjectRenderer->stdWrapValue('templateName', $configuration)->willReturn('foo');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
...@@ -258,6 +272,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -258,6 +272,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('templateName', $configuration)->willReturn('bar'); $contentObjectRenderer->stdWrapValue('templateName', $configuration)->willReturn('bar');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
...@@ -283,6 +298,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -283,6 +298,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('layoutRootPath', $configuration)->willReturn('foo/bar.html'); $contentObjectRenderer->stdWrapValue('layoutRootPath', $configuration)->willReturn('foo/bar.html');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -311,6 +327,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -311,6 +327,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -343,6 +360,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -343,6 +360,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrap('FILE', ['file' => 'foo/bar.html'])->shouldBeCalled(); $contentObjectRenderer->stdWrap('FILE', ['file' => 'foo/bar.html'])->shouldBeCalled();
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setLayoutRootPaths(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setLayoutRootPaths(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -387,6 +405,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -387,6 +405,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('layoutRootPath', $configuration)->willReturn('foo/main.html'); $contentObjectRenderer->stdWrapValue('layoutRootPath', $configuration)->willReturn('foo/main.html');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -415,6 +434,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -415,6 +434,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('partialRootPath', $configuration)->willReturn('foo/bar.html'); $contentObjectRenderer->stdWrapValue('partialRootPath', $configuration)->willReturn('foo/bar.html');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -452,6 +472,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -452,6 +472,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$standAloneView->render(Argument::cetera())->willReturn(''); $standAloneView->render(Argument::cetera())->willReturn('');
$standAloneView->renderSection(Argument::cetera())->willReturn(''); $standAloneView->renderSection(Argument::cetera())->willReturn('');
GeneralUtility::addInstance(StandaloneView::class, $standAloneView->reveal()); GeneralUtility::addInstance(StandaloneView::class, $standAloneView->reveal());
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$subject->render($configuration); $subject->render($configuration);
...@@ -470,6 +491,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -470,6 +491,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
]; ];
$contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
...@@ -518,6 +540,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -518,6 +540,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$standAloneView->render(Argument::cetera())->willReturn(''); $standAloneView->render(Argument::cetera())->willReturn('');
$standAloneView->renderSection(Argument::cetera())->willReturn(''); $standAloneView->renderSection(Argument::cetera())->willReturn('');
GeneralUtility::addInstance(StandaloneView::class, $standAloneView->reveal()); GeneralUtility::addInstance(StandaloneView::class, $standAloneView->reveal());
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$subject->render($configuration); $subject->render($configuration);
...@@ -544,6 +567,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -544,6 +567,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('format', $configuration)->willReturn('xml'); $contentObjectRenderer->stdWrapValue('format', $configuration)->willReturn('xml');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -569,6 +593,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -569,6 +593,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -597,6 +622,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -597,6 +622,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('pluginName', ['pluginName' => 'foo'])->willReturn('foo'); $contentObjectRenderer->stdWrapValue('pluginName', ['pluginName' => 'foo'])->willReturn('foo');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
...@@ -628,6 +654,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -628,6 +654,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -656,6 +683,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -656,6 +683,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('controllerExtensionName', ['controllerExtensionName' => 'foo'])->willReturn('foo'); $contentObjectRenderer->stdWrapValue('controllerExtensionName', ['controllerExtensionName' => 'foo'])->willReturn('foo');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
...@@ -687,6 +715,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -687,6 +715,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
...@@ -715,6 +744,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -715,6 +744,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('controllerName', ['controllerName' => 'foo'])->willReturn('foo'); $contentObjectRenderer->stdWrapValue('controllerName', ['controllerName' => 'foo'])->willReturn('foo');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
...@@ -746,6 +776,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -746,6 +776,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -774,6 +805,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -774,6 +805,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->stdWrapValue('controllerActionName', ['controllerActionName' => 'foo'])->willReturn('foo'); $contentObjectRenderer->stdWrapValue('controllerActionName', ['controllerActionName' => 'foo'])->willReturn('foo');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename('')->shouldBeCalled(); $standAloneView->setTemplatePathAndFilename('')->shouldBeCalled();
...@@ -804,6 +836,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -804,6 +836,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -853,6 +886,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -853,6 +886,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$standAloneView->render(Argument::cetera())->willReturn(''); $standAloneView->render(Argument::cetera())->willReturn('');
$standAloneView->renderSection(Argument::cetera())->willReturn(''); $standAloneView->renderSection(Argument::cetera())->willReturn('');
GeneralUtility::addInstance(StandaloneView::class, $standAloneView->reveal()); GeneralUtility::addInstance(StandaloneView::class, $standAloneView->reveal());
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($this->prophesize(ContentObjectRenderer::class)->reveal()); $subject = new FluidTemplateContentObject($this->prophesize(ContentObjectRenderer::class)->reveal());
$subject->render($configuration); $subject->render($configuration);
...@@ -914,6 +948,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -914,6 +948,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
$standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void')); $standAloneView->setTemplatePathAndFilename(Argument::cetera())->willReturn(new ReturnTypeNode('void'));
...@@ -945,6 +980,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -945,6 +980,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8); $contentObjectRenderer->stdWrapValue(Argument::cetera())->shouldBeCalledTimes(8);
$contentObjectRenderer->cObjGetSingle(Argument::cetera())->willReturn('foo'); $contentObjectRenderer->cObjGetSingle(Argument::cetera())->willReturn('foo');
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
...@@ -1014,6 +1050,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase ...@@ -1014,6 +1050,7 @@ class FluidTemplateContentObjectTest extends UnitTestCase
$contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class); $contentObjectRenderer = $this->prophesize(ContentObjectRenderer::class);
GeneralUtility::addInstance(ContentDataProcessor::class, $this->contentDataProcessor);
$subject = new FluidTemplateContentObject($contentObjectRenderer->reveal()); $subject = new FluidTemplateContentObject($contentObjectRenderer->reveal());
$standAloneView = $this->prophesize(StandaloneView::class); $standAloneView = $this->prophesize(StandaloneView::class);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment