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_FailoverTransportTest extends \SwiftMailerTestCase { public f..

Decoded Output download

<?php
 class Swift_Transport_FailoverTransportTest extends \SwiftMailerTestCase { public function testFirstTransportIsUsed() { $message1 = $this->getMockery("Swift_Mime_SimpleMessage"); $message2 = $this->getMockery("Swift_Mime_SimpleMessage"); $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $connectionState = false; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState) { return $connectionState; }); $t1->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState) { if (!$connectionState) { $connectionState = true; } }); $t1->shouldReceive("send")->twice()->with(\Mockery::anyOf($message1, $message2), \Mockery::any())->andReturnUsing(function () use(&$connectionState) { if ($connectionState) { return 1; } }); $t2->shouldReceive("start")->never(); $t2->shouldReceive("send")->never(); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $this->assertEquals(1, $transport->send($message1)); $this->assertEquals(1, $transport->send($message2)); } public function testMessageCanBeTriedOnNextTransportIfExceptionThrown() { $e = new Swift_TransportException("b0rken"); $message = $this->getMockery("Swift_Mime_SimpleMessage"); $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $connectionState1 = false; $connectionState2 = false; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState1) { if (!$connectionState1) { $connectionState1 = true; } }); $t1->shouldReceive("send")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e) { if ($connectionState1) { throw $e; } }); $t2->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState2) { if (!$connectionState2) { $connectionState2 = true; } }); $t2->shouldReceive("send")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState2) { if ($connectionState2) { return 1; } }); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $this->assertEquals(1, $transport->send($message)); } public function testZeroIsReturnedIfTransportReturnsZero() { $message = $this->getMockery("Swift_Mime_SimpleMessage")->shouldIgnoreMissing(); $t1 = $this->getMockery("Swift_Transport")->shouldIgnoreMissing(); $connectionState = false; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState) { return $connectionState; }); $t1->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState) { if (!$connectionState) { $connectionState = true; } }); $testCase = $this; $t1->shouldReceive("send")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState, $testCase) { if (!$connectionState) { $testCase->fail(); } return 0; }); $transport = $this->getTransport(array($t1)); $transport->start(); $this->assertEquals(0, $transport->send($message)); } public function testTransportsWhichThrowExceptionsAreNotRetried() { $e = new Swift_TransportException("maur b0rken"); $message1 = $this->getMockery("Swift_Mime_SimpleMessage"); $message2 = $this->getMockery("Swift_Mime_SimpleMessage"); $message3 = $this->getMockery("Swift_Mime_SimpleMessage"); $message4 = $this->getMockery("Swift_Mime_SimpleMessage"); $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $connectionState1 = false; $connectionState2 = false; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState1) { if (!$connectionState1) { $connectionState1 = true; } }); $t1->shouldReceive("send")->once()->with($message1, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e) { if ($connectionState1) { throw $e; } }); $t1->shouldReceive("send")->never()->with($message2, \Mockery::any()); $t1->shouldReceive("send")->never()->with($message3, \Mockery::any()); $t1->shouldReceive("send")->never()->with($message4, \Mockery::any()); $t2->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState2) { if (!$connectionState2) { $connectionState2 = true; } }); $t2->shouldReceive("send")->times(4)->with(\Mockery::anyOf($message1, $message2, $message3, $message4), \Mockery::any())->andReturnUsing(function () use(&$connectionState2) { if ($connectionState2) { return 1; } }); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $this->assertEquals(1, $transport->send($message1)); $this->assertEquals(1, $transport->send($message2)); $this->assertEquals(1, $transport->send($message3)); $this->assertEquals(1, $transport->send($message4)); } public function testExceptionIsThrownIfAllTransportsDie() { $e = new Swift_TransportException("b0rken"); $message = $this->getMockery("Swift_Mime_SimpleMessage"); $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $connectionState1 = false; $connectionState2 = false; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState1) { if (!$connectionState1) { $connectionState1 = true; } }); $t1->shouldReceive("send")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e) { if ($connectionState1) { throw $e; } }); $t2->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState2) { if (!$connectionState2) { $connectionState2 = true; } }); $t2->shouldReceive("send")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState2, $e) { if ($connectionState2) { throw $e; } }); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); try { $transport->send($message); $this->fail("All transports failed so Exception should be thrown"); } catch (Exception $e) { } } public function testStoppingTransportStopsAllDelegates() { $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $connectionState1 = true; $connectionState2 = true; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("stop")->once()->andReturnUsing(function () use(&$connectionState1) { if ($connectionState1) { $connectionState1 = false; } }); $t2->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("stop")->once()->andReturnUsing(function () use(&$connectionState2) { if ($connectionState2) { $connectionState2 = false; } }); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $transport->stop(); } public function testTransportShowsAsNotStartedIfAllDelegatesDead() { $e = new Swift_TransportException("b0rken"); $message = $this->getMockery("Swift_Mime_SimpleMessage"); $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $connectionState1 = false; $connectionState2 = false; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState1) { if (!$connectionState1) { $connectionState1 = true; } }); $t1->shouldReceive("send")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e) { if ($connectionState1) { $connectionState1 = false; throw $e; } }); $t2->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState2) { if (!$connectionState2) { $connectionState2 = true; } }); $t2->shouldReceive("send")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState2, $e) { if ($connectionState2) { $connectionState2 = false; throw $e; } }); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $this->assertTrue($transport->isStarted()); try { $transport->send($message); $this->fail("All transports failed so Exception should be thrown"); } catch (Exception $e) { $this->assertFalse($transport->isStarted()); } } public function testRestartingTransportRestartsDeadDelegates() { $e = new Swift_TransportException("b0rken"); $message1 = $this->getMockery("Swift_Mime_SimpleMessage"); $message2 = $this->getMockery("Swift_Mime_SimpleMessage"); $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $connectionState1 = false; $connectionState2 = false; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("start")->twice()->andReturnUsing(function () use(&$connectionState1) { if (!$connectionState1) { $connectionState1 = true; } }); $t1->shouldReceive("send")->once()->with($message1, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e) { if ($connectionState1) { $connectionState1 = false; throw $e; } }); $t1->shouldReceive("send")->once()->with($message2, \Mockery::any())->andReturnUsing(function () use(&$connectionState1) { if ($connectionState1) { return 10; } }); $t2->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("start")->once()->andReturnUsing(function () use(&$connectionState2) { if (!$connectionState2) { $connectionState2 = true; } }); $t2->shouldReceive("send")->once()->with($message1, \Mockery::any())->andReturnUsing(function () use(&$connectionState2, $e) { if ($connectionState2) { $connectionState2 = false; throw $e; } }); $t2->shouldReceive("send")->never()->with($message2, \Mockery::any()); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $this->assertTrue($transport->isStarted()); try { $transport->send($message1); $this->fail("All transports failed so Exception should be thrown"); } catch (Exception $e) { $this->assertFalse($transport->isStarted()); } $transport->start(); $this->assertTrue($transport->isStarted()); $this->assertEquals(10, $transport->send($message2)); } public function testFailureReferenceIsPassedToDelegates() { $failures = array(); $message = $this->getMockery("Swift_Mime_SimpleMessage"); $t1 = $this->getMockery("Swift_Transport"); $connectionState = false; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use($connectionState) { return $connectionState; }); $t1->shouldReceive("start")->once()->andReturnUsing(function () use($connectionState) { if (!$connectionState) { $connectionState = true; } }); $t1->shouldReceive("send")->once()->with($message, $failures)->andReturnUsing(function () use($connectionState) { if ($connectionState) { return 1; } }); $transport = $this->getTransport(array($t1)); $transport->start(); $transport->send($message, $failures); } public function testRegisterPluginDelegatesToLoadedTransports() { $plugin = $this->createPlugin(); $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $t1->shouldReceive("registerPlugin")->once()->with($plugin); $t2->shouldReceive("registerPlugin")->once()->with($plugin); $transport = $this->getTransport(array($t1, $t2)); $transport->registerPlugin($plugin); } public function testEachDelegateIsPinged() { $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $connectionState1 = false; $connectionState2 = false; $testCase = $this; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("ping")->once()->andReturn(true); $transport = $this->getTransport(array($t1, $t2)); $this->assertTrue($transport->isStarted()); $this->assertTrue($transport->ping()); } public function testDelegateIsKilledWhenPingFails() { $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $testCase = $this; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("ping")->once()->andReturn(false); $t2->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("ping")->twice()->andReturn(true); $transport = $this->getTransport(array($t1, $t2)); $this->assertTrue($transport->ping()); $this->assertTrue($transport->ping()); $this->assertTrue($transport->isStarted()); } public function XtestTransportShowsAsNotStartedIfAllPingFails() { $t1 = $this->getMockery("Swift_Transport"); $t2 = $this->getMockery("Swift_Transport"); $testCase = $this; $t1->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("ping")->once()->andReturn(false); $t2->shouldReceive("isStarted")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("ping")->once()->andReturn(false); $transport = $this->getTransport(array($t1, $t2)); $this->assertFalse($transport->ping()); $this->assertFalse($transport->isStarted()); $this->assertFalse($transport->ping()); } private function getTransport(array $transports) { $transport = new Swift_Transport_FailoverTransport(); $transport->setTransports($transports); return $transport; } private function createPlugin() { return $this->getMockery("Swift_Events_EventListener"); } } ?>

Did this file decode correctly?

Original Code

<?php
 class Swift_Transport_FailoverTransportTest extends \SwiftMailerTestCase { public function testFirstTransportIsUsed() { $message1 = $this->getMockery("\x53\x77\x69\x66\164\137\115\151\155\145\x5f\123\151\155\160\x6c\145\x4d\145\x73\x73\141\x67\x65"); $message2 = $this->getMockery("\123\x77\x69\x66\164\x5f\x4d\151\155\x65\x5f\x53\151\x6d\x70\154\145\115\x65\163\x73\141\x67\x65"); $t1 = $this->getMockery("\x53\167\151\146\164\137\124\162\x61\156\x73\160\157\x72\x74"); $t2 = $this->getMockery("\x53\167\151\x66\x74\137\x54\x72\141\156\163\160\157\x72\x74"); $connectionState = false; $t1->shouldReceive("\151\163\x53\164\141\162\x74\x65\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState) { return $connectionState; }); $t1->shouldReceive("\163\x74\141\162\x74")->once()->andReturnUsing(function () use(&$connectionState) { if (!$connectionState) { $connectionState = true; } }); $t1->shouldReceive("\163\145\156\144")->twice()->with(\Mockery::anyOf($message1, $message2), \Mockery::any())->andReturnUsing(function () use(&$connectionState) { if ($connectionState) { return 1; } }); $t2->shouldReceive("\x73\164\141\x72\164")->never(); $t2->shouldReceive("\x73\x65\x6e\144")->never(); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $this->assertEquals(1, $transport->send($message1)); $this->assertEquals(1, $transport->send($message2)); } public function testMessageCanBeTriedOnNextTransportIfExceptionThrown() { $e = new Swift_TransportException("\142\x30\x72\x6b\x65\156"); $message = $this->getMockery("\123\x77\151\146\x74\137\115\x69\155\145\137\x53\151\155\160\154\145\115\145\x73\x73\x61\x67\x65"); $t1 = $this->getMockery("\123\x77\x69\x66\164\137\x54\162\141\x6e\x73\x70\157\162\164"); $t2 = $this->getMockery("\123\167\x69\x66\x74\137\x54\162\141\x6e\x73\x70\157\x72\164"); $connectionState1 = false; $connectionState2 = false; $t1->shouldReceive("\x69\x73\123\x74\x61\x72\164\x65\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("\x73\164\141\162\164")->once()->andReturnUsing(function () use(&$connectionState1) { if (!$connectionState1) { $connectionState1 = true; } }); $t1->shouldReceive("\163\145\x6e\x64")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e) { if ($connectionState1) { throw $e; } }); $t2->shouldReceive("\151\163\123\164\x61\162\x74\145\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("\163\164\x61\162\x74")->once()->andReturnUsing(function () use(&$connectionState2) { if (!$connectionState2) { $connectionState2 = true; } }); $t2->shouldReceive("\x73\x65\x6e\x64")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState2) { if ($connectionState2) { return 1; } }); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $this->assertEquals(1, $transport->send($message)); } public function testZeroIsReturnedIfTransportReturnsZero() { $message = $this->getMockery("\123\x77\x69\146\164\x5f\x4d\151\155\x65\137\x53\151\x6d\160\154\x65\x4d\x65\163\163\x61\x67\x65")->shouldIgnoreMissing(); $t1 = $this->getMockery("\123\167\151\146\164\137\124\x72\x61\156\x73\x70\x6f\x72\x74")->shouldIgnoreMissing(); $connectionState = false; $t1->shouldReceive("\x69\x73\123\164\x61\162\164\x65\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState) { return $connectionState; }); $t1->shouldReceive("\163\x74\141\162\x74")->once()->andReturnUsing(function () use(&$connectionState) { if (!$connectionState) { $connectionState = true; } }); $testCase = $this; $t1->shouldReceive("\163\x65\156\x64")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState, $testCase) { if (!$connectionState) { $testCase->fail(); } return 0; }); $transport = $this->getTransport(array($t1)); $transport->start(); $this->assertEquals(0, $transport->send($message)); } public function testTransportsWhichThrowExceptionsAreNotRetried() { $e = new Swift_TransportException("\155\141\165\162\x20\142\60\x72\x6b\x65\156"); $message1 = $this->getMockery("\x53\x77\151\x66\164\137\115\151\x6d\x65\x5f\x53\x69\155\160\x6c\145\x4d\145\x73\163\141\147\145"); $message2 = $this->getMockery("\123\167\x69\146\164\x5f\115\x69\x6d\x65\x5f\123\151\x6d\x70\x6c\145\115\145\163\x73\141\x67\145"); $message3 = $this->getMockery("\x53\x77\151\146\164\137\x4d\x69\x6d\x65\x5f\123\x69\x6d\160\154\145\115\x65\x73\163\141\x67\145"); $message4 = $this->getMockery("\x53\167\x69\x66\x74\x5f\x4d\151\x6d\x65\137\123\x69\155\x70\x6c\x65\115\145\163\x73\x61\x67\x65"); $t1 = $this->getMockery("\123\x77\151\x66\164\137\x54\x72\x61\156\163\x70\x6f\162\164"); $t2 = $this->getMockery("\123\167\x69\x66\x74\137\x54\162\x61\x6e\x73\x70\157\162\x74"); $connectionState1 = false; $connectionState2 = false; $t1->shouldReceive("\151\x73\x53\164\141\x72\164\145\144")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("\x73\164\x61\x72\x74")->once()->andReturnUsing(function () use(&$connectionState1) { if (!$connectionState1) { $connectionState1 = true; } }); $t1->shouldReceive("\x73\x65\x6e\x64")->once()->with($message1, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e) { if ($connectionState1) { throw $e; } }); $t1->shouldReceive("\163\x65\x6e\144")->never()->with($message2, \Mockery::any()); $t1->shouldReceive("\163\145\x6e\x64")->never()->with($message3, \Mockery::any()); $t1->shouldReceive("\163\x65\x6e\x64")->never()->with($message4, \Mockery::any()); $t2->shouldReceive("\151\163\123\164\x61\x72\164\x65\144")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("\163\164\x61\x72\x74")->once()->andReturnUsing(function () use(&$connectionState2) { if (!$connectionState2) { $connectionState2 = true; } }); $t2->shouldReceive("\x73\x65\156\144")->times(4)->with(\Mockery::anyOf($message1, $message2, $message3, $message4), \Mockery::any())->andReturnUsing(function () use(&$connectionState2) { if ($connectionState2) { return 1; } }); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $this->assertEquals(1, $transport->send($message1)); $this->assertEquals(1, $transport->send($message2)); $this->assertEquals(1, $transport->send($message3)); $this->assertEquals(1, $transport->send($message4)); } public function testExceptionIsThrownIfAllTransportsDie() { $e = new Swift_TransportException("\142\x30\x72\x6b\145\156"); $message = $this->getMockery("\x53\167\x69\x66\x74\137\x4d\x69\x6d\145\x5f\x53\151\x6d\x70\x6c\x65\115\x65\x73\x73\141\x67\x65"); $t1 = $this->getMockery("\x53\167\x69\146\164\x5f\124\x72\x61\x6e\x73\160\x6f\x72\164"); $t2 = $this->getMockery("\123\x77\x69\x66\x74\x5f\124\162\141\x6e\x73\x70\x6f\162\164"); $connectionState1 = false; $connectionState2 = false; $t1->shouldReceive("\151\163\x53\164\141\162\x74\145\144")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("\x73\164\141\162\x74")->once()->andReturnUsing(function () use(&$connectionState1) { if (!$connectionState1) { $connectionState1 = true; } }); $t1->shouldReceive("\163\145\156\x64")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e) { if ($connectionState1) { throw $e; } }); $t2->shouldReceive("\x69\x73\123\164\141\x72\164\145\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("\163\x74\x61\x72\164")->once()->andReturnUsing(function () use(&$connectionState2) { if (!$connectionState2) { $connectionState2 = true; } }); $t2->shouldReceive("\163\145\x6e\144")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState2, $e) { if ($connectionState2) { throw $e; } }); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); try { $transport->send($message); $this->fail("\x41\154\154\40\164\x72\x61\x6e\163\x70\x6f\162\x74\x73\x20\146\141\x69\x6c\x65\x64\x20\163\157\40\x45\x78\x63\145\160\164\151\x6f\156\x20\163\150\157\x75\154\x64\40\142\145\x20\164\x68\162\x6f\167\x6e"); } catch (Exception $e) { } } public function testStoppingTransportStopsAllDelegates() { $t1 = $this->getMockery("\x53\167\x69\x66\x74\137\x54\x72\x61\x6e\x73\160\157\162\x74"); $t2 = $this->getMockery("\x53\167\x69\x66\x74\x5f\124\x72\141\156\163\x70\x6f\162\x74"); $connectionState1 = true; $connectionState2 = true; $t1->shouldReceive("\x69\163\x53\x74\141\162\x74\145\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("\163\x74\x6f\x70")->once()->andReturnUsing(function () use(&$connectionState1) { if ($connectionState1) { $connectionState1 = false; } }); $t2->shouldReceive("\151\x73\x53\164\141\162\x74\x65\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("\x73\x74\x6f\x70")->once()->andReturnUsing(function () use(&$connectionState2) { if ($connectionState2) { $connectionState2 = false; } }); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $transport->stop(); } public function testTransportShowsAsNotStartedIfAllDelegatesDead() { $e = new Swift_TransportException("\142\x30\x72\x6b\x65\x6e"); $message = $this->getMockery("\123\x77\x69\146\164\137\x4d\151\x6d\145\137\x53\x69\155\x70\x6c\x65\115\145\163\x73\141\147\x65"); $t1 = $this->getMockery("\x53\x77\151\146\164\137\124\x72\141\x6e\163\x70\157\x72\x74"); $t2 = $this->getMockery("\123\167\151\146\164\137\x54\162\x61\x6e\163\160\157\162\x74"); $connectionState1 = false; $connectionState2 = false; $t1->shouldReceive("\x69\163\x53\164\x61\x72\x74\x65\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("\163\x74\x61\162\x74")->once()->andReturnUsing(function () use(&$connectionState1) { if (!$connectionState1) { $connectionState1 = true; } }); $t1->shouldReceive("\x73\x65\x6e\x64")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e) { if ($connectionState1) { $connectionState1 = false; throw $e; } }); $t2->shouldReceive("\151\163\123\x74\x61\162\x74\145\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("\x73\x74\x61\162\x74")->once()->andReturnUsing(function () use(&$connectionState2) { if (!$connectionState2) { $connectionState2 = true; } }); $t2->shouldReceive("\163\x65\156\144")->once()->with($message, \Mockery::any())->andReturnUsing(function () use(&$connectionState2, $e) { if ($connectionState2) { $connectionState2 = false; throw $e; } }); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $this->assertTrue($transport->isStarted()); try { $transport->send($message); $this->fail("\x41\x6c\x6c\40\164\162\141\x6e\x73\x70\157\162\x74\x73\40\x66\141\x69\154\145\x64\x20\x73\x6f\40\x45\x78\143\x65\x70\x74\x69\x6f\156\x20\163\150\x6f\165\x6c\x64\40\142\x65\x20\164\150\x72\157\x77\156"); } catch (Exception $e) { $this->assertFalse($transport->isStarted()); } } public function testRestartingTransportRestartsDeadDelegates() { $e = new Swift_TransportException("\x62\60\x72\153\x65\156"); $message1 = $this->getMockery("\x53\x77\151\x66\164\137\x4d\x69\x6d\145\x5f\123\151\x6d\160\x6c\x65\115\145\163\163\x61\147\x65"); $message2 = $this->getMockery("\x53\167\x69\x66\164\x5f\x4d\x69\155\x65\x5f\x53\x69\x6d\160\x6c\145\115\145\x73\163\141\147\x65"); $t1 = $this->getMockery("\123\167\151\x66\164\137\124\162\141\156\x73\x70\157\162\164"); $t2 = $this->getMockery("\x53\167\151\x66\x74\137\x54\x72\x61\156\x73\160\157\x72\164"); $connectionState1 = false; $connectionState2 = false; $t1->shouldReceive("\x69\163\123\164\141\162\x74\145\144")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("\163\164\x61\x72\164")->twice()->andReturnUsing(function () use(&$connectionState1) { if (!$connectionState1) { $connectionState1 = true; } }); $t1->shouldReceive("\x73\145\x6e\144")->once()->with($message1, \Mockery::any())->andReturnUsing(function () use(&$connectionState1, $e) { if ($connectionState1) { $connectionState1 = false; throw $e; } }); $t1->shouldReceive("\x73\x65\156\144")->once()->with($message2, \Mockery::any())->andReturnUsing(function () use(&$connectionState1) { if ($connectionState1) { return 10; } }); $t2->shouldReceive("\x69\x73\x53\x74\x61\x72\164\x65\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("\163\x74\141\x72\164")->once()->andReturnUsing(function () use(&$connectionState2) { if (!$connectionState2) { $connectionState2 = true; } }); $t2->shouldReceive("\163\x65\x6e\144")->once()->with($message1, \Mockery::any())->andReturnUsing(function () use(&$connectionState2, $e) { if ($connectionState2) { $connectionState2 = false; throw $e; } }); $t2->shouldReceive("\x73\x65\x6e\144")->never()->with($message2, \Mockery::any()); $transport = $this->getTransport(array($t1, $t2)); $transport->start(); $this->assertTrue($transport->isStarted()); try { $transport->send($message1); $this->fail("\x41\x6c\154\x20\x74\162\141\156\x73\x70\157\x72\x74\163\x20\146\x61\151\x6c\145\x64\40\x73\157\x20\105\170\x63\145\160\x74\151\x6f\x6e\40\x73\150\x6f\165\x6c\144\40\x62\x65\x20\164\x68\162\157\x77\156"); } catch (Exception $e) { $this->assertFalse($transport->isStarted()); } $transport->start(); $this->assertTrue($transport->isStarted()); $this->assertEquals(10, $transport->send($message2)); } public function testFailureReferenceIsPassedToDelegates() { $failures = array(); $message = $this->getMockery("\x53\x77\x69\146\x74\137\x4d\x69\155\x65\x5f\x53\x69\155\160\154\x65\115\145\163\x73\x61\147\x65"); $t1 = $this->getMockery("\x53\x77\x69\x66\164\137\x54\x72\141\x6e\x73\160\157\x72\164"); $connectionState = false; $t1->shouldReceive("\151\x73\x53\164\141\162\164\x65\x64")->zeroOrMoreTimes()->andReturnUsing(function () use($connectionState) { return $connectionState; }); $t1->shouldReceive("\x73\x74\x61\x72\164")->once()->andReturnUsing(function () use($connectionState) { if (!$connectionState) { $connectionState = true; } }); $t1->shouldReceive("\163\145\x6e\x64")->once()->with($message, $failures)->andReturnUsing(function () use($connectionState) { if ($connectionState) { return 1; } }); $transport = $this->getTransport(array($t1)); $transport->start(); $transport->send($message, $failures); } public function testRegisterPluginDelegatesToLoadedTransports() { $plugin = $this->createPlugin(); $t1 = $this->getMockery("\x53\x77\151\x66\164\x5f\x54\x72\141\156\x73\x70\157\x72\x74"); $t2 = $this->getMockery("\123\167\151\x66\x74\x5f\x54\x72\x61\x6e\x73\x70\x6f\162\x74"); $t1->shouldReceive("\162\x65\147\x69\x73\164\x65\162\120\154\x75\x67\151\156")->once()->with($plugin); $t2->shouldReceive("\162\145\x67\151\163\164\145\162\120\154\x75\147\x69\x6e")->once()->with($plugin); $transport = $this->getTransport(array($t1, $t2)); $transport->registerPlugin($plugin); } public function testEachDelegateIsPinged() { $t1 = $this->getMockery("\x53\167\151\146\164\137\x54\162\141\x6e\163\160\157\x72\164"); $t2 = $this->getMockery("\123\167\151\146\164\x5f\124\x72\x61\x6e\163\160\x6f\x72\x74"); $connectionState1 = false; $connectionState2 = false; $testCase = $this; $t1->shouldReceive("\151\163\123\164\x61\x72\x74\145\144")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("\x70\151\x6e\x67")->once()->andReturn(true); $transport = $this->getTransport(array($t1, $t2)); $this->assertTrue($transport->isStarted()); $this->assertTrue($transport->ping()); } public function testDelegateIsKilledWhenPingFails() { $t1 = $this->getMockery("\123\x77\x69\146\x74\137\x54\162\x61\156\163\160\x6f\x72\164"); $t2 = $this->getMockery("\x53\167\151\x66\x74\137\124\x72\x61\x6e\x73\160\x6f\162\164"); $testCase = $this; $t1->shouldReceive("\x69\x73\123\x74\x61\x72\164\145\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("\x70\151\x6e\x67")->once()->andReturn(false); $t2->shouldReceive("\x69\163\x53\x74\141\x72\x74\x65\144")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("\x70\x69\156\x67")->twice()->andReturn(true); $transport = $this->getTransport(array($t1, $t2)); $this->assertTrue($transport->ping()); $this->assertTrue($transport->ping()); $this->assertTrue($transport->isStarted()); } public function XtestTransportShowsAsNotStartedIfAllPingFails() { $t1 = $this->getMockery("\123\x77\151\146\x74\137\x54\162\141\156\163\x70\157\x72\x74"); $t2 = $this->getMockery("\123\x77\x69\x66\x74\137\x54\162\141\156\163\160\x6f\162\164"); $testCase = $this; $t1->shouldReceive("\151\163\123\x74\141\162\x74\x65\144")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState1) { return $connectionState1; }); $t1->shouldReceive("\x70\151\x6e\147")->once()->andReturn(false); $t2->shouldReceive("\x69\x73\x53\164\x61\x72\x74\x65\x64")->zeroOrMoreTimes()->andReturnUsing(function () use(&$connectionState2) { return $connectionState2; }); $t2->shouldReceive("\160\151\x6e\x67")->once()->andReturn(false); $transport = $this->getTransport(array($t1, $t2)); $this->assertFalse($transport->ping()); $this->assertFalse($transport->isStarted()); $this->assertFalse($transport->ping()); } private function getTransport(array $transports) { $transport = new Swift_Transport_FailoverTransport(); $transport->setTransports($transports); return $transport; } private function createPlugin() { return $this->getMockery("\x53\167\151\x66\x74\137\x45\166\145\156\x74\163\x5f\105\166\x65\x6e\x74\114\151\x73\x74\x65\156\145\x72"); } }

Function Calls

None

Variables

None

Stats

MD5 9c4b0a9b0c6408d13a194e7cea79b97c
Eval Count 0
Decode Time 183 ms