[TASK] Shorten the extend class in all unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / Core / ViewHelper / ViewHelperResolverTest.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\Core\ViewHelper;
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 */
16 use TYPO3\CMS\Extbase\Object\ObjectManager;
17 use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolver;
18 use TYPO3\CMS\Fluid\ViewHelpers\CObjectViewHelper;
19 use TYPO3\CMS\Fluid\ViewHelpers\Format\HtmlentitiesViewHelper;
20 use TYPO3\CMS\Fluid\ViewHelpers\RenderViewHelper;
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22
23 /**
24 * Test case
25 */
26 class ViewHelperResolverTest extends UnitTestCase
27 {
28 /**
29 * @test
30 */
31 public function createViewHelperInstanceCreatesViewHelperInstanceUsingObjectManager()
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
45 /**
46 * @test
47 * @dataProvider getResolveViewHelperNameTestValues
48 * @param string $namespace
49 * @param string $method
50 * @param string $expected
51 */
52 public function resolveViewHelperClassNameResolvesExpectedViewHelperClassName($namespace, $method, $expected)
53 {
54 $viewHelperResolver = new ViewHelperResolver();
55 $this->assertEquals($expected, $viewHelperResolver->resolveViewHelperClassName($namespace, $method));
56 }
57
58 /**
59 * @return array
60 */
61 public function getResolveViewHelperNameTestValues()
62 {
63 return [
64 ['f', 'cObject', CObjectViewHelper::class],
65 ['f', 'format.htmlentities', HtmlentitiesViewHelper::class],
66 ['f', 'render', RenderViewHelper::class]
67 ];
68 }
69 }