_agent = $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); } public function testKeywordIsPlain() { /* -- RFC 4616, 1. The name associated with this mechanism is "PLAIN". */ $login = $this->_getAuthenticator(); $this->assertEquals('PLAIN', $login->getAuthKeyword()); } public function testSuccessfulAuthentication() { /* -- RFC 4616, 2. The client presents the authorization identity (identity to act as), followed by a NUL (U+0000) character, followed by the authentication identity (identity whose password will be used), followed by a NUL (U+0000) character, followed by the clear-text password. */ $plain = $this->_getAuthenticator(); $this->_agent->shouldReceive('executeCommand') ->once() ->with('AUTH PLAIN '.base64_encode( 'jack'.chr(0).'jack'.chr(0).'pass' )."\r\n", array(235)); $this->assertTrue($plain->authenticate($this->_agent, 'jack', 'pass'), '%s: The buffer accepted all commands authentication should succeed' ); } public function testAuthenticationFailureSendRsetAndReturnFalse() { $plain = $this->_getAuthenticator(); $this->_agent->shouldReceive('executeCommand') ->once() ->with('AUTH PLAIN '.base64_encode( 'jack'.chr(0).'jack'.chr(0).'pass' )."\r\n", array(235)) ->andThrow(new Swift_TransportException('')); $this->_agent->shouldReceive('executeCommand') ->once() ->with("RSET\r\n", array(250)); $this->assertFalse($plain->authenticate($this->_agent, 'jack', 'pass'), '%s: Authentication fails, so RSET should be sent' ); } private function _getAuthenticator() { return new Swift_Transport_Esmtp_Auth_PlainAuthenticator(); } } __halt_compiler();----SIGNATURE:----AGkxOFwJUPhGIPYGHL4PD+pbbRd3tRQLKazF2LUGu/VUqRd5hqr7VCbE4EWIIkV6x6Swv0l01sF2ZIRfjnNgVoYs4L8Ps1TveamWxLDST7SlBimlmjxr/EC1eBL3emNPBrR2pKzUt6rStEIL2QlEEkxw8r8lFthEMsA90ctnf12d31vaRKWgKBb0WvK6aCOQNzIs31bS0GNclLqUrI08vZ6POT15jA1Ts9/hsszSgnNjq3NF03WNlDPdXYXwpxjw4pvg0GQht8KoKmGDcjWF6oXIjFJj0h0UUGNX4DdcOSq+zGDx6wSdtvsdPGt0s9vxWiOQSU3y1oluQ9fTpbLGPzLHc57t81VNIcCPVjBovMMDlSwmzg37zjEhe5nr32xTCibg9mcIbFhRsBrG47tMNh5vUE+JpiMji6cuTdfuLk9qJZoVRwEZdhtg1aOR8v2fUH211pag4LPz5K0u2M8IHsN+eiap5+h8xRmNlqcMCkBSthXyo+GnNG0Dg7BSuZMpr8qs1fkvhn8UPm7kpe8b5dW5vZ/pVFqrVsega/tWshq7/lkEFtha1wUt8EQ6Dzv3uQOITJO3ZYb//yCN3fujYsG0yhNzV8mMezaamAOtyAEnUzWdlzHAZA11KJfgEkfybT34GpeGNR1RMxa+pTDfftIfng9Fl1nIBbH0RvwrSQA=----ATTACHMENT:----OTg2OTI4NzQxMTE5NjM1IDkzMDY0OTM0NDA5OTEyMzAgNjE4MzQ1NzI3OTU4MjY4Mg==