class NotificationFake implements Fake, Dispatcher, Factory (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected array $notifications

All of the notifications that have been sent.

string|null $locale

Locale used when sending notifications.

protected bool $serializeAndRestore

Indicates if notifications should be serialized and restored when pushed to the queue.

Methods

static void
macro(string $name, object|callable $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Checks if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

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

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

void
assertSentTo(mixed $notifiable, string|Closure $notification, callable|null $callback = null)

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

void
assertSentOnDemandTimes(string $notification, int $times = 1)

Assert if a notification was sent on-demand a number of times.

void
assertSentToTimes(mixed $notifiable, string $notification, int $times = 1)

Assert if a notification was sent a number of times.

void
assertNotSentTo(mixed $notifiable, string|Closure $notification, callable|null $callback = null)

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

void
assertNothingSent()

Assert that no notifications were sent.

void
assertNothingSentTo(mixed $notifiable)

Assert that no notifications were sent to the given notifiable.

void
assertSentTimes(string $notification, int $expectedCount)

Assert the total amount of times a notification was sent.

void
assertCount(int $expectedCount)

Assert the total count of notification that were sent.

sent(mixed $notifiable, string $notification, callable|null $callback = null)

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

bool
hasSent(mixed $notifiable, string $notification)

Determine if there are more notifications left to inspect.

array
notificationsFor(mixed $notifiable, string $notification)

Get all of the notifications for a notifiable entity by type.

void
send(Collection|array|mixed $notifiables, mixed $notification)

Send the given notification to the given notifiable entities.

void
sendNow(Collection|array|mixed $notifiables, mixed $notification, array|null $channels = null)

Send the given notification immediately.

mixed
channel(string|null $name = null)

Get a channel instance by name.

$this
locale(string $locale)

Set the locale of notifications.

$this
serializeAndRestore(bool $serializeAndRestore = true)

Specify if notification should be serialized and restored when being "pushed" to the queue.

mixed
serializeAndRestoreNotification(mixed $notification)

Serialize and unserialize the notification to simulate the queueing process.

array
sentNotifications()

Get the notifications that have been sent.

Details

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

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

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

Parameters

string|Closure $notification
callable|null $callback

Return Value

void

Exceptions

Exception

void assertSentTo(mixed $notifiable, string|Closure $notification, callable|null $callback = null)

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

Parameters

mixed $notifiable
string|Closure $notification
callable|null $callback

Return Value

void

Exceptions

Exception

void assertSentOnDemandTimes(string $notification, int $times = 1)

Assert if a notification was sent on-demand a number of times.

Parameters

string $notification
int $times

Return Value

void

void assertSentToTimes(mixed $notifiable, string $notification, int $times = 1)

Assert if a notification was sent a number of times.

Parameters

mixed $notifiable
string $notification
int $times

Return Value

void

void assertNotSentTo(mixed $notifiable, string|Closure $notification, callable|null $callback = null)

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

Parameters

mixed $notifiable
string|Closure $notification
callable|null $callback

Return Value

void

Exceptions

Exception

void assertNothingSent()

Assert that no notifications were sent.

Return Value

void

void assertNothingSentTo(mixed $notifiable)

Assert that no notifications were sent to the given notifiable.

Parameters

mixed $notifiable

Return Value

void

Exceptions

Exception

void assertSentTimes(string $notification, int $expectedCount)

Assert the total amount of times a notification was sent.

Parameters

string $notification
int $expectedCount

Return Value

void

void assertCount(int $expectedCount)

Assert the total count of notification that were sent.

Parameters

int $expectedCount

Return Value

void

Collection sent(mixed $notifiable, string $notification, callable|null $callback = null)

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

Parameters

mixed $notifiable
string $notification
callable|null $callback

Return Value

Collection

bool hasSent(mixed $notifiable, string $notification)

Determine if there are more notifications left to inspect.

Parameters

mixed $notifiable
string $notification

Return Value

bool

protected array notificationsFor(mixed $notifiable, string $notification)

Get all of the notifications for a notifiable entity by type.

Parameters

mixed $notifiable
string $notification

Return Value

array

void send(Collection|array|mixed $notifiables, mixed $notification)

Send the given notification to the given notifiable entities.

Parameters

Collection|array|mixed $notifiables
mixed $notification

Return Value

void

void sendNow(Collection|array|mixed $notifiables, mixed $notification, array|null $channels = null)

Send the given notification immediately.

Parameters

Collection|array|mixed $notifiables
mixed $notification
array|null $channels

Return Value

void

mixed channel(string|null $name = null)

Get a channel instance by name.

Parameters

string|null $name

Return Value

mixed

$this locale(string $locale)

Set the locale of notifications.

Parameters

string $locale

Return Value

$this

$this serializeAndRestore(bool $serializeAndRestore = true)

Specify if notification should be serialized and restored when being "pushed" to the queue.

Parameters

bool $serializeAndRestore

Return Value

$this

protected mixed serializeAndRestoreNotification(mixed $notification)

Serialize and unserialize the notification to simulate the queueing process.

Parameters

mixed $notification

Return Value

mixed

array sentNotifications()

Get the notifications that have been sent.

Return Value

array