Skip to content

Commit 25f94f9

Browse files
committed
Add test to prove the fix made in pull/2899
Ensure that event listeners are not lost when merging the global and local listeners. Fixes #2897 Fixes #2899
1 parent 9d4f3e9 commit 25f94f9

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

lib/Cake/Test/Case/Event/CakeEventManagerTest.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22
/**
3-
* ControllerTestCaseTest file
4-
*
5-
* Test Case for ControllerTestCase class
6-
*
73
* CakePHP : Rapid Development Framework (http://cakephp.org)
84
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
95
*
@@ -504,4 +500,22 @@ public function testDispatchLocalHandledByGlobal() {
504500
$this->assertEquals('ok', $event->data['callback']);
505501
}
506502

503+
/**
504+
* Test that events are dispatched properly when there are global and local
505+
* listeners at the same priority.
506+
*
507+
* @return void
508+
*/
509+
public function testDispatchWithGlobalAndLocalEvents() {
510+
$listener = new CustomTestEventListener();
511+
CakeEventManager::instance()->attach($listener);
512+
$listener2 = new CakeEventTestListener();
513+
$manager = new CakeEventManager();
514+
$manager->attach([$listener2, 'listenerFunction'], 'fake.event');
515+
516+
$manager->dispatch(new CakeEvent('fake.event', $this));
517+
$this->assertEquals(array('listenerFunction'), $listener->callStack);
518+
$this->assertEquals(array('listenerFunction'), $listener2->callStack);
519+
}
520+
507521
}

0 commit comments

Comments
 (0)