Skip to content

Commit

Permalink
Add sentFrom search criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-mailosaur committed Oct 19, 2020
1 parent 0b6bf66 commit 6c3eca4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Models/SearchCriteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

class SearchCriteria
{
/**
* @var string The full email address from which the target email was sent.
*/
public $sentFrom = null;

/**
* @var string The full email address to which the target email was sent.
*/
Expand All @@ -30,6 +35,7 @@ class SearchCriteria
public function __toArray()
{
return array(
'sentFrom' => $this->sentFrom,
'sentTo' => $this->sentTo,
'subject' => $this->subject,
'body' => $this->body,
Expand Down
25 changes: 25 additions & 0 deletions tests/EmailsTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,31 @@ public function testSearchNoCriteriaError()
$this->client->messages->search($this->server, new SearchCriteria());
}

public function testSearchBySentFrom()
{
$targetEmail = $this->emails[1];

$criteria = new SearchCriteria();

$criteria->sentFrom = $targetEmail->from[0]->email;

$results = $this->client->messages->search($this->server, $criteria)->items;

$this->assertCount(1, $results);
$this->assertEquals($targetEmail->from[0]->email, $results[0]->from[0]->email);
$this->assertEquals($targetEmail->subject, $results[0]->subject);
}

public function testSearchBySentFromInvalidEmail()
{
$this->expectException(\Mailosaur\Models\MailosaurException::class);

$criteria = new SearchCriteria();
$criteria->sentFrom = '.not_an_email_address';

$this->client->messages->search($this->server, $criteria);
}

public function testSearchBySentTo()
{
$targetEmail = $this->emails[1];
Expand Down

0 comments on commit 6c3eca4

Please sign in to comment.