Skip to content

Commit

Permalink
Merge pull request #740 from smrtab/master
Browse files Browse the repository at this point in the history
Fixes #739 Wrong condition
  • Loading branch information
thinkingserious authored Oct 22, 2018
2 parents dc9dba2 + 6f0b19a commit 77f4c12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/mail/EmailAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function __construct(
*/
public function setEmailAddress($emailAddress)
{
if (!is_string($emailAddress) &&
filter_var($emailAddress, FILTER_VALIDATE_EMAIL)
if (!(is_string($emailAddress) &&
filter_var($emailAddress, FILTER_VALIDATE_EMAIL))
) {
throw new TypeException(
'$emailAddress must be valid and of type string.'
Expand Down
11 changes: 11 additions & 0 deletions test/unit/MailHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,15 @@ public function testEmailName()
'{"name":"\\"O\'Keeffe, John \\\\\\"Billy\\\\\\"\\"","email":"[email protected]"}'
);
}

/**
* This method tests TypeException for wrong email address
*
* @expectedException \SendGrid\Mail\TypeException
*/
public function testEmailAddress()
{
$email = new EmailAddress();
$email->setEmailAddress('[email protected]@wrong');
}
}

0 comments on commit 77f4c12

Please sign in to comment.