public function testAllConnectionsAreClosed()
 {
     $mock1 = new FullMockConnection();
     $mock1->setReturnValue("isAlive", true);
     $mock1->setReturnValueAt(0, "isAlive", false);
     $mock1->setReturnValueAt(1, "isAlive", true);
     $mock1->expectOnce("stop");
     $mock2 = new FullMockConnection();
     $mock2->setReturnValue("isAlive", true);
     $mock2->setReturnValueAt(0, "isAlive", false);
     $mock2->setReturnValueAt(1, "isAlive", true);
     $mock2->expectOnce("stop");
     $mock3 = new FullMockConnection();
     $mock3->setReturnValue("isAlive", true);
     $mock3->setReturnValueAt(0, "isAlive", false);
     $mock3->setReturnValueAt(1, "isAlive", true);
     $mock3->expectOnce("stop");
     $multi = new Swift_Connection_Rotator();
     $multi->addConnection($mock1);
     $multi->addConnection($mock2);
     $multi->addConnection($mock3);
     $multi->start();
     for ($i = 0; $i < 10; $i++) {
         $multi->nextConnection();
     }
     $multi->stop();
 }
 public function testIsAliveReturnsFalseIfTheConnectionIsClosed()
 {
     $mock1 = new FullMockConnection();
     $mock1->setReturnValue("isAlive", false);
     $mock1->expectOnce("start");
     $mock1->expectNever("stop");
     $mock2 = new FullMockConnection();
     $mock2->setReturnValue("isAlive", true);
     $mock2->expectOnce("start");
     $mock2->expectOnce("stop");
     $multi = new Swift_Connection_Multi();
     $multi->addConnection($mock1, "mock1");
     $multi->addConnection($mock2, "mock2");
     $multi->start();
     $this->assertTrue($multi->isAlive());
     $multi->stop();
     $this->assertFalse($multi->isAlive());
 }
 public function testPostConnectIsInvokedInConnectionAfterHandshake()
 {
     $conn = new FullMockConnection();
     $conn->setReturnValueAt(0, "read", "220 ESMTP");
     $conn->setReturnValueAt(1, "read", "250 xxx");
     $conn->expectOnce("postConnect");
     $swift = new Swift($conn, "mydomain");
 }