-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests to incearse codecov coverage
Signed-off-by: sergiu <[email protected]>
- Loading branch information
1 parent
67214f5
commit 84edc30
Showing
7 changed files
with
214 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DotTest\Mail; | ||
|
||
use DateTimeImmutable; | ||
use Dot\Mail\Email; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mime\Address; | ||
use Symfony\Component\Mime\Exception\LogicException; | ||
|
||
class EmailTest extends TestCase | ||
{ | ||
public function testGettersAndSetters(): void | ||
{ | ||
$subject = new Email(); | ||
|
||
$subject->date(new DateTimeImmutable('now')); | ||
$subject->returnPath('[email protected]'); | ||
$subject->setSender('[email protected]', 'testSender'); | ||
$subject->addFrom(['[email protected]', '[email protected]'], 'testAddFrom'); | ||
$subject->setFrom('[email protected]', 'testSetFrom'); | ||
$subject->addReplyTo('[email protected]', 'testAddReplyTo'); | ||
$subject->setReplyTo('[email protected]', 'testSetReplyTo'); | ||
$subject->addTo('[email protected]', 'testAddTo'); | ||
$subject->setTo('[email protected]', 'testAddTo'); | ||
$subject->addCc('[email protected]', 'testAddCc'); | ||
$subject->setCc(new Address('[email protected]'), 'testSetBcc'); | ||
$subject->addBcc('[email protected]', 'testAddBcc'); | ||
$subject->setBcc('[email protected]', 'testSetBcc'); | ||
$subject->priority(6); | ||
$subject->text('test text body'); | ||
$subject->html('test html body'); | ||
$subject->setEncoding('UTF-8'); | ||
|
||
$this->assertInstanceOf(DateTimeImmutable::class, $subject->getDate()); | ||
$this->assertInstanceOf(Address::class, $subject->getReturnPath()); | ||
$this->assertInstanceOf(Address::class, $subject->getSender()); | ||
$this->assertIsArray($subject->getFrom()); | ||
$this->assertIsArray($subject->getReplyTo()); | ||
$this->assertIsArray($subject->getTo()); | ||
$this->assertIsArray($subject->getCc()); | ||
$this->assertIsArray($subject->getBcc()); | ||
$this->assertIsInt($subject->getPriority()); | ||
$this->assertIsString($subject->getTextBody()); | ||
$this->assertIsString($subject->getHtmlBody()); | ||
$this->assertIsString($subject->getEncoding()); | ||
$this->assertIsString($subject->getHtmlCharset()); | ||
$this->assertIsString($subject->getTextCharset()); | ||
} | ||
|
||
public function testEnsureBodyValidity(): void | ||
{ | ||
$subject = new Email(); | ||
$this->expectException(LogicException::class); | ||
$subject->ensureValidity(); | ||
} | ||
|
||
public function testEnsureValidity(): void | ||
{ | ||
$subject = new Email(); | ||
$subject->html('test html body'); | ||
$subject->getHeaders()->addHeader('X-Unsent', '1'); | ||
|
||
$this->expectException(LogicException::class); | ||
$subject->ensureValidity(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DotTest\Mail\Options; | ||
|
||
use Dot\Mail\Options\SmtpOptions; | ||
use DotTest\Mail\CommonTrait; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mailer\Exception\InvalidArgumentException; | ||
|
||
class SmtpOptionsTest extends TestCase | ||
{ | ||
use CommonTrait; | ||
|
||
public function testSmtpGettersAndSetters(): void | ||
{ | ||
$subject = new SmtpOptions(); | ||
|
||
$subject->setName('smtpTest'); | ||
$subject->setConnectionTimeLimit(123); | ||
|
||
$this->assertIsString($subject->getName()); | ||
$this->assertIsArray($subject->getConnectionConfig()); | ||
$this->assertIsString($subject->getHost()); | ||
$this->assertIsString($subject->getConnectionClass()); | ||
$this->assertIsInt($subject->getPort()); | ||
$this->assertIsInt($subject->getConnectionTimeLimit()); | ||
|
||
$this->expectException(InvalidArgumentException::class); | ||
$subject->setPort(0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters