Skip to content

Commit

Permalink
Added assertContains deprecation coverage if using phpunit < 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonferens committed Mar 11, 2020
1 parent a5020c9 commit cac3e74
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

All notable changes to `mail-intercept` will be documented in this file

## 0.1.0 - 2019-12-06
## 0.2.2 - 2020-03-11

- Initial release
- Added coverage for string assertion deprecations if using PHPUnit < 8.0

## 0.2.1 - 2020-03-11

- Fixed composer install command

## 0.2.0 - 2020-02-06

- Added new assertions for sender, cc, bcc, content type, and reply to
- Refactored to, from, and subject to use different getters
- Update readme to include new assertions

## 0.1.0 - 2019-12-06

- Initial release
14 changes: 11 additions & 3 deletions src/Assertions/ContentAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,30 @@ trait ContentAssertions
*/
public function assertMailBodyContainsString(string $needle, Swift_Message $mail)
{
$this->assertStringContainsString(
$method = method_exists($this, 'assertStringContainsString')
? 'assertStringContainsString'
: 'assertContains';

$this->{$method}(
$needle,
$mail->getBody(),
"The expected [{$needle}] string was not found in the body."
);
}

/**
* Assert mail body contains string.
* Assert mail body does not contain string.
*
* @param string $needle
* @param Swift_Message $mail
*/
public function assertMailBodyNotContainsString(string $needle, Swift_Message $mail)
{
$this->assertStringNotContainsString(
$method = method_exists($this, 'assertStringNotContainsString')
? 'assertStringNotContainsString'
: 'assertNotContains';

$this->{$method}(
$needle,
$mail->getBody(),
"The expected [{$needle}] string was found in the body."
Expand Down

0 comments on commit cac3e74

Please sign in to comment.