setConnection() public method

Sets the currently active connection.
public setConnection ( Phergie_Connection $connection ) : Phergie_Driver_Abstract
$connection Phergie_Connection Active connection
return Phergie_Driver_Abstract Provides a fluent interface
Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
 /**
  * Tests setting a connection and retrieving it afterward.
  *
  * @return void
  */
 public function testSetConnection()
 {
     $connection = $this->getMockConnection();
     $this->driver->setConnection($connection);
     $this->assertSame($connection, $this->driver->getConnection());
 }