[CLEANUP] Rework/simplify copyright header and remove @package
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / ViewHelpers / ViewHelperBaseTestcase.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers;
3
4 /* *
5 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
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 3 of the *
9 * License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13
14 /**
15 * Base test class for testing view helpers
16 */
17 abstract class ViewHelperBaseTestcase extends \TYPO3\CMS\Core\Tests\UnitTestCase {
18
19 /**
20 * @var \TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperVariableContainer
21 */
22 protected $viewHelperVariableContainer;
23
24 /**
25 * @var \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer
26 */
27 protected $templateVariableContainer;
28
29 /**
30 * @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
31 */
32 protected $uriBuilder;
33
34 /**
35 * @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
36 */
37 protected $controllerContext;
38
39 /**
40 * @var \TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder
41 */
42 protected $tagBuilder;
43
44 /**
45 * @var \TYPO3\CMS\Fluid\Core\ViewHelper\Arguments
46 */
47 protected $arguments;
48
49 /**
50 * @var \TYPO3\CMS\Extbase\Mvc\Web\Request
51 */
52 protected $request;
53
54 /**
55 * @var \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext
56 */
57 protected $renderingContext;
58
59 /**
60 * @var \TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService
61 */
62 protected $mvcPropertyMapperConfigurationService;
63
64 /**
65 * @return void
66 */
67 public function setUp() {
68 $this->viewHelperVariableContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
69 $this->templateVariableContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer');
70 $this->uriBuilder = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
71 $this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder));
72 $this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder));
73 $this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder));
74 $this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder));
75 $this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder));
76 $this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder));
77 $this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder));
78 $this->uriBuilder->expects($this->any())->method('setLinkAccessRestrictedPages')->will($this->returnValue($this->uriBuilder));
79 $this->uriBuilder->expects($this->any())->method('setTargetPageUid')->will($this->returnValue($this->uriBuilder));
80 $this->uriBuilder->expects($this->any())->method('setTargetPageType')->will($this->returnValue($this->uriBuilder));
81 $this->uriBuilder->expects($this->any())->method('setNoCache')->will($this->returnValue($this->uriBuilder));
82 $this->uriBuilder->expects($this->any())->method('setUseCacheHash')->will($this->returnValue($this->uriBuilder));
83 $this->uriBuilder->expects($this->any())->method('setAddQueryStringMethod')->will($this->returnValue($this->uriBuilder));
84 $this->request = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
85 $this->controllerContext = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
86 $this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder));
87 $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
88 $this->tagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder');
89 $this->arguments = array();
90 $this->renderingContext = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext', array('dummy'));
91 $this->renderingContext->injectTemplateVariableContainer($this->templateVariableContainer);
92 $this->renderingContext->_set('viewHelperVariableContainer', $this->viewHelperVariableContainer);
93 $this->renderingContext->setControllerContext($this->controllerContext);
94 $this->mvcPropertyMapperConfigurationService = $this->getAccessibleMock('TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService', array('dummy'));
95 }
96
97 /**
98 * @param \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper
99 * @return void
100 */
101 protected function injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper) {
102 $viewHelper->setRenderingContext($this->renderingContext);
103 $viewHelper->setArguments($this->arguments);
104 if ($viewHelper instanceof \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper) {
105 $viewHelper->_set('tag', $this->tagBuilder);
106 }
107 }
108 }