class NotificationFake implements Fake, Dispatcher, Factory

Traits

Constants

protected LOCALES_CONTEXT_KEY

Context key for one-send locale overrides owned by individual fakes.

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, callable|object $macro)

Register a custom macro.

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

Mix another object into the class.

static bool
hasMacro(string $name)

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

callable|null
resolveTruthTest(callable|array|null $callback)

Resolve a truth-test callback or an array of expected properties.

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.

void
assertSentOnDemand(Closure|string $notification, callable|array|null $callback = null)

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

void
assertSentTo(mixed $notifiable, Closure|string $notification, callable|array|int|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
assertSentOnDemandOnce(string $notification)

Assert if a notification was sent on-demand exactly once.

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

Assert if a notification was sent a number of times.

void
assertSentToOnce(mixed $notifiable, string $notification)

Assert if a notification was sent exactly once.

void
assertNotSentTo(mixed $notifiable, Closure|string $notification, callable|array|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|array|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(mixed $notifiables, mixed $notification)

Send the given notification to the given notifiable entities.

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

Send the given notification immediately.

mixed
channel(UnitEnum|string|null $name = null)

Get a channel instance by name.

locale(string $locale)

Set the locale of notifications.

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.

static void
flushState()

Flush all static state.

Details

in Macroable at line 30
static void macro(string $name, callable|object $macro)

Register a custom macro.

Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 44
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 61
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 72
static void flushMacros()

Flush the existing macros.

Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 83
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 108
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in MatchesProperties at line 19
protected callable|null resolveTruthTest(callable|array|null $callback)

Resolve a truth-test callback or an array of expected properties.

Parameters

callable|array|null $callback

Return Value

callable|null

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

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

Parameters

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

Return Value

void

Exceptions

Exception

at line 89
void assertSentTo(mixed $notifiable, Closure|string $notification, callable|array|int|null $callback = null)

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

Parameters

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

Return Value

void

Exceptions

Exception

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

at line 129
void assertSentOnDemandOnce(string $notification)

Assert if a notification was sent on-demand exactly once.

Parameters

string $notification

Return Value

void

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

at line 151
void assertSentToOnce(mixed $notifiable, string $notification)

Assert if a notification was sent exactly once.

Parameters

mixed $notifiable
string $notification

Return Value

void

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

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

Parameters

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

Return Value

void

Exceptions

Exception

at line 191
void assertNothingSent()

Assert that no notifications were sent.

Return Value

void

at line 208
void assertNothingSentTo(mixed $notifiable)

Assert that no notifications were sent to the given notifiable.

Parameters

mixed $notifiable

Return Value

void

Exceptions

Exception

at line 231
void assertSentTimes(string $notification, int $expectedCount)

Assert the total amount of times a notification was sent.

Parameters

string $notification
int $expectedCount

Return Value

void

at line 251
void assertCount(int $expectedCount)

Assert the total count of notification that were sent.

Parameters

int $expectedCount

Return Value

void

at line 267
Collection sent(mixed $notifiable, string $notification, callable|array|null $callback = null)

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

Parameters

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

Return Value

Collection

at line 285
bool hasSent(mixed $notifiable, string $notification)

Determine if there are more notifications left to inspect.

Parameters

mixed $notifiable
string $notification

Return Value

bool

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

at line 301
void send(mixed $notifiables, mixed $notification)

Send the given notification to the given notifiable entities.

Parameters

mixed $notifiables
mixed $notification

Return Value

void

at line 309
void sendNow(mixed $notifiables, mixed $notification, array|null $channels = null)

Send the given notification immediately.

Parameters

mixed $notifiables
mixed $notification
array|null $channels

Return Value

void

at line 354
mixed channel(UnitEnum|string|null $name = null)

Get a channel instance by name.

Parameters

UnitEnum|string|null $name

Return Value

mixed

at line 364
NotificationFake locale(string $locale)

Set the locale of notifications.

Parameters

string $locale

Return Value

NotificationFake

at line 376
NotificationFake serializeAndRestore(bool $serializeAndRestore = true)

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

Parameters

bool $serializeAndRestore

Return Value

NotificationFake

at line 386
protected mixed serializeAndRestoreNotification(mixed $notification)

Serialize and unserialize the notification to simulate the queueing process.

Parameters

mixed $notification

Return Value

mixed

at line 394
array sentNotifications()

Get the notifications that have been sent.

Return Value

array

at line 402
static void flushState()

Flush all static state.

Return Value

void