-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from PhantPHP/Email-recipients
Email to recipents list
- Loading branch information
Showing
5 changed files
with
75 additions
and
18 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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phant\DataStructure\Web; | ||
|
||
use Phant\DataStructure\Web\EmailAddressAndName; | ||
|
||
class EmailAddressAndNameList extends \Phant\DataStructure\Abstract\Collection | ||
{ | ||
final public function add( | ||
EmailAddressAndName $emailAddressAndName | ||
): self { | ||
return $this->addItem($emailAddressAndName); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Web; | ||
|
||
use Phant\DataStructure\Web\{ | ||
EmailAddress, | ||
EmailAddressAndName, | ||
EmailAddressAndNameList, | ||
}; | ||
|
||
final class EmailAddressAndNameListTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
protected EmailAddressAndNameList $fixture; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->fixture = new EmailAddressAndNameList(); | ||
} | ||
|
||
public function testAdd(): void | ||
{ | ||
$this->assertEquals(0, $this->fixture->getNbItems()); | ||
|
||
$this->fixture->add( | ||
new EmailAddressAndName( | ||
new EmailAddress('[email protected]'), | ||
'John DOE' | ||
) | ||
); | ||
|
||
$this->assertEquals(1, $this->fixture->getNbItems()); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
Email, | ||
EmailAddress, | ||
EmailAddressAndName, | ||
EmailAddressAndNameList, | ||
EmailAttachment, | ||
EmailAttachmentList, | ||
}; | ||
|
@@ -39,9 +40,11 @@ public function testInterface(): void | |
new EmailAddress('[email protected]'), | ||
'Acme' | ||
), | ||
new EmailAddressAndName( | ||
new EmailAddress('[email protected]'), | ||
'John DOE' | ||
(new EmailAddressAndNameList())->add( | ||
new EmailAddressAndName( | ||
new EmailAddress('[email protected]'), | ||
'John DOE' | ||
) | ||
), | ||
new EmailAddressAndName( | ||
new EmailAddress('[email protected]'), | ||
|
@@ -65,9 +68,10 @@ public function testInterface(): void | |
$this->assertEquals('Acme', $email->from->name); | ||
|
||
$this->assertIsObject($email->to); | ||
$this->assertInstanceOf(EmailAddressAndName::class, $email->to); | ||
$this->assertEquals('[email protected]', (string)$email->to->emailAddress); | ||
$this->assertEquals('John DOE', $email->to->name); | ||
$this->assertInstanceOf(EmailAddressAndNameList::class, $email->to); | ||
$to = $email->to->itemsIterator()->current(); | ||
$this->assertEquals('[email protected]', (string)$to->emailAddress); | ||
$this->assertEquals('John DOE', $to->name); | ||
|
||
$this->assertIsObject($email->replyTo); | ||
$this->assertInstanceOf(EmailAddressAndName::class, $email->replyTo); | ||
|
@@ -110,9 +114,10 @@ public function testMake(): void | |
$this->assertEquals('Acme', $email->from->name); | ||
|
||
$this->assertIsObject($email->to); | ||
$this->assertInstanceOf(EmailAddressAndName::class, $email->to); | ||
$this->assertEquals('[email protected]', (string)$email->to->emailAddress); | ||
$this->assertEquals('John DOE', $email->to->name); | ||
$this->assertInstanceOf(EmailAddressAndNameList::class, $email->to); | ||
$to = $email->to->itemsIterator()->current(); | ||
$this->assertEquals('[email protected]', (string)$to->emailAddress); | ||
$this->assertEquals('John DOE', $to->name); | ||
|
||
$this->assertIsObject($email->replyTo); | ||
$this->assertInstanceOf(EmailAddressAndName::class, $email->replyTo); | ||
|
@@ -152,9 +157,10 @@ public function testMakeBasic(): void | |
$this->assertNull($email->from->name); | ||
|
||
$this->assertIsObject($email->to); | ||
$this->assertInstanceOf(EmailAddressAndName::class, $email->to); | ||
$this->assertEquals('[email protected]', (string)$email->to->emailAddress); | ||
$this->assertNull($email->to->name); | ||
$this->assertInstanceOf(EmailAddressAndNameList::class, $email->to); | ||
$to = $email->to->itemsIterator()->current(); | ||
$this->assertEquals('[email protected]', (string)$to->emailAddress); | ||
$this->assertNull($to->name); | ||
|
||
$this->assertNull($email->replyTo); | ||
|
||
|