From 35c22a291e9441997a076fec8f6e4ab275dbf793 Mon Sep 17 00:00:00 2001 From: Rachman Chavik Date: Fri, 31 Jan 2014 16:43:42 +0700 Subject: [PATCH] Add test to prove Event Manager regression --- .../Test/Case/Event/CakeEventManagerTest.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/Cake/Test/Case/Event/CakeEventManagerTest.php b/lib/Cake/Test/Case/Event/CakeEventManagerTest.php index 8c3653de3..a21c4975b 100644 --- a/lib/Cake/Test/Case/Event/CakeEventManagerTest.php +++ b/lib/Cake/Test/Case/Event/CakeEventManagerTest.php @@ -484,4 +484,24 @@ class CakeEventManagerTest extends CakeTestCase { CakeEventManager::instance(new CakeEventManager()); } +/** + * test callback + */ + public function onMyEvent($event) { + $event->data['callback'] = 'ok'; + } + +/** + * Tests events dispatched by a local manager can be handled by + * handler registered in the global event manager + */ + public function testDispatchLocalHandledByGlobal() { + $callback = array($this, 'onMyEvent'); + CakeEventManager::instance()->attach($callback, 'my_event'); + $manager = new CakeEventManager(); + $event = new CakeEvent('my_event', $manager); + $manager->dispatch($event); + $this->assertEquals('ok', $event->data['callback']); + } + }