d71a699cb4c57a667d6d138944586477cc75f9ed
[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 FLOW3 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 abstract class ViewHelperBaseTestcase extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
14
15 /**
16 * @var \TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperVariableContainer
17 */
18 protected $viewHelperVariableContainer;
19
20 /**
21 * @var \TYPO3\CMS\Fluid\Core\ViewHelper\TemplateVariableContainer
22 */
23 protected $templateVariableContainer;
24
25 /**
26 * @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder
27 */
28 protected $uriBuilder;
29
30 /**
31 * @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
32 */
33 protected $controllerContext;
34
35 /**
36 * @var \TYPO3\CMS\Fluid\Core\ViewHelper\TagBuilder
37 */
38 protected $tagBuilder;
39
40 /**
41 * @var \TYPO3\CMS\Fluid\Core\ViewHelper\Arguments
42 */
43 protected $arguments;
44
45 /**
46 * @var \TYPO3\CMS\Extbase\Mvc\Web\Request
47 */
48 protected $request;
49
50 /**
51 * @var \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext
52 */
53 protected $renderingContext;
54
55 /**
56 * @return void
57 */
58 public function setUp() {
59 $this->viewHelperVariableContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
60 $this->templateVariableContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer');
61 $this->uriBuilder = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
62 $this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder));
63 $this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder));
64 $this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder));
65 $this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder));
66 $this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder));
67 $this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder));
68 $this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder));
69 $this->uriBuilder->expects($this->any())->method('setLinkAccessRestrictedPages')->will($this->returnValue($this->uriBuilder));
70 $this->uriBuilder->expects($this->any())->method('setTargetPageUid')->will($this->returnValue($this->uriBuilder));
71 $this->uriBuilder->expects($this->any())->method('setTargetPageType')->will($this->returnValue($this->uriBuilder));
72 $this->uriBuilder->expects($this->any())->method('setNoCache')->will($this->returnValue($this->uriBuilder));
73 $this->uriBuilder->expects($this->any())->method('setUseCacheHash')->will($this->returnValue($this->uriBuilder));
74 $this->request = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
75 $this->controllerContext = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext', array(), array(), '', FALSE);
76 $this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder));
77 $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
78 $this->tagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder');
79 $this->arguments = array();
80 $this->renderingContext = new \TYPO3\CMS\Fluid\Core\Rendering\RenderingContext();
81 $this->renderingContext->injectTemplateVariableContainer($this->templateVariableContainer);
82 $this->renderingContext->injectViewHelperVariableContainer($this->viewHelperVariableContainer);
83 $this->renderingContext->setControllerContext($this->controllerContext);
84 }
85
86 /**
87 * @param \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper
88 * @return void
89 */
90 protected function injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper) {
91 $viewHelper->setRenderingContext($this->renderingContext);
92 $viewHelper->setArguments($this->arguments);
93 if ($viewHelper instanceof \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper) {
94 $viewHelper->injectTagBuilder($this->tagBuilder);
95 }
96 }
97 }
98
99 ?>