Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php abstract class Swift_Transport_AbstractSmtpTest extends \SwiftMailerTestCase { prot..

Decoded Output download

<?php
 abstract class Swift_Transport_AbstractSmtpTest extends \SwiftMailerTestCase { protected abstract function getTransport($buf); public function testStartAccepts220ServiceGreeting() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh
\xa"); $this->finishBuffer($buf); try { $this->assertFalse($smtp->isStarted(), "%s: SMTP should begin non-started"); $smtp->start(); $this->assertTrue($smtp->isStarted(), "%s: start() should have started connection"); } catch (Exception $e) { $this->fail("220 is a valid SMTP greeting and should be accepted"); } } public function testBadGreetingCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("554 I'm busy\xd\xa"); $this->finishBuffer($buf); try { $this->assertFalse($smtp->isStarted(), "%s: SMTP should begin non-started"); $smtp->start(); $this->fail("554 greeting indicates an error and should cause an exception"); } catch (Swift_TransportException $e) { $this->assertFalse($smtp->isStarted(), "%s: start() should have failed"); } } public function testStartSendsHeloToInitiate() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh\xd\xa"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^HELO example.org\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 ServerName" . "\xd\xa"); $this->finishBuffer($buf); try { $smtp->start(); } catch (Exception $e) { $this->fail("Starting SMTP should send HELO and accept 250 response"); } } public function testInvalidHeloResponseCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh
"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^HELO example.org\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("504 WTF" . "
"); $this->finishBuffer($buf); try { $this->assertFalse($smtp->isStarted(), "%s: SMTP should begin non-started"); $smtp->start(); $this->fail("Non 250 HELO response should raise Exception"); } catch (Swift_TransportException $e) { $this->assertFalse($smtp->isStarted(), "%s: SMTP start() should have failed"); } } public function testDomainNameIsPlacedInHelo() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh\xd\xa"); $buf->shouldReceive("write")->once()->with("HELO mydomain.com\xd
")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 ServerName" . "\xd
"); $this->finishBuffer($buf); $smtp->setLocalDomain("mydomain.com"); $smtp->start(); } public function testSuccessfulMailCommand() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("write")->once()->with("MAIL FROM:<[email protected]>
\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK\xd\xa"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); } catch (Exception $e) { $this->fail("MAIL FROM should accept a 250 response"); } } public function testInvalidResponseCodeFromMailCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("write")->once()->with("MAIL FROM:<[email protected]>
\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("553 Bad" . "\xd
"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); $this->fail("MAIL FROM should accept a 250 response"); } catch (Swift_TransportException $e) { } } public function testSenderIsPreferredOverFrom() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getSender")->once()->andReturn(array("[email protected]" => "Someone")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("write")->once()->with("MAIL FROM:<[email protected]>
")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK" . "\xd
"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testReturnPathIsPreferredOverSender() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getSender")->once()->andReturn(array("[email protected]" => "Someone")); $message->shouldReceive("getReturnPath")->once()->andReturn("[email protected]"); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("write")->once()->with("MAIL FROM:<[email protected]>\xd
")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK" . "\xd\xa"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testSuccessfulRcptCommandWith250Response() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("write")->once()->with("MAIL FROM:<[email protected]>\xd
")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK" . "\xd
"); $buf->shouldReceive("write")->once()->with("RCPT TO:<foo@bar>
\xa")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("250 OK" . "\xd\xa"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); } catch (Exception $e) { $this->fail("RCPT TO should accept a 250 response"); } } public function testUtf8AddressWithIdnEncoder() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("me@d\xc3\266main.com" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@b\303\244r" => null)); $buf->shouldReceive("write")->once()->with("MAIL FROM:<[email protected]>
")->andReturn(1); $buf->shouldReceive("write")->once()->with("RCPT TO:<foo@xn--br-via>\xd
")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK" . "
\xa"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testUtf8AddressWithUtf8Encoder() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf, null, new Swift_AddressEncoder_Utf8AddressEncoder()); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("m\xc3\xab@d\xc3\xb6main.com" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("f\303\266\xc3\266@b\xc3\244r" => null)); $buf->shouldReceive("write")->once()->with("MAIL FROM:<m\303\253@d\xc3\266main.com>
")->andReturn(1); $buf->shouldReceive("write")->once()->with("RCPT TO:<f\303\xb6\xc3\xb6@b\xc3\xa4r>
\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK" . "\xd
"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testNonEncodableSenderCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("m\xc3\[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); $this->fail("m\xc3\[email protected] cannot be encoded (not observed)"); } catch (Swift_AddressEncoderException $e) { $this->assertEquals("m\xc3\[email protected]", $e->getAddress()); } } public function testMailFromCommandIsOnlySentOncePerMessage() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("write")->once()->with("MAIL FROM:<[email protected]>\xd
")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK" . "
\xa"); $buf->shouldReceive("write")->once()->with("RCPT TO:<foo@bar>\xd\xa")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("250 OK" . "\xd
"); $buf->shouldReceive("write")->never()->with("MAIL FROM:<[email protected]>
"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testMultipleRecipientsSendsMultipleRcpt() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null, "zip@button" => "Zip Button", "test@domain" => "Test user", "t\xc3\253st@domain" => "Test user")); $buf->shouldReceive("write")->once()->with("RCPT TO:<foo@bar>\xd\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK" . "
"); $buf->shouldReceive("write")->once()->with("RCPT TO:<zip@button>
")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("250 OK" . "
\xa"); $buf->shouldReceive("write")->once()->with("RCPT TO:<test@domain>
")->andReturn(3); $buf->shouldReceive("readLine")->once()->with(3)->andReturn("250 OK" . "\xd\xa"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testCcRecipientsSendsMultipleRcpt() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $message->shouldReceive("getCc")->once()->andReturn(array("zip@button" => "Zip Button", "test@domain" => "Test user")); $buf->shouldReceive("write")->once()->with("RCPT TO:<foo@bar>
")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK" . "
"); $buf->shouldReceive("write")->once()->with("RCPT TO:<zip@button>
")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("250 OK" . "
\xa"); $buf->shouldReceive("write")->once()->with("RCPT TO:<test@domain>\xd\xa")->andReturn(3); $buf->shouldReceive("readLine")->once()->with(3)->andReturn("250 OK" . "\xd\xa"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testSendReturnsNumberOfSuccessfulRecipients() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $message->shouldReceive("getCc")->once()->andReturn(array("zip@button" => "Zip Button", "test@domain" => "Test user")); $buf->shouldReceive("write")->once()->with("RCPT TO:<foo@bar>\xd\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK" . "\xd
"); $buf->shouldReceive("write")->once()->with("RCPT TO:<zip@button>\xd\xa")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("501 Nobody here" . "\xd\xa"); $buf->shouldReceive("write")->once()->with("RCPT TO:<test@domain>
\xa")->andReturn(3); $buf->shouldReceive("readLine")->once()->with(3)->andReturn("250 OK" . "\xd
"); $this->finishBuffer($buf); $smtp->start(); $this->assertEquals(2, $smtp->send($message), "%s: 1 of 3 recipients failed so 2 should be returned"); } public function testRsetIsSentIfNoSuccessfulRecipients() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("write")->once()->with("RCPT TO:<foo@bar>
")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("503 Bad" . "
"); $buf->shouldReceive("write")->once()->with("RSET\xd
")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("250 OK" . "\xd
"); $this->finishBuffer($buf); $smtp->start(); $this->assertEquals(0, $smtp->send($message), "%s: 1 of 1 recipients failed so 0 should be returned"); } public function testSuccessfulDataCommand() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("write")->once()->with("DATA
")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("354 Go ahead" . "\xd
"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); } catch (Exception $e) { $this->fail("354 is the expected response to DATA"); } } public function testBadDataResponseCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("write")->once()->with("DATA\xd\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("451 Bad" . "
"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); $this->fail("354 is the expected response to DATA (not observed)"); } catch (Swift_TransportException $e) { } } public function testMessageIsStreamedToBufferForData() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("write")->once()->with("DATA\xd\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("354 OK" . "\xd
"); $buf->shouldReceive("write")->once()->with("\xd\xa.\xd
")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("250 OK" . "
\xa"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testBadResponseAfterDataTransmissionCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->once()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->once()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("write")->once()->with("DATA\xd\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("354 OK" . "\xd\xa"); $buf->shouldReceive("write")->once()->with("\xd\xa.
\xa")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("554 Error" . "
\xa"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); $this->fail("250 is the expected response after a DATA transmission (not observed)"); } catch (Swift_TransportException $e) { } } public function testBccRecipientsAreRemovedFromHeaders() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->zeroOrMoreTimes()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->zeroOrMoreTimes()->andReturn(array("foo@bar" => null)); $message->shouldReceive("getBcc")->zeroOrMoreTimes()->andReturn(array("zip@button" => "Zip Button", "test@domain" => "Test user")); $message->shouldReceive("setBcc")->once()->with(array()); $message->shouldReceive("setBcc")->zeroOrMoreTimes(); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testMessageStateIsRestoredOnFailure() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->zeroOrMoreTimes()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->zeroOrMoreTimes()->andReturn(array("foo@bar" => null)); $message->shouldReceive("getBcc")->zeroOrMoreTimes()->andReturn(array("zip@button" => "Zip Button", "test@domain" => "Test user")); $message->shouldReceive("setBcc")->once()->with(array()); $message->shouldReceive("setBcc")->once()->with(array("zip@button" => "Zip Button", "test@domain" => "Test user")); $buf->shouldReceive("write")->once()->with("MAIL FROM:<[email protected]>
\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK
\xa"); $buf->shouldReceive("write")->once()->with("RCPT TO:<foo@bar>
")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("250 OK\xd\xa"); $buf->shouldReceive("write")->once()->with("DATA\xd\xa")->andReturn(3); $buf->shouldReceive("readLine")->once()->with(3)->andReturn("451 No\xd
"); $this->finishBuffer($buf); $smtp->start(); try { $smtp->send($message); $this->fail("A bad response was given so exception is expected"); } catch (Swift_TransportException $e) { } } public function testStopSendsQuitCommand() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("write")->once()->with("QUIT
\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("221 Bye\xd\xa"); $buf->shouldReceive("terminate")->once(); $this->finishBuffer($buf); $this->assertFalse($smtp->isStarted()); $smtp->start(); $this->assertTrue($smtp->isStarted()); $smtp->stop(); $this->assertFalse($smtp->isStarted()); } public function testBufferCanBeFetched() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $ref = $smtp->getBuffer(); $this->assertEquals($buf, $ref); } public function testBufferCanBeWrittenToUsingExecuteCommand() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $buf->shouldReceive("write")->zeroOrMoreTimes()->with("FOO\xd
")->andReturn(1); $buf->shouldReceive("readLine")->zeroOrMoreTimes()->with(1)->andReturn("250 OK\xd
"); $res = $smtp->executeCommand("FOO
"); $this->assertEquals("250 OK\xd\xa", $res); } public function testResponseCodesAreValidated() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $buf->shouldReceive("write")->zeroOrMoreTimes()->with("FOO
\xa")->andReturn(1); $buf->shouldReceive("readLine")->zeroOrMoreTimes()->with(1)->andReturn("551 Not ok
"); try { $smtp->executeCommand("FOO\xd\xa", array(250, 251)); $this->fail("A 250 or 251 response was needed but 551 was returned."); } catch (Swift_TransportException $e) { } } public function testFailedRecipientsCanBeCollectedByReference() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->zeroOrMoreTimes()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->zeroOrMoreTimes()->andReturn(array("foo@bar" => null)); $message->shouldReceive("getBcc")->zeroOrMoreTimes()->andReturn(array("zip@button" => "Zip Button", "test@domain" => "Test user")); $message->shouldReceive("setBcc")->atLeast()->once()->with(array()); $message->shouldReceive("setBcc")->atLeast()->once()->with(array("zip@button" => "Zip Button", "test@domain" => "Test user")); $buf->shouldReceive("write")->once()->with("MAIL FROM:<[email protected]>
\xa")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK\xd\xa"); $buf->shouldReceive("write")->once()->with("RCPT TO:<foo@bar>\xd\xa")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("250 OK
"); $buf->shouldReceive("write")->once()->with("RCPT TO:<zip@button>\xd
")->andReturn(3); $buf->shouldReceive("readLine")->once()->with(3)->andReturn("500 Bad\xd\xa"); $buf->shouldReceive("write")->once()->with("RCPT TO:<test@domain>
\xa")->andReturn(4); $buf->shouldReceive("readLine")->once()->with(4)->andReturn("500 Bad\xd\xa"); $this->finishBuffer($buf); $smtp->start(); $this->assertEquals(1, $smtp->send($message, $failures)); } public function testSendingRegeneratesMessageId() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("getFrom")->zeroOrMoreTimes()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->zeroOrMoreTimes()->andReturn(array("foo@bar" => null)); $message->shouldReceive("generateId")->once(); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testPing() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh
\xa"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^NOOP\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 OK" . "
\xa"); $this->finishBuffer($buf); $this->assertTrue($smtp->ping()); } public function testPingOnDeadConnection() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh\xd
"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^NOOP\r\n$~D"))->andThrow("Swift_TransportException"); $this->finishBuffer($buf); $smtp->start(); $this->assertTrue($smtp->isStarted()); $this->assertFalse($smtp->ping()); $this->assertFalse($smtp->isStarted()); } public function testSetLocalDomain() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $smtp->setLocalDomain("example.com"); $this->assertEquals("example.com", $smtp->getLocalDomain()); $smtp->setLocalDomain("192.168.0.1"); $this->assertEquals("[192.168.0.1]", $smtp->getLocalDomain()); $smtp->setLocalDomain("[192.168.0.1]"); $this->assertEquals("[192.168.0.1]", $smtp->getLocalDomain()); $smtp->setLocalDomain("fd00::"); $this->assertEquals("[IPv6:fd00::]", $smtp->getLocalDomain()); $smtp->setLocalDomain("[IPv6:fd00::]"); $this->assertEquals("[IPv6:fd00::]", $smtp->getLocalDomain()); } protected function getBuffer() { return $this->getMockery("Swift_Transport_IoBuffer")->shouldIgnoreMissing(); } protected function createMessage() { return $this->getMockery("Swift_Mime_SimpleMessage")->shouldIgnoreMissing(); } protected function finishBuffer($buf) { $buf->shouldReceive("readLine")->zeroOrMoreTimes()->with(0)->andReturn("220 server.com foo" . "\xd\xa"); $buf->shouldReceive("write")->zeroOrMoreTimes()->with(Mockery::pattern("~^(EH|HE)LO .*?\r\n$~D"))->andReturn($x = uniqid('', true)); $buf->shouldReceive("readLine")->zeroOrMoreTimes()->with($x)->andReturn("250 ServerName" . "
"); $buf->shouldReceive("write")->zeroOrMoreTimes()->with(Mockery::pattern("~^MAIL FROM:<.*?>\r\n$~D"))->andReturn($x = uniqid('', true)); $buf->shouldReceive("readLine")->zeroOrMoreTimes()->with($x)->andReturn("250 OK
\xa"); $buf->shouldReceive("write")->zeroOrMoreTimes()->with(Mockery::pattern("~^RCPT TO:<.*?>\r\n$~D"))->andReturn($x = uniqid('', true)); $buf->shouldReceive("readLine")->zeroOrMoreTimes()->with($x)->andReturn("250 OK\xd\xa"); $buf->shouldReceive("write")->zeroOrMoreTimes()->with("DATA\xd\xa")->andReturn($x = uniqid('', true)); $buf->shouldReceive("readLine")->zeroOrMoreTimes()->with($x)->andReturn("354 OK\xd
"); $buf->shouldReceive("write")->zeroOrMoreTimes()->with("
.
\xa")->andReturn($x = uniqid('', true)); $buf->shouldReceive("readLine")->zeroOrMoreTimes()->with($x)->andReturn("250 OK
"); $buf->shouldReceive("write")->zeroOrMoreTimes()->with("RSET
\xa")->andReturn($x = uniqid('', true)); $buf->shouldReceive("readLine")->zeroOrMoreTimes()->with($x)->andReturn("250 OK
"); $buf->shouldReceive("write")->zeroOrMoreTimes()->andReturn(false); $buf->shouldReceive("readLine")->zeroOrMoreTimes()->andReturn(false); } } ?>

Did this file decode correctly?

Original Code

<?php
 abstract class Swift_Transport_AbstractSmtpTest extends \SwiftMailerTestCase { protected abstract function getTransport($buf); public function testStartAccepts220ServiceGreeting() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\151\x6e\151\164\151\x61\154\x69\x7a\x65")->once(); $buf->shouldReceive("\x72\x65\141\144\114\x69\156\145")->once()->with(0)->andReturn("\x32\x32\60\x20\x73\x6f\x6d\145\x2e\163\x65\x72\x76\145\x72\x2e\164\154\144\40\142\154\145\x68\15\xa"); $this->finishBuffer($buf); try { $this->assertFalse($smtp->isStarted(), "\45\x73\x3a\40\123\115\x54\x50\40\163\150\157\165\154\x64\40\142\145\x67\151\156\x20\156\157\x6e\55\x73\164\x61\162\x74\145\144"); $smtp->start(); $this->assertTrue($smtp->isStarted(), "\45\x73\72\40\x73\164\141\162\164\x28\51\x20\x73\x68\x6f\165\x6c\x64\x20\x68\141\x76\x65\x20\163\164\x61\x72\x74\145\144\40\143\157\x6e\x6e\x65\143\x74\x69\x6f\x6e"); } catch (Exception $e) { $this->fail("\x32\62\60\40\x69\163\x20\x61\40\x76\141\x6c\151\x64\x20\123\x4d\x54\120\x20\147\162\145\x65\x74\151\x6e\x67\40\x61\x6e\144\x20\x73\x68\x6f\x75\154\144\40\x62\145\x20\141\143\x63\x65\x70\x74\145\144"); } } public function testBadGreetingCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\151\x6e\x69\164\151\141\x6c\x69\x7a\145")->once(); $buf->shouldReceive("\x72\145\141\x64\114\x69\156\x65")->once()->with(0)->andReturn("\x35\65\64\x20\x49\x27\x6d\x20\x62\x75\x73\x79\xd\xa"); $this->finishBuffer($buf); try { $this->assertFalse($smtp->isStarted(), "\x25\x73\72\x20\123\x4d\x54\120\x20\x73\150\157\x75\154\144\40\142\x65\x67\151\x6e\x20\156\157\156\55\163\x74\x61\x72\164\x65\x64"); $smtp->start(); $this->fail("\x35\65\64\40\x67\x72\145\x65\164\151\156\147\x20\x69\x6e\144\x69\143\x61\x74\145\163\x20\x61\x6e\40\145\x72\x72\x6f\x72\x20\x61\156\144\x20\163\x68\x6f\165\x6c\x64\x20\143\141\165\x73\x65\40\x61\x6e\40\x65\170\143\145\x70\x74\151\x6f\x6e"); } catch (Swift_TransportException $e) { $this->assertFalse($smtp->isStarted(), "\x25\x73\x3a\40\163\164\141\162\x74\50\51\x20\163\x68\x6f\165\x6c\144\x20\x68\141\166\x65\x20\146\x61\151\154\x65\x64"); } } public function testStartSendsHeloToInitiate() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\x69\156\x69\x74\151\x61\x6c\x69\172\x65")->once(); $buf->shouldReceive("\162\x65\141\x64\x4c\151\156\145")->once()->with(0)->andReturn("\62\x32\x30\x20\x73\x6f\155\145\x2e\x73\145\x72\x76\145\x72\56\164\154\x64\40\142\x6c\145\150\xd\xa"); $buf->shouldReceive("\x77\x72\151\164\145")->once()->with(Mockery::pattern("\x7e\x5e\x48\105\114\x4f\40\x65\170\141\155\160\154\145\56\157\x72\x67\x5c\162\x5c\156\x24\176\104"))->andReturn(1); $buf->shouldReceive("\162\x65\x61\x64\x4c\151\x6e\x65")->once()->with(1)->andReturn("\62\65\60\x20\x53\145\x72\166\x65\162\x4e\x61\x6d\145" . "\xd\xa"); $this->finishBuffer($buf); try { $smtp->start(); } catch (Exception $e) { $this->fail("\123\x74\141\x72\164\151\156\147\x20\123\115\x54\x50\40\163\x68\x6f\165\154\144\x20\x73\x65\x6e\x64\40\x48\105\x4c\x4f\x20\141\x6e\x64\x20\141\x63\x63\x65\x70\164\x20\62\65\60\x20\x72\x65\163\x70\157\156\163\x65"); } } public function testInvalidHeloResponseCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\x69\x6e\x69\x74\x69\x61\154\x69\172\x65")->once(); $buf->shouldReceive("\x72\145\x61\x64\x4c\151\x6e\145")->once()->with(0)->andReturn("\62\62\x30\x20\x73\157\155\x65\56\x73\145\x72\x76\145\x72\x2e\164\x6c\x64\40\x62\x6c\x65\x68\15\12"); $buf->shouldReceive("\167\162\151\164\145")->once()->with(Mockery::pattern("\x7e\x5e\110\105\114\117\x20\145\170\x61\x6d\x70\154\145\x2e\x6f\x72\147\134\x72\x5c\x6e\44\176\x44"))->andReturn(1); $buf->shouldReceive("\162\x65\x61\144\114\151\156\x65")->once()->with(1)->andReturn("\x35\x30\64\x20\x57\x54\106" . "\15\12"); $this->finishBuffer($buf); try { $this->assertFalse($smtp->isStarted(), "\45\x73\x3a\x20\x53\x4d\x54\120\x20\163\x68\x6f\x75\x6c\144\40\x62\x65\147\x69\x6e\x20\156\x6f\x6e\55\x73\x74\x61\x72\164\145\144"); $smtp->start(); $this->fail("\116\157\156\40\x32\65\60\x20\110\105\x4c\x4f\40\162\x65\x73\x70\157\156\x73\x65\40\x73\150\157\165\x6c\x64\x20\162\141\x69\x73\145\40\x45\170\143\145\x70\164\x69\157\x6e"); } catch (Swift_TransportException $e) { $this->assertFalse($smtp->isStarted(), "\x25\x73\72\x20\123\x4d\124\x50\40\163\x74\141\162\x74\x28\51\x20\163\150\157\165\154\x64\40\150\x61\x76\x65\x20\x66\141\x69\154\x65\x64"); } } public function testDomainNameIsPlacedInHelo() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\x69\156\151\x74\x69\x61\x6c\x69\x7a\145")->once(); $buf->shouldReceive("\x72\x65\141\144\114\x69\x6e\145")->once()->with(0)->andReturn("\x32\62\x30\40\163\157\155\145\x2e\x73\145\162\x76\145\x72\x2e\164\x6c\144\40\x62\x6c\145\x68\xd\xa"); $buf->shouldReceive("\x77\x72\151\164\145")->once()->with("\110\x45\114\x4f\40\155\171\144\x6f\x6d\x61\x69\156\56\x63\x6f\x6d\xd\12")->andReturn(1); $buf->shouldReceive("\162\145\x61\144\x4c\151\156\x65")->once()->with(1)->andReturn("\62\65\60\x20\123\145\x72\166\145\162\x4e\141\155\x65" . "\xd\12"); $this->finishBuffer($buf); $smtp->setLocalDomain("\x6d\171\x64\157\155\141\151\156\x2e\143\x6f\x6d"); $smtp->start(); } public function testSuccessfulMailCommand() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\145\x74\106\x72\157\155")->once()->andReturn(array("\155\x65\x40\x64\157\x6d\x61\x69\x6e\x2e\x63\157\155" => "\115\x65")); $message->shouldReceive("\147\x65\x74\x54\157")->once()->andReturn(array("\146\x6f\x6f\100\142\x61\162" => null)); $buf->shouldReceive("\151\156\x69\x74\x69\x61\154\151\172\x65")->once(); $buf->shouldReceive("\167\162\x69\x74\145")->once()->with("\115\x41\x49\x4c\40\106\x52\117\x4d\72\x3c\x6d\x65\100\x64\157\x6d\x61\x69\x6e\56\x63\157\x6d\x3e\15\xa")->andReturn(1); $buf->shouldReceive("\x72\x65\x61\144\x4c\x69\x6e\145")->once()->with(1)->andReturn("\62\x35\60\40\117\113\xd\xa"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); } catch (Exception $e) { $this->fail("\x4d\101\x49\x4c\x20\x46\122\117\115\x20\x73\x68\157\165\154\144\40\141\x63\x63\145\x70\x74\40\x61\x20\x32\x35\60\40\x72\145\163\160\157\156\163\x65"); } } public function testInvalidResponseCodeFromMailCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\147\x65\164\x46\x72\157\155")->once()->andReturn(array("\155\x65\100\144\157\155\141\x69\x6e\56\143\x6f\x6d" => "\115\x65")); $message->shouldReceive("\x67\x65\x74\x54\x6f")->once()->andReturn(array("\146\x6f\x6f\100\142\141\x72" => null)); $buf->shouldReceive("\x77\x72\x69\164\145")->once()->with("\115\x41\x49\114\x20\x46\122\117\x4d\72\74\x6d\x65\100\x64\157\155\141\x69\156\56\x63\157\155\x3e\15\xa")->andReturn(1); $buf->shouldReceive("\162\145\141\x64\114\151\156\x65")->once()->with(1)->andReturn("\x35\x35\63\x20\102\x61\144" . "\xd\12"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); $this->fail("\x4d\101\111\x4c\40\106\122\x4f\115\x20\163\150\157\x75\154\144\40\x61\x63\x63\145\160\164\x20\141\40\x32\x35\60\x20\x72\x65\x73\160\157\156\163\145"); } catch (Swift_TransportException $e) { } } public function testSenderIsPreferredOverFrom() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\x65\x74\x46\162\x6f\155")->once()->andReturn(array("\x6d\x65\x40\x64\157\155\141\151\x6e\56\x63\157\155" => "\115\145")); $message->shouldReceive("\147\x65\x74\x53\x65\156\x64\x65\162")->once()->andReturn(array("\x61\156\x6f\164\x68\145\x72\x40\144\157\155\x61\x69\x6e\56\143\157\x6d" => "\123\157\x6d\145\157\x6e\x65")); $message->shouldReceive("\147\x65\x74\124\157")->once()->andReturn(array("\146\x6f\157\x40\x62\141\x72" => null)); $buf->shouldReceive("\167\162\151\164\x65")->once()->with("\x4d\x41\x49\114\40\x46\122\x4f\x4d\72\74\x61\156\157\164\150\145\x72\x40\144\x6f\x6d\141\x69\156\x2e\x63\x6f\155\x3e\15\12")->andReturn(1); $buf->shouldReceive("\x72\x65\141\x64\114\x69\156\x65")->once()->with(1)->andReturn("\x32\x35\x30\40\117\113" . "\xd\12"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testReturnPathIsPreferredOverSender() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\x65\164\106\162\x6f\155")->once()->andReturn(array("\155\145\100\x64\x6f\155\141\151\x6e\x2e\x63\157\155" => "\115\145")); $message->shouldReceive("\x67\x65\x74\123\145\x6e\x64\145\162")->once()->andReturn(array("\x61\156\x6f\x74\x68\x65\162\100\x64\157\x6d\x61\151\156\56\x63\x6f\x6d" => "\x53\x6f\x6d\x65\157\x6e\145")); $message->shouldReceive("\147\145\x74\x52\145\164\x75\162\x6e\x50\141\x74\x68")->once()->andReturn("\155\x6f\x72\145\x40\144\x6f\155\x61\x69\x6e\x2e\x63\x6f\155"); $message->shouldReceive("\147\145\x74\x54\x6f")->once()->andReturn(array("\146\x6f\157\100\x62\141\162" => null)); $buf->shouldReceive("\x77\x72\x69\x74\x65")->once()->with("\x4d\x41\x49\x4c\40\x46\x52\117\115\x3a\74\155\157\162\x65\x40\x64\x6f\155\x61\x69\156\56\143\157\155\x3e\xd\12")->andReturn(1); $buf->shouldReceive("\x72\145\x61\144\114\x69\x6e\x65")->once()->with(1)->andReturn("\62\65\60\40\117\113" . "\xd\xa"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testSuccessfulRcptCommandWith250Response() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\145\x74\106\x72\157\x6d")->once()->andReturn(array("\x6d\x65\100\x64\157\155\x61\151\x6e\56\143\157\x6d" => "\x4d\x65")); $message->shouldReceive("\147\x65\164\124\x6f")->once()->andReturn(array("\146\x6f\x6f\100\142\141\x72" => null)); $buf->shouldReceive("\167\162\151\164\x65")->once()->with("\x4d\x41\x49\114\x20\x46\122\117\x4d\x3a\x3c\x6d\145\100\x64\157\x6d\x61\151\x6e\x2e\x63\157\x6d\76\xd\12")->andReturn(1); $buf->shouldReceive("\x72\145\x61\144\x4c\x69\x6e\x65")->once()->with(1)->andReturn("\x32\x35\x30\40\117\113" . "\xd\12"); $buf->shouldReceive("\x77\162\x69\x74\145")->once()->with("\x52\103\120\124\40\124\x4f\x3a\x3c\x66\x6f\x6f\100\142\x61\x72\x3e\15\xa")->andReturn(2); $buf->shouldReceive("\x72\x65\141\144\x4c\151\x6e\x65")->once()->with(2)->andReturn("\62\x35\x30\40\x4f\113" . "\xd\xa"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); } catch (Exception $e) { $this->fail("\122\103\x50\124\40\124\x4f\40\x73\x68\157\165\x6c\x64\40\141\143\x63\x65\x70\164\40\x61\x20\62\x35\60\x20\162\145\163\160\157\x6e\x73\x65"); } } public function testUtf8AddressWithIdnEncoder() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\147\x65\x74\x46\162\157\155")->once()->andReturn(array("\155\145\100\144\xc3\266\155\x61\151\156\56\143\157\x6d" => "\x4d\x65")); $message->shouldReceive("\x67\x65\164\x54\x6f")->once()->andReturn(array("\146\157\x6f\x40\142\303\244\162" => null)); $buf->shouldReceive("\167\x72\x69\x74\x65")->once()->with("\x4d\101\x49\114\x20\x46\x52\x4f\115\72\74\155\x65\100\x78\x6e\55\x2d\x64\155\x61\151\156\55\x6a\165\x61\x2e\x63\x6f\x6d\76\15\12")->andReturn(1); $buf->shouldReceive("\x77\162\151\164\x65")->once()->with("\x52\103\x50\124\x20\124\x4f\x3a\74\146\157\x6f\x40\170\156\55\55\142\162\x2d\166\151\141\76\xd\12")->andReturn(1); $buf->shouldReceive("\162\145\x61\x64\x4c\151\156\145")->once()->with(1)->andReturn("\x32\x35\60\40\x4f\113" . "\15\xa"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testUtf8AddressWithUtf8Encoder() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf, null, new Swift_AddressEncoder_Utf8AddressEncoder()); $message = $this->createMessage(); $message->shouldReceive("\x67\x65\164\106\162\157\155")->once()->andReturn(array("\155\xc3\xab\100\x64\xc3\xb6\x6d\141\x69\156\x2e\x63\x6f\x6d" => "\115\x65")); $message->shouldReceive("\147\145\164\124\x6f")->once()->andReturn(array("\146\303\266\xc3\266\100\x62\xc3\244\x72" => null)); $buf->shouldReceive("\x77\x72\x69\164\145")->once()->with("\x4d\101\x49\x4c\40\106\x52\117\x4d\72\x3c\x6d\303\253\100\144\xc3\266\x6d\x61\x69\x6e\56\x63\x6f\x6d\76\15\12")->andReturn(1); $buf->shouldReceive("\x77\x72\x69\164\145")->once()->with("\122\103\120\124\40\124\x4f\x3a\74\x66\303\xb6\xc3\xb6\100\142\xc3\xa4\x72\76\15\xa")->andReturn(1); $buf->shouldReceive("\162\x65\x61\x64\x4c\151\x6e\145")->once()->with(1)->andReturn("\x32\65\x30\40\x4f\113" . "\xd\12"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testNonEncodableSenderCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\147\145\x74\106\162\x6f\155")->once()->andReturn(array("\155\xc3\xab\100\x64\x6f\155\x61\151\x6e\56\143\157\x6d" => "\x4d\x65")); $message->shouldReceive("\147\x65\164\x54\157")->once()->andReturn(array("\x66\157\x6f\x40\142\x61\x72" => null)); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); $this->fail("\155\xc3\xab\100\x64\x6f\x6d\x61\151\x6e\x2e\143\x6f\x6d\x20\x63\141\x6e\x6e\157\164\x20\142\145\40\x65\x6e\143\x6f\x64\145\x64\40\50\156\157\x74\40\157\x62\163\145\162\x76\x65\x64\51"); } catch (Swift_AddressEncoderException $e) { $this->assertEquals("\x6d\xc3\xab\x40\144\157\155\141\x69\x6e\56\x63\157\155", $e->getAddress()); } } public function testMailFromCommandIsOnlySentOncePerMessage() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\147\145\x74\106\162\157\x6d")->once()->andReturn(array("\x6d\x65\x40\144\157\x6d\141\x69\x6e\56\x63\x6f\x6d" => "\x4d\145")); $message->shouldReceive("\x67\145\164\x54\157")->once()->andReturn(array("\146\157\157\x40\x62\x61\x72" => null)); $buf->shouldReceive("\167\162\151\x74\145")->once()->with("\115\101\x49\114\x20\106\x52\117\115\x3a\x3c\x6d\145\100\144\x6f\x6d\141\151\x6e\56\143\157\x6d\x3e\xd\12")->andReturn(1); $buf->shouldReceive("\x72\x65\141\144\x4c\151\156\145")->once()->with(1)->andReturn("\62\65\x30\40\x4f\113" . "\15\xa"); $buf->shouldReceive("\x77\x72\x69\164\145")->once()->with("\x52\x43\120\x54\x20\124\x4f\72\74\x66\157\157\x40\x62\141\x72\76\xd\xa")->andReturn(2); $buf->shouldReceive("\x72\x65\141\x64\x4c\x69\156\145")->once()->with(2)->andReturn("\62\x35\60\40\x4f\113" . "\xd\12"); $buf->shouldReceive("\x77\x72\151\164\x65")->never()->with("\115\x41\x49\114\x20\x46\122\117\115\72\x3c\x6d\145\100\x64\157\155\141\x69\156\56\x63\x6f\x6d\x3e\15\12"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testMultipleRecipientsSendsMultipleRcpt() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\145\x74\x46\162\x6f\x6d")->once()->andReturn(array("\155\x65\x40\x64\x6f\x6d\141\151\x6e\56\143\x6f\155" => "\115\145")); $message->shouldReceive("\x67\x65\164\124\x6f")->once()->andReturn(array("\146\157\157\100\x62\x61\162" => null, "\x7a\151\x70\100\x62\165\x74\x74\157\156" => "\132\151\x70\x20\x42\165\x74\164\157\x6e", "\164\x65\x73\164\x40\144\x6f\x6d\141\x69\156" => "\x54\x65\163\164\40\x75\163\145\162", "\x74\xc3\253\163\x74\100\144\157\155\141\151\x6e" => "\x54\145\x73\x74\40\x75\x73\145\x72")); $buf->shouldReceive("\167\162\x69\x74\x65")->once()->with("\122\x43\x50\x54\40\x54\x4f\x3a\74\146\157\157\100\x62\x61\x72\x3e\xd\xa")->andReturn(1); $buf->shouldReceive("\162\x65\141\144\114\151\x6e\145")->once()->with(1)->andReturn("\62\65\x30\40\117\113" . "\15\12"); $buf->shouldReceive("\x77\x72\x69\x74\x65")->once()->with("\x52\103\120\124\x20\x54\x4f\72\74\x7a\151\160\x40\x62\x75\164\164\157\x6e\76\15\12")->andReturn(2); $buf->shouldReceive("\162\145\x61\144\x4c\x69\156\x65")->once()->with(2)->andReturn("\x32\65\60\x20\117\113" . "\15\xa"); $buf->shouldReceive("\x77\162\151\x74\145")->once()->with("\x52\x43\120\124\x20\124\x4f\x3a\74\x74\x65\x73\164\x40\144\x6f\155\x61\151\156\76\15\12")->andReturn(3); $buf->shouldReceive("\162\145\141\x64\114\x69\x6e\x65")->once()->with(3)->andReturn("\62\x35\x30\40\x4f\x4b" . "\xd\xa"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testCcRecipientsSendsMultipleRcpt() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\145\x74\106\x72\x6f\x6d")->once()->andReturn(array("\x6d\145\100\x64\157\x6d\141\x69\x6e\x2e\x63\x6f\x6d" => "\115\145")); $message->shouldReceive("\x67\x65\164\124\x6f")->once()->andReturn(array("\x66\157\x6f\x40\x62\x61\x72" => null)); $message->shouldReceive("\147\145\164\x43\x63")->once()->andReturn(array("\x7a\x69\x70\x40\142\165\164\164\x6f\156" => "\x5a\151\x70\40\x42\x75\164\164\157\156", "\164\x65\163\164\100\x64\x6f\155\x61\151\156" => "\x54\x65\x73\164\40\x75\163\x65\x72")); $buf->shouldReceive("\167\162\x69\x74\145")->once()->with("\122\x43\x50\124\40\x54\117\72\x3c\146\x6f\x6f\100\x62\x61\162\x3e\15\12")->andReturn(1); $buf->shouldReceive("\x72\x65\x61\144\114\151\156\x65")->once()->with(1)->andReturn("\x32\x35\x30\x20\117\113" . "\15\12"); $buf->shouldReceive("\167\x72\x69\164\145")->once()->with("\122\x43\120\x54\40\x54\x4f\72\74\172\151\x70\100\142\x75\x74\x74\x6f\x6e\x3e\15\12")->andReturn(2); $buf->shouldReceive("\x72\145\141\144\114\x69\156\x65")->once()->with(2)->andReturn("\62\65\60\x20\117\113" . "\15\xa"); $buf->shouldReceive("\x77\x72\x69\x74\145")->once()->with("\122\x43\120\x54\40\124\117\72\x3c\164\x65\163\x74\100\144\x6f\x6d\x61\x69\x6e\76\xd\xa")->andReturn(3); $buf->shouldReceive("\x72\145\x61\x64\114\151\156\x65")->once()->with(3)->andReturn("\62\x35\x30\40\117\x4b" . "\xd\xa"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testSendReturnsNumberOfSuccessfulRecipients() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\x65\164\x46\162\157\155")->once()->andReturn(array("\x6d\145\100\144\x6f\155\141\x69\x6e\56\143\157\155" => "\x4d\x65")); $message->shouldReceive("\147\x65\x74\124\x6f")->once()->andReturn(array("\146\x6f\157\100\142\141\x72" => null)); $message->shouldReceive("\x67\145\x74\x43\x63")->once()->andReturn(array("\x7a\x69\160\x40\x62\x75\x74\164\x6f\x6e" => "\132\151\x70\40\x42\x75\x74\164\x6f\156", "\x74\x65\x73\164\100\144\157\155\x61\151\156" => "\x54\145\x73\164\40\x75\x73\x65\162")); $buf->shouldReceive("\x77\162\x69\x74\145")->once()->with("\x52\x43\x50\124\x20\x54\117\72\74\146\157\x6f\100\142\141\162\76\xd\xa")->andReturn(1); $buf->shouldReceive("\x72\x65\x61\144\x4c\151\156\x65")->once()->with(1)->andReturn("\x32\x35\x30\x20\117\x4b" . "\xd\12"); $buf->shouldReceive("\x77\x72\x69\164\145")->once()->with("\122\x43\x50\x54\x20\124\117\72\74\x7a\x69\160\x40\142\165\x74\164\x6f\156\76\xd\xa")->andReturn(2); $buf->shouldReceive("\162\145\141\144\x4c\x69\x6e\145")->once()->with(2)->andReturn("\65\60\61\x20\116\157\x62\157\x64\171\x20\x68\x65\x72\145" . "\xd\xa"); $buf->shouldReceive("\x77\x72\151\164\145")->once()->with("\x52\103\120\124\x20\124\117\x3a\74\x74\145\x73\164\100\144\x6f\x6d\x61\151\156\x3e\15\xa")->andReturn(3); $buf->shouldReceive("\162\x65\141\144\x4c\151\x6e\x65")->once()->with(3)->andReturn("\x32\65\x30\x20\117\113" . "\xd\12"); $this->finishBuffer($buf); $smtp->start(); $this->assertEquals(2, $smtp->send($message), "\x25\163\x3a\x20\61\x20\x6f\146\40\63\40\x72\x65\143\151\160\151\x65\156\164\x73\40\146\x61\x69\154\145\x64\40\163\157\x20\62\x20\163\x68\x6f\x75\154\144\40\x62\x65\40\162\145\164\x75\x72\x6e\145\144"); } public function testRsetIsSentIfNoSuccessfulRecipients() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\x65\164\106\162\x6f\155")->once()->andReturn(array("\x6d\145\x40\144\157\155\141\x69\156\56\143\x6f\x6d" => "\115\145")); $message->shouldReceive("\147\145\164\x54\157")->once()->andReturn(array("\x66\157\157\100\x62\x61\162" => null)); $buf->shouldReceive("\167\162\x69\164\145")->once()->with("\122\x43\120\124\40\x54\117\x3a\74\x66\x6f\x6f\x40\x62\x61\162\x3e\15\12")->andReturn(1); $buf->shouldReceive("\x72\x65\141\x64\114\151\156\145")->once()->with(1)->andReturn("\65\x30\x33\40\102\x61\x64" . "\15\12"); $buf->shouldReceive("\167\x72\151\164\x65")->once()->with("\x52\x53\105\124\xd\12")->andReturn(2); $buf->shouldReceive("\162\x65\x61\144\x4c\x69\x6e\x65")->once()->with(2)->andReturn("\x32\x35\x30\40\117\113" . "\xd\12"); $this->finishBuffer($buf); $smtp->start(); $this->assertEquals(0, $smtp->send($message), "\x25\163\x3a\40\61\x20\x6f\x66\x20\x31\x20\162\x65\143\151\x70\x69\145\156\164\163\40\x66\x61\x69\x6c\145\x64\40\163\x6f\x20\x30\40\x73\150\x6f\x75\154\144\x20\x62\x65\x20\x72\145\x74\165\x72\x6e\x65\144"); } public function testSuccessfulDataCommand() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\147\145\x74\x46\162\157\155")->once()->andReturn(array("\155\145\x40\x64\157\155\141\x69\156\x2e\143\157\x6d" => "\115\x65")); $message->shouldReceive("\147\x65\x74\124\x6f")->once()->andReturn(array("\146\157\x6f\x40\x62\x61\162" => null)); $buf->shouldReceive("\167\x72\x69\164\x65")->once()->with("\104\x41\x54\x41\15\12")->andReturn(1); $buf->shouldReceive("\x72\x65\141\x64\x4c\151\156\145")->once()->with(1)->andReturn("\63\x35\64\x20\107\157\40\141\x68\x65\141\x64" . "\xd\12"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); } catch (Exception $e) { $this->fail("\x33\65\64\40\151\163\40\164\x68\145\x20\145\170\160\x65\143\164\145\144\40\162\145\x73\x70\x6f\x6e\163\145\40\164\157\40\x44\x41\x54\101"); } } public function testBadDataResponseCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\x65\164\x46\162\x6f\x6d")->once()->andReturn(array("\155\x65\x40\x64\x6f\155\x61\151\156\x2e\x63\157\x6d" => "\x4d\x65")); $message->shouldReceive("\147\145\164\124\157")->once()->andReturn(array("\146\x6f\157\100\x62\141\162" => null)); $buf->shouldReceive("\167\x72\x69\x74\145")->once()->with("\104\101\x54\101\xd\xa")->andReturn(1); $buf->shouldReceive("\x72\145\x61\x64\x4c\x69\156\145")->once()->with(1)->andReturn("\64\65\61\40\102\x61\144" . "\15\12"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); $this->fail("\x33\x35\x34\x20\151\x73\40\x74\150\145\x20\145\170\x70\145\x63\164\x65\144\x20\162\145\163\160\157\x6e\163\145\x20\x74\x6f\40\104\x41\x54\101\40\x28\156\157\164\40\x6f\142\x73\x65\x72\166\x65\x64\x29"); } catch (Swift_TransportException $e) { } } public function testMessageIsStreamedToBufferForData() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\x65\x74\x46\162\x6f\x6d")->once()->andReturn(array("\x6d\145\100\x64\157\x6d\x61\x69\x6e\56\x63\x6f\155" => "\115\145")); $message->shouldReceive("\147\145\164\124\157")->once()->andReturn(array("\146\157\157\100\142\141\162" => null)); $buf->shouldReceive("\167\162\x69\164\x65")->once()->with("\x44\101\x54\x41\xd\xa")->andReturn(1); $buf->shouldReceive("\162\x65\x61\x64\x4c\151\x6e\x65")->once()->with(1)->andReturn("\63\x35\64\40\117\x4b" . "\xd\12"); $buf->shouldReceive("\x77\x72\151\x74\x65")->once()->with("\xd\xa\x2e\xd\12")->andReturn(2); $buf->shouldReceive("\162\x65\x61\x64\114\x69\156\145")->once()->with(2)->andReturn("\62\x35\60\40\117\x4b" . "\15\xa"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testBadResponseAfterDataTransmissionCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\147\145\x74\106\x72\157\x6d")->once()->andReturn(array("\x6d\x65\100\144\157\x6d\x61\151\156\x2e\x63\x6f\155" => "\x4d\145")); $message->shouldReceive("\x67\x65\164\124\157")->once()->andReturn(array("\146\x6f\157\100\x62\141\162" => null)); $buf->shouldReceive("\167\x72\x69\164\x65")->once()->with("\104\101\124\x41\xd\xa")->andReturn(1); $buf->shouldReceive("\162\145\x61\144\114\x69\156\145")->once()->with(1)->andReturn("\x33\x35\x34\40\117\x4b" . "\xd\xa"); $buf->shouldReceive("\x77\162\151\x74\x65")->once()->with("\xd\xa\56\15\xa")->andReturn(2); $buf->shouldReceive("\162\145\141\x64\114\151\x6e\145")->once()->with(2)->andReturn("\65\x35\x34\40\105\x72\x72\x6f\x72" . "\15\xa"); $this->finishBuffer($buf); try { $smtp->start(); $smtp->send($message); $this->fail("\x32\x35\x30\40\x69\x73\x20\x74\x68\145\40\x65\170\160\x65\x63\x74\145\144\40\162\145\163\160\x6f\156\x73\x65\40\x61\x66\164\145\162\x20\141\x20\x44\101\x54\x41\x20\x74\x72\141\156\x73\155\x69\163\163\x69\x6f\156\x20\50\x6e\157\164\40\157\142\163\145\162\166\x65\x64\x29"); } catch (Swift_TransportException $e) { } } public function testBccRecipientsAreRemovedFromHeaders() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\x65\164\x46\x72\157\x6d")->zeroOrMoreTimes()->andReturn(array("\155\145\100\144\157\x6d\141\151\156\56\x63\x6f\x6d" => "\115\x65")); $message->shouldReceive("\147\x65\164\124\x6f")->zeroOrMoreTimes()->andReturn(array("\146\157\x6f\x40\142\x61\x72" => null)); $message->shouldReceive("\x67\x65\164\x42\x63\x63")->zeroOrMoreTimes()->andReturn(array("\x7a\x69\160\x40\x62\165\x74\x74\157\x6e" => "\132\151\x70\40\x42\165\164\164\157\x6e", "\164\145\163\164\x40\x64\x6f\155\141\x69\156" => "\124\145\163\164\x20\165\163\145\x72")); $message->shouldReceive("\x73\145\x74\102\x63\x63")->once()->with(array()); $message->shouldReceive("\163\145\164\102\143\143")->zeroOrMoreTimes(); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testMessageStateIsRestoredOnFailure() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\145\164\106\x72\157\155")->zeroOrMoreTimes()->andReturn(array("\x6d\145\100\144\x6f\155\141\x69\156\x2e\143\x6f\x6d" => "\115\x65")); $message->shouldReceive("\x67\x65\164\x54\157")->zeroOrMoreTimes()->andReturn(array("\x66\157\x6f\x40\x62\x61\x72" => null)); $message->shouldReceive("\147\145\164\x42\x63\143")->zeroOrMoreTimes()->andReturn(array("\172\151\x70\100\x62\165\164\x74\x6f\156" => "\132\x69\x70\40\102\165\164\164\157\x6e", "\x74\145\163\164\100\x64\x6f\155\141\x69\156" => "\124\145\163\x74\x20\165\x73\145\162")); $message->shouldReceive("\163\x65\x74\102\143\x63")->once()->with(array()); $message->shouldReceive("\163\x65\x74\102\143\143")->once()->with(array("\172\151\160\x40\142\165\x74\164\157\x6e" => "\132\x69\x70\40\x42\x75\x74\164\157\156", "\164\x65\163\164\100\x64\x6f\x6d\141\151\x6e" => "\x54\x65\x73\x74\40\165\x73\x65\162")); $buf->shouldReceive("\167\162\x69\164\x65")->once()->with("\x4d\101\111\x4c\40\106\122\x4f\115\x3a\x3c\x6d\x65\100\144\x6f\x6d\x61\151\x6e\56\143\x6f\x6d\76\15\xa")->andReturn(1); $buf->shouldReceive("\x72\145\141\144\x4c\x69\x6e\145")->once()->with(1)->andReturn("\x32\x35\x30\x20\117\x4b\15\xa"); $buf->shouldReceive("\x77\162\x69\x74\145")->once()->with("\x52\103\120\124\40\x54\x4f\x3a\x3c\146\157\x6f\x40\142\x61\162\76\15\12")->andReturn(2); $buf->shouldReceive("\162\145\141\x64\x4c\151\x6e\x65")->once()->with(2)->andReturn("\62\65\60\40\117\113\xd\xa"); $buf->shouldReceive("\167\x72\151\x74\x65")->once()->with("\x44\x41\124\x41\xd\xa")->andReturn(3); $buf->shouldReceive("\162\145\141\144\x4c\x69\156\x65")->once()->with(3)->andReturn("\x34\65\x31\x20\x4e\157\xd\12"); $this->finishBuffer($buf); $smtp->start(); try { $smtp->send($message); $this->fail("\101\x20\142\141\144\40\x72\x65\x73\x70\x6f\x6e\163\x65\x20\x77\x61\x73\x20\147\x69\x76\145\156\x20\x73\157\x20\145\170\x63\x65\x70\x74\151\x6f\x6e\x20\151\163\40\145\x78\160\x65\143\164\145\x64"); } catch (Swift_TransportException $e) { } } public function testStopSendsQuitCommand() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $buf->shouldReceive("\x69\x6e\151\x74\x69\141\x6c\x69\172\x65")->once(); $buf->shouldReceive("\x77\x72\x69\x74\x65")->once()->with("\x51\x55\x49\x54\15\xa")->andReturn(1); $buf->shouldReceive("\162\145\x61\144\114\151\x6e\x65")->once()->with(1)->andReturn("\62\x32\61\40\102\x79\x65\xd\xa"); $buf->shouldReceive("\x74\x65\x72\x6d\151\x6e\141\164\145")->once(); $this->finishBuffer($buf); $this->assertFalse($smtp->isStarted()); $smtp->start(); $this->assertTrue($smtp->isStarted()); $smtp->stop(); $this->assertFalse($smtp->isStarted()); } public function testBufferCanBeFetched() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $ref = $smtp->getBuffer(); $this->assertEquals($buf, $ref); } public function testBufferCanBeWrittenToUsingExecuteCommand() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $buf->shouldReceive("\167\162\x69\x74\145")->zeroOrMoreTimes()->with("\106\117\x4f\xd\12")->andReturn(1); $buf->shouldReceive("\x72\x65\x61\x64\x4c\151\156\x65")->zeroOrMoreTimes()->with(1)->andReturn("\62\65\x30\40\x4f\113\xd\12"); $res = $smtp->executeCommand("\106\x4f\x4f\15\12"); $this->assertEquals("\62\65\60\40\x4f\x4b\xd\xa", $res); } public function testResponseCodesAreValidated() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $buf->shouldReceive("\167\162\x69\164\145")->zeroOrMoreTimes()->with("\106\x4f\x4f\15\xa")->andReturn(1); $buf->shouldReceive("\x72\145\141\x64\114\151\x6e\x65")->zeroOrMoreTimes()->with(1)->andReturn("\x35\x35\61\x20\116\x6f\x74\40\157\153\15\12"); try { $smtp->executeCommand("\x46\117\x4f\xd\xa", array(250, 251)); $this->fail("\101\x20\x32\65\60\x20\157\162\40\x32\65\61\40\x72\145\163\160\x6f\x6e\x73\145\x20\167\141\163\x20\x6e\x65\x65\144\x65\144\40\142\x75\164\x20\x35\x35\x31\40\x77\x61\x73\x20\x72\145\164\165\x72\156\x65\x64\56"); } catch (Swift_TransportException $e) { } } public function testFailedRecipientsCanBeCollectedByReference() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\147\x65\x74\106\x72\157\x6d")->zeroOrMoreTimes()->andReturn(array("\155\145\x40\144\x6f\x6d\x61\151\156\x2e\x63\157\x6d" => "\x4d\x65")); $message->shouldReceive("\x67\x65\x74\124\x6f")->zeroOrMoreTimes()->andReturn(array("\x66\157\x6f\100\x62\141\x72" => null)); $message->shouldReceive("\x67\145\x74\102\x63\143")->zeroOrMoreTimes()->andReturn(array("\172\x69\160\x40\142\165\x74\164\157\x6e" => "\132\151\x70\x20\x42\x75\164\164\x6f\x6e", "\164\145\x73\164\100\144\x6f\x6d\x61\x69\156" => "\124\145\x73\x74\x20\x75\x73\145\x72")); $message->shouldReceive("\x73\145\x74\x42\143\143")->atLeast()->once()->with(array()); $message->shouldReceive("\x73\x65\164\102\x63\x63")->atLeast()->once()->with(array("\172\151\x70\100\x62\165\164\164\157\x6e" => "\x5a\x69\x70\40\102\165\x74\164\157\156", "\x74\145\x73\x74\100\144\157\155\x61\151\x6e" => "\124\145\x73\164\40\x75\x73\x65\x72")); $buf->shouldReceive("\x77\x72\151\164\x65")->once()->with("\115\101\x49\x4c\40\106\122\x4f\115\72\74\x6d\145\100\x64\157\x6d\141\x69\x6e\x2e\143\x6f\155\x3e\15\xa")->andReturn(1); $buf->shouldReceive("\162\x65\x61\144\114\151\x6e\145")->once()->with(1)->andReturn("\x32\x35\60\x20\117\113\xd\xa"); $buf->shouldReceive("\x77\x72\151\164\x65")->once()->with("\x52\103\x50\x54\x20\124\x4f\72\74\x66\157\x6f\x40\x62\x61\162\76\xd\xa")->andReturn(2); $buf->shouldReceive("\x72\x65\x61\144\x4c\x69\x6e\x65")->once()->with(2)->andReturn("\x32\x35\x30\x20\x4f\x4b\15\12"); $buf->shouldReceive("\x77\x72\151\164\x65")->once()->with("\122\103\120\x54\40\x54\117\72\74\172\151\x70\100\x62\165\x74\164\157\x6e\76\xd\12")->andReturn(3); $buf->shouldReceive("\x72\x65\x61\x64\x4c\x69\x6e\145")->once()->with(3)->andReturn("\65\x30\x30\40\102\x61\144\xd\xa"); $buf->shouldReceive("\x77\162\x69\164\x65")->once()->with("\122\x43\x50\124\40\x54\x4f\72\x3c\164\x65\163\164\100\144\x6f\x6d\141\151\x6e\76\15\xa")->andReturn(4); $buf->shouldReceive("\162\x65\141\144\x4c\x69\x6e\x65")->once()->with(4)->andReturn("\x35\60\x30\x20\102\141\144\xd\xa"); $this->finishBuffer($buf); $smtp->start(); $this->assertEquals(1, $smtp->send($message, $failures)); } public function testSendingRegeneratesMessageId() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $message = $this->createMessage(); $message->shouldReceive("\x67\x65\x74\106\x72\x6f\155")->zeroOrMoreTimes()->andReturn(array("\155\145\100\144\157\x6d\141\x69\156\56\x63\x6f\x6d" => "\x4d\145")); $message->shouldReceive("\x67\145\164\x54\x6f")->zeroOrMoreTimes()->andReturn(array("\146\x6f\157\100\142\141\162" => null)); $message->shouldReceive("\x67\x65\156\x65\162\x61\x74\145\x49\144")->once(); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); } public function testPing() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\151\x6e\x69\x74\151\x61\154\151\x7a\x65")->once(); $buf->shouldReceive("\162\145\141\x64\114\x69\x6e\145")->once()->with(0)->andReturn("\62\x32\x30\40\x73\x6f\155\x65\56\x73\x65\162\x76\x65\162\56\164\x6c\144\40\x62\x6c\145\150\15\xa"); $buf->shouldReceive("\167\162\x69\164\145")->once()->with(Mockery::pattern("\176\x5e\x4e\117\117\x50\x5c\x72\134\156\x24\x7e\104"))->andReturn(1); $buf->shouldReceive("\x72\x65\141\144\x4c\x69\x6e\145")->once()->with(1)->andReturn("\62\65\x30\40\117\x4b" . "\15\xa"); $this->finishBuffer($buf); $this->assertTrue($smtp->ping()); } public function testPingOnDeadConnection() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\151\x6e\151\164\x69\x61\154\x69\x7a\145")->once(); $buf->shouldReceive("\x72\x65\141\144\x4c\x69\156\145")->once()->with(0)->andReturn("\62\62\60\40\x73\x6f\x6d\145\56\x73\145\162\x76\x65\162\x2e\x74\x6c\x64\x20\x62\x6c\x65\150\xd\12"); $buf->shouldReceive("\x77\162\x69\164\145")->once()->with(Mockery::pattern("\176\x5e\116\117\117\x50\134\x72\134\x6e\x24\176\104"))->andThrow("\123\x77\151\x66\164\x5f\x54\x72\141\x6e\163\x70\157\162\x74\x45\x78\x63\x65\x70\x74\151\157\156"); $this->finishBuffer($buf); $smtp->start(); $this->assertTrue($smtp->isStarted()); $this->assertFalse($smtp->ping()); $this->assertFalse($smtp->isStarted()); } public function testSetLocalDomain() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $smtp->setLocalDomain("\145\170\141\155\x70\154\145\56\x63\x6f\155"); $this->assertEquals("\145\170\141\x6d\x70\x6c\145\x2e\x63\x6f\155", $smtp->getLocalDomain()); $smtp->setLocalDomain("\x31\71\62\x2e\x31\66\70\x2e\60\56\x31"); $this->assertEquals("\x5b\x31\71\x32\56\61\66\70\56\60\x2e\x31\135", $smtp->getLocalDomain()); $smtp->setLocalDomain("\133\x31\71\x32\x2e\x31\66\70\56\x30\x2e\61\135"); $this->assertEquals("\x5b\61\71\62\x2e\x31\x36\x38\x2e\x30\x2e\x31\x5d", $smtp->getLocalDomain()); $smtp->setLocalDomain("\146\x64\x30\x30\x3a\x3a"); $this->assertEquals("\x5b\111\x50\x76\x36\x3a\x66\144\60\x30\72\x3a\x5d", $smtp->getLocalDomain()); $smtp->setLocalDomain("\133\x49\120\x76\66\72\146\144\x30\x30\72\72\135"); $this->assertEquals("\133\111\120\166\x36\x3a\x66\x64\60\x30\72\72\x5d", $smtp->getLocalDomain()); } protected function getBuffer() { return $this->getMockery("\123\167\x69\x66\164\x5f\124\162\x61\x6e\163\160\x6f\x72\x74\137\x49\x6f\x42\x75\x66\146\145\162")->shouldIgnoreMissing(); } protected function createMessage() { return $this->getMockery("\123\x77\x69\x66\164\x5f\x4d\151\155\x65\137\123\x69\x6d\x70\154\145\x4d\x65\x73\163\x61\x67\145")->shouldIgnoreMissing(); } protected function finishBuffer($buf) { $buf->shouldReceive("\162\x65\141\x64\114\x69\156\x65")->zeroOrMoreTimes()->with(0)->andReturn("\x32\62\60\x20\x73\x65\162\x76\145\x72\56\x63\157\x6d\40\146\x6f\x6f" . "\xd\xa"); $buf->shouldReceive("\x77\162\x69\x74\145")->zeroOrMoreTimes()->with(Mockery::pattern("\x7e\x5e\50\x45\x48\174\110\105\x29\x4c\117\x20\x2e\52\77\134\x72\x5c\x6e\44\176\x44"))->andReturn($x = uniqid('', true)); $buf->shouldReceive("\162\x65\x61\144\114\x69\156\145")->zeroOrMoreTimes()->with($x)->andReturn("\x32\65\x30\40\123\x65\162\166\145\x72\x4e\x61\155\145" . "\15\12"); $buf->shouldReceive("\x77\x72\x69\x74\x65")->zeroOrMoreTimes()->with(Mockery::pattern("\176\136\x4d\101\x49\x4c\x20\106\x52\x4f\x4d\72\x3c\x2e\52\77\76\x5c\162\134\x6e\44\x7e\104"))->andReturn($x = uniqid('', true)); $buf->shouldReceive("\162\x65\x61\x64\x4c\151\156\x65")->zeroOrMoreTimes()->with($x)->andReturn("\62\65\60\x20\117\x4b\15\xa"); $buf->shouldReceive("\167\x72\151\x74\145")->zeroOrMoreTimes()->with(Mockery::pattern("\x7e\136\122\103\x50\124\40\124\x4f\x3a\74\x2e\x2a\77\x3e\x5c\x72\x5c\156\44\176\x44"))->andReturn($x = uniqid('', true)); $buf->shouldReceive("\162\145\x61\144\x4c\x69\x6e\145")->zeroOrMoreTimes()->with($x)->andReturn("\62\x35\60\40\x4f\x4b\xd\xa"); $buf->shouldReceive("\167\x72\151\x74\x65")->zeroOrMoreTimes()->with("\x44\101\124\x41\xd\xa")->andReturn($x = uniqid('', true)); $buf->shouldReceive("\162\x65\x61\x64\114\x69\x6e\145")->zeroOrMoreTimes()->with($x)->andReturn("\63\x35\64\x20\x4f\113\xd\12"); $buf->shouldReceive("\167\162\x69\x74\x65")->zeroOrMoreTimes()->with("\15\12\x2e\15\xa")->andReturn($x = uniqid('', true)); $buf->shouldReceive("\162\145\141\144\114\151\x6e\x65")->zeroOrMoreTimes()->with($x)->andReturn("\x32\x35\60\40\x4f\x4b\15\12"); $buf->shouldReceive("\x77\x72\151\164\145")->zeroOrMoreTimes()->with("\122\123\x45\124\15\xa")->andReturn($x = uniqid('', true)); $buf->shouldReceive("\162\x65\141\144\x4c\151\x6e\145")->zeroOrMoreTimes()->with($x)->andReturn("\x32\65\x30\40\x4f\x4b\15\12"); $buf->shouldReceive("\167\162\x69\164\145")->zeroOrMoreTimes()->andReturn(false); $buf->shouldReceive("\162\x65\x61\144\114\151\156\145")->zeroOrMoreTimes()->andReturn(false); } }

Function Calls

None

Variables

None

Stats

MD5 cb99e206bed2f801cf783c46a725e4e7
Eval Count 0
Decode Time 133 ms