| @@ 260-309 (lines=50) @@ | ||
| 257 | $this->registry->act($this->event); |
|
| 258 | } |
|
| 259 | ||
| 260 | public function testActionsAreExecutedByPriority() |
|
| 261 | { |
|
| 262 | $prioritizedActions = array( |
|
| 263 | array( |
|
| 264 | 'name' => 'email2', |
|
| 265 | 'action' => $this->action4, |
|
| 266 | 'priority' => 100, |
|
| 267 | ), |
|
| 268 | array( |
|
| 269 | 'name' => 'database', |
|
| 270 | 'action' => $this->action1, |
|
| 271 | 'priority' => 44, |
|
| 272 | ), |
|
| 273 | array( |
|
| 274 | 'name' => 'email', |
|
| 275 | 'action' => $this->action2, |
|
| 276 | 'priority' => 22, |
|
| 277 | ), |
|
| 278 | array( |
|
| 279 | 'name' => 'database2', |
|
| 280 | 'action' => $this->action3, |
|
| 281 | 'priority' => 11, |
|
| 282 | ), |
|
| 283 | ); |
|
| 284 | ||
| 285 | $this->registryForPriority->addAction('database', $this->action1, 44); |
|
| 286 | $this->registryForPriority->addAction('database2', $this->action3, 11); |
|
| 287 | $this->registryForPriority->addAction('email', $this->action2, 22); |
|
| 288 | $this->registryForPriority->addAction('email2', $this->action4, 100); |
|
| 289 | ||
| 290 | $this->action4->expects($this->once()) |
|
| 291 | ->method('act'); |
|
| 292 | ||
| 293 | $this->action1->expects($this->once()) |
|
| 294 | ->method('act'); |
|
| 295 | ||
| 296 | $this->action2->expects($this->once()) |
|
| 297 | ->method('act'); |
|
| 298 | ||
| 299 | $this->action3->expects($this->once()) |
|
| 300 | ->method('act'); |
|
| 301 | ||
| 302 | $this->registryForPriority->act($this->event); |
|
| 303 | ||
| 304 | $registryReflection = new ReflectionObject($this->registryForPriority); |
|
| 305 | $actions = $registryReflection->getProperty('actions'); |
|
| 306 | $actions->setAccessible(true); |
|
| 307 | ||
| 308 | $this->assertEquals($prioritizedActions, $actions->getValue($this->registryForPriority)); |
|
| 309 | } |
|
| 310 | ||
| 311 | public function testActionsAreExecutedByPriorityWithSamePriorities() |
|
| 312 | { |
|
| @@ 311-360 (lines=50) @@ | ||
| 308 | $this->assertEquals($prioritizedActions, $actions->getValue($this->registryForPriority)); |
|
| 309 | } |
|
| 310 | ||
| 311 | public function testActionsAreExecutedByPriorityWithSamePriorities() |
|
| 312 | { |
|
| 313 | $prioritizedActions = array( |
|
| 314 | array( |
|
| 315 | 'name' => 'email2', |
|
| 316 | 'action' => $this->action4, |
|
| 317 | 'priority' => 100, |
|
| 318 | ), |
|
| 319 | array( |
|
| 320 | 'name' => 'database', |
|
| 321 | 'action' => $this->action1, |
|
| 322 | 'priority' => 44, |
|
| 323 | ), |
|
| 324 | array( |
|
| 325 | 'name' => 'database2', |
|
| 326 | 'action' => $this->action3, |
|
| 327 | 'priority' => 11, |
|
| 328 | ), |
|
| 329 | array( |
|
| 330 | 'name' => 'email', |
|
| 331 | 'action' => $this->action2, |
|
| 332 | 'priority' => 11, |
|
| 333 | ), |
|
| 334 | ); |
|
| 335 | ||
| 336 | $this->registryForPriority->addAction('database', $this->action1, 44); |
|
| 337 | $this->registryForPriority->addAction('database2', $this->action3, 11); |
|
| 338 | $this->registryForPriority->addAction('email', $this->action2, 11); |
|
| 339 | $this->registryForPriority->addAction('email2', $this->action4, 100); |
|
| 340 | ||
| 341 | $this->action4->expects($this->once()) |
|
| 342 | ->method('act'); |
|
| 343 | ||
| 344 | $this->action1->expects($this->once()) |
|
| 345 | ->method('act'); |
|
| 346 | ||
| 347 | $this->action2->expects($this->once()) |
|
| 348 | ->method('act'); |
|
| 349 | ||
| 350 | $this->action3->expects($this->once()) |
|
| 351 | ->method('act'); |
|
| 352 | ||
| 353 | $this->registryForPriority->act($this->event); |
|
| 354 | ||
| 355 | $registryReflection = new ReflectionObject($this->registryForPriority); |
|
| 356 | $actions = $registryReflection->getProperty('actions'); |
|
| 357 | $actions->setAccessible(true); |
|
| 358 | ||
| 359 | $this->assertEquals($prioritizedActions, $actions->getValue($this->registryForPriority)); |
|
| 360 | } |
|
| 361 | ||
| 362 | public function testSetDebugMethod() |
|
| 363 | { |
|