MailFake

class MailFake implements Factory, Mailer, MailQueue (View source)

Traits

ReflectsClosures

Properties

protected string $currentMailer The mailer currently being used to send a message.
protected array $mailables All of the mailables that have been sent.
protected array $queuedMailables All of the mailables that have been queued.

Methods

array closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

from ReflectsClosures
string firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

from ReflectsClosures
void assertSent(string|Closure $mailable, callable|int|null $callback = null)

Assert if a mailable was sent based on a truth-test callback.

void assertSentTimes(string $mailable, int $times = 1)

Assert if a mailable was sent a number of times.

void assertNotSent(string $mailable, callable|null $callback = null)

Determine if a mailable was not sent based on a truth-test callback.

void assertNothingSent()

Assert that no mailables were sent.

void assertQueued(string|Closure $mailable, callable|int|null $callback = null)

Assert if a mailable was queued based on a truth-test callback.

void assertQueuedTimes(string $mailable, int $times = 1)

Assert if a mailable was queued a number of times.

void assertNotQueued(string $mailable, callable|null $callback = null)

Determine if a mailable was not queued based on a truth-test callback.

void assertNothingQueued()

Assert that no mailables were queued.

Collection sent(string $mailable, callable|null $callback = null)

Get all of the mailables matching a truth-test callback.

bool hasSent(string $mailable)

Determine if the given mailable has been sent.

Collection queued(string $mailable, callable|null $callback = null)

Get all of the queued mailables matching a truth-test callback.

bool hasQueued(string $mailable)

Determine if the given mailable has been queued.

Collection mailablesOf(string $type)

Get all of the mailed mailables for a given type.

Collection queuedMailablesOf(string $type)

Get all of the mailed mailables for a given type.

Mailer mailer(string|null $name = null)

Get a mailer instance by name.

PendingMail to(mixed $users)

Begin the process of mailing a mailable class instance.

PendingMail bcc(mixed $users)

Begin the process of mailing a mailable class instance.

void raw(string $text, mixed $callback)

Send a new message with only a raw text part.

void send(Mailable|string|array $view, array $data = [], Closure|string|null $callback = null)

Send a new message using a view.

mixed queue(Mailable|string|array $view, string|null $queue = null)

Queue a new e-mail message for sending.

mixed later(DateTimeInterface|DateInterval|int $delay, Mailable|string|array $view, string|null $queue = null)

Queue a new e-mail message for sending after (n) seconds.

array failures()

Get the array of failed recipients.

Details

protected array closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

protected string firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

Parameters

Closure $closure

Return Value

string

Exceptions

RuntimeException

void assertSent(string|Closure $mailable, callable|int|null $callback = null)

Assert if a mailable was sent based on a truth-test callback.

Parameters

string|Closure $mailable
callable|int|null $callback

Return Value

void

protected void assertSentTimes(string $mailable, int $times = 1)

Assert if a mailable was sent a number of times.

Parameters

string $mailable
int $times

Return Value

void

void assertNotSent(string $mailable, callable|null $callback = null)

Determine if a mailable was not sent based on a truth-test callback.

Parameters

string $mailable
callable|null $callback

Return Value

void

void assertNothingSent()

Assert that no mailables were sent.

Return Value

void

void assertQueued(string|Closure $mailable, callable|int|null $callback = null)

Assert if a mailable was queued based on a truth-test callback.

Parameters

string|Closure $mailable
callable|int|null $callback

Return Value

void

protected void assertQueuedTimes(string $mailable, int $times = 1)

Assert if a mailable was queued a number of times.

Parameters

string $mailable
int $times

Return Value

void

void assertNotQueued(string $mailable, callable|null $callback = null)

Determine if a mailable was not queued based on a truth-test callback.

Parameters

string $mailable
callable|null $callback

Return Value

void

void assertNothingQueued()

Assert that no mailables were queued.

Return Value

void

Collection sent(string $mailable, callable|null $callback = null)

Get all of the mailables matching a truth-test callback.

Parameters

string $mailable
callable|null $callback

Return Value

Collection

bool hasSent(string $mailable)

Determine if the given mailable has been sent.

Parameters

string $mailable

Return Value

bool

Collection queued(string $mailable, callable|null $callback = null)

Get all of the queued mailables matching a truth-test callback.

Parameters

string $mailable
callable|null $callback

Return Value

Collection

bool hasQueued(string $mailable)

Determine if the given mailable has been queued.

Parameters

string $mailable

Return Value

bool

protected Collection mailablesOf(string $type)

Get all of the mailed mailables for a given type.

Parameters

string $type

Return Value

Collection

protected Collection queuedMailablesOf(string $type)

Get all of the mailed mailables for a given type.

Parameters

string $type

Return Value

Collection

Mailer mailer(string|null $name = null)

Get a mailer instance by name.

Parameters

string|null $name

Return Value

Mailer

PendingMail to(mixed $users)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users

Return Value

PendingMail

PendingMail bcc(mixed $users)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users

Return Value

PendingMail

void raw(string $text, mixed $callback)

Send a new message with only a raw text part.

Parameters

string $text
mixed $callback

Return Value

void

void send(Mailable|string|array $view, array $data = [], Closure|string|null $callback = null)

Send a new message using a view.

Parameters

Mailable|string|array $view
array $data
Closure|string|null $callback

Return Value

void

mixed queue(Mailable|string|array $view, string|null $queue = null)

Queue a new e-mail message for sending.

Parameters

Mailable|string|array $view
string|null $queue

Return Value

mixed

mixed later(DateTimeInterface|DateInterval|int $delay, Mailable|string|array $view, string|null $queue = null)

Queue a new e-mail message for sending after (n) seconds.

Parameters

DateTimeInterface|DateInterval|int $delay
Mailable|string|array $view
string|null $queue

Return Value

mixed

array failures()

Get the array of failed recipients.

Return Value

array

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/7.x/Illuminate/Support/Testing/Fakes/MailFake.html