Sets the currently active connection.
public setConnection ( Phergie_Connection $connection ) : Phergie_Driver_Abstract | ||
$connection | Phergie_Connection | Active connection |
리턴 | Phergie_Driver_Abstract | Provides a fluent interface |
/** * 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); }
/** * 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()); }