Skip to content

Commit 010384b

Browse files
committed
unit test to verify fix of Resque_Event::stopListening
1 parent fab92ef commit 010384b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/Resque/Tests/EventTest.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,24 @@ public function testAfterEnqueueEventCallbackFires()
101101
));
102102
$this->assertContains($callback, $this->callbacksHit, $event . ' callback (' . $callback .') was not called');
103103
}
104+
105+
public function testStopListeningRemovesListener()
106+
{
107+
$callback = 'beforePerformEventCallback';
108+
$event = 'beforePerform';
109+
110+
Resque_Event::listen($event, array($this, $callback));
111+
Resque_Event::stopListening($event, array($this, $callback));
112+
113+
$job = $this->getEventTestJob();
114+
$this->worker->perform($job);
115+
$this->worker->work(0);
116+
117+
$this->assertNotContains($callback, $this->callbacksHit,
118+
$event . ' callback (' . $callback .') was called though Resque_Event::stopListening was called'
119+
);
120+
}
121+
104122

105123
public function beforePerformEventDontPerformCallback($instance)
106124
{
@@ -146,4 +164,4 @@ public function afterForkEventCallback($job)
146164
{
147165
$this->assertValidEventCallback(__FUNCTION__, $job);
148166
}
149-
}
167+
}

0 commit comments

Comments
 (0)