From 8ad989cabe6a18b106aee74bfd74c139ed8357da Mon Sep 17 00:00:00 2001 From: Majna Date: Thu, 5 Jan 2012 18:31:00 +0100 Subject: [PATCH] Fix dispatching event when event key name is used. --- lib/Cake/Event/CakeEventManager.php | 2 +- .../Test/Case/Event/CakeEventManagerTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Event/CakeEventManager.php b/lib/Cake/Event/CakeEventManager.php index f4aaaa596..8b3ceb0f7 100644 --- a/lib/Cake/Event/CakeEventManager.php +++ b/lib/Cake/Event/CakeEventManager.php @@ -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) { diff --git a/lib/Cake/Test/Case/Event/CakeEventManagerTest.php b/lib/Cake/Test/Case/Event/CakeEventManagerTest.php index f43feeebb..98d1df9e0 100644 --- a/lib/Cake/Test/Case/Event/CakeEventManagerTest.php +++ b/lib/Cake/Test/Case/Event/CakeEventManagerTest.php @@ -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 *