diff options
author | Anna Larch <anna@nextcloud.com> | 2021-12-01 18:22:50 +0300 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2021-12-02 17:48:19 +0300 |
commit | 8117ab30d8d4d0770386eb1585d723f06a286e94 (patch) | |
tree | 39d4988ca3f51b1177b4910b18330836f92c4a54 /tests | |
parent | 6334b6e09ee641346a47bb64ba7b73ff45f8b60d (diff) |
(Re)wrap message ID in '<>' brackets before inserting in the db
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Integration/Db/MessageTest.php | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/tests/Integration/Db/MessageTest.php b/tests/Integration/Db/MessageTest.php new file mode 100644 index 000000000..1ea5e4a7b --- /dev/null +++ b/tests/Integration/Db/MessageTest.php @@ -0,0 +1,89 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2021 Anna Larch <anna.larch@gmx.net> + * + * @author 2021 Anna Larch <anna.larch@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCA\Mail\Tests\Integration\Db; + +use ChristophWurst\Nextcloud\Testing\TestCase; +use OCA\Mail\Db\Message; + +class MessageTest extends TestCase { + protected function setUp(): void { + } + + public function testNewForMessageId(): void { + $expected = '<abc@123.com>'; + $message = new Message(); + + $message->setMessageId($expected); + $message->setThreadRootId($expected); + + $this->assertEquals($expected, $message->getMessageId()); + $this->assertEquals($expected, $message->getThreadRootId()); + } + + public function testNewWithMessageIdNoAngleBrackets(): void { + $expected = '<abc@123.com>'; + $noBrackets = 'abc@123.com'; + $message = new Message(); + + $message->setMessageId($noBrackets); + $message->setThreadRootId($noBrackets); + + $this->assertEquals($expected, $message->getMessageId()); + $this->assertEquals($expected, $message->getThreadRootId()); + } + + public function testNewWithMessageIdOneAngleBrackets(): void { + $expected = '<abc@123.com>'; + $noBrackets = '<abc@123.com'; + $message = new Message(); + + $message->setMessageId($noBrackets); + $message->setThreadRootId($noBrackets); + + $this->assertEquals($expected, $message->getMessageId()); + $this->assertEquals($expected, $message->getThreadRootId()); + + $noBrackets = 'abc@123.com>'; + $message = new Message(); + + $message->setMessageId($noBrackets); + $message->setThreadRootId($noBrackets); + + $this->assertEquals($expected, $message->getMessageId()); + $this->assertEquals($expected, $message->getThreadRootId()); + } + + public function testThreadrootIdNull(): void { + $expected = '<abc@123.com>'; + $message = new Message(); + + $message->setMessageId($expected); + $message->setThreadRootId(null); + + $this->assertEquals($expected, $message->getMessageId()); + $this->assertNull($message->getThreadRootId()); + } +} |