/**
  * Tests a successful poll with a custom formatter.
  */
 public function testSuccessfulPollWithCustomFormatter()
 {
     // Configure plugin with formatter
     $this->plugin = new Plugin(array('urls' => array($this->url), 'targets' => array('nick!user@host' => array('#channel')), 'formatter' => new TestFormatter()));
     $this->plugin->setLogger($this->logger);
     $this->plugin->setEventEmitter($this->emitter);
     // Simulate the Http plugin response for the first poll
     $feed = $this->getFeed();
     $feedString = $this->getFeedString($feed);
     $this->emitter->once('http.request', function ($request) use($feedString) {
         $request->callResolve($feedString, array(), 200);
     });
     // Invoke the first poll
     $this->plugin->setLoop($this->loop);
     $this->plugin->setEventQueue($this->event, $this->queue);
     // Verify the next poll is queued
     Phake::verify($this->loop)->addTimer(300, Phake::capture($callback));
     // Simulate the Http plugin response for the next poll
     $this->addFeedEntry($feed);
     $feedString = $this->getFeedString($feed);
     $this->emitter->once('http.request', function ($request) use($feedString) {
         $request->callResolve($feedString, array(), 200);
     });
     // Invoke the next poll
     $callback();
     // Verify that the new item is sent using the custom formatter
     Phake::verify($this->queue, Phake::times(1))->ircPrivmsg('#channel', 'Title 2');
 }
 /**
  * Registers the given listener to respond only once to the given event.
  *
  * @param string $event Must be one of state machine's $supported_events, hence one of the ON_* constants.
  * @param callable $listener
  *
  * @throws Error If the given event is not supported.
  */
 public function once($event, callable $listener)
 {
     $this->guardSupportedEvents($event);
     $this->event_emitter->once($event, $listener);
 }