19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 use TYPO3\TestingFramework\Fluid\Unit\Core\Rendering\RenderingContextFixture;
21 use TYPO3Fluid\Fluid\Core\Variables\StandardVariableProvider;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
36 protected function setUp()
38 $this->renderingContext = $this->getAccessibleMock(RenderingContextFixture::class, [
'dummy']);
47 ->setMethods([
'setControllerAction',
'setControllerName'])
49 $request = $this->getMockBuilder(Request::class)
50 ->setMethods([
'getControllerActionName',
'getControllerSubpackageKey',
'getControllerName'])
52 $request->expects($this->exactly(2))->method(
'getControllerSubpackageKey')->willReturn(
'test1');
53 $request->expects($this->once())->method(
'getControllerName')->willReturn(
'test2');
54 $controllerContext = $this->getMockBuilder(ControllerContext::class)
55 ->setMethods([
'getRequest'])
57 $controllerContext->expects($this->once())->method(
'getRequest')->willReturn($request);
58 $renderingContext->expects($this->once())->method(
'setControllerName')->with(
'test1\\test2');
67 $templateVariableContainer = $this->createMock(StandardVariableProvider::class);
68 $this->renderingContext->setVariableProvider($templateVariableContainer);
69 $this->assertSame($this->renderingContext->getVariableProvider(), $templateVariableContainer,
'Template Variable Container could not be read out again.');
77 $controllerContext = $this->getMockBuilder(\
TYPO3\CMS\
Extbase\Mvc\Controller\ControllerContext::class)
78 ->setMethods([
'getRequest'])
79 ->disableOriginalConstructor()
81 $controllerContext->expects($this->atLeastOnce())->method(
'getRequest')->willReturn($this->createMock(Request::class));
82 $this->renderingContext->setControllerContext($controllerContext);
83 $this->assertSame($this->renderingContext->getControllerContext(), $controllerContext);
91 $viewHelperVariableContainer = $this->createMock(ViewHelperVariableContainer::class);
92 $this->renderingContext->_set(
'viewHelperVariableContainer', $viewHelperVariableContainer);
93 $this->assertSame($viewHelperVariableContainer, $this->renderingContext->getViewHelperVariableContainer());
104 $subject =
new RenderingContextFixture();
105 $request = $this->getMockBuilder(Request::class)->setMethods([
'setControllerActionName'])->getMock();
106 $request->expects($this->at(0))->method(
'setControllerActionName')->with(
'index');
107 $request->expects($this->at(1))->method(
'setControllerActionName')->with(lcfirst($expected));
108 $controllerContext = $this->getMockBuilder(ControllerContext::class)->setMethods([
'getRequest'])->getMock();
109 $controllerContext->expects($this->atLeastOnce())->method(
'getRequest')->willReturn($request);
110 $subject->setControllerContext($controllerContext);
111 $subject->setControllerAction($input);
112 $this->assertAttributeSame($expected,
'controllerAction', $subject);
121 [
'default',
'default'],
122 [
'default.html',
'default'],
123 [
'default.sub.html',
'default'],
124 [
'Sub/Default',
'Sub/Default'],
125 [
'Sub/Default.html',
'Sub/Default'],
126 [
'Sub/Default.sub.html',
'Sub/Default']