_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:----ltoH9n3hyFO4MR58vcydGXr/IencUGax8NEZDD2xuCszYT5rCB3s8xQ1u+94IWyAQPq/rLZ6EORvl3ikEUWvCEmrGIVPv4Amo51psFCqBRnfkKcplryyBLaG5DWyIVF1IBwFwlhe4zUO4W1OmKpxWy13UefKO1qtYsEl4+aA2YZS85ONY4M1wuDYhSDTyloztbTDr3A3ufrZaUKYaqVVPD9Ig5L4DtoY/O/l/I8N4z209KHV9CHLKwqw89rajJnY3VUT66UiChVdNRsYBE+U9Zu4q5OUFqStcx1RktrEEy2p55Cj16dv07/wjGA7d/SbLh9YiaGrT1nNjOraS6xLvzdYvZ3V3+Dp+pI57jvc5JoSFFKcW6Kjx4vyXarOZS+cNYeNVyrnZ8ytrTtAXeZo8AdR6HBzmf4ZO+tLIGwpgv9ThvW9QvelfZOrCXQjrIeQB9qjBv7nsbyynonvIw7eromAxJhm4IPsVYt04WS3otXb8Pd9wb9khV4IS8IoOQJg0n8b0UGe8wR2LzMiqJa0UP2Vji+HouWtlPQaZS68cLmGNzyw0dXImI39+3tmSTCwQ8r707JqxVjv5C4HLLlTISS6SdqmpzgqrUFWoRJoENZZx7W9McjaCz754Cax9exJO8JfHWKTopDXWMtoIjEgG1iTI4uARFRIMJkrDvi0U8M=----ATTACHMENT:----ODk1NzI1NDE5NTgzNDM4NCA0MDMzNjI5NjMzNDc0MzIxIDMzNzczNTk0MTc0NzUyODc=