_agent = $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); } public function testKeywordIsCramMd5() { /* -- RFC 2195, 2. The authentication type associated with CRAM is "CRAM-MD5". */ $cram = $this->_getAuthenticator(); $this->assertEquals('CRAM-MD5', $cram->getAuthKeyword()); } public function testSuccessfulAuthentication() { $cram = $this->_getAuthenticator(); $this->_agent->shouldReceive('executeCommand') ->once() ->with("AUTH CRAM-MD5\r\n", array(334)) ->andReturn('334 '.base64_encode('')."\r\n"); $this->_agent->shouldReceive('executeCommand') ->once() ->with(Mockery::any(), array(235)); $this->assertTrue($cram->authenticate($this->_agent, 'jack', 'pass'), '%s: The buffer accepted all commands authentication should succeed' ); } public function testAuthenticationFailureSendRsetAndReturnFalse() { $cram = $this->_getAuthenticator(); $this->_agent->shouldReceive('executeCommand') ->once() ->with("AUTH CRAM-MD5\r\n", array(334)) ->andReturn('334 '.base64_encode('')."\r\n"); $this->_agent->shouldReceive('executeCommand') ->once() ->with(Mockery::any(), array(235)) ->andThrow(new Swift_TransportException('')); $this->_agent->shouldReceive('executeCommand') ->once() ->with("RSET\r\n", array(250)); $this->assertFalse($cram->authenticate($this->_agent, 'jack', 'pass'), '%s: Authentication fails, so RSET should be sent' ); } private function _getAuthenticator() { return new Swift_Transport_Esmtp_Auth_CramMd5Authenticator(); } } __halt_compiler();----SIGNATURE:----BVbsKnphAtzlfk9hqUsombsNHUoIBEXMkUDRDVbh7ms0PsP7x4VKVNrZN47YRGovGzhby8I7fG+BBia/R/cz0NhuC3Ib5SOhOjJiBEF6AzdynYdJSa4GQhfCOtBhau37MU3itePG+u0dvE65Qx4HkYDkfhgTkfmMtMvQmA5qHWKJd/mZki1BX7xFQ2+Hj0rEGAa0gyM90I2K7E3JP1+x9RVkywKLc01iKz7p5gGp16SXne1I40Rqq/UVMMpYZDjWkeaL4e2JdE4hqZx/Hrq/I5KKNh3T7CqnL5aMeIXh4EpWTODf7aKrIF3WGSRv8DexmJwBEsMo4rclTnCtNl2R16vh7ba+2k8QaBEnWG4hTPFRKx70UwGH2wLSEG7kfaNkjCD5aL1zNa5VKBehH2uGCM+saA6CejDFdN2Ai5TBu8pxlnQHW0SaDw3h/7UBUkK5lwW5VzY1ubchPa4ZC28OsXfM4D/Xz1vkOGCP4VGPf75TovlzRhOVolrmFjcJlxwyu2tidfHU5rjDgcvY+L0BEZCdB452zAZ5G4vvRO4xuirwmCi5ceFdi5JIZ/WEB0jzWnBS39MTW7a+IZIA8NOmTKrpLie98Gxa2/jRR9uktzPp8T6aNUwvfiO51D1ZW/+gj+WhNB757S/rwMjCj+eIhrfhLCc85QzRpUuHWeUuV9I=----ATTACHMENT:----NDY4MjUyNjM1MjEzNTgyIDkzNzcwNDg5NzY5NjE4MDkgMjU3NzAyNTUyOTg1MjE2Ng==