diff options
Diffstat (limited to 'tests/lib/Mail')
-rw-r--r-- | tests/lib/Mail/EMailTemplateTest.php | 25 | ||||
-rw-r--r-- | tests/lib/Mail/MailerTest.php | 18 | ||||
-rw-r--r-- | tests/lib/Mail/MessageTest.php | 8 | ||||
-rw-r--r-- | tests/lib/Mail/Provider/AddressTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Mail/Provider/AttachmentTest.php | 8 | ||||
-rw-r--r-- | tests/lib/Mail/Provider/MessageTest.php | 18 |
6 files changed, 41 insertions, 40 deletions
diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php index 76b37d48ff3..1912bf060e2 100644 --- a/tests/lib/Mail/EMailTemplateTest.php +++ b/tests/lib/Mail/EMailTemplateTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later @@ -47,7 +48,7 @@ class EMailTemplateTest extends TestCase { public function testEMailTemplateCustomFooter(): void { $this->defaults - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getDefaultColorPrimary') ->willReturn('#0082c9'); $this->defaults @@ -59,8 +60,8 @@ class EMailTemplateTest extends TestCase { ->method('getName') ->willReturn('TestCloud'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) @@ -88,7 +89,7 @@ class EMailTemplateTest extends TestCase { public function testEMailTemplateDefaultFooter(): void { $this->defaults - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getDefaultColorPrimary') ->willReturn('#0082c9'); $this->defaults @@ -104,8 +105,8 @@ class EMailTemplateTest extends TestCase { ->method('getLogo') ->willReturn('/img/logo-mail-header.png'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) @@ -131,7 +132,7 @@ class EMailTemplateTest extends TestCase { public function testEMailTemplateSingleButton(): void { $this->defaults - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getDefaultColorPrimary') ->willReturn('#0082c9'); $this->defaults @@ -147,8 +148,8 @@ class EMailTemplateTest extends TestCase { ->method('getLogo') ->willReturn('/img/logo-mail-header.png'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) @@ -176,7 +177,7 @@ class EMailTemplateTest extends TestCase { public function testEMailTemplateAlternativePlainTexts(): void { $this->defaults - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getDefaultColorPrimary') ->willReturn('#0082c9'); $this->defaults @@ -192,8 +193,8 @@ class EMailTemplateTest extends TestCase { ->method('getLogo') ->willReturn('/img/logo-mail-header.png'); $this->defaults - ->expects($this->any()) - ->method('getTextColorPrimary') + ->expects($this->atLeastOnce()) + ->method('getDefaultTextColorPrimary') ->willReturn('#ffffff'); $this->urlGenerator ->expects($this->once()) diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php index 02a2605fc77..7b911e5c4e2 100644 --- a/tests/lib/Mail/MailerTest.php +++ b/tests/lib/Mail/MailerTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -18,6 +19,7 @@ use OCP\IL10N; use OCP\IURLGenerator; use OCP\L10N\IFactory; use OCP\Mail\Events\BeforeMessageSent; +use OCP\Server; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; use Symfony\Component\Mailer\Mailer as SymfonyMailer; @@ -66,7 +68,7 @@ class MailerTest extends TestCase { /** * @return array */ - public function sendmailModeProvider(): array { + public static function sendmailModeProvider(): array { return [ 'smtp' => ['smtp', ' -bs'], 'pipe' => ['pipe', ' -t -i'], @@ -74,10 +76,10 @@ class MailerTest extends TestCase { } /** - * @dataProvider sendmailModeProvider * @param $sendmailMode * @param $binaryParam */ + #[\PHPUnit\Framework\Attributes\DataProvider('sendmailModeProvider')] public function testGetSendmailInstanceSendMail($sendmailMode, $binaryParam): void { $this->config ->expects($this->exactly(2)) @@ -87,7 +89,7 @@ class MailerTest extends TestCase { ['mail_sendmailmode', 'smtp', $sendmailMode], ]); - $path = \OCP\Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'); + $path = Server::get(IBinaryFinder::class)->findBinaryPath('sendmail'); if ($path === false) { $path = '/usr/sbin/sendmail'; } @@ -97,10 +99,10 @@ class MailerTest extends TestCase { } /** - * @dataProvider sendmailModeProvider * @param $sendmailMode * @param $binaryParam */ + #[\PHPUnit\Framework\Attributes\DataProvider('sendmailModeProvider')] public function testGetSendmailInstanceSendMailQmail($sendmailMode, $binaryParam): void { $this->config ->expects($this->exactly(2)) @@ -170,7 +172,7 @@ class MailerTest extends TestCase { ['mail_smtpport', 25, 25], ]); $this->mailer = $this->getMockBuilder(Mailer::class) - ->setMethods(['getInstance']) + ->onlyMethods(['getInstance']) ->setConstructorArgs( [ $this->config, @@ -227,7 +229,7 @@ class MailerTest extends TestCase { /** * @return array */ - public function mailAddressProvider() { + public static function mailAddressProvider(): array { return [ ['lukas@owncloud.com', true, false], ['lukas@localhost', true, false], @@ -241,9 +243,7 @@ class MailerTest extends TestCase { ]; } - /** - * @dataProvider mailAddressProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('mailAddressProvider')] public function testValidateMailAddress($email, $expected, $strict): void { $this->config ->expects($this->atMost(1)) diff --git a/tests/lib/Mail/MessageTest.php b/tests/lib/Mail/MessageTest.php index 260d3aaff76..18ef9793b5b 100644 --- a/tests/lib/Mail/MessageTest.php +++ b/tests/lib/Mail/MessageTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -27,7 +28,7 @@ class MessageTest extends TestCase { /** * @return array */ - public function mailAddressProvider() { + public static function mailAddressProvider(): array { return [ [ ['lukas@owncloud.com' => 'Lukas Reschke'], @@ -65,18 +66,17 @@ class MessageTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->symfonyEmail = $this->getMockBuilder(Email::class) - ->disableOriginalConstructor()->getMock(); + $this->symfonyEmail = $this->createMock(Email::class); $this->message = new Message($this->symfonyEmail, false); } /** - * @dataProvider mailAddressProvider * * @param string $unconverted * @param string $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('mailAddressProvider')] public function testConvertAddresses($unconverted, $expected): void { $this->assertEquals($expected, self::invokePrivate($this->message, 'convertAddresses', [$unconverted])); } diff --git a/tests/lib/Mail/Provider/AddressTest.php b/tests/lib/Mail/Provider/AddressTest.php index ee03f6f1e83..dc5e73526eb 100644 --- a/tests/lib/Mail/Provider/AddressTest.php +++ b/tests/lib/Mail/Provider/AddressTest.php @@ -24,7 +24,7 @@ class AddressTest extends TestCase { } public function testAddress(): void { - + // test set by constructor $this->assertEquals('user1@testing.com', $this->address->getAddress()); // test set by setter @@ -34,7 +34,7 @@ class AddressTest extends TestCase { } public function testLabel(): void { - + // test set by constructor $this->assertEquals('User One', $this->address->getLabel()); // test set by setter diff --git a/tests/lib/Mail/Provider/AttachmentTest.php b/tests/lib/Mail/Provider/AttachmentTest.php index 283391650b5..f02b1d54a7b 100644 --- a/tests/lib/Mail/Provider/AttachmentTest.php +++ b/tests/lib/Mail/Provider/AttachmentTest.php @@ -29,7 +29,7 @@ class AttachmentTest extends TestCase { } public function testName(): void { - + // test set by constructor $this->assertEquals('example1.txt', $this->attachment->getName()); // test set by setter @@ -39,7 +39,7 @@ class AttachmentTest extends TestCase { } public function testType(): void { - + // test set by constructor $this->assertEquals('text/plain', $this->attachment->getType()); // test set by setter @@ -49,7 +49,7 @@ class AttachmentTest extends TestCase { } public function testContents(): void { - + // test set by constructor $this->assertEquals('This is the contents of a file', $this->attachment->getContents()); // test set by setter @@ -59,7 +59,7 @@ class AttachmentTest extends TestCase { } public function testEmbedded(): void { - + // test set by constructor $this->assertEquals(false, $this->attachment->getEmbedded()); // test set by setter diff --git a/tests/lib/Mail/Provider/MessageTest.php b/tests/lib/Mail/Provider/MessageTest.php index 1791a03421c..6b387e5b010 100644 --- a/tests/lib/Mail/Provider/MessageTest.php +++ b/tests/lib/Mail/Provider/MessageTest.php @@ -56,14 +56,14 @@ class MessageTest extends TestCase { } public function testId(): void { - + // test set by constructor $this->assertEquals('cd02ea42-feac-4863-b9d8-484d16a587ea', $this->message->id()); } public function testFrom(): void { - + // test not set $this->assertNull($this->message->getFrom()); // test set by setter @@ -73,7 +73,7 @@ class MessageTest extends TestCase { } public function testReplyTo(): void { - + // test not set $this->assertNull($this->message->getReplyTo()); // test set by setter @@ -83,7 +83,7 @@ class MessageTest extends TestCase { } public function testTo(): void { - + // test not set $this->assertEquals([], $this->message->getTo()); // test set by setter single @@ -96,7 +96,7 @@ class MessageTest extends TestCase { } public function testCc(): void { - + // test not set $this->assertEquals([], $this->message->getCc()); // test set by setter single @@ -109,7 +109,7 @@ class MessageTest extends TestCase { } public function testBcc(): void { - + // test not set $this->assertEquals([], $this->message->getBcc()); // test set by setter single @@ -122,7 +122,7 @@ class MessageTest extends TestCase { } public function testSubject(): void { - + // test not set $this->assertNull($this->message->getSubject()); // test set by setter @@ -132,7 +132,7 @@ class MessageTest extends TestCase { } public function testBody(): void { - + // test not set $this->assertNull($this->message->getBody()); // test set by setter - text body @@ -149,7 +149,7 @@ class MessageTest extends TestCase { } public function testAttachments(): void { - + // test not set $this->assertEquals([], $this->message->getAttachments()); // test set by setter single |