Merge pull request #396 from majna/2.1-event

2.1 event
This commit is contained in:
Renan Gonçalves aka renan.saddam 2012-01-05 09:46:09 -08:00
commit 5690d423c8
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
*