Skip to content

Commit

Permalink
Add test to prove the fix made in pull/2899
Browse files Browse the repository at this point in the history
Ensure that event listeners are not lost when merging the global and
local listeners.

Fixes #2897
Fixes #2899
  • Loading branch information
markstory committed Feb 27, 2014
1 parent 9d4f3e9 commit 25f94f9
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/Cake/Test/Case/Event/CakeEventManagerTest.php
@@ -1,9 +1,5 @@
<?php
/**
* ControllerTestCaseTest file
*
* Test Case for ControllerTestCase class
*
* CakePHP : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
Expand Down Expand Up @@ -504,4 +500,22 @@ public function testDispatchLocalHandledByGlobal() {
$this->assertEquals('ok', $event->data['callback']);
}

/**
* Test that events are dispatched properly when there are global and local
* listeners at the same priority.
*
* @return void
*/
public function testDispatchWithGlobalAndLocalEvents() {
$listener = new CustomTestEventListener();
CakeEventManager::instance()->attach($listener);
$listener2 = new CakeEventTestListener();
$manager = new CakeEventManager();
$manager->attach([$listener2, 'listenerFunction'], 'fake.event');

$manager->dispatch(new CakeEvent('fake.event', $this));
$this->assertEquals(array('listenerFunction'), $listener->callStack);
$this->assertEquals(array('listenerFunction'), $listener2->callStack);
}

}

0 comments on commit 25f94f9

Please sign in to comment.