123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- // Copyright 2019 Hackware SpA <human@hackware.cl>
- // "Hackware Web Services Core" is released under the MIT License terms.
- namespace Hawese\Tests;
- use Hawese\Core\Mailer;
- class MailerTest extends TestCase
- {
- public function setUp(): void
- {
- parent::setUp();
- $this->mailer = new Mailer(true); // True enables exceptions
- $this->mailer->CharSet = Mailer::CHARSET_UTF8;
- $this->mailer->setFrom('from@example.com', 'Example From');
- $this->mailer->addAddress('to_mail@example.com', 'Example To');
- $this->mailer->Subject = 'Example subject';
- $this->mailer->Body = '<p>Example body</p>';
- $this->mailer->AltBody = 'Example body';
- $this->mailer->isMail();
- }
- public function testSend()
- {
- $this->assertTrue($this->mailer->send());
- $this->assertStringContainsString(
- 'Example body',
- $this->mailer->getSentMIMEMessage()
- );
- }
- public function testJsonSerialize()
- {
- $this->assertJsonStringEqualsJsonString(
- json_encode([
- 'From' => $this->mailer->From,
- 'FromName' => $this->mailer->FromName,
- 'Subject' => $this->mailer->Subject,
- 'To' => [['t*****l@example.com', 'Example To']]
- ]),
- json_encode($this->mailer)
- );
- }
- }
|