_getBuffer(); $smtp = $this->_getTransport($buf); $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext1->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('AUTH'); $ext1->shouldReceive('getPriorityOver') ->zeroOrMoreTimes() ->with('STARTTLS') ->andReturn(1); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $ext2->shouldReceive('getPriorityOver') ->zeroOrMoreTimes() ->with('AUTH') ->andReturn(-1); $this->_finishBuffer($buf); $smtp->setExtensionHandlers(array($ext1, $ext2)); $this->assertEquals(array($ext2, $ext1), $smtp->getExtensionHandlers()); } public function testHandlersAreNotifiedOfParams() { $buf = $this->_getBuffer(); $smtp = $this->_getTransport($buf); $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $buf->shouldReceive('readLine') ->once() ->with(0) ->andReturn("220 server.com foo\r\n"); $buf->shouldReceive('write') ->once() ->with('~^EHLO .*?\r\n$~D') ->andReturn(1); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-ServerName.tld\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-AUTH PLAIN LOGIN\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250 SIZE=123456\r\n"); $ext1->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('AUTH'); $ext1->shouldReceive('setKeywordParams') ->once() ->with(array('PLAIN', 'LOGIN')); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('SIZE'); $ext2->shouldReceive('setKeywordParams') ->zeroOrMoreTimes() ->with(array('123456')); $this->_finishBuffer($buf); $smtp->setExtensionHandlers(array($ext1, $ext2)); $smtp->start(); } public function testSupportedExtensionHandlersAreRunAfterEhlo() { $buf = $this->_getBuffer(); $smtp = $this->_getTransport($buf); $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $buf->shouldReceive('readLine') ->once() ->with(0) ->andReturn("220 server.com foo\r\n"); $buf->shouldReceive('write') ->once() ->with('~^EHLO .*?\r\n$~D') ->andReturn(1); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-ServerName.tld\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-AUTH PLAIN LOGIN\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250 SIZE=123456\r\n"); $ext1->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('AUTH'); $ext1->shouldReceive('afterEhlo') ->once() ->with($smtp); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('SIZE'); $ext2->shouldReceive('afterEhlo') ->zeroOrMoreTimes() ->with($smtp); $ext3->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $ext3->shouldReceive('afterEhlo') ->never() ->with($smtp); $this->_finishBuffer($buf); $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); $smtp->start(); } public function testExtensionsCanModifyMailFromParams() { $buf = $this->_getBuffer(); $dispatcher = $this->_createEventDispatcher(); $smtp = new Swift_Transport_EsmtpTransport($buf, array(), $dispatcher); $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $message = $this->_createMessage(); $message->shouldReceive('getFrom') ->zeroOrMoreTimes() ->andReturn(array('me@domain' => 'Me')); $message->shouldReceive('getTo') ->zeroOrMoreTimes() ->andReturn(array('foo@bar' => null)); $buf->shouldReceive('readLine') ->once() ->with(0) ->andReturn("220 server.com foo\r\n"); $buf->shouldReceive('write') ->once() ->with('~^EHLO .*?\r\n$~D') ->andReturn(1); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-ServerName.tld\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-AUTH PLAIN LOGIN\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250 SIZE=123456\r\n"); $buf->shouldReceive('write') ->once() ->with("MAIL FROM: FOO ZIP\r\n") ->andReturn(2); $buf->shouldReceive('readLine') ->once() ->with(2) ->andReturn("250 OK\r\n"); $buf->shouldReceive('write') ->once() ->with("RCPT TO:\r\n") ->andReturn(3); $buf->shouldReceive('readLine') ->once() ->with(3) ->andReturn("250 OK\r\n"); $this->_finishBuffer($buf); $ext1->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('AUTH'); $ext1->shouldReceive('getMailParams') ->once() ->andReturn('FOO'); $ext1->shouldReceive('getPriorityOver') ->zeroOrMoreTimes() ->with('AUTH') ->andReturn(-1); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('SIZE'); $ext2->shouldReceive('getMailParams') ->once() ->andReturn('ZIP'); $ext2->shouldReceive('getPriorityOver') ->zeroOrMoreTimes() ->with('AUTH') ->andReturn(1); $ext3->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $ext3->shouldReceive('getMailParams') ->never(); $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); $smtp->start(); $smtp->send($message); } public function testExtensionsCanModifyRcptParams() { $buf = $this->_getBuffer(); $dispatcher = $this->_createEventDispatcher(); $smtp = new Swift_Transport_EsmtpTransport($buf, array(), $dispatcher); $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $message = $this->_createMessage(); $message->shouldReceive('getFrom') ->zeroOrMoreTimes() ->andReturn(array('me@domain' => 'Me')); $message->shouldReceive('getTo') ->zeroOrMoreTimes() ->andReturn(array('foo@bar' => null)); $buf->shouldReceive('readLine') ->once() ->with(0) ->andReturn("220 server.com foo\r\n"); $buf->shouldReceive('write') ->once() ->with('~^EHLO .+?\r\n$~D') ->andReturn(1); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-ServerName.tld\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-AUTH PLAIN LOGIN\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250 SIZE=123456\r\n"); $buf->shouldReceive('write') ->once() ->with("MAIL FROM:\r\n") ->andReturn(2); $buf->shouldReceive('readLine') ->once() ->with(2) ->andReturn("250 OK\r\n"); $buf->shouldReceive('write') ->once() ->with("RCPT TO: FOO ZIP\r\n") ->andReturn(3); $buf->shouldReceive('readLine') ->once() ->with(3) ->andReturn("250 OK\r\n"); $this->_finishBuffer($buf); $ext1->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('AUTH'); $ext1->shouldReceive('getRcptParams') ->once() ->andReturn('FOO'); $ext1->shouldReceive('getPriorityOver') ->zeroOrMoreTimes() ->with('AUTH') ->andReturn(-1); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('SIZE'); $ext2->shouldReceive('getRcptParams') ->once() ->andReturn('ZIP'); $ext2->shouldReceive('getPriorityOver') ->zeroOrMoreTimes() ->with('AUTH') ->andReturn(1); $ext3->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $ext3->shouldReceive('getRcptParams') ->never(); $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); $smtp->start(); $smtp->send($message); } public function testExtensionsAreNotifiedOnCommand() { $buf = $this->_getBuffer(); $smtp = $this->_getTransport($buf); $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $buf->shouldReceive('readLine') ->once() ->with(0) ->andReturn("220 server.com foo\r\n"); $buf->shouldReceive('write') ->once() ->with('~^EHLO .+?\r\n$~D') ->andReturn(1); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-ServerName.tld\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-AUTH PLAIN LOGIN\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250 SIZE=123456\r\n"); $buf->shouldReceive('write') ->once() ->with("FOO\r\n") ->andReturn(2); $buf->shouldReceive('readLine') ->once() ->with(2) ->andReturn("250 Cool\r\n"); $this->_finishBuffer($buf); $ext1->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('AUTH'); $ext1->shouldReceive('onCommand') ->once() ->with($smtp, "FOO\r\n", array(250, 251), Mockery::any(), Mockery::any()); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('SIZE'); $ext2->shouldReceive('onCommand') ->once() ->with($smtp, "FOO\r\n", array(250, 251), Mockery::any(), Mockery::any()); $ext3->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $ext3->shouldReceive('onCommand') ->never() ->with(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()); $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); $smtp->start(); $smtp->executeCommand("FOO\r\n", array(250, 251)); } public function testChainOfCommandAlgorithmWhenNotifyingExtensions() { $buf = $this->_getBuffer(); $smtp = $this->_getTransport($buf); $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $buf->shouldReceive('readLine') ->once() ->with(0) ->andReturn("220 server.com foo\r\n"); $buf->shouldReceive('write') ->once() ->with('~^EHLO .+?\r\n$~D') ->andReturn(1); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-ServerName.tld\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250-AUTH PLAIN LOGIN\r\n"); $buf->shouldReceive('readLine') ->once() ->with(1) ->andReturn("250 SIZE=123456\r\n"); $buf->shouldReceive('write') ->never() ->with("FOO\r\n"); $this->_finishBuffer($buf); $ext1->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('AUTH'); $ext1->shouldReceive('onCommand') ->once() ->with($smtp, "FOO\r\n", array(250, 251), Mockery::any(), Mockery::any()) ->andReturnUsing(function ($a, $b, $c, $d, &$e) { $e = true; return '250 ok'; }); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('SIZE'); $ext2->shouldReceive('onCommand') ->never() ->with(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()); $ext3->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $ext3->shouldReceive('onCommand') ->never() ->with(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()); $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); $smtp->start(); $smtp->executeCommand("FOO\r\n", array(250, 251)); } public function testExtensionsCanExposeMixinMethods() { $buf = $this->_getBuffer(); $smtp = $this->_getTransport($buf); $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing(); $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext1->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('AUTH'); $ext1->shouldReceive('exposeMixinMethods') ->zeroOrMoreTimes() ->andReturn(array('setUsername', 'setPassword')); $ext1->shouldReceive('setUsername') ->once() ->with('mick'); $ext1->shouldReceive('setPassword') ->once() ->with('pass'); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $this->_finishBuffer($buf); $smtp->setExtensionHandlers(array($ext1, $ext2)); $smtp->setUsername('mick'); $smtp->setPassword('pass'); } public function testMixinMethodsBeginningWithSetAndNullReturnAreFluid() { $buf = $this->_getBuffer(); $smtp = $this->_getTransport($buf); $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing(); $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext1->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('AUTH'); $ext1->shouldReceive('exposeMixinMethods') ->zeroOrMoreTimes() ->andReturn(array('setUsername', 'setPassword')); $ext1->shouldReceive('setUsername') ->once() ->with('mick') ->andReturn(null); $ext1->shouldReceive('setPassword') ->once() ->with('pass') ->andReturn(null); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $this->_finishBuffer($buf); $smtp->setExtensionHandlers(array($ext1, $ext2)); $ret = $smtp->setUsername('mick'); $this->assertEquals($smtp, $ret); $ret = $smtp->setPassword('pass'); $this->assertEquals($smtp, $ret); } public function testMixinSetterWhichReturnValuesAreNotFluid() { $buf = $this->_getBuffer(); $smtp = $this->_getTransport($buf); $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing(); $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); $ext1->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('AUTH'); $ext1->shouldReceive('exposeMixinMethods') ->zeroOrMoreTimes() ->andReturn(array('setUsername', 'setPassword')); $ext1->shouldReceive('setUsername') ->once() ->with('mick') ->andReturn('x'); $ext1->shouldReceive('setPassword') ->once() ->with('pass') ->andReturn('x'); $ext2->shouldReceive('getHandledKeyword') ->zeroOrMoreTimes() ->andReturn('STARTTLS'); $this->_finishBuffer($buf); $smtp->setExtensionHandlers(array($ext1, $ext2)); $this->assertEquals('x', $smtp->setUsername('mick')); $this->assertEquals('x', $smtp->setPassword('pass')); } } __halt_compiler();----SIGNATURE:----ojD6A/2Y17HMjTneEJJ0VDUhkk8Mkn0rWq9ylQtPv0svojPlRps1rkaoeVfNk+R+kxTOC1tZ4SFHRA2eD8AZmTdsGaOvBPnp7gePH0EnSp0SNbWhXgdaV/XrAYCLsaOsvlpYOF88gTX+i4Zq8oCPplDCS4F4H/qfey+5gCzBQu0OszP945RsqBUsKX+v2jGD7VVjIq5+nl26cZQXn8lw2+aE/TenwSasrjN7CSAwxDGRJevYIs4toyimf+YNwsOAp61W30AdTEyaBbROgkJKlsKLM80BMvy/qUI7nEh4gU6aWUtJJPdL9C9gOp4njgWaT4eibh1O8LIZqvmJ+b4JqeIffbuMfNjcUOTfuKckyfhLXT3Qo1Nk27ZmGZL54HcCZElsQG2IGmhkj9q3P5SSoIoGJ+45t1qdNchxrj1LGAf/CMMenGEzm6NZBHFfh4jC4I4ox69kOoPqZGVa0NLbr4pE/fCEdBxd3rBbh6txP3o6njtKyEZmvoypx4ybYoAs7O775mwZvDMEU37SrEm0wcyTyxUwQIdCNvT2SbBTlLbsTK8V9UAvT+8Ja4ZxmtWQs1hmH2YvhlWUGfzWXQ3q5tdtcLyHBy1AAuUOao4Ufz+nklXrxQzuRG3e6S3iOi2siyzTuJhcCY4aSAvI+lAYaEvniJCxe4bbt/I9T9Roc74=----ATTACHMENT:----MjI0ODY4NjUyMTM0MDgwNCA3NTQwNTQ1OTI3Mjg0MTcwIDY5MDk0Njc4NDUxNzI0NDg=