From 010384b2965970366ea9ca1c9b87046d4bf25e40 Mon Sep 17 00:00:00 2001 From: ebernhardson Date: Wed, 4 Apr 2012 18:27:08 -0700 Subject: [PATCH] unit test to verify fix of Resque_Event::stopListening --- test/Resque/Tests/EventTest.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/Resque/Tests/EventTest.php b/test/Resque/Tests/EventTest.php index 3d2a536..0bf5ee9 100644 --- a/test/Resque/Tests/EventTest.php +++ b/test/Resque/Tests/EventTest.php @@ -101,6 +101,24 @@ class Resque_Tests_EventTest extends Resque_Tests_TestCase )); $this->assertContains($callback, $this->callbacksHit, $event . ' callback (' . $callback .') was not called'); } + + public function testStopListeningRemovesListener() + { + $callback = 'beforePerformEventCallback'; + $event = 'beforePerform'; + + Resque_Event::listen($event, array($this, $callback)); + Resque_Event::stopListening($event, array($this, $callback)); + + $job = $this->getEventTestJob(); + $this->worker->perform($job); + $this->worker->work(0); + + $this->assertNotContains($callback, $this->callbacksHit, + $event . ' callback (' . $callback .') was called though Resque_Event::stopListening was called' + ); + } + public function beforePerformEventDontPerformCallback($instance) { @@ -146,4 +164,4 @@ class Resque_Tests_EventTest extends Resque_Tests_TestCase { $this->assertValidEventCallback(__FUNCTION__, $job); } -} \ No newline at end of file +}