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

Traits

Properties

MailManager $manager

The mailer instance.

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

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 void
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.

void
__construct(MailManager $manager)

Create a new mail fake.

void
assertSent(string|Closure $mailable, callable|array|string|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
assertNotOutgoing(string|Closure $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(string|Closure $mailable, callable|array|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(string|Closure $mailable, callable|array|string|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|Closure $mailable, callable|array|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(string|Closure $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(string|Closure $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(string|null $name = null)

Get a mailer instance by name.

to(mixed $users)

Begin the process of mailing a mailable class instance.

cc(mixed $users)

Begin the process of mailing a mailable class instance.

bcc(mixed $users)

Begin the process of mailing a mailable class instance.

raw(string $text, mixed $callback)

Send a new message with only a raw text part.

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

Send a new message using a view.

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

Send a new message synchronously using a view.

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

Send a new message using a view.

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

Queue a new 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
prepareMailableAndCallback(string|Closure $mailable, callable|null $callback)

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

$this
forgetMailers()

Forget all of the resolved mailer instances.

mixed
__call(string $method, array $parameters)

Handle dynamic method calls to the mailer.

Details

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

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

static protected void throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

void

Exceptions

BadMethodCallException

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

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

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

void __construct(MailManager $manager)

Create a new mail fake.

Parameters

MailManager $manager

Return Value

void

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

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

Parameters

string|Closure $mailable
callable|array|string|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 assertNotOutgoing(string|Closure $mailable, callable|null $callback = null)

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

Parameters

string|Closure $mailable
callable|null $callback

Return Value

void

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

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

Parameters

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

Return Value

void

void assertNothingOutgoing()

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

Return Value

void

void assertNothingSent()

Assert that no mailables were sent.

Return Value

void

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

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

Parameters

string|Closure $mailable
callable|array|string|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|Closure $mailable, callable|array|string|null $callback = null)

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

Parameters

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

Return Value

void

void assertNothingQueued()

Assert that no mailables were queued.

Return Value

void

void assertSentCount(int $count)

Assert the total number of mailables that were sent.

Parameters

int $count

Return Value

void

void assertQueuedCount(int $count)

Assert the total number of mailables that were queued.

Parameters

int $count

Return Value

void

void assertOutgoingCount(int $count)

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

Parameters

int $count

Return Value

void

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

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

Parameters

string|Closure $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|Closure $mailable, callable|null $callback = null)

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

Parameters

string|Closure $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 cc(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

SentMessage|null raw(string $text, mixed $callback)

Send a new message with only a raw text part.

Parameters

string $text
mixed $callback

Return Value

SentMessage|null

SentMessage|null 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

SentMessage|null

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

Send a new message synchronously using a view.

Parameters

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

Return Value

SentMessage|null

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

Send a new message using a view.

Parameters

Mailable|string|array $view
bool $shouldQueue

Return Value

mixed|void

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

Queue a new 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

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

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

Parameters

string|Closure $mailable
callable|null $callback

Return Value

array

$this forgetMailers()

Forget all of the resolved mailer instances.

Return Value

$this

mixed __call(string $method, array $parameters)

Handle dynamic method calls to the mailer.

Parameters

string $method
array $parameters

Return Value

mixed