private static function stopEvent($method, $args) { $callback_method = str_replace("Stop", '', $method); if (!self::isCallableEvent($callback_method)) { throw new PHPResqueEventException("The {$callback_method} does not exists. So you can't stop it."); } if (!\Resque_Event::stopListening($callback_method, $args)) { throw new PHPResqueEventException("The {$callback_method} can not stopped."); } }
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'); }