저자: Phergie Development Team (team@phergie.org)
예제 #1
0
 /**
  * Removes a connection from the connection list.
  *
  * @param Phergie_Connection|string $connection Instance or hostmask for
  *        the connection to remove
  *
  * @return Phergie_Connection_Handler Provides a fluent interface
  */
 public function removeConnection($connection)
 {
     if ($connection instanceof Phergie_Connection) {
         $hostmask = (string) $connection->getHostmask();
     } elseif (is_string($connection) && isset($this->connections[$connection])) {
         $hostmask = $connection;
     } else {
         return $this;
     }
     unset($this->connections[$hostmask]);
     return $this;
 }
예제 #2
0
파일: TestCase.php 프로젝트: nickl-/phergie
 /**
  * Returns a mock connection object.
  *
  * @return Phergie_Connection
  */
 protected function getMockConnection()
 {
     if (empty($this->connection)) {
         $this->connection = $this->getMock('Phergie_Connection');
         $this->connection->expects($this->any())->method('getNick')->will($this->returnValue($this->nick));
     }
     return $this->connection;
 }
예제 #3
0
 /**
  * Sets the plugin to be tested
  * If a plugin requries config for testing, an array placed in
  * $this->config will be parsed into a Phergie_Config object and
  * attached to the plugin
  */
 protected function setPlugin(Phergie_Plugin_Abstract $plugin)
 {
     $this->plugin = $plugin;
     $this->plugin->setEventHandler($this->handler);
     $this->plugin->setConnection($this->connection);
     $this->connection->setNick('test');
     if (!empty($this->config)) {
         $config = new Phergie_Config();
         foreach ($this->config as $configKey => $configValue) {
             $config[$configKey] = $configValue;
         }
         $plugin->setConfig($config);
     }
 }
예제 #4
0
 /**
  * Tests that options can be set collectively after the connection is
  * instantiated.
  *
  * @return void
  */
 public function testSetOptions()
 {
     $connection = new Phergie_Connection();
     $connection->setOptions($this->options);
     foreach ($this->options as $key => $value) {
         $this->assertEquals($value, $connection->{'get' . ucfirst($key)}());
     }
 }
예제 #5
0
 /**
  * Overrides the parent class to set the currently active socket handler
  * when the active connection is changed.
  *
  * @param Phergie_Connection $connection Active connection
  *
  * @return Phergie_Driver_Streams Provides a fluent interface
  */
 public function setConnection(Phergie_Connection $connection)
 {
     // Set the active socket handler
     $hostmask = (string) $connection->getHostmask();
     if (!empty($this->sockets[$hostmask])) {
         $this->socket = $this->sockets[$hostmask];
     }
     // Set the active connection
     return parent::setConnection($connection);
 }
예제 #6
0
 /**
  * Outputs a prompt when the bot terminates a connection to a server.
  *
  * @param Phergie_Connection $connection Terminated connection 
  *
  * @return void
  */
 public function onQuit(Phergie_Connection $connection)
 {
     $host = $connection->getHostmask()->getHost();
     $this->console('Disconnecting from ' . $host);
 }