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