TYPO3 CMS  TYPO3_6-2
AbstractTemplateViewTest.php
Go to the documentation of this file.
1 <?php
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 Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
18 
22  protected $view;
23 
27  protected $renderingContext;
28 
33 
38 
44  public function setUp() {
45  $this->templateVariableContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer', array('exists', 'remove', 'add'));
46  $this->viewHelperVariableContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer', array('setView'));
47  $this->renderingContext = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext', array('getViewHelperVariableContainer', 'getTemplateVariableContainer'));
48  $this->renderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->viewHelperVariableContainer));
49  $this->renderingContext->expects($this->any())->method('getTemplateVariableContainer')->will($this->returnValue($this->templateVariableContainer));
50  $this->view = $this->getMock('TYPO3\\CMS\\Fluid\\View\\AbstractTemplateView', array('getTemplateSource', 'getLayoutSource', 'getPartialSource', 'canRender', 'getTemplateIdentifier', 'getLayoutIdentifier', 'getPartialIdentifier'));
51  $this->view->setRenderingContext($this->renderingContext);
52  }
53 
58  $this->viewHelperVariableContainer->expects($this->once())->method('setView')->with($this->view);
59  $this->view->setRenderingContext($this->renderingContext);
60  }
61 
66  $this->templateVariableContainer->expects($this->at(0))->method('exists')->with('foo')->will($this->returnValue(FALSE));
67  $this->templateVariableContainer->expects($this->at(1))->method('add')->with('foo', 'FooValue');
68  $this->templateVariableContainer->expects($this->at(2))->method('exists')->with('bar')->will($this->returnValue(FALSE));
69  $this->templateVariableContainer->expects($this->at(3))->method('add')->with('bar', 'BarValue');
70 
71  $this->view
72  ->assign('foo', 'FooValue')
73  ->assign('bar', 'BarValue');
74  }
75 
80  $this->templateVariableContainer->expects($this->at(0))->method('exists')->with('foo')->will($this->returnValue(FALSE));
81  $this->templateVariableContainer->expects($this->at(1))->method('add')->with('foo', 'FooValue');
82  $this->templateVariableContainer->expects($this->at(2))->method('exists')->with('foo')->will($this->returnValue(TRUE));
83  $this->templateVariableContainer->expects($this->at(3))->method('remove')->with('foo');
84  $this->templateVariableContainer->expects($this->at(4))->method('add')->with('foo', 'FooValueOverridden');
85 
86  $this->view->assign('foo', 'FooValue');
87  $this->view->assign('foo', 'FooValueOverridden');
88  }
89 
94  $this->templateVariableContainer->expects($this->at(0))->method('exists')->with('foo')->will($this->returnValue(FALSE));
95  $this->templateVariableContainer->expects($this->at(1))->method('add')->with('foo', 'FooValue');
96  $this->templateVariableContainer->expects($this->at(2))->method('exists')->with('bar')->will($this->returnValue(FALSE));
97  $this->templateVariableContainer->expects($this->at(3))->method('add')->with('bar', 'BarValue');
98  $this->templateVariableContainer->expects($this->at(4))->method('exists')->with('baz')->will($this->returnValue(FALSE));
99  $this->templateVariableContainer->expects($this->at(5))->method('add')->with('baz', 'BazValue');
100 
101  $this->view
102  ->assignMultiple(array('foo' => 'FooValue', 'bar' => 'BarValue'))
103  ->assignMultiple(array('baz' => 'BazValue'));
104  }
105 
110  $this->templateVariableContainer->expects($this->at(0))->method('exists')->with('foo')->will($this->returnValue(FALSE));
111  $this->templateVariableContainer->expects($this->at(1))->method('add')->with('foo', 'FooValue');
112  $this->templateVariableContainer->expects($this->at(2))->method('exists')->with('foo')->will($this->returnValue(TRUE));
113  $this->templateVariableContainer->expects($this->at(3))->method('remove')->with('foo');
114  $this->templateVariableContainer->expects($this->at(4))->method('add')->with('foo', 'FooValueOverridden');
115  $this->templateVariableContainer->expects($this->at(5))->method('exists')->with('bar')->will($this->returnValue(FALSE));
116  $this->templateVariableContainer->expects($this->at(6))->method('add')->with('bar', 'BarValue');
117 
118  $this->view->assign('foo', 'FooValue');
119  $this->view->assignMultiple(array('foo' => 'FooValueOverridden', 'bar' => 'BarValue'));
120  }
121 }