Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 13 additions & 11 deletions tests/AddressListTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand All @@ -14,8 +16,8 @@
use OCA\Mail\Address;
use OCA\Mail\AddressList;

class AddressListTest extends TestCase {
public function testSerialize() {
final class AddressListTest extends TestCase {
public function testSerialize(): void {
$list = new AddressList([
Address::fromRaw('User 1', 'user1@domain.tld'),
Address::fromRaw('User 2', 'user2@domain.tld'),
Expand All @@ -37,7 +39,7 @@ public function testSerialize() {
$this->assertEquals($expected, $json);
}

public function testParseSingleAddress() {
public function testParseSingleAddress(): void {
$source = 'a@b.c';
$expected = new AddressList([
Address::fromRaw('a@b.c', 'a@b.c'),
Expand All @@ -48,7 +50,7 @@ public function testParseSingleAddress() {
$this->assertEquals($expected, $list);
}

public function testFromHordeList() {
public function testFromHordeList(): void {
$hordeList = new Horde_Mail_Rfc822_List([
new Horde_Mail_Rfc822_Address(),
new Horde_Mail_Rfc822_Group(),
Expand All @@ -59,7 +61,7 @@ public function testFromHordeList() {
$this->assertCount(1, $list);
}

public function testToHorde() {
public function testToHorde(): void {
$list = new AddressList([
Address::fromRaw('A', 'a@domain.tld'),
Address::fromRaw('B', 'b@domain.tld'),
Expand All @@ -78,7 +80,7 @@ public function testToHorde() {
$this->assertEquals($expected, $hordeList);
}

public function testFromAndToHorde() {
public function testFromAndToHorde(): void {
$add1 = new Horde_Mail_Rfc822_Address('a@domain.tld');
$add1->personal = 'A';
$add2 = new Horde_Mail_Rfc822_Address('b@domain.tld');
Expand All @@ -98,7 +100,7 @@ public function testFromAndToHorde() {
$this->assertEquals($expected, $hordeList);
}

public function testMergeIdentical() {
public function testMergeIdentical(): void {
$a = new AddressList([
Address::fromRaw('A', 'a@b.c'),
]);
Expand All @@ -111,7 +113,7 @@ public function testMergeIdentical() {
$this->assertCount(1, $c);
}

public function testMergeNonIdentical() {
public function testMergeNonIdentical(): void {
$a = new AddressList([
Address::fromRaw('A', 'a@b.c'),
]);
Expand All @@ -126,7 +128,7 @@ public function testMergeNonIdentical() {
$this->assertCount(2, $c);
}

public function testMergeMixed() {
public function testMergeMixed(): void {
$a = new AddressList([
Address::fromRaw('A', 'a@b.c'),
Address::fromRaw('B', 'b@b.c'),
Expand All @@ -140,7 +142,7 @@ public function testMergeMixed() {
$this->assertCount(2, $c);
}

public function testMergeEmpty() {
public function testMergeEmpty(): void {
$a = new AddressList([
Address::fromRaw('A', 'a@b.c'),
Address::fromRaw('B', 'b@b.c'),
Expand All @@ -152,7 +154,7 @@ public function testMergeEmpty() {
$this->assertCount(2, $c);
}

public function testMergeToEmpty() {
public function testMergeToEmpty(): void {
$a = new AddressList([
]);
$b = new AddressList([
Expand Down
16 changes: 9 additions & 7 deletions tests/AddressTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand All @@ -11,8 +13,8 @@
use Horde_Mail_Rfc822_Address;
use OCA\Mail\Address;

class AddressTest extends TestCase {
public function testSerialization() {
final class AddressTest extends TestCase {
public function testSerialization(): void {
$address = Address::fromRaw('Christoph Wurst', 'christoph@domain.tld');

$expected = [
Expand All @@ -24,7 +26,7 @@ public function testSerialization() {
$this->assertEquals($expected, $json);
}

public function testToHorde() {
public function testToHorde(): void {
$address = Address::fromRaw('Christoph Wurst', 'christoph@domain.tld');
$expected = new Horde_Mail_Rfc822_Address('christoph@domain.tld');
$expected->personal = 'Christoph Wurst';
Expand All @@ -34,15 +36,15 @@ public function testToHorde() {
$this->assertEquals($expected, $horde);
}

public function testEqualsIdentical() {
public function testEqualsIdentical(): void {
$address = Address::fromRaw('Christoph Wurst', 'christoph@domain.tld');

$equals = $address->equals($address);

$this->assertTrue($equals);
}

public function testEquals() {
public function testEquals(): void {
$address1 = Address::fromRaw('Christoph Wurst', 'christoph@domain1.tld');
$address2 = Address::fromRaw('Christoph Wurst', 'christoph@domain1.tld');

Expand All @@ -51,7 +53,7 @@ public function testEquals() {
$this->assertTrue($equals);
}

public function testDoesNotEqual() {
public function testDoesNotEqual(): void {
$address1 = Address::fromRaw('Christoph Wurst', 'christoph@domain1.tld');
$address2 = Address::fromRaw('Christoph Wurst', 'christoph@domain2.tld');

Expand All @@ -60,7 +62,7 @@ public function testDoesNotEqual() {
$this->assertFalse($equals);
}

public function testDoesNotEqualBecauseDifferentLabel() {
public function testDoesNotEqualBecauseDifferentLabel(): void {
$address1 = Address::fromRaw('Christoph Wurst', 'christoph@domain.tld');
$address2 = Address::fromRaw('Wurst Christoph', 'christoph@domain.tld');

Expand Down
14 changes: 8 additions & 6 deletions tests/FolderTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-only
Expand All @@ -12,7 +14,7 @@
use OCA\Mail\Folder;
use PHPUnit\Framework\MockObject\MockObject;

class FolderTest extends TestCase {
final class FolderTest extends TestCase {
/** @var int */
private $accountId;

Expand All @@ -29,7 +31,7 @@ private function mockFolder(array $attributes = [], $delimiter = '.') {
$this->folder = new Folder($this->accountId, $this->mailbox, $attributes, $delimiter, []);
}

public function testGetMailbox() {
public function testGetMailbox(): void {
$this->mockFolder();
$this->mailbox->expects($this->once())
->method('__get')
Expand All @@ -39,7 +41,7 @@ public function testGetMailbox() {
$this->assertSame('Sent', $this->folder->getMailbox());
}

public function testGetDelimiter() {
public function testGetDelimiter(): void {
$this->mockFolder([], ',');

$this->assertSame(',', $this->folder->getDelimiter());
Expand All @@ -51,13 +53,13 @@ public function testGetDelimiterNull(): void {
$this->assertNull($this->folder->getDelimiter());
}

public function testGetAttributes() {
public function testGetAttributes(): void {
$this->mockFolder(['\noselect']);

$this->assertSame(['\noselect'], $this->folder->getAttributes());
}

public function testSetStatus() {
public function testSetStatus(): void {
$this->mockFolder();

$this->folder->setStatus([
Expand All @@ -67,7 +69,7 @@ public function testSetStatus() {
$this->addToAssertionCount(1);
}

public function testSpecialUse() {
public function testSpecialUse(): void {
$this->mockFolder();

$this->folder->addSpecialUse('flagged');
Expand Down
18 changes: 9 additions & 9 deletions tests/HordeTranslationHandlerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-only
Expand All @@ -10,7 +12,7 @@
use ChristophWurst\Nextcloud\Testing\TestCase;
use OCA\Mail\HordeTranslationHandler;

class HordeTranslationHandlerTest extends TestCase {
final class HordeTranslationHandlerTest extends TestCase {
private $handler;

protected function setUp(): void {
Expand All @@ -19,7 +21,7 @@ protected function setUp(): void {
$this->handler = new HordeTranslationHandler();
}

public function testT() {
public function testT(): void {
$message = 'Hello';

$expected = $message;
Expand All @@ -28,18 +30,16 @@ public function testT() {
$this->assertEquals($expected, $actual);
}

public function singularPluralDataProvider() {
return [
[0],
[1],
[2],
];
public function singularPluralDataProvider(): \Iterator {
yield [0];
yield [1];
yield [2];
}

/**
* @dataProvider singularPluralDataProvider
*/
public function testNgettext($number) {
public function testNgettext($number): void {
$singular = 'mail';
$plural = 'mails';

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Connector/ImapMailboxConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use OCA\Mail\Tests\Integration\Framework\ImapTestAccount;
use OCP\Server;

class ImapMailboxConnectorTest extends AbstractMailboxConnectorTest {
final class ImapMailboxConnectorTest extends AbstractMailboxConnectorTest {
use ImapTest;
use ImapTestAccount;

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Connector/JmapMailboxConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use OCA\Mail\Tests\Integration\Framework\JmapTestAccount;
use OCP\Server;

class JmapMailboxConnectorTest extends AbstractMailboxConnectorTest {
final class JmapMailboxConnectorTest extends AbstractMailboxConnectorTest {
use JmapTestAccount;

protected function createConnector(): IMailboxConnector {
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Connector/JmapMessageConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use OCP\Server;
use Psr\Log\NullLogger;

class JmapMessageConnectorTest extends TestCase {
final class JmapMessageConnectorTest extends TestCase {
use DatabaseTransaction;
use JmapTestAccount;

Expand Down
10 changes: 5 additions & 5 deletions tests/Integration/Db/AliasMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* @group DB
*/
class AliasMapperTest extends TestCase {
final class AliasMapperTest extends TestCase {
use DatabaseTransaction;

/** @var AliasMapper */
Expand All @@ -42,7 +42,7 @@ public function setup(): void {
$this->mapper = new AliasMapper($this->db);
}

public function testFind() {
public function testFind(): void {
$accountMapper = new MailAccountMapper($this->db);
$account = new MailAccount();
$account->setName('Peter Parker');
Expand Down Expand Up @@ -86,7 +86,7 @@ public function testFind() {
);
}

public function testCountByAccountId() {
public function testCountByAccountId(): void {
$account = $this->insertAccount();

self::assertSame(0, $this->mapper->countByAccountId($account->getId(), $account->getUserId()));
Expand All @@ -102,7 +102,7 @@ public function testCountByAccountId() {
self::assertSame(2, $this->mapper->countByAccountId($account->getId(), $account->getUserId()));
}

public function testCountByAccountIdIgnoresOtherUsers() {
public function testCountByAccountIdIgnoresOtherUsers(): void {
$account = $this->insertAccount();

$alias = new Alias();
Expand Down Expand Up @@ -156,7 +156,7 @@ private function insertAccount(string $userId = 'user12345'): MailAccount {
return (new MailAccountMapper($this->db))->insert($account);
}

public function testDeleteProvisionedAliasesByUid() {
public function testDeleteProvisionedAliasesByUid(): void {
$accountMapper = new MailAccountMapper($this->db);

// Create first account with provisioning_id
Expand Down
Loading
Loading