diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2018-03-27 15:33:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-27 15:33:14 +0300 |
commit | f61a653ccdc0a6eb7c1cc698e28becf49c69c114 (patch) | |
tree | 3971602c66aa8f91f41e8a0d5d587383086e7e7f /tests | |
parent | 16357e10147ff9bd3c5e6ae97a41437a04adc364 (diff) | |
parent | a1f3aaf8795dfee7944c9cb2620c4866b2be5133 (diff) |
Merge pull request #851 from nextcloud/fix/no-sender
Fix no sender null check
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Model/IMAPMessageTest.php (renamed from tests/Model/ImapMessageTest.php) | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/tests/Model/ImapMessageTest.php b/tests/Model/IMAPMessageTest.php index d7220ba01..9f1693090 100644 --- a/tests/Model/ImapMessageTest.php +++ b/tests/Model/IMAPMessageTest.php @@ -19,6 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCA\Mail\Tests\Model; use ChristophWurst\Nextcloud\Testing\TestCase; @@ -29,7 +30,7 @@ use OCA\Mail\AddressList; use OCA\Mail\Model\IMAPMessage; use OCA\Mail\Service\Html; -class ImapMessageTest extends TestCase { +class IMAPMessageTest extends TestCase { public function testNoFrom() { $data = new Horde_Imap_Client_Data_Fetch(); @@ -40,7 +41,7 @@ class ImapMessageTest extends TestCase { public function testIconvHtmlMessage() { $conn = $this->getMockBuilder('Horde_Imap_Client_Socket') - ->disableOriginalConstructor() + ->disableOriginalConstructor() ->setMethods(['fetch']) ->getMock(); @@ -55,13 +56,14 @@ class ImapMessageTest extends TestCase { $urlGenerator->expects($this->any()) ->method('linkToRoute') ->will($this->returnCallback(function ($url) { - return "https://docs.example.com/server/go.php?to=$url"; - })); + return "https://docs.example.com/server/go.php?to=$url"; + })); $htmlService = new Html($urlGenerator, $request); // mock first fetch $firstFetch = new Horde_Imap_Client_Data_Fetch(); - $firstPart = Horde_Mime_Part::parseMessage(file_get_contents(__DIR__ . '/../data/mail-message-123.txt'), ['level' => 1]); + $firstPart = Horde_Mime_Part::parseMessage(file_get_contents(__DIR__ . '/../data/mail-message-123.txt'), + ['level' => 1]); $firstFetch->setStructure($firstPart); $firstFetch->setBodyPart(1, $firstPart->getPart(1)->getContents()); $firstFetch->setBodyPart(2, $firstPart->getPart(2)->getContents()); @@ -73,11 +75,23 @@ class ImapMessageTest extends TestCase { $message = new IMAPMessage($conn, 'INBOX', 123, null, true, $htmlService); - $htmlBody = $message->getHtmlBody(0, 0, 123, function() {return null;}); + $htmlBody = $message->getHtmlBody(0, 0, 123, function() { + return null; + }); $this->assertTrue(strlen($htmlBody) > 1000); $plainTextBody = $message->getPlainBody(); $this->assertTrue(strlen($plainTextBody) > 1000); } -} + public function testSerialize() { + $data = new Horde_Imap_Client_Data_Fetch(); + $m = new IMAPMessage(null, 'INBOX', 123, $data); + $m->setUid('1234'); + + $json = $m->jsonSerialize(); + + $this->assertEquals('1234', $json['id']); + } + +} |