getConnections() public method

Returns a list of specified connection objects.
public getConnections ( array | string $keys = null ) : array
$keys array | string One or more hostmasks identifying the connections to return (optional)
return array List of Phergie_Connection objects corresponding to the specified hostmask(s)
示例#1
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]);
     }
 }