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 class Swift_Transport_EsmtpTransportTest extends Swift_Transport_AbstractSmtpEventS..

Decoded Output download

<?php
 class Swift_Transport_EsmtpTransportTest extends Swift_Transport_AbstractSmtpEventSupportTest { protected function getTransport($buf, $dispatcher = null, $addressEncoder = null) { $dispatcher = $dispatcher ?? $this->createEventDispatcher(); $addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); return new Swift_Transport_EsmtpTransport($buf, array(), $dispatcher, "example.org", $addressEncoder); } public function testHostCanBeSetAndFetched() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $smtp->setHost("foo"); $this->assertEquals("foo", $smtp->getHost(), "%s: Host should be returned"); } public function testPortCanBeSetAndFetched() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $smtp->setPort(25); $this->assertEquals(25, $smtp->getPort(), "%s: Port should be returned"); } public function testTimeoutCanBeSetAndFetched() { $buf = $this->getBuffer(); $buf->shouldReceive("setParam")->once()->with("timeout", 10); $smtp = $this->getTransport($buf); $smtp->setTimeout(10); $this->assertEquals(10, $smtp->getTimeout(), "%s: Timeout should be returned"); } public function testEncryptionCanBeSetAndFetched() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $smtp->setEncryption("tls"); $this->assertEquals("tls", $smtp->getEncryption(), "%s: Crypto should be returned"); } public function testStartSendsHeloToInitiate() { $this->addToAssertionCount(1); } public function testStartSendsEhloToInitiate() { $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("~^EHLO .+?\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 ServerName" . "
"); $this->finishBuffer($buf); try { $smtp->start(); } catch (Exception $e) { $this->fail("Starting Esmtp should send EHLO and accept 250 response: " . $e->getMessage()); } } public function testHeloIsUsedAsFallback() { $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("~^EHLO .+?\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("501 WTF" . "\xd\xa"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^HELO .+?\r\n$~D"))->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("250 HELO" . "
\xa"); $this->finishBuffer($buf); try { $smtp->start(); } catch (Exception $e) { $this->fail("Starting Esmtp should fallback to HELO if needed 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("~^EHLO .+?\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("501 WTF" . "
\xa"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^HELO .+?\r\n$~D"))->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("504 WTF" . "\xd\xa"); $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 (Exception $e) { $this->assertFalse($smtp->isStarted(), "%s: SMTP start() should have failed"); } } public function testDomainNameIsPlacedInEhlo() { $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("EHLO mydomain.com
")->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 ServerName" . "
\xa"); $this->finishBuffer($buf); $smtp->setLocalDomain("mydomain.com"); $smtp->start(); } 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(Mockery::pattern("~^EHLO .+?\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("501 WTF" . "
"); $buf->shouldReceive("write")->once()->with("HELO mydomain.com
")->andReturn(2); $buf->shouldReceive("readLine")->once()->with(2)->andReturn("250 ServerName" . "\xd\xa"); $this->finishBuffer($buf); $smtp->setLocalDomain("mydomain.com"); $smtp->start(); } public function testPipelining() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $this->assertNull($smtp->getPipelining()); $message = $this->createMessage(); $message->shouldReceive("getFrom")->zeroOrMoreTimes()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->zeroOrMoreTimes()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh
"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^EHLO .+?\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250-ServerName" . "
\xa"); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 PIPELINING" . "\xd\xa"); $buf->shouldReceive("write")->ordered()->once()->with("MAIL FROM:<[email protected]>\xd
")->andReturn(1); $buf->shouldReceive("write")->ordered()->once()->with("RCPT TO:<foo@bar>
\xa")->andReturn(2); $buf->shouldReceive("write")->ordered()->once()->with("DATA
\xa")->andReturn(3); $buf->shouldReceive("readLine")->ordered()->once()->with(1)->andReturn("250 OK
"); $buf->shouldReceive("readLine")->ordered()->once()->with(2)->andReturn("250 OK
"); $buf->shouldReceive("readLine")->ordered()->once()->with(3)->andReturn("354 OK
"); $this->finishBuffer($buf); $smtp->start(); $sent = $smtp->send($message, $failedRecipients); $this->assertEquals(1, $sent); $this->assertEmpty($failedRecipients); $this->assertTrue($smtp->getPipelining()); } public function testPipeliningWithRecipientFailure() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $this->assertNull($smtp->getPipelining()); $message = $this->createMessage(); $message->shouldReceive("getFrom")->zeroOrMoreTimes()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->zeroOrMoreTimes()->andReturn(array("good@foo" => null, "bad@foo" => null, "good@bar" => null)); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh
\xa"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^EHLO .+?\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250-ServerName" . "
"); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 PIPELINING" . "\xd\xa"); $buf->shouldReceive("write")->ordered()->once()->with("MAIL FROM:<[email protected]>
")->andReturn(1); $buf->shouldReceive("write")->ordered()->once()->with("RCPT TO:<good@foo>
")->andReturn(2); $buf->shouldReceive("write")->ordered()->once()->with("RCPT TO:<bad@foo>
\xa")->andReturn(3); $buf->shouldReceive("write")->ordered()->once()->with("RCPT TO:<good@bar>
")->andReturn(4); $buf->shouldReceive("write")->ordered()->once()->with("DATA
\xa")->andReturn(5); $buf->shouldReceive("readLine")->ordered()->once()->with(1)->andReturn("250 OK
\xa"); $buf->shouldReceive("readLine")->ordered()->once()->with(2)->andReturn("250 OK\xd\xa"); $buf->shouldReceive("readLine")->ordered()->once()->with(3)->andReturn("450 Unknown address bad@foo
\xa"); $buf->shouldReceive("readLine")->ordered()->once()->with(4)->andReturn("250 OK
"); $buf->shouldReceive("readLine")->ordered()->once()->with(5)->andReturn("354 OK\xd
"); $this->finishBuffer($buf); $smtp->start(); $sent = $smtp->send($message, $failedRecipients); $this->assertEquals(2, $sent); $this->assertEquals(array("bad@foo"), $failedRecipients); $this->assertTrue($smtp->getPipelining()); } public function testPipeliningWithSenderFailure() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $this->assertNull($smtp->getPipelining()); $message = $this->createMessage(); $message->shouldReceive("getFrom")->zeroOrMoreTimes()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->zeroOrMoreTimes()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh
\xa"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^EHLO .+?\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250-ServerName" . "
"); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 PIPELINING" . "\xd\xa"); $buf->shouldReceive("write")->ordered()->once()->with("MAIL FROM:<[email protected]>
\xa")->andReturn(1); $buf->shouldReceive("write")->ordered()->once()->with("RCPT TO:<foo@bar>
\xa")->andReturn(2); $buf->shouldReceive("write")->ordered()->once()->with("DATA
\xa")->andReturn(3); $buf->shouldReceive("readLine")->ordered()->once()->with(1)->andReturn("550 Unknown address [email protected]\xd\xa"); $smtp->start(); $this->expectException("Swift_TransportException"); $this->expectExceptionMessage("Expected response code 250 but got code "550""); $smtp->send($message, $failedRecipients); } public function testPipeliningWithDataFailure() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $this->assertNull($smtp->getPipelining()); $message = $this->createMessage(); $message->shouldReceive("getFrom")->zeroOrMoreTimes()->andReturn(array("[email protected]" => "Me")); $message->shouldReceive("getTo")->zeroOrMoreTimes()->andReturn(array("foo@bar" => null)); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh
"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^EHLO .+?\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250-ServerName" . "
\xa"); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 PIPELINING" . "\xd\xa"); $buf->shouldReceive("write")->ordered()->once()->with("MAIL FROM:<[email protected]>
\xa")->andReturn(1); $buf->shouldReceive("write")->ordered()->once()->with("RCPT TO:<foo@bar>\xd
")->andReturn(2); $buf->shouldReceive("write")->ordered()->once()->with("DATA
\xa")->andReturn(3); $buf->shouldReceive("readLine")->ordered()->once()->with(1)->andReturn("250 OK\xd
"); $buf->shouldReceive("readLine")->ordered()->once()->with(2)->andReturn("250 OK
"); $buf->shouldReceive("readLine")->ordered()->once()->with(3)->andReturn("452 Insufficient system storage
\xa"); $smtp->start(); $this->expectException("Swift_TransportException"); $this->expectExceptionMessage("Expected response code 354 but got code "452""); $smtp->send($message, $failedRecipients); } public function providerPipeliningOverride() { return array(array(null, true, true), array(null, false, false), array(true, false, true), array(true, true, true), array(false, false, false), array(false, true, false)); } public function testPipeliningOverride($enabled, bool $supported, bool $expected) { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $this->assertNull($smtp->getPipelining()); $smtp->setPipelining($enabled); $this->assertSame($enabled, $smtp->getPipelining()); $message = $this->createMessage(); $message->shouldReceive("getFrom")->zeroOrMoreTimes()->andReturn(array("[email protected]" => "Me")); $buf->shouldReceive("initialize")->once(); $buf->shouldReceive("readLine")->once()->with(0)->andReturn("220 some.server.tld bleh
"); $buf->shouldReceive("write")->once()->with(Mockery::pattern("~^EHLO .+?\r\n$~D"))->andReturn(1); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250-ServerName" . "
\xa"); $buf->shouldReceive("readLine")->once()->with(1)->andReturn("250 " . ($supported ? "PIPELINING" : "FOOBAR") . "
"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); $this->assertSame($expected, $smtp->getPipelining()); } public function testFluidInterface() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("setParam")->once()->with("timeout", 30); $ref = $smtp->setHost("foo")->setPort(25)->setEncryption("tls")->setTimeout(30)->setPipelining(false); $this->assertEquals($ref, $smtp); } } ?>

Did this file decode correctly?

Original Code

<?php
 class Swift_Transport_EsmtpTransportTest extends Swift_Transport_AbstractSmtpEventSupportTest { protected function getTransport($buf, $dispatcher = null, $addressEncoder = null) { $dispatcher = $dispatcher ?? $this->createEventDispatcher(); $addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); return new Swift_Transport_EsmtpTransport($buf, array(), $dispatcher, "\x65\170\x61\x6d\160\x6c\x65\56\157\162\147", $addressEncoder); } public function testHostCanBeSetAndFetched() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $smtp->setHost("\146\x6f\157"); $this->assertEquals("\x66\x6f\157", $smtp->getHost(), "\45\x73\72\40\110\157\163\164\x20\163\150\157\165\x6c\144\x20\x62\x65\x20\x72\145\164\x75\x72\156\x65\x64"); } public function testPortCanBeSetAndFetched() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $smtp->setPort(25); $this->assertEquals(25, $smtp->getPort(), "\x25\x73\72\40\120\x6f\x72\164\40\x73\x68\157\165\154\144\x20\x62\x65\x20\x72\x65\x74\x75\162\156\145\144"); } public function testTimeoutCanBeSetAndFetched() { $buf = $this->getBuffer(); $buf->shouldReceive("\163\145\x74\x50\141\x72\x61\x6d")->once()->with("\x74\x69\x6d\145\157\165\164", 10); $smtp = $this->getTransport($buf); $smtp->setTimeout(10); $this->assertEquals(10, $smtp->getTimeout(), "\x25\x73\72\x20\124\x69\x6d\x65\x6f\165\164\x20\163\150\157\x75\x6c\x64\40\142\x65\x20\162\x65\x74\x75\162\x6e\145\144"); } public function testEncryptionCanBeSetAndFetched() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $smtp->setEncryption("\164\154\163"); $this->assertEquals("\164\154\x73", $smtp->getEncryption(), "\45\x73\x3a\40\103\162\171\160\x74\x6f\40\163\x68\157\165\154\x64\40\142\145\40\162\145\164\x75\x72\x6e\145\x64"); } public function testStartSendsHeloToInitiate() { $this->addToAssertionCount(1); } public function testStartSendsEhloToInitiate() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\x69\156\x69\164\x69\x61\154\x69\172\145")->once(); $buf->shouldReceive("\x72\145\x61\144\x4c\151\x6e\145")->once()->with(0)->andReturn("\x32\x32\60\x20\163\x6f\155\145\x2e\163\145\x72\166\x65\x72\56\164\154\144\x20\x62\x6c\x65\150\15\xa"); $buf->shouldReceive("\x77\162\151\164\145")->once()->with(Mockery::pattern("\176\136\x45\x48\114\117\x20\x2e\x2b\77\134\x72\x5c\x6e\x24\176\x44"))->andReturn(1); $buf->shouldReceive("\x72\x65\x61\144\114\x69\x6e\145")->once()->with(1)->andReturn("\62\x35\x30\40\x53\145\x72\166\145\162\x4e\141\155\x65" . "\15\12"); $this->finishBuffer($buf); try { $smtp->start(); } catch (Exception $e) { $this->fail("\x53\x74\141\162\x74\151\156\147\40\105\163\x6d\164\x70\x20\x73\150\x6f\165\x6c\x64\40\163\x65\x6e\144\40\x45\110\114\117\40\x61\x6e\x64\40\x61\143\x63\145\x70\164\x20\x32\x35\60\40\162\145\163\160\157\x6e\163\145\x3a\x20" . $e->getMessage()); } } public function testHeloIsUsedAsFallback() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\151\156\151\164\x69\x61\x6c\151\x7a\x65")->once(); $buf->shouldReceive("\162\x65\141\x64\114\151\156\145")->once()->with(0)->andReturn("\62\x32\60\x20\x73\x6f\x6d\x65\56\x73\145\x72\x76\145\162\x2e\x74\x6c\x64\40\x62\x6c\x65\x68\15\xa"); $buf->shouldReceive("\167\162\151\x74\145")->once()->with(Mockery::pattern("\x7e\x5e\x45\110\x4c\117\x20\x2e\53\77\x5c\x72\x5c\x6e\x24\176\104"))->andReturn(1); $buf->shouldReceive("\x72\145\141\144\x4c\x69\x6e\x65")->once()->with(1)->andReturn("\x35\60\x31\x20\x57\x54\x46" . "\xd\xa"); $buf->shouldReceive("\167\162\151\164\x65")->once()->with(Mockery::pattern("\x7e\x5e\x48\105\114\117\40\x2e\x2b\77\134\162\x5c\x6e\x24\x7e\104"))->andReturn(2); $buf->shouldReceive("\x72\145\x61\x64\x4c\151\x6e\145")->once()->with(2)->andReturn("\x32\x35\x30\40\110\x45\x4c\x4f" . "\15\xa"); $this->finishBuffer($buf); try { $smtp->start(); } catch (Exception $e) { $this->fail("\x53\164\x61\162\x74\151\x6e\x67\40\105\163\155\164\x70\x20\163\150\x6f\x75\x6c\144\x20\x66\141\x6c\154\142\x61\143\153\x20\x74\157\40\110\x45\114\x4f\40\151\x66\x20\x6e\145\145\144\145\x64\40\141\156\144\40\141\x63\x63\145\160\x74\40\62\x35\x30\x20\x72\x65\163\x70\x6f\156\163\145"); } } public function testInvalidHeloResponseCausesException() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\151\x6e\x69\x74\x69\x61\x6c\151\x7a\x65")->once(); $buf->shouldReceive("\x72\145\x61\144\114\151\x6e\145")->once()->with(0)->andReturn("\62\x32\60\x20\x73\157\155\x65\x2e\x73\145\162\166\145\162\x2e\x74\154\144\x20\142\x6c\x65\150\15\12"); $buf->shouldReceive("\x77\162\x69\x74\x65")->once()->with(Mockery::pattern("\x7e\136\105\110\x4c\117\x20\56\x2b\x3f\x5c\162\x5c\156\x24\176\104"))->andReturn(1); $buf->shouldReceive("\162\x65\141\x64\x4c\x69\x6e\x65")->once()->with(1)->andReturn("\x35\x30\61\x20\x57\124\106" . "\15\xa"); $buf->shouldReceive("\x77\162\151\164\x65")->once()->with(Mockery::pattern("\176\x5e\x48\105\114\x4f\40\x2e\53\x3f\134\162\134\x6e\44\x7e\104"))->andReturn(2); $buf->shouldReceive("\x72\x65\x61\x64\114\151\x6e\145")->once()->with(2)->andReturn("\x35\60\64\40\127\124\106" . "\xd\xa"); $this->finishBuffer($buf); try { $this->assertFalse($smtp->isStarted(), "\45\163\x3a\40\123\115\x54\120\40\163\150\157\165\x6c\144\x20\x62\x65\147\x69\156\x20\x6e\x6f\x6e\55\x73\164\x61\x72\x74\145\144"); $smtp->start(); $this->fail("\x4e\157\x6e\x20\62\x35\60\x20\110\105\x4c\117\x20\x72\145\x73\160\x6f\x6e\163\145\40\x73\150\157\165\x6c\144\40\162\x61\x69\x73\x65\40\x45\x78\143\145\x70\164\x69\157\156"); } catch (Exception $e) { $this->assertFalse($smtp->isStarted(), "\45\x73\x3a\x20\x53\x4d\124\x50\40\x73\164\x61\x72\164\x28\51\x20\163\150\157\x75\x6c\x64\x20\x68\141\x76\145\40\146\141\151\154\145\144"); } } public function testDomainNameIsPlacedInEhlo() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\151\156\x69\x74\151\x61\154\x69\x7a\145")->once(); $buf->shouldReceive("\x72\145\x61\x64\114\x69\156\x65")->once()->with(0)->andReturn("\62\62\x30\x20\x73\x6f\155\145\56\x73\x65\x72\x76\145\162\56\164\154\144\40\142\x6c\x65\x68\xd\12"); $buf->shouldReceive("\x77\x72\x69\x74\x65")->once()->with("\x45\110\x4c\117\40\155\171\x64\157\155\141\x69\156\x2e\x63\x6f\x6d\15\12")->andReturn(1); $buf->shouldReceive("\x72\x65\141\144\x4c\x69\156\x65")->once()->with(1)->andReturn("\x32\65\x30\x20\123\145\162\x76\x65\162\116\141\155\x65" . "\15\xa"); $this->finishBuffer($buf); $smtp->setLocalDomain("\x6d\171\x64\x6f\x6d\141\151\x6e\56\143\157\155"); $smtp->start(); } public function testDomainNameIsPlacedInHelo() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\x69\x6e\151\x74\x69\x61\x6c\151\172\145")->once(); $buf->shouldReceive("\162\x65\141\144\114\x69\156\145")->once()->with(0)->andReturn("\x32\x32\60\40\163\x6f\x6d\x65\56\x73\145\x72\166\x65\162\x2e\164\154\x64\x20\142\x6c\145\x68\xd\xa"); $buf->shouldReceive("\x77\x72\x69\x74\145")->once()->with(Mockery::pattern("\x7e\136\105\x48\114\117\40\x2e\x2b\x3f\x5c\162\x5c\x6e\x24\x7e\x44"))->andReturn(1); $buf->shouldReceive("\162\x65\141\x64\114\x69\x6e\145")->once()->with(1)->andReturn("\65\x30\61\x20\127\124\x46" . "\15\12"); $buf->shouldReceive("\x77\x72\x69\x74\145")->once()->with("\110\105\x4c\x4f\40\x6d\171\x64\157\x6d\x61\151\x6e\56\143\157\155\15\12")->andReturn(2); $buf->shouldReceive("\x72\145\141\144\x4c\151\156\145")->once()->with(2)->andReturn("\62\x35\60\40\123\145\162\x76\x65\x72\x4e\141\155\x65" . "\xd\xa"); $this->finishBuffer($buf); $smtp->setLocalDomain("\x6d\x79\x64\x6f\x6d\141\x69\x6e\x2e\x63\x6f\x6d"); $smtp->start(); } public function testPipelining() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $this->assertNull($smtp->getPipelining()); $message = $this->createMessage(); $message->shouldReceive("\x67\145\164\106\x72\157\x6d")->zeroOrMoreTimes()->andReturn(array("\155\x65\100\x64\x6f\x6d\x61\x69\x6e\x2e\x63\x6f\x6d" => "\x4d\145")); $message->shouldReceive("\x67\x65\x74\124\x6f")->zeroOrMoreTimes()->andReturn(array("\146\157\x6f\x40\x62\x61\162" => null)); $buf->shouldReceive("\151\156\151\x74\x69\x61\x6c\x69\x7a\x65")->once(); $buf->shouldReceive("\162\x65\141\x64\x4c\151\156\x65")->once()->with(0)->andReturn("\62\x32\x30\x20\x73\x6f\155\x65\x2e\x73\145\162\166\x65\x72\x2e\164\x6c\x64\x20\142\x6c\x65\150\15\12"); $buf->shouldReceive("\x77\162\151\x74\145")->once()->with(Mockery::pattern("\x7e\x5e\x45\110\114\x4f\x20\x2e\53\x3f\x5c\162\134\x6e\x24\x7e\x44"))->andReturn(1); $buf->shouldReceive("\x72\145\x61\x64\114\151\x6e\x65")->once()->with(1)->andReturn("\x32\x35\60\55\x53\x65\x72\x76\145\162\x4e\141\x6d\x65" . "\15\xa"); $buf->shouldReceive("\x72\145\141\x64\114\x69\156\x65")->once()->with(1)->andReturn("\x32\65\60\40\x50\x49\120\x45\x4c\x49\116\x49\116\x47" . "\xd\xa"); $buf->shouldReceive("\167\162\x69\x74\x65")->ordered()->once()->with("\115\x41\111\114\40\106\122\x4f\115\72\74\155\x65\100\144\x6f\155\x61\151\156\x2e\x63\157\x6d\x3e\xd\12")->andReturn(1); $buf->shouldReceive("\x77\x72\x69\x74\145")->ordered()->once()->with("\122\103\120\124\40\x54\x4f\72\74\146\x6f\157\100\142\141\162\76\15\xa")->andReturn(2); $buf->shouldReceive("\x77\162\151\164\x65")->ordered()->once()->with("\104\101\124\x41\15\xa")->andReturn(3); $buf->shouldReceive("\x72\145\141\x64\x4c\151\156\x65")->ordered()->once()->with(1)->andReturn("\x32\x35\x30\40\117\113\15\12"); $buf->shouldReceive("\x72\x65\141\144\x4c\151\156\x65")->ordered()->once()->with(2)->andReturn("\62\65\x30\x20\117\113\15\12"); $buf->shouldReceive("\162\145\x61\144\x4c\151\156\x65")->ordered()->once()->with(3)->andReturn("\63\65\x34\40\x4f\113\15\12"); $this->finishBuffer($buf); $smtp->start(); $sent = $smtp->send($message, $failedRecipients); $this->assertEquals(1, $sent); $this->assertEmpty($failedRecipients); $this->assertTrue($smtp->getPipelining()); } public function testPipeliningWithRecipientFailure() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $this->assertNull($smtp->getPipelining()); $message = $this->createMessage(); $message->shouldReceive("\x67\145\164\106\x72\x6f\155")->zeroOrMoreTimes()->andReturn(array("\x6d\145\x40\x64\x6f\x6d\141\x69\156\x2e\x63\157\155" => "\115\145")); $message->shouldReceive("\147\x65\x74\x54\157")->zeroOrMoreTimes()->andReturn(array("\x67\157\157\x64\x40\146\157\157" => null, "\x62\141\x64\100\146\157\x6f" => null, "\x67\x6f\157\x64\x40\x62\x61\162" => null)); $buf->shouldReceive("\151\x6e\151\x74\151\141\x6c\x69\x7a\145")->once(); $buf->shouldReceive("\x72\145\x61\x64\x4c\151\x6e\145")->once()->with(0)->andReturn("\x32\62\60\40\163\x6f\x6d\x65\x2e\x73\x65\162\x76\145\x72\56\164\154\144\40\142\x6c\x65\150\15\xa"); $buf->shouldReceive("\167\162\x69\164\145")->once()->with(Mockery::pattern("\176\x5e\105\110\114\117\40\56\x2b\77\x5c\x72\x5c\x6e\x24\x7e\x44"))->andReturn(1); $buf->shouldReceive("\162\x65\141\x64\x4c\x69\156\145")->once()->with(1)->andReturn("\x32\x35\60\55\123\x65\162\166\145\x72\x4e\141\x6d\145" . "\15\12"); $buf->shouldReceive("\x72\145\141\x64\x4c\151\156\145")->once()->with(1)->andReturn("\x32\65\x30\x20\x50\x49\120\x45\114\111\x4e\x49\x4e\x47" . "\xd\xa"); $buf->shouldReceive("\x77\162\151\x74\145")->ordered()->once()->with("\115\x41\x49\x4c\40\x46\122\x4f\x4d\72\74\x6d\145\100\x64\x6f\155\141\151\156\x2e\143\157\155\76\15\12")->andReturn(1); $buf->shouldReceive("\x77\x72\x69\x74\x65")->ordered()->once()->with("\122\x43\x50\124\40\124\x4f\x3a\x3c\x67\157\157\144\100\146\x6f\x6f\x3e\15\12")->andReturn(2); $buf->shouldReceive("\167\x72\x69\x74\x65")->ordered()->once()->with("\x52\x43\120\124\40\x54\x4f\x3a\74\x62\141\x64\100\x66\x6f\x6f\76\15\xa")->andReturn(3); $buf->shouldReceive("\x77\162\151\x74\145")->ordered()->once()->with("\x52\x43\x50\x54\40\124\117\x3a\74\147\157\157\144\x40\142\x61\x72\76\15\12")->andReturn(4); $buf->shouldReceive("\167\x72\151\164\x65")->ordered()->once()->with("\104\x41\124\x41\15\xa")->andReturn(5); $buf->shouldReceive("\x72\145\x61\x64\114\151\x6e\145")->ordered()->once()->with(1)->andReturn("\62\x35\x30\x20\117\x4b\15\xa"); $buf->shouldReceive("\162\145\x61\x64\114\x69\x6e\145")->ordered()->once()->with(2)->andReturn("\62\x35\x30\40\117\113\xd\xa"); $buf->shouldReceive("\x72\145\x61\144\x4c\x69\156\145")->ordered()->once()->with(3)->andReturn("\x34\x35\60\x20\x55\156\x6b\x6e\157\167\x6e\40\141\x64\x64\162\x65\x73\163\x20\142\141\144\x40\x66\157\x6f\15\xa"); $buf->shouldReceive("\162\145\x61\x64\x4c\151\x6e\x65")->ordered()->once()->with(4)->andReturn("\x32\x35\x30\40\117\x4b\15\12"); $buf->shouldReceive("\162\x65\141\x64\114\x69\x6e\x65")->ordered()->once()->with(5)->andReturn("\x33\65\x34\40\117\x4b\xd\12"); $this->finishBuffer($buf); $smtp->start(); $sent = $smtp->send($message, $failedRecipients); $this->assertEquals(2, $sent); $this->assertEquals(array("\142\x61\x64\100\146\x6f\x6f"), $failedRecipients); $this->assertTrue($smtp->getPipelining()); } public function testPipeliningWithSenderFailure() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $this->assertNull($smtp->getPipelining()); $message = $this->createMessage(); $message->shouldReceive("\x67\x65\x74\106\162\157\155")->zeroOrMoreTimes()->andReturn(array("\x6d\x65\x40\x64\157\x6d\x61\x69\x6e\x2e\143\157\x6d" => "\x4d\x65")); $message->shouldReceive("\147\x65\164\124\x6f")->zeroOrMoreTimes()->andReturn(array("\146\x6f\157\100\x62\141\x72" => null)); $buf->shouldReceive("\x69\156\151\x74\x69\141\154\x69\172\x65")->once(); $buf->shouldReceive("\162\x65\141\x64\x4c\151\x6e\145")->once()->with(0)->andReturn("\x32\62\x30\40\163\x6f\155\x65\56\x73\145\x72\166\145\162\x2e\164\x6c\144\40\142\154\x65\150\15\xa"); $buf->shouldReceive("\x77\x72\x69\164\x65")->once()->with(Mockery::pattern("\176\136\x45\110\114\x4f\x20\56\53\x3f\134\x72\134\x6e\x24\176\104"))->andReturn(1); $buf->shouldReceive("\x72\145\141\x64\x4c\151\x6e\x65")->once()->with(1)->andReturn("\62\65\60\55\123\x65\162\166\x65\162\x4e\141\x6d\145" . "\15\12"); $buf->shouldReceive("\162\145\x61\144\114\151\156\145")->once()->with(1)->andReturn("\x32\65\60\40\x50\111\x50\x45\114\x49\116\111\116\107" . "\xd\xa"); $buf->shouldReceive("\167\162\151\x74\x65")->ordered()->once()->with("\x4d\x41\111\114\x20\x46\x52\117\x4d\72\x3c\155\x65\100\144\157\x6d\x61\151\x6e\56\x63\157\x6d\76\15\xa")->andReturn(1); $buf->shouldReceive("\167\x72\x69\164\145")->ordered()->once()->with("\x52\103\x50\124\40\124\x4f\x3a\74\x66\157\x6f\x40\x62\x61\162\x3e\15\xa")->andReturn(2); $buf->shouldReceive("\x77\162\151\164\145")->ordered()->once()->with("\104\101\124\101\15\xa")->andReturn(3); $buf->shouldReceive("\x72\145\x61\x64\x4c\x69\156\145")->ordered()->once()->with(1)->andReturn("\65\65\60\40\x55\x6e\153\x6e\x6f\x77\156\x20\141\x64\144\x72\145\163\163\40\155\145\x40\144\x6f\x6d\141\151\156\x2e\x63\157\x6d\xd\xa"); $smtp->start(); $this->expectException("\x53\x77\x69\x66\164\x5f\124\162\141\156\x73\x70\x6f\x72\x74\x45\x78\143\145\160\164\151\x6f\156"); $this->expectExceptionMessage("\x45\170\160\145\x63\164\x65\144\x20\x72\145\x73\x70\x6f\156\x73\x65\x20\143\157\144\145\x20\x32\65\60\40\x62\165\x74\40\147\x6f\164\40\143\x6f\144\x65\x20\x22\65\65\x30\x22"); $smtp->send($message, $failedRecipients); } public function testPipeliningWithDataFailure() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $this->assertNull($smtp->getPipelining()); $message = $this->createMessage(); $message->shouldReceive("\147\145\x74\106\162\157\x6d")->zeroOrMoreTimes()->andReturn(array("\x6d\x65\x40\144\x6f\155\x61\x69\x6e\56\143\x6f\155" => "\x4d\x65")); $message->shouldReceive("\147\145\x74\124\157")->zeroOrMoreTimes()->andReturn(array("\146\x6f\157\x40\x62\141\162" => null)); $buf->shouldReceive("\151\156\151\x74\151\141\154\x69\x7a\145")->once(); $buf->shouldReceive("\162\x65\141\x64\x4c\x69\x6e\145")->once()->with(0)->andReturn("\62\x32\x30\x20\x73\x6f\155\x65\x2e\163\x65\x72\x76\145\162\x2e\164\154\x64\x20\x62\154\145\x68\15\12"); $buf->shouldReceive("\x77\162\x69\164\145")->once()->with(Mockery::pattern("\x7e\x5e\105\x48\x4c\117\x20\x2e\x2b\x3f\134\x72\x5c\x6e\x24\x7e\104"))->andReturn(1); $buf->shouldReceive("\x72\x65\141\x64\114\x69\156\145")->once()->with(1)->andReturn("\62\x35\x30\55\123\x65\162\x76\x65\x72\116\141\x6d\x65" . "\15\xa"); $buf->shouldReceive("\162\145\141\144\x4c\x69\x6e\145")->once()->with(1)->andReturn("\62\65\x30\40\x50\111\x50\105\114\x49\x4e\111\116\x47" . "\xd\xa"); $buf->shouldReceive("\167\x72\x69\x74\x65")->ordered()->once()->with("\x4d\x41\x49\x4c\40\x46\x52\x4f\115\72\x3c\155\145\100\144\157\155\141\x69\x6e\x2e\143\157\155\76\15\xa")->andReturn(1); $buf->shouldReceive("\x77\162\x69\164\x65")->ordered()->once()->with("\122\x43\120\124\x20\x54\117\x3a\74\146\157\157\x40\142\141\x72\76\xd\12")->andReturn(2); $buf->shouldReceive("\x77\162\x69\x74\145")->ordered()->once()->with("\104\101\124\x41\15\xa")->andReturn(3); $buf->shouldReceive("\x72\x65\141\144\114\151\156\x65")->ordered()->once()->with(1)->andReturn("\x32\65\60\x20\117\x4b\xd\12"); $buf->shouldReceive("\x72\x65\141\x64\x4c\x69\156\145")->ordered()->once()->with(2)->andReturn("\x32\x35\x30\x20\117\x4b\15\12"); $buf->shouldReceive("\162\x65\141\144\114\x69\156\x65")->ordered()->once()->with(3)->andReturn("\64\65\x32\40\111\x6e\163\165\x66\146\x69\143\x69\x65\156\164\x20\x73\x79\163\164\x65\155\x20\163\x74\x6f\x72\141\147\145\15\xa"); $smtp->start(); $this->expectException("\123\167\151\146\x74\137\x54\x72\x61\156\163\x70\157\x72\164\105\170\x63\145\x70\164\151\x6f\156"); $this->expectExceptionMessage("\x45\170\160\x65\143\164\x65\144\x20\162\145\163\x70\x6f\156\x73\x65\40\x63\x6f\x64\145\40\x33\65\x34\40\x62\x75\x74\40\x67\x6f\x74\x20\143\x6f\144\x65\x20\x22\x34\x35\x32\42"); $smtp->send($message, $failedRecipients); } public function providerPipeliningOverride() { return array(array(null, true, true), array(null, false, false), array(true, false, true), array(true, true, true), array(false, false, false), array(false, true, false)); } public function testPipeliningOverride($enabled, bool $supported, bool $expected) { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $this->assertNull($smtp->getPipelining()); $smtp->setPipelining($enabled); $this->assertSame($enabled, $smtp->getPipelining()); $message = $this->createMessage(); $message->shouldReceive("\x67\145\x74\x46\x72\x6f\155")->zeroOrMoreTimes()->andReturn(array("\155\x65\x40\x64\x6f\x6d\x61\x69\x6e\56\x63\157\x6d" => "\x4d\145")); $buf->shouldReceive("\x69\156\x69\x74\x69\141\154\151\172\145")->once(); $buf->shouldReceive("\x72\x65\x61\x64\x4c\151\x6e\x65")->once()->with(0)->andReturn("\62\x32\x30\40\163\x6f\155\x65\x2e\163\145\x72\166\145\162\56\164\x6c\x64\40\142\x6c\145\x68\15\12"); $buf->shouldReceive("\167\x72\x69\164\145")->once()->with(Mockery::pattern("\176\136\105\110\x4c\x4f\x20\56\x2b\x3f\134\x72\134\x6e\x24\176\104"))->andReturn(1); $buf->shouldReceive("\162\x65\x61\144\x4c\x69\156\145")->once()->with(1)->andReturn("\x32\x35\x30\55\123\145\162\x76\145\162\116\x61\x6d\145" . "\15\xa"); $buf->shouldReceive("\162\x65\141\144\114\x69\156\145")->once()->with(1)->andReturn("\x32\65\x30\40" . ($supported ? "\120\x49\120\105\114\111\116\x49\116\x47" : "\106\117\x4f\102\x41\x52") . "\15\12"); $this->finishBuffer($buf); $smtp->start(); $smtp->send($message); $this->assertSame($expected, $smtp->getPipelining()); } public function testFluidInterface() { $buf = $this->getBuffer(); $smtp = $this->getTransport($buf); $buf->shouldReceive("\163\x65\164\x50\141\162\141\155")->once()->with("\x74\x69\155\x65\157\x75\164", 30); $ref = $smtp->setHost("\x66\x6f\x6f")->setPort(25)->setEncryption("\x74\x6c\163")->setTimeout(30)->setPipelining(false); $this->assertEquals($ref, $smtp); } }

Function Calls

None

Variables

None

Stats

MD5 a47568889d895ef1d7a116a66072583b
Eval Count 0
Decode Time 101 ms