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:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-10-13 17:51:59 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-10-13 17:51:59 +0300
commit261bab88ab89a4e317aaaf9868c32325319daf17 (patch)
treed1385b9cdc377b23f6c888789269ff077f8c9323 /tests
parent5b086709703285e3d4b1fb8ad2c5b6598c23ebae (diff)
Use consecutive assertions instead of the deprecated at
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Controller/PageControllerTest.php26
-rw-r--r--tests/Unit/IMAP/MessageMapperTest.php56
-rw-r--r--tests/Unit/Listener/DeleteDraftListenerTest.php11
-rw-r--r--tests/Unit/Listener/SaveSentMessageListenerTest.php31
-rw-r--r--tests/Unit/Service/Autocompletion/AddressCollectorTest.php28
5 files changed, 90 insertions, 62 deletions
diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php
index 2b93ef010..9b902557f 100644
--- a/tests/Unit/Controller/PageControllerTest.php
+++ b/tests/Unit/Controller/PageControllerTest.php
@@ -133,14 +133,16 @@ class PageControllerTest extends TestCase {
$account1,
$account2,
]));
- $this->mailManager->expects($this->at(0))
+ $this->mailManager->expects($this->exactly(2))
->method('getMailboxes')
- ->with($account1)
- ->willReturn([$mailbox]);
- $this->mailManager->expects($this->at(1))
- ->method('getMailboxes')
- ->with($account2)
- ->willReturn([]);
+ ->withConsecutive(
+ [$account1],
+ [$account2]
+ )
+ ->willReturnOnConsecutiveCalls(
+ [$mailbox],
+ []
+ );
$account1->expects($this->once())
->method('jsonSerialize')
->will($this->returnValue([
@@ -212,12 +214,12 @@ class PageControllerTest extends TestCase {
->with($this->equalTo('jane'), $this->equalTo('settings'),
$this->equalTo('email'), $this->equalTo(''))
->will($this->returnValue('jane@doe.cz'));
- $this->initialState->expects($this->at(0))
- ->method('provideInitialState')
- ->with('mail', 'prefill_displayName', 'Jane Doe');
- $this->initialState->expects($this->at(1))
+ $this->initialState->expects($this->exactly(2))
->method('provideInitialState')
- ->with('mail', 'prefill_email', 'jane@doe.cz');
+ ->withConsecutive(
+ ['mail', 'prefill_displayName', 'Jane Doe'],
+ ['mail', 'prefill_email', 'jane@doe.cz']
+ );
$expected = new TemplateResponse($this->appName, 'index',
[
diff --git a/tests/Unit/IMAP/MessageMapperTest.php b/tests/Unit/IMAP/MessageMapperTest.php
index fa9f4fa95..02625c302 100644
--- a/tests/Unit/IMAP/MessageMapperTest.php
+++ b/tests/Unit/IMAP/MessageMapperTest.php
@@ -152,19 +152,27 @@ class MessageMapperTest extends TestCase {
$query = new Horde_Imap_Client_Fetch_Query();
$query->uid();
$uidResults = new Horde_Imap_Client_Fetch_Results();
- $client->expects($this->at(1))
+ $bodyResults = new Horde_Imap_Client_Fetch_Results();
+ $client->expects($this->exactly(2))
->method('fetch')
- ->with(
- $mailbox,
- $query,
+ ->withConsecutive(
+ [
+ $mailbox,
+ $query,
+ [
+ 'ids' => new Horde_Imap_Client_Ids('123:321'),
+ ]
+ ],
[
- 'ids' => new Horde_Imap_Client_Ids('123:321'),
+ $mailbox,
+ $this->anything(),
+ $this->anything()
]
- )->willReturn($uidResults);
- $bodyResults = new Horde_Imap_Client_Fetch_Results();
- $client->expects($this->at(2))
- ->method('fetch')
- ->willReturn($bodyResults);
+ )
+ ->willReturnOnConsecutiveCalls(
+ $uidResults,
+ $bodyResults
+ );
$this->mapper->findAll(
$client,
@@ -199,19 +207,27 @@ class MessageMapperTest extends TestCase {
$query = new Horde_Imap_Client_Fetch_Query();
$query->uid();
$uidResults = new Horde_Imap_Client_Fetch_Results();
- $client->expects($this->at(1))
+ $bodyResults = new Horde_Imap_Client_Fetch_Results();
+ $client->expects($this->exactly(2))
->method('fetch')
- ->with(
- $mailbox,
- $query,
+ ->withConsecutive(
+ [
+ $mailbox,
+ $query,
+ [
+ 'ids' => new Horde_Imap_Client_Ids('301:321'),
+ ]
+ ],
[
- 'ids' => new Horde_Imap_Client_Ids('301:321'),
+ $mailbox,
+ $this->anything(),
+ $this->anything()
]
- )->willReturn($uidResults);
- $bodyResults = new Horde_Imap_Client_Fetch_Results();
- $client->expects($this->at(2))
- ->method('fetch')
- ->willReturn($bodyResults);
+ )
+ ->willReturnOnConsecutiveCalls(
+ $uidResults,
+ $bodyResults
+ );
$this->mapper->findAll(
$client,
diff --git a/tests/Unit/Listener/DeleteDraftListenerTest.php b/tests/Unit/Listener/DeleteDraftListenerTest.php
index 0f9e10638..f262120a2 100644
--- a/tests/Unit/Listener/DeleteDraftListenerTest.php
+++ b/tests/Unit/Listener/DeleteDraftListenerTest.php
@@ -130,10 +130,13 @@ class DeleteDraftListenerTest extends TestCase {
->willReturn($client);
$mailbox = new Mailbox();
$mailbox->setName('Drafts');
- $this->mailboxMapper->expects($this->at(0))
+ $this->mailboxMapper->expects($this->exactly(2))
->method('findSpecial')
->with($account, 'drafts')
- ->willThrowException(new DoesNotExistException(''));
+ ->willReturnOnConsecutiveCalls(
+ $this->throwException(new DoesNotExistException('')),
+ $mailbox
+ );
$client->expects($this->once())
->method('createMailbox')
->with(
@@ -147,10 +150,6 @@ class DeleteDraftListenerTest extends TestCase {
$this->mailboxSync->expects($this->once())
->method('sync')
->with($account, $this->logger, true);
- $this->mailboxMapper->expects($this->at(1))
- ->method('findSpecial')
- ->with($account, 'drafts')
- ->willReturn($mailbox);
$this->messageMapper->expects($this->once())
->method('addFlag')
->with(
diff --git a/tests/Unit/Listener/SaveSentMessageListenerTest.php b/tests/Unit/Listener/SaveSentMessageListenerTest.php
index 8ae29bb3e..35b627d43 100644
--- a/tests/Unit/Listener/SaveSentMessageListenerTest.php
+++ b/tests/Unit/Listener/SaveSentMessageListenerTest.php
@@ -112,10 +112,17 @@ class SaveSentMessageListenerTest extends TestCase {
$message,
$mail
);
- $this->mailboxMapper->expects($this->at(0))
+ $mailbox = new Mailbox();
+ $this->mailboxMapper->expects($this->exactly(2))
->method('findSpecial')
- ->with($account, 'sent')
- ->willThrowException(new DoesNotExistException(''));
+ ->withConsecutive(
+ [$account, 'sent'],
+ [$account, 'sent']
+ )
+ ->willReturnOnConsecutiveCalls(
+ $this->throwException(new DoesNotExistException('')),
+ $mailbox
+ );
$client = $this->createMock(\Horde_Imap_Client_Socket::class);
$this->imapClientFactory
->method('getClient')
@@ -166,10 +173,17 @@ class SaveSentMessageListenerTest extends TestCase {
$message,
$mail
);
- $this->mailboxMapper->expects($this->at(0))
+ $mailbox = new Mailbox();
+ $this->mailboxMapper->expects($this->exactly(2))
->method('findSpecial')
- ->with($account, 'sent')
- ->willThrowException(new DoesNotExistException(''));
+ ->withConsecutive(
+ [$account, 'sent'],
+ [$account, 'sent']
+ )
+ ->willReturnOnConsecutiveCalls(
+ $this->throwException(new DoesNotExistException('')),
+ $mailbox
+ );
$client = $this->createMock(\Horde_Imap_Client_Socket::class);
$this->imapClientFactory
->method('getClient')
@@ -185,11 +199,6 @@ class SaveSentMessageListenerTest extends TestCase {
],
]
);
- $mailbox = new Mailbox();
- $this->mailboxMapper->expects($this->at(1))
- ->method('findSpecial')
- ->with($account, 'sent')
- ->willReturn($mailbox);
$this->messageMapper->expects($this->once())
->method('save')
->with(
diff --git a/tests/Unit/Service/Autocompletion/AddressCollectorTest.php b/tests/Unit/Service/Autocompletion/AddressCollectorTest.php
index 167b7ab34..3b4c8b317 100644
--- a/tests/Unit/Service/Autocompletion/AddressCollectorTest.php
+++ b/tests/Unit/Service/Autocompletion/AddressCollectorTest.php
@@ -64,20 +64,22 @@ class AddressCollectorTest extends TestCase {
$address2->setEmail('example@user.com');
$address2->setUserId($this->userId);
- $this->mapper->expects($this->at(0))
+ $this->mapper->expects($this->exactly(2))
->method('exists')
- ->with($this->userId, 'user@example.com')
- ->will($this->returnValue(false));
- $this->mapper->expects($this->at(1))
+ ->withConsecutive(
+ [$this->userId, 'user@example.com'],
+ [$this->userId, 'example@user.com']
+ )
+ ->willReturnOnConsecutiveCalls(
+ false,
+ false
+ );
+ $this->mapper->expects($this->exactly(2))
->method('insert')
- ->with($address1);
- $this->mapper->expects($this->at(2))
- ->method('exists')
- ->with($this->userId, 'example@user.com')
- ->will($this->returnValue(false));
- $this->mapper->expects($this->at(3))
- ->method('insert')
- ->with($address2);
+ ->withConsecutive(
+ [$address1],
+ [$address2]
+ );
$this->collector->addAddresses($addressList);
}
@@ -88,7 +90,7 @@ class AddressCollectorTest extends TestCase {
];
$addressList = AddressList::parse($addresses);
- $this->mapper->expects($this->at(0))
+ $this->mapper->expects($this->once())
->method('exists')
->with($this->userId, $addresses[0])
->will($this->returnValue(true));