Author: Phergie Development Team (team@phergie.org)
Inheritance: implements Countable, implements IteratorAggregate
Ejemplo n.º 1
0
 /**
  * Sends resulting outgoing events from earlier processing in handleEvents().
  *
  * @param Phergie_Connection $connection Active connection
  *
  * @return void
  */
 protected function processEvents(Phergie_Connection $connection)
 {
     $this->plugins->preDispatch();
     if (count($this->events)) {
         foreach ($this->events as $event) {
             $this->ui->onCommand($event, $connection);
             $method = 'do' . ucfirst(strtolower($event->getType()));
             call_user_func_array(array($this->driver, $method), $event->getArguments());
         }
     }
     $this->plugins->postDispatch();
     if ($this->events->hasEventOfType(Phergie_Event_Request::TYPE_QUIT)) {
         $this->ui->onQuit($connection);
         $this->connections->removeConnection($connection);
     }
     $this->events->clearEvents();
 }
Ejemplo n.º 2
0
 /**
  * Tests retrieving multiple connections by their hostmasks.
  *
  * @return void
  */
 public function testGetConnectionsWithMultipleConnections()
 {
     $hostmasks = $hostmaskStrings = $connections = array();
     $connection = $this->getMockConnection();
     foreach (range(1, 2) as $index) {
         $hostmasks[$index] = $this->getMockHostmask('nick' . $index, 'username' . $index, 'host' . $index);
         $hostmaskStrings[$index] = (string) $hostmasks[$index];
         $connections[$index] = clone $connection;
         $connections[$index]->expects($this->any())->method('getHostmask')->will($this->returnValue($hostmasks[$index]));
         $this->connections->addConnection($connections[$index]);
     }
     $returned = $this->connections->getConnections($hostmaskStrings);
     $this->assertInternalType('array', $returned);
     $this->assertEquals(2, count($returned));
     foreach ($hostmaskStrings as $index => $hostmaskString) {
         $this->assertArrayHasKey($hostmaskString, $returned);
         $this->assertSame($connections[$index], $returned[$hostmaskString]);
     }
 }