Skip to content

Commit

Permalink
[TASK] use Fluid TemplateView instead of deprecated TYPO3 StandaloneView
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrichmathes committed Oct 11, 2024
1 parent 75e5c81 commit c359c75
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions Tests/Functional/AbstractComponentTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
namespace Sitegeist\MediaComponents\Tests\Functional;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
use TYPO3Fluid\Fluid\View\TemplateView;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters;
use TYPO3\CMS\Extbase\Mvc\Request;

abstract class AbstractComponentTestCase extends FunctionalTestCase
{
Expand Down Expand Up @@ -33,13 +37,21 @@ protected function cleanUpTestResult($result = '')

protected function getTestView($html = '')
{
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setTemplateSource('<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:mc="http://typo3.org/ns/Sitegeist/MediaComponents/Components"
xmlns:mvh="http://typo3.org/ns/Sitegeist/MediaComponents/ViewHelpers"
data-namespace-typo3-fluid="true"
>' . $html);
$view = new TemplateView();
$view->setRenderingContext(
GeneralUtility::makeInstance(RenderingContextFactory::class)->create(
[],
new Request(
(new ServerRequest)->withAttribute(
'extbase',
new ExtbaseRequestParameters
)
)
)
);

$view->getRenderingContext()->getViewHelperResolver()->addNamespace('mvh', 'Sitegeist\\MediaComponents\\ViewHelpers');
$view->getRenderingContext()->getTemplatePaths()->setTemplateSource($html);

return $view;
}
Expand Down

0 comments on commit c359c75

Please sign in to comment.