/** * Test that an exception is thrown is a bad response is sent (test uses a 500 response) */ public function testExceptionIsThrownIfBadResponseReceived() { try { $auth = $this->getAuthObject(); $smtp = new PartialSmtpConnectionIO(); $smtp->setReturnValueAt(0, "read", "500 Something"); $smtp->setExtension("AUTH", array($this->getAuthMethod())); $smtp->setUsername("foo"); $smtp->setPassword("bar"); $smtp->attachAuthenticator($auth); $smtp->postConnect(new Swift($smtp, "xx", Swift::NO_START)); $this->fail("This should have thrown an exception since a 235 response was needed."); } catch (Swift_ConnectionException $e) { $this->pass(); } }
/** * Test that RSET is issued after a bad response. */ public function testRSETIsSentOnFailure() { try { $auth = $this->getAuthObject(); $smtp = new PartialSmtpConnectionIO(); $smtp->setReturnValueAt(0, "read", "500 Something"); $smtp->expectAt(1, "write", array("RSET", "*")); $smtp->setExtension("AUTH", array("CRAM-MD5")); $smtp->setUsername("foo"); $smtp->setPassword("bar"); $smtp->attachAuthenticator($auth); $smtp->postConnect(new Swift($smtp, "xx", Swift::NO_START)); $this->fail("This should have thrown an exception since a 235 response was needed."); } catch (Swift_ConnectionException $e) { $this->pass(); } }
/** * Test that RSET is issued after a bad response. */ public function testRSETIsSentOnFailure() { try { $auth = $this->getAuthObject(); $smtp = new PartialSmtpConnectionIO(); $smtp->setReturnValueAt(0, "read", "334 " . base64_encode("username:"******"read", "400 No"); $smtp->setReturnValueAt(2, "read", "400 No"); $smtp->expectAt(0, "write", array("AUTH LOGIN", "*")); $smtp->expectAt(1, "write", array(base64_encode("foo"), "*")); $smtp->expectAt(2, "write", array("RSET", "*")); $smtp->setExtension("AUTH", array("LOGIN", "*")); $smtp->setUsername("foo"); $smtp->setPassword("bar"); $smtp->attachAuthenticator($auth); $smtp->postConnect(new Swift($smtp, "xx", Swift::NO_START)); $this->fail("This should have failed since a 334 and 235 response were wanted."); } catch (Swift_ConnectionException $e) { $this->pass(); } }