aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Mail/MessageTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Mail/MessageTest.php')
-rw-r--r--tests/lib/Mail/MessageTest.php59
1 files changed, 29 insertions, 30 deletions
diff --git a/tests/lib/Mail/MessageTest.php b/tests/lib/Mail/MessageTest.php
index 1d309ca742d..18ef9793b5b 100644
--- a/tests/lib/Mail/MessageTest.php
+++ b/tests/lib/Mail/MessageTest.php
@@ -1,9 +1,9 @@
<?php
+
/**
- * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Mail;
@@ -28,7 +28,7 @@ class MessageTest extends TestCase {
/**
* @return array
*/
- public function mailAddressProvider() {
+ public static function mailAddressProvider(): array {
return [
[
['lukas@owncloud.com' => 'Lukas Reschke'],
@@ -66,19 +66,18 @@ 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
*/
- public function testConvertAddresses($unconverted, $expected) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('mailAddressProvider')]
+ public function testConvertAddresses($unconverted, $expected): void {
$this->assertEquals($expected, self::invokePrivate($this->message, 'convertAddresses', [$unconverted]));
}
@@ -92,28 +91,28 @@ class MessageTest extends TestCase {
$this->symfonyEmail
->expects($this->once())
->method('from')
- ->willReturn(new Address('pierres-general-store@stardewvalley.com', 'Pierres General Store'));
+ ->with(new Address('pierres-general-store@stardewvalley.com', 'Pierres General Store'));
$this->symfonyEmail
->expects($this->once())
->method('to')
- ->willReturn(new Address('lewis-tent@stardewvalley.com', "Lewis' Tent Life"));
+ ->with(new Address('lewis-tent@stardewvalley.com', "Lewis' Tent Life"));
$this->symfonyEmail
->expects($this->once())
->method('replyTo')
- ->willReturn(new Address('penny@stardewvalley-library.co.edu', 'Penny'));
+ ->with(new Address('penny@stardewvalley-library.co.edu', 'Penny'));
$this->symfonyEmail
->expects($this->once())
->method('cc')
- ->willReturn(new Address('gunther@stardewvalley-library.co.edu', 'Gunther'));
+ ->with(new Address('gunther@stardewvalley-library.co.edu', 'Gunther'));
$this->symfonyEmail
->expects($this->once())
->method('bcc')
- ->willReturn(new Address('pam@stardewvalley-bus.com', 'Pam'));
+ ->with(new Address('pam@stardewvalley-bus.com', 'Pam'));
$this->message->setRecipients();
}
- public function testSetTo() {
+ public function testSetTo(): void {
$expected = ['pierres-general-store@stardewvalley.com' => 'Pierres General Store'];
$message = $this->message->setTo(['pierres-general-store@stardewvalley.com' => 'Pierres General Store']);
@@ -142,7 +141,7 @@ class MessageTest extends TestCase {
$message->setRecipients();
}
- public function testSetGetFrom() {
+ public function testSetGetFrom(): void {
$expected = ['pierres-general-store@stardewvalley.com' => 'Pierres General Store'];
$message = $this->message->setFrom(['pierres-general-store@stardewvalley.com' => 'Pierres General Store']);
@@ -150,7 +149,7 @@ class MessageTest extends TestCase {
$this->assertEquals($expected, $message->getFrom());
}
- public function testSetGetTo() {
+ public function testSetGetTo(): void {
$expected = ['lewis-tent@stardewvalley.com' => "Lewis' Tent Life"];
$message = $this->message->setTo(['lewis-tent@stardewvalley.com' => "Lewis' Tent Life"]);
@@ -158,7 +157,7 @@ class MessageTest extends TestCase {
$this->assertEquals($expected, $message->getTo());
}
- public function testSetGetReplyTo() {
+ public function testSetGetReplyTo(): void {
$expected = ['penny@stardewvalley-library.co.edu' => 'Penny'];
$message = $this->message->setReplyTo(['penny@stardewvalley-library.co.edu' => 'Penny']);
@@ -166,7 +165,7 @@ class MessageTest extends TestCase {
$this->assertEquals($expected, $message->getReplyTo());
}
- public function testSetGetCC() {
+ public function testSetGetCC(): void {
$expected = ['gunther@stardewvalley-library.co.edu' => 'Gunther'];
$message = $this->message->setCc(['gunther@stardewvalley-library.co.edu' => 'Gunther']);
@@ -174,7 +173,7 @@ class MessageTest extends TestCase {
$this->assertEquals($expected, $message->getCc());
}
- public function testSetGetBCC() {
+ public function testSetGetBCC(): void {
$expected = ['pam@stardewvalley-bus.com' => 'Pam'];
$message = $this->message->setBcc(['pam@stardewvalley-bus.com' => 'Pam']);
@@ -182,7 +181,7 @@ class MessageTest extends TestCase {
$this->assertEquals($expected, $message->getBcc());
}
- public function testSetPlainBody() {
+ public function testSetPlainBody(): void {
$this->symfonyEmail
->expects($this->once())
->method('text')
@@ -191,7 +190,7 @@ class MessageTest extends TestCase {
$this->message->setPlainBody('Fancy Body');
}
- public function testGetPlainBody() {
+ public function testGetPlainBody(): void {
$this->symfonyEmail
->expects($this->once())
->method('getTextBody')
@@ -200,7 +199,7 @@ class MessageTest extends TestCase {
$this->assertSame('Fancy Body', $this->message->getPlainBody());
}
- public function testSetHtmlBody() {
+ public function testSetHtmlBody(): void {
$this->symfonyEmail
->expects($this->once())
->method('html')
@@ -209,7 +208,7 @@ class MessageTest extends TestCase {
$this->message->setHtmlBody('<blink>Fancy Body</blink>');
}
- public function testPlainTextRenderOption() {
+ public function testPlainTextRenderOption(): void {
/** @var MockObject|Email $symfonyEmail */
$symfonyEmail = $this->getMockBuilder(Email::class)
->disableOriginalConstructor()->getMock();
@@ -232,7 +231,7 @@ class MessageTest extends TestCase {
$message->useTemplate($template);
}
- public function testBothRenderingOptions() {
+ public function testBothRenderingOptions(): void {
/** @var MockObject|Email $symfonyEmail */
$symfonyEmail = $this->getMockBuilder(Email::class)
->disableOriginalConstructor()->getMock();
@@ -255,9 +254,9 @@ class MessageTest extends TestCase {
$message->useTemplate($template);
}
- public function testSetAutoSubmitted1() {
+ public function testSetAutoSubmitted1(): void {
$headers = new Headers($this->createMock(HeaderInterface::class));
- $headers->addTextHeader(AutoSubmitted::HEADER, "yes");
+ $headers->addTextHeader(AutoSubmitted::HEADER, 'yes');
$symfonyEmail = $this->createMock(Email::class);
$symfonyEmail->method('getHeaders')
@@ -268,7 +267,7 @@ class MessageTest extends TestCase {
$this->assertNotSame('no', $message->getAutoSubmitted());
}
- public function testSetAutoSubmitted2() {
+ public function testSetAutoSubmitted2(): void {
$headers = new Headers($this->createMock(HeaderInterface::class));
$headers->addTextHeader(AutoSubmitted::HEADER, 'no');
$symfonyEmail = $this->createMock(Email::class);
@@ -281,7 +280,7 @@ class MessageTest extends TestCase {
$this->assertSame('auto-generated', $message->getAutoSubmitted());
}
- public function testGetAutoSubmitted() {
+ public function testGetAutoSubmitted(): void {
$headers = new Headers($this->createMock(HeaderInterface::class));
$headers->addTextHeader(AutoSubmitted::HEADER, 'no');
$symfonyEmail = $this->createMock(Email::class);
@@ -290,6 +289,6 @@ class MessageTest extends TestCase {
->willReturn($headers);
$message = new Message($symfonyEmail, false);
- $this->assertSame("no", $message->getAutoSubmitted());
+ $this->assertSame('no', $message->getAutoSubmitted());
}
}