‪TYPO3CMS  9.5
ViewHelperResolverTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪ViewHelperResolverTest extends UnitTestCase
27 {
32  {
33  $objectManager = $this->getMockBuilder(ObjectManager::class)
34  ->setMethods(['get'])
35  ->disableOriginalConstructor()
36  ->getMock();
37  $objectManager->expects($this->once())->method('get')->with('x')->willReturn('y');
38  $resolver = $this->getMockBuilder(ViewHelperResolver::class)
39  ->setMethods(['getObjectManager'])
40  ->getMock();
41  $resolver->expects($this->once())->method('getObjectManager')->willReturn($objectManager);
42  $this->assertEquals('y', $resolver->createViewHelperInstanceFromClassName('x'));
43  }
44 
52  public function ‪resolveViewHelperClassNameResolvesExpectedViewHelperClassName($namespace, $method, $expected)
53  {
54  $viewHelperResolver = new ‪ViewHelperResolver();
55  $this->assertEquals($expected, $viewHelperResolver->resolveViewHelperClassName($namespace, $method));
56  }
57 
62  {
63  return [
64  ['f', 'cObject', CObjectViewHelper::class],
65  ['f', 'format.htmlentities', HtmlentitiesViewHelper::class],
66  ['f', 'render', RenderViewHelper::class]
67  ];
68  }
69 }
‪TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolver
Definition: ViewHelperResolver.php:52
‪TYPO3\CMS\Fluid\ViewHelpers\RenderViewHelper
Definition: RenderViewHelper.php:22
‪TYPO3\CMS\Fluid\ViewHelpers\CObjectViewHelper
Definition: CObjectViewHelper.php:81
‪TYPO3\CMS\Fluid\Tests\Unit\Core\ViewHelper\ViewHelperResolverTest\resolveViewHelperClassNameResolvesExpectedViewHelperClassName
‪resolveViewHelperClassNameResolvesExpectedViewHelperClassName($namespace, $method, $expected)
Definition: ViewHelperResolverTest.php:52
‪TYPO3\CMS\Fluid\Tests\Unit\Core\ViewHelper
Definition: ViewHelperResolverTest.php:2
‪TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesViewHelper
Definition: HtmlentitiesViewHelper.php:50
‪TYPO3\CMS\Fluid\Tests\Unit\Core\ViewHelper\ViewHelperResolverTest
Definition: ViewHelperResolverTest.php:27
‪TYPO3\CMS\Fluid\Tests\Unit\Core\ViewHelper\ViewHelperResolverTest\getResolveViewHelperNameTestValues
‪array getResolveViewHelperNameTestValues()
Definition: ViewHelperResolverTest.php:61
‪TYPO3\CMS\Fluid\Tests\Unit\Core\ViewHelper\ViewHelperResolverTest\createViewHelperInstanceCreatesViewHelperInstanceUsingObjectManager
‪createViewHelperInstanceCreatesViewHelperInstanceUsingObjectManager()
Definition: ViewHelperResolverTest.php:31
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:25