| @@ 173-218 (lines=46) @@ | ||
| 170 | $this->subscriber->onView($event); |
|
| 171 | } |
|
| 172 | ||
| 173 | public function testViewWithoutTemplateVar() |
|
| 174 | { |
|
| 175 | $this->parameterResolver |
|
| 176 | ->expects($this->once()) |
|
| 177 | ->method('resolveApi') |
|
| 178 | ->will($this->returnValue(false)); |
|
| 179 | ||
| 180 | $event = $this->createViewEventMock(); |
|
| 181 | $event |
|
| 182 | ->expects($this->once()) |
|
| 183 | ->method('getView') |
|
| 184 | ->will($this->returnValue($view = $this->createViewMock())); |
|
| 185 | ||
| 186 | $view |
|
| 187 | ->expects($this->once()) |
|
| 188 | ->method('getData') |
|
| 189 | ->will($this->returnValue($data = new \stdClass())); |
|
| 190 | ||
| 191 | $this->parameterResolver |
|
| 192 | ->expects($this->once()) |
|
| 193 | ->method('resolveTemplate') |
|
| 194 | ->will($this->returnValue($template = 'template')); |
|
| 195 | ||
| 196 | $view |
|
| 197 | ->expects($this->once()) |
|
| 198 | ->method('setTemplate') |
|
| 199 | ->with($this->identicalTo($template)) |
|
| 200 | ->will($this->returnSelf()); |
|
| 201 | ||
| 202 | $event |
|
| 203 | ->expects($this->once()) |
|
| 204 | ->method('getResource') |
|
| 205 | ->will($this->returnValue($resource = $this->createResourceMock())); |
|
| 206 | ||
| 207 | $view |
|
| 208 | ->expects($this->once()) |
|
| 209 | ->method('getTemplateVar') |
|
| 210 | ->will($this->returnValue(null)); |
|
| 211 | ||
| 212 | $view |
|
| 213 | ->expects($this->once()) |
|
| 214 | ->method('setData') |
|
| 215 | ->with($this->identicalTo(['data' => $data, 'resource' => $resource])); |
|
| 216 | ||
| 217 | $this->subscriber->onView($event); |
|
| 218 | } |
|
| 219 | ||
| 220 | public function testViewWithTemplateVar() |
|
| 221 | { |
|
| @@ 220-265 (lines=46) @@ | ||
| 217 | $this->subscriber->onView($event); |
|
| 218 | } |
|
| 219 | ||
| 220 | public function testViewWithTemplateVar() |
|
| 221 | { |
|
| 222 | $this->parameterResolver |
|
| 223 | ->expects($this->once()) |
|
| 224 | ->method('resolveApi') |
|
| 225 | ->will($this->returnValue(false)); |
|
| 226 | ||
| 227 | $event = $this->createViewEventMock(); |
|
| 228 | $event |
|
| 229 | ->expects($this->once()) |
|
| 230 | ->method('getView') |
|
| 231 | ->will($this->returnValue($view = $this->createViewMock())); |
|
| 232 | ||
| 233 | $view |
|
| 234 | ->expects($this->once()) |
|
| 235 | ->method('getData') |
|
| 236 | ->will($this->returnValue($data = new \stdClass())); |
|
| 237 | ||
| 238 | $this->parameterResolver |
|
| 239 | ->expects($this->once()) |
|
| 240 | ->method('resolveTemplate') |
|
| 241 | ->will($this->returnValue($template = 'template')); |
|
| 242 | ||
| 243 | $view |
|
| 244 | ->expects($this->once()) |
|
| 245 | ->method('setTemplate') |
|
| 246 | ->with($this->identicalTo($template)) |
|
| 247 | ->will($this->returnSelf()); |
|
| 248 | ||
| 249 | $event |
|
| 250 | ->expects($this->once()) |
|
| 251 | ->method('getResource') |
|
| 252 | ->will($this->returnValue($resource = $this->createResourceMock())); |
|
| 253 | ||
| 254 | $view |
|
| 255 | ->expects($this->once()) |
|
| 256 | ->method('getTemplateVar') |
|
| 257 | ->will($this->returnValue($templateVar = 'template_var')); |
|
| 258 | ||
| 259 | $view |
|
| 260 | ->expects($this->once()) |
|
| 261 | ->method('setData') |
|
| 262 | ->with($this->identicalTo([$templateVar => $data, 'resource' => $resource])); |
|
| 263 | ||
| 264 | $this->subscriber->onView($event); |
|
| 265 | } |
|
| 266 | ||
| 267 | /** |
|
| 268 | * @return \PHPUnit_Framework_MockObject_MockObject|ParameterResolverInterface |
|