Fix dispatching event when event key name is used.

This commit is contained in:
Majna 2012-01-05 18:31:00 +01:00
parent f9c8d0cbf9
commit 8ad989cabe
2 changed files with 17 additions and 1 deletions

View file

@ -224,7 +224,7 @@ class CakeEventManager {
*/
public function dispatch($event) {
if (is_string($event)) {
$Event = new CakeEvent($event);
$event = new CakeEvent($event);
}
if (!$this->_isGlobal) {

View file

@ -210,6 +210,22 @@ class CakeEventManagerTest extends CakeTestCase {
$manager->dispatch($event);
}
/**
* Tests event dispatching using event key name
*
* @return void
*/
public function testDispatchWithKeyName() {
$manager = new CakeEventManager;
$listener = new CakeEventTestListener;
$manager->attach(array($listener, 'listenerFunction'), 'fake.event');
$event = 'fake.event';
$manager->dispatch($event);
$expected = array('listenerFunction');
$this->assertEquals($expected, $listener->callStack);
}
/**
* Tests event dispatching with a return value
*