class MailFake implements Factory, Fake, Mailer, MailQueue

Traits

Properties

protected string|null $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

mixed
forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

static never
throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

string
firstClosureParameterType(Closure $closure)

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

array
firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

array
closureParameterTypes(Closure $closure)

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

array
closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

__construct(MailManager $manager)

Create a new mail fake.

void
assertSent(Closure|string $mailable, array|callable|int|string|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
assertSentOnce(string $mailable)

Assert if a mailable was sent exactly once.

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

Determine if a mailable was not sent or queued to be sent based on a truth-test callback.

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

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

void
assertNothingOutgoing()

Assert that no mailables were sent or queued to be sent.

void
assertNothingSent()

Assert that no mailables were sent.

void
assertQueued(Closure|string $mailable, array|callable|int|string|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
assertQueuedOnce(string $mailable)

Assert if a mailable was queued exactly once.

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

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

void
assertNothingQueued()

Assert that no mailables were queued.

void
assertSentCount(int $count)

Assert the total number of mailables that were sent.

void
assertQueuedCount(int $count)

Assert the total number of mailables that were queued.

void
assertOutgoingCount(int $count)

Assert the total number of mailables that were sent or queued.

sent(Closure|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.

queued(Closure|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.

mailablesOf(string $type)

Get all of the mailed mailables for a given type.

queuedMailablesOf(string $type)

Get all of the mailed mailables for a given type.

mailer(UnitEnum|string|null $name = null)

Get a mailer instance by name.

driver(UnitEnum|string|null $driver = null)

Get a mailer driver instance.

to(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

cc(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

bcc(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

html(string $html, Closure|string $callback)

Send a new message with only an HTML part.

raw(string $text, Closure|string $callback)

Send a new message with only a raw text part.

plain(string $view, array $data, Closure|string $callback)

Send a new message with only a plain part.

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

Send a new message using a view.

sendNow(array|Mailable|string $mailable, array $data = [], Closure|string|null $callback = null)

Send a new message synchronously using a view.

mixed
sendMail(array|Mailable|string $view, bool $shouldQueue = false)

Send a new message using a view.

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

Queue a new message for sending.

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

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

mixed
onQueue(UnitEnum|string|null $queue, Mailable $view)

Queue a new mail message for sending on the given queue.

mixed
queueOn(UnitEnum|string $queue, Mailable $view)

Queue a new mail message for sending on the given queue.

mixed
laterOn(UnitEnum|string $queue, DateInterval|DateTimeInterface|int $delay, Mailable $view)

Queue a new mail message for sending after (n) seconds on the given queue.

array
prepareMailableAndCallback(Closure|string $mailable, array|callable|int|string|null $callback)

Infer mailable class using reflection if a typehinted closure is passed to assertion.

string
pullCurrentMailer()

Get and clear the mailer for the current operation.

forgetMailers()

Forget all of the resolved mailer instances.

mixed
__call(string $method, array $parameters)

Handle dynamic method calls to the mailer.

Details

in ForwardsCalls at line 22
protected mixed forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 52
protected mixed forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 66
static protected never throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

never

Exceptions

BadMethodCallException

in ReflectsClosures at line 26
protected string firstClosureParameterType(Closure $closure)

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

Parameters

Closure $closure

Return Value

string

Exceptions

ReflectionException
RuntimeException

in ReflectsClosures at line 49
protected array firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException
RuntimeException

in ReflectsClosures at line 75
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

in ReflectsClosures at line 97
protected array closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

at line 53
__construct(MailManager $manager)

Create a new mail fake.

Parameters

MailManager $manager

at line 61
void assertSent(Closure|string $mailable, array|callable|int|string|null $callback = null)

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

Parameters

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

Return Value

void

at line 94
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

at line 112
void assertSentOnce(string $mailable)

Assert if a mailable was sent exactly once.

Parameters

string $mailable

Return Value

void

at line 120
void assertNotOutgoing(Closure|string $mailable, callable|null $callback = null)

Determine if a mailable was not sent or queued to be sent based on a truth-test callback.

Parameters

Closure|string $mailable
callable|null $callback

Return Value

void

at line 129
void assertNotSent(Closure|string $mailable, array|callable|string|null $callback = null)

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

Parameters

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

Return Value

void

at line 157
void assertNothingOutgoing()

Assert that no mailables were sent or queued to be sent.

Return Value

void

at line 166
void assertNothingSent()

Assert that no mailables were sent.

Return Value

void

at line 178
void assertQueued(Closure|string $mailable, array|callable|int|string|null $callback = null)

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

Parameters

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

Return Value

void

at line 209
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

at line 227
void assertQueuedOnce(string $mailable)

Assert if a mailable was queued exactly once.

Parameters

string $mailable

Return Value

void

at line 235
void assertNotQueued(Closure|string $mailable, array|callable|string|null $callback = null)

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

Parameters

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

Return Value

void

at line 263
void assertNothingQueued()

Assert that no mailables were queued.

Return Value

void

at line 275
void assertSentCount(int $count)

Assert the total number of mailables that were sent.

Parameters

int $count

Return Value

void

at line 289
void assertQueuedCount(int $count)

Assert the total number of mailables that were queued.

Parameters

int $count

Return Value

void

at line 303
void assertOutgoingCount(int $count)

Assert the total number of mailables that were sent or queued.

Parameters

int $count

Return Value

void

at line 319
Collection sent(Closure|string $mailable, callable|null $callback = null)

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

Parameters

Closure|string $mailable
callable|null $callback

Return Value

Collection

at line 335
bool hasSent(string $mailable)

Determine if the given mailable has been sent.

Parameters

string $mailable

Return Value

bool

at line 343
Collection queued(Closure|string $mailable, callable|null $callback = null)

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

Parameters

Closure|string $mailable
callable|null $callback

Return Value

Collection

at line 359
bool hasQueued(string $mailable)

Determine if the given mailable has been queued.

Parameters

string $mailable

Return Value

bool

at line 367
protected Collection mailablesOf(string $type)

Get all of the mailed mailables for a given type.

Parameters

string $type

Return Value

Collection

at line 375
protected Collection queuedMailablesOf(string $type)

Get all of the mailed mailables for a given type.

Parameters

string $type

Return Value

Collection

at line 383
Mailer mailer(UnitEnum|string|null $name = null)

Get a mailer instance by name.

Parameters

UnitEnum|string|null $name

Return Value

Mailer

at line 397
Mailer driver(UnitEnum|string|null $driver = null)

Get a mailer driver instance.

Parameters

UnitEnum|string|null $driver

Return Value

Mailer

at line 405
PendingMail to(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users
string|null $name

Return Value

PendingMail

at line 417
PendingMail cc(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users
string|null $name

Return Value

PendingMail

at line 429
PendingMail bcc(mixed $users, string|null $name = null)

Begin the process of mailing a mailable class instance.

Parameters

mixed $users
string|null $name

Return Value

PendingMail

at line 441
SentMessage|null html(string $html, Closure|string $callback)

Send a new message with only an HTML part.

Parameters

string $html
Closure|string $callback

Return Value

SentMessage|null

at line 451
SentMessage|null raw(string $text, Closure|string $callback)

Send a new message with only a raw text part.

Parameters

string $text
Closure|string $callback

Return Value

SentMessage|null

at line 461
SentMessage|null plain(string $view, array $data, Closure|string $callback)

Send a new message with only a plain part.

Parameters

string $view
array $data
Closure|string $callback

Return Value

SentMessage|null

at line 471
SentMessage|null send(array|Mailable|string $view, array $data = [], Closure|string|null $callback = null)

Send a new message using a view.

Parameters

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

Return Value

SentMessage|null

at line 481
SentMessage|null sendNow(array|Mailable|string $mailable, array $data = [], Closure|string|null $callback = null)

Send a new message synchronously using a view.

Parameters

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

Return Value

SentMessage|null

at line 491
protected mixed sendMail(array|Mailable|string $view, bool $shouldQueue = false)

Send a new message using a view.

Parameters

array|Mailable|string $view
bool $shouldQueue

Return Value

mixed

at line 515
mixed queue(array|Mailable|string $view, UnitEnum|string|null $queue = null)

Queue a new message for sending.

Parameters

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

Return Value

mixed

Exceptions

InvalidArgumentException

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

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

Parameters

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

Return Value

mixed

Exceptions

InvalidArgumentException

at line 548
mixed onQueue(UnitEnum|string|null $queue, Mailable $view)

Queue a new mail message for sending on the given queue.

Parameters

UnitEnum|string|null $queue
Mailable $view

Return Value

mixed

at line 556
mixed queueOn(UnitEnum|string $queue, Mailable $view)

Queue a new mail message for sending on the given queue.

Parameters

UnitEnum|string $queue
Mailable $view

Return Value

mixed

at line 564
mixed laterOn(UnitEnum|string $queue, DateInterval|DateTimeInterface|int $delay, Mailable $view)

Queue a new mail message for sending after (n) seconds on the given queue.

Parameters

UnitEnum|string $queue
DateInterval|DateTimeInterface|int $delay
Mailable $view

Return Value

mixed

at line 572
protected array prepareMailableAndCallback(Closure|string $mailable, array|callable|int|string|null $callback)

Infer mailable class using reflection if a typehinted closure is passed to assertion.

Parameters

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

Return Value

array

at line 584
protected string pullCurrentMailer()

Get and clear the mailer for the current operation.

Return Value

string

at line 595
MailFake forgetMailers()

Forget all of the resolved mailer instances.

Return Value

MailFake

at line 605
mixed __call(string $method, array $parameters)

Handle dynamic method calls to the mailer.

Parameters

string $method
array $parameters

Return Value

mixed