Skip to content
Permalink
Browse files

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
  • Loading branch information...
markstory committed Feb 27, 2014
1 parent 9d4f3e9 commit 25f94f9b7108d5bb41053ddcc691123c6e7e766a
Showing with 18 additions and 4 deletions.
  1. +18 −4 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)
*
@@ -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.
You can’t perform that action at this time.