_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:----Bb5SqklYb2DT5XViEhOu7QUGEk5y/44EuWCPu1GvbvNhgWkzKT5Y9gwpRItqwz2aLDKW57CCHSUN5JHAZN1j/ElMMiqvTWzDG2r+seu5l7p1Zlalrx0iz6e/eAQSsedFF35Tv1+zCuANjXJCQEJv9CGxlWHkJxbKt5YLz7d3C9OhDfV1hfcKuGdnHH8g4gzFr1szHQGW7sBB768oNE+qx0J5QaCb1gPtyIV63MdczQOj0yXf6k9kjXDUXP1AGFQcPY7AfQHUBe0gVIOEOPc8LCqGMgS/n1m+l53zg7ZcVchZMGHQTCYsWFiyR5wWQ+3C1zvYe5+pHgKIscvNZ5aNCAulOJWDHIhAEnGkqi0S/5429Oi0xGJGOjPJkAeetp4L5xZQme6tIsrZhgFaMJ1wVoHB2J7Cqfxc0bCB8q42wlJxj8PYh8CUtBQJ5f5kqob6Y3pdbGuJ1mq6TC26uFHWV79Uj0+jhI1ky/wWNWzmcZ05rkz+1Ud2hq/5ro/3jPmqZYkefeCb9ihUzS4GyFW+pUzz73cxswgAJiFiSNQ4w41owvL9COeNn/TErEHxqV+P8OITnisGlM1KcR/kzmcFNbLhzQc15NHEEFWk03QWltmNyz/DuugMh0rjB00ukXdxyDvwHkpShtbA8AxqmS0ooMNn2ETiDIX/Ybi7WXttwYQ=----ATTACHMENT:----OTE0MzEyODI5NTI5MzM1NCAzOTg5ODQ3NzkzMjY2OTQwIDkxNjkwNjg3Mjc3OTQyMjc=