TYPO3 CMS  TYPO3_8-7
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 
25 class ViewHelperResolverTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
26 {
31  {
32  $objectManager = $this->getMockBuilder(ObjectManager::class)
33  ->setMethods(['get'])
34  ->disableOriginalConstructor()
35  ->getMock();
36  $objectManager->expects($this->once())->method('get')->with('x')->willReturn('y');
37  $resolver = $this->getMockBuilder(ViewHelperResolver::class)
38  ->setMethods(['getObjectManager'])
39  ->getMock();
40  $resolver->expects($this->once())->method('getObjectManager')->willReturn($objectManager);
41  $this->assertEquals('y', $resolver->createViewHelperInstanceFromClassName('x'));
42  }
43 
51  public function resolveViewHelperClassNameResolvesExpectedViewHelperClassName($namespace, $method, $expected)
52  {
53  $viewHelperResolver = new ViewHelperResolver();
54  $this->assertEquals($expected, $viewHelperResolver->resolveViewHelperClassName($namespace, $method));
55  }
56 
61  {
62  return [
63  ['f', 'cObject', CObjectViewHelper::class],
64  ['f', 'format.htmlentities', HtmlentitiesViewHelper::class],
65  ['f', 'render', RenderViewHelper::class]
66  ];
67  }
68 }
resolveViewHelperClassNameResolvesExpectedViewHelperClassName($namespace, $method, $expected)