[!!!][TASK] Extract testing framework for TYPO3
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / Core / Parser / SyntaxTree / LegacyNamespaceExpressionNodeTest.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\Core\Parser\SyntaxTree;
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\Fluid\Core\Parser\SyntaxTree\Expression\LegacyNamespaceExpressionNode;
17 use TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextFixture;
18
19 /**
20 * Class LegacyNamespaceExpressionNodeTest
21 */
22 class LegacyNamespaceExpressionNodeTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
23 {
24 /**
25 * @test
26 * @dataProvider getEvaluateExpressionTestValues
27 * @param array $matches
28 * @param array $expected
29 */
30 public function evaluateExpressionExtractsNamespaces(array $matches, array $expected)
31 {
32 $resolver = $this->getMockBuilder('TYPO3Fluid\\Fluid\\Core\\ViewHelper\\ViewHelperResolver')
33 ->setMethods(['addNamespace'])
34 ->getMock();
35 $resolver->expects($this->once())->method('addNamespace')->with($expected[0], $expected[1]);
36 $context = $this->getMockBuilder(RenderingContextFixture::class)
37 ->setMethods(['getViewHelperResolver'])
38 ->getMock();
39 $context->expects($this->once())->method('getViewHelperResolver')->willReturn($resolver);
40 LegacyNamespaceExpressionNode::evaluateExpression($context, $matches[0], $matches);
41 }
42
43 /**
44 * @return array
45 */
46 public function getEvaluateExpressionTestValues()
47 {
48 return [
49 [
50 ['foo', 'bar', 'baz'],
51 ['bar', 'baz']
52 ],
53 [
54 ['test1', 'test2', 'test3'],
55 ['test2', 'test3']
56 ]
57 ];
58 }
59 }