Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Apr 1, 2021
1 parent c68b8d8 commit 58b6df6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-mail-preview` will be documented in this file.

## 5.2.0 - 2021-04-01

- add `assertNothingSent`

## 5.1.4 - 2021-03-12

- MailManager extension in afterResolving() for better service ordering (#73)
Expand Down
14 changes: 14 additions & 0 deletions src/SentMails/SentMails.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public function add(SentMail $sentMail): self
return $this;
}

public function reset(): self
{
$this->mails = [];

return $this;
}

public function count(): int
{
return count($this->mails);
Expand Down Expand Up @@ -81,6 +88,13 @@ public function assertSent(Closure $findMail, int $expectedCount = 1): self
return $this;
}

public function assertNothingSent(): self
{
Assert::assertCount(0, $this->all(), "Unexpected mails were sent");

return $this;
}

public function assertTimesSent(int $expectedCount, Closure $findMail): self
{
$this->assertSent($findMail, $expectedCount);
Expand Down
6 changes: 6 additions & 0 deletions tests/Feature/SentMailsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public function it_can_get_all_mails()
SentMails::assertCount(1);
}

/** @test */
public function it_can_assert_that_nothing_was_sent()
{
SentMails::reset()->assertNothingSent();
}

/** @test */
public function it_can_make_an_assertion_on_the_latest_mail()
{
Expand Down

0 comments on commit 58b6df6

Please sign in to comment.