public function testConnectMailserverUseSsl()
{
// using fake imap handler behaviour in test
$fake = new ImapHandlerFakeData();
// set up the fake handler behaviour
$fake->add('isAvailable', null, [true]);
$fake->add('setTimeout', [1, 60], [true]);
$fake->add('setTimeout', [2, 60], [true]);
$fake->add('setTimeout', [3, 60], [true]);
$fake->add('getErrors', null, [false]);
$fake->add('getConnection', null, [function () {
// the current crm code needs a valid resource to an imap server
// but also will accept a file resource
return fopen('fakeImapResource', 'w+');
}]);
$fake->add('getMailboxes', ['{:/service=/notls/novalidate-cert/secure}', '*'], [[]]);
$fake->add('ping', null, [true]);
$fake->add('reopen', ['{:/service=}', 32768, 0], [true]);
// instantiate a fake imap handler
$imap = new ImapHandlerFake($fake);
$_REQUEST['ssl'] = 1;
// using fake imap in InboundEmail class (only for testing)
$ie = new InboundEmail($imap);
// test connection, it should pass
$ret = $ie->connectMailserver();
$this->assertEquals('true', $ret);
}