Skip to content

Commit

Permalink
[BC BREAK] remove TestMailer::sentTestEmails()
Browse files Browse the repository at this point in the history
use TestMailer::sentEmails()->all() instead
  • Loading branch information
kbond committed Oct 7, 2021
1 parent 1ad786e commit 59b0ce5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
15 changes: 0 additions & 15 deletions src/TestMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Symfony\Component\Mailer\Event\MessageEvent;
use Symfony\Component\Mailer\Event\MessageEvents;
use Symfony\Component\Mime\Email;

/**
* @author Kevin Bond <kevinbond@gmail.com>
Expand Down Expand Up @@ -48,20 +47,6 @@ public function sentEmails(): SentEmails
return SentEmails::fromEvents(self::$events);
}

/**
* @return TestEmail[]
*/
public function sentTestEmails(string $testEmailClass = TestEmail::class): array
{
// todo deprecate/remove

if (!\is_a($testEmailClass, TestEmail::class, true)) {
throw new \InvalidArgumentException(\sprintf('$testEmailClass must be a class that\'s an instance of "%s".', TestEmail::class));
}

return \array_map(static fn(Email $email) => new $testEmailClass($email), $this->sentEmails()->all());
}

/**
* Reset the collected emails.
*/
Expand Down
4 changes: 3 additions & 1 deletion tests/InteractsWithMailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ public function sent_test_email_argument_must_be_an_instance_of_test_email(): vo
{
self::bootKernel();

self::$container->get('mailer')->send(new Email1());

$this->expectException(\InvalidArgumentException::class);

$this->mailer()->sentTestEmails(\stdClass::class);
$this->mailer()->sentEmails()->all(\stdClass::class);
}

/**
Expand Down

0 comments on commit 59b0ce5

Please sign in to comment.