add Emailer and EmailFactory interfaces with laravel + fake impls

This commit is contained in:
Yisroel Baum 2026-05-06 22:06:30 +03:00
parent e16cb45387
commit 2890781a56
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
6 changed files with 104 additions and 0 deletions

View file

@ -0,0 +1,13 @@
<?php
namespace Tests\Fakes;
use App\Email\EmailFactory;
class FakeEmailFactory implements EmailFactory
{
public function makeConfirmationEmail(string $token): string
{
return "confirm:{$token}";
}
}

View file

@ -0,0 +1,35 @@
<?php
namespace Tests\Fakes;
use App\Email\Emailer;
class FakeEmailer implements Emailer
{
/**
* @var array<int, array{from: string, to: string, body: string}>
*/
private array $sentEmails = [];
public function send(string $from, string $to, string $body): void
{
$this->sentEmails[] = [
'from' => $from,
'to' => $to,
'body' => $body,
];
}
public function getNumberOfEmailsSent(): int
{
return count($this->sentEmails);
}
/**
* @return array<int, array{from: string, to: string, body: string}>
*/
public function getSentEmails(): array
{
return $this->sentEmails;
}
}