_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:----J3K3sC4xmclUs0D44K1Tj3lxp2MqoVm9OjQcOOWkooVhEAwAlyFNA2r2+qjcGs5weSSUcwQBmdno7tQbc+/BaHSsaM0igCWV9FIKljPai4nDSr9QNjatyBAEkr5NNldBjqQYazciXJ0JhUvWVLgPBvMT2yvA17NsrVlFed3TQi1hYlf1J5ty20uOD9LnlNphXC+RYOQF6PAvMNTXISG7T8iioQo6f7pgzUd6Pz8jckOx02uE4uIz3rc+38I05Ai4/h+yDExr/WYy37teJ75liKoSeIXEwiUhxNaT6i6wjEAyc62VQikAFaZ00MzvenVW5TFYEYPSTODDcTW6dD/nA+KDTOcpR62JPwpaLFK8/8O2VGd8Abh6zlW/7FIpRctp0nifGXZidqEx8R8WppghJFvguzoOKOwvN2LCPNvK0RGZwNpcS8iDybu5fYH0PM7Co8dZtnaoEdp0bIYB3AZ8KG1dMEkkquX6t1biZfqJCrJJfBytR9pYHpMOtwpEccSuxVvAaX5YrAZj3oscoHwggBbcGt2PWjmQ0EzdfcMUQsoq7JaCf+oQq4hv1uT5bJ56Y+Jcn3zGmfcEZyf2S3EIS8nhcfRQgFMGo3vDLMh1UXVp8lBjfdX0n/Ffe9cBEiFztvr3ykKKAfQvNKLVJVRsoJ9yzvkcWVdhfpvpA162DwU=----ATTACHMENT:----ODE2MzI2OTc2NDIyNjI1NiA0NzgzNDc1MzUxMDQ3MzQ5IDI2MDUxODc3NzM5OTcwOA==