‪TYPO3CMS  11.5
UriViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 class ‪UriViewHelperTest extends FunctionalTestCase
27 {
31  protected ‪$initializeDatabase = false;
32 
36  public function ‪renderRendersTagWithHrefFromRoute(): void
37  {
38  // Mock Uribuilder in this functional test so we don't have to work with existing routes
39  $uriBuilderMock = $this->getMockBuilder(UriBuilder::class)->setConstructorArgs([new ‪Router()])->getMock();
40  $uriBuilderMock->expects(self::once())->method('buildUriFromRoute')
41  ->with('theRouteArgument', ['parameter' => 'to pass'], 'theReferenceTypeArgument')->willReturn('theUri');
42  GeneralUtility::setSingletonInstance(UriBuilder::class, $uriBuilderMock);
43 
44  $view = new ‪StandaloneView();
45  $view->setTemplateSource('<f:be.uri route="theRouteArgument" parameters="{parameter: \'to pass\'}" referenceType="theReferenceTypeArgument">foo</f:be.uri>');
46  self::assertEquals('theUri', $view->render());
47  }
48 
53  {
54  // Mock Uribuilder in this functional test so we don't have to work with existing routes
55  $uriBuilderMock = $this->getMockBuilder(UriBuilder::class)->setConstructorArgs([new ‪Router()])->getMock();
56  $uriBuilderMock->expects(self::once())->method('buildUriFromRoute')
57  ->with('theRouteArgument', [], 'theReferenceTypeArgument')->willReturn('theUri');
58  GeneralUtility::setSingletonInstance(UriBuilder::class, $uriBuilderMock);
59 
60  $view = new ‪StandaloneView();
61  $view->setTemplateSource('<f:be.uri route="theRouteArgument" referenceType="theReferenceTypeArgument">foo</f:be.uri>');
62  self::assertEquals('theUri', $view->render());
63  }
64 }
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Be\UriViewHelperTest\renderPassesEmptyArrayToUriBuilderForNoParameters
‪renderPassesEmptyArrayToUriBuilderForNoParameters()
Definition: UriViewHelperTest.php:51
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Be\UriViewHelperTest
Definition: UriViewHelperTest.php:27
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Be\UriViewHelperTest\renderRendersTagWithHrefFromRoute
‪renderRendersTagWithHrefFromRoute()
Definition: UriViewHelperTest.php:35
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:40
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Be\UriViewHelperTest\$initializeDatabase
‪bool $initializeDatabase
Definition: UriViewHelperTest.php:30
‪TYPO3\CMS\Fluid\Tests\Functional\ViewHelpers\Be
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Backend\Routing\Router
Definition: Router.php:39