@@ 134-179 (lines=46) @@ | ||
131 | $this->subscriber->onView($event); |
|
132 | } |
|
133 | ||
134 | public function testViewWithoutTemplateVar() |
|
135 | { |
|
136 | $this->parameterResolver |
|
137 | ->expects($this->once()) |
|
138 | ->method('resolveApi') |
|
139 | ->will($this->returnValue(false)); |
|
140 | ||
141 | $event = $this->createViewEventMock(); |
|
142 | $event |
|
143 | ->expects($this->once()) |
|
144 | ->method('getView') |
|
145 | ->will($this->returnValue($view = $this->createViewMock())); |
|
146 | ||
147 | $view |
|
148 | ->expects($this->once()) |
|
149 | ->method('getData') |
|
150 | ->will($this->returnValue($data = new \stdClass())); |
|
151 | ||
152 | $this->parameterResolver |
|
153 | ->expects($this->once()) |
|
154 | ->method('resolveTemplate') |
|
155 | ->will($this->returnValue($template = 'template')); |
|
156 | ||
157 | $view |
|
158 | ->expects($this->once()) |
|
159 | ->method('setTemplate') |
|
160 | ->with($this->identicalTo($template)) |
|
161 | ->will($this->returnSelf()); |
|
162 | ||
163 | $event |
|
164 | ->expects($this->once()) |
|
165 | ->method('getResource') |
|
166 | ->will($this->returnValue($resource = $this->createResourceMock())); |
|
167 | ||
168 | $view |
|
169 | ->expects($this->once()) |
|
170 | ->method('getTemplateVar') |
|
171 | ->will($this->returnValue(null)); |
|
172 | ||
173 | $view |
|
174 | ->expects($this->once()) |
|
175 | ->method('setData') |
|
176 | ->with($this->identicalTo(['data' => $data, 'resource' => $resource])); |
|
177 | ||
178 | $this->subscriber->onView($event); |
|
179 | } |
|
180 | ||
181 | public function testViewWithTemplateVar() |
|
182 | { |
|
@@ 181-226 (lines=46) @@ | ||
178 | $this->subscriber->onView($event); |
|
179 | } |
|
180 | ||
181 | public function testViewWithTemplateVar() |
|
182 | { |
|
183 | $this->parameterResolver |
|
184 | ->expects($this->once()) |
|
185 | ->method('resolveApi') |
|
186 | ->will($this->returnValue(false)); |
|
187 | ||
188 | $event = $this->createViewEventMock(); |
|
189 | $event |
|
190 | ->expects($this->once()) |
|
191 | ->method('getView') |
|
192 | ->will($this->returnValue($view = $this->createViewMock())); |
|
193 | ||
194 | $view |
|
195 | ->expects($this->once()) |
|
196 | ->method('getData') |
|
197 | ->will($this->returnValue($data = new \stdClass())); |
|
198 | ||
199 | $this->parameterResolver |
|
200 | ->expects($this->once()) |
|
201 | ->method('resolveTemplate') |
|
202 | ->will($this->returnValue($template = 'template')); |
|
203 | ||
204 | $view |
|
205 | ->expects($this->once()) |
|
206 | ->method('setTemplate') |
|
207 | ->with($this->identicalTo($template)) |
|
208 | ->will($this->returnSelf()); |
|
209 | ||
210 | $event |
|
211 | ->expects($this->once()) |
|
212 | ->method('getResource') |
|
213 | ->will($this->returnValue($resource = $this->createResourceMock())); |
|
214 | ||
215 | $view |
|
216 | ->expects($this->once()) |
|
217 | ->method('getTemplateVar') |
|
218 | ->will($this->returnValue($templateVar = 'template_var')); |
|
219 | ||
220 | $view |
|
221 | ->expects($this->once()) |
|
222 | ->method('setData') |
|
223 | ->with($this->identicalTo([$templateVar => $data, 'resource' => $resource])); |
|
224 | ||
225 | $this->subscriber->onView($event); |
|
226 | } |
|
227 | ||
228 | /** |
|
229 | * @return \PHPUnit_Framework_MockObject_MockObject|ParameterResolverInterface |