Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-10-16 17:14:35 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2019-10-16 20:31:58 +0300
commit765d7511f1f7c1cc97623139c8567533d28d5f04 (patch)
treeb4856081811ccc1ca67182fe5219b5e5dbcbed02 /tests
parentb920e14e3481df3934aa28246e557fbb636f4540 (diff)
Move ImapConnector over
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/Service/Autoconfig/ImapConnectorTest.php21
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/Service/Autoconfig/ImapConnectorTest.php b/tests/Service/Autoconfig/ImapConnectorTest.php
index a3fea541a..5d1dc8b10 100644
--- a/tests/Service/Autoconfig/ImapConnectorTest.php
+++ b/tests/Service/Autoconfig/ImapConnectorTest.php
@@ -24,30 +24,37 @@ namespace OCA\Mail\Tests\Service\Autoconfig;
use ChristophWurst\Nextcloud\Testing\TestCase;
use Horde_Imap_Client_Exception;
use OC;
+use OCA\Mail\Account;
use OCA\Mail\Db\MailAccount;
+use OCA\Mail\IMAP\IMAPClientFactory;
use OCA\Mail\Service\AutoConfig\ImapConnector;
use OCP\ILogger;
use OCP\Security\ICrypto;
+use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit_Framework_MockObject_MockObject;
class ImapConnectorTest extends TestCase {
- /** @var ICrypto */
+ /** @var ICrypto|MockObject */
private $crypto;
- /** @var ILogger|PHPUnit_Framework_MockObject_MockObject */
+ /** @var ILogger|MockObject */
private $logger;
+ /** @var IMAPClientFactory|MockObject */
+ private $clientFactory;
+
/** @var ImapConnector */
private $connector;
protected function setUp() {
parent::setUp();
- $this->crypto = OC::$server->getCrypto();
+ $this->crypto = $this->createMock(ICrypto::class);
$this->logger = $this->createMock(ILogger::class);
+ $this->clientFactory = $this->createMock(IMAPClientFactory::class);
- $this->connector = new ImapConnector($this->crypto, $this->logger, 'christopher');
+ $this->connector = new ImapConnector($this->crypto, $this->logger, $this->clientFactory, 'christopher');
}
public function testSuccessfulConnection() {
@@ -77,6 +84,12 @@ class ImapConnectorTest extends TestCase {
$user = 'user@domain.tld';
$this->expectException(Horde_Imap_Client_Exception::class);
+ $client = $this->createMock(\Horde_Imap_Client_Socket::class);
+ $client->method('login')
+ ->willThrowException(new Horde_Imap_Client_Exception());
+ $this->clientFactory->method('getClient')
+ ->willReturn($client);
+
$this->connector->connect($email, $password, $name, $host, $port, $ssl, $user);
$this->fail('should not have been reached');