class TestResponse

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected JsonRpcResponse $response
protected JsonRpcResponse> $notifications

Methods

mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

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.

__construct(Primitive $primitive, iterable|JsonRpcResponse $response, string|null $requestedUri = null)

Consume a primitive's response and collect its notifications.

assertSee(array|string $text)

Assert that the response contains the given text.

assertDontSee(array|string $text)

Assert that the response does not contain the given text.

assertStructuredContent(Closure|array $structuredContent)

Assert that the response contains the given structured content.

assertStructuredContentCount(int $count, string|null $key = null)

Assert that the structured content has the expected count of items at the given key.

assertStructuredContentPath(string $path, mixed $expect)

Assert that the expected value and type exists at the given path in the structured content.

assertStructuredContentPaths(array $paths)

Assert that the expected values and types exist at the given paths in the structured content.

assertStructuredContentPathCanonicalizing(string $path, array $expect)

Assert that the given path in the structured content contains all of the expected values without looking at the order.

assertStructuredContentPathsCanonicalizing(array $paths)

Assert that the given paths in the structured content contain all of the expected values without looking at the order.

assertExactStructuredContent(array $data)

Assert that the structured content is exactly the given JSON.

assertSimilarStructuredContent(array $data)

Assert that the structured content has the similar JSON as given.

assertStructuredContentFragment(array $data)

Assert that the structured content contains the given JSON fragment.

assertStructuredContentFragments(array $data)

Assert that the structured content contains the given JSON fragments.

assertStructuredContentMissing(array $data, bool $exact = false)

Assert that the structured content does not contain the given JSON fragment.

assertStructuredContentMissingExact(array $data)

Assert that the structured content does not contain the exact JSON fragment.

assertStructuredContentMissingPath(string $path)

Assert that the structured content does not contain the given path.

assertStructuredContentMissingPaths(array $paths)

Assert that the structured content does not contain the given paths.

assertStructuredContentStructure(array|null $structure = null, array|null $responseData = null)

Assert that the structured content has a given JSON structure.

assertExactStructuredContentStructure(array|null $structure = null, array|null $responseData = null)

Assert that the structured content has the exact JSON structure.

assertStructuredContentIsArray(string|null $key = null)

Assert that the given key in the structured content is a JSON array.

assertStructuredContentIsObject(string|null $key = null)

Assert that the given key in the structured content is a JSON object.

assertNotificationCount(int $count)

Assert the number of notifications received.

assertSentNotification(string $method, array|null $params = null)

Assert that the given notification was received.

assertName(string $name)

Assert the primitive's name.

assertTitle(string $title)

Assert the primitive's title.

assertDescription(string $description)

Assert the primitive's description.

assertOk()

Assert that the response has no errors.

assertNotRegistered()

Assert that the primitive is not registered.

assertHasNoErrors()

Assert that the response has no errors.

assertHasErrors(array $messages = [])

Assert that the response contains errors matching the given messages.

assertAuthenticated(string|null $guard = null)

Assert that the current user is authenticated.

assertGuest(string|null $guard = null)

Assert that the current user is a guest.

assertAuthenticatedAs(Authenticatable $user, string|null $guard = null)

Assert that the current user matches the given user.

bool
isAuthenticated(string|null $guard = null)

Determine whether the current user is authenticated.

assertHasCompletions(array $expectedValues = [])

Assert that the response contains the expected completions.

assertCompletionValues(array $values)

Assert the complete set of completion values.

assertCompletionCount(int $count)

Assert the number of completion values.

void
dd()

Dump the response and end execution.

dump()

Dump the response.

void
ddErrors()

Dump the response errors and end execution.

array
content()

Get the primitive's textual response content.

array
errors()

Get the response's error messages.

array
completionValues()

Get the response's completion values.

array|null
structuredContent()

Get the response's structured content.

assertableStructuredContent()

Get the response's structured content for JSON assertions.

mixed
toJsonRepresentation(mixed $value)

Normalize a value through its JSON representation.

Details

in Conditionable at line 23
mixed when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Conditionable at line 56
mixed unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

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

at line 44
__construct(Primitive $primitive, iterable|JsonRpcResponse $response, string|null $requestedUri = null)

Consume a primitive's response and collect its notifications.

Parameters

Primitive $primitive
iterable|JsonRpcResponse $response
string|null $requestedUri

at line 70
TestResponse assertSee(array|string $text)

Assert that the response contains the given text.

Parameters

array|string $text

Return Value

TestResponse

at line 99
TestResponse assertDontSee(array|string $text)

Assert that the response does not contain the given text.

Parameters

array|string $text

Return Value

TestResponse

at line 128
TestResponse assertStructuredContent(Closure|array $structuredContent)

Assert that the response contains the given structured content.

Parameters

Closure|array $structuredContent

Return Value

TestResponse

at line 156
TestResponse assertStructuredContentCount(int $count, string|null $key = null)

Assert that the structured content has the expected count of items at the given key.

Parameters

int $count
string|null $key

Return Value

TestResponse

at line 172
TestResponse assertStructuredContentPath(string $path, mixed $expect)

Assert that the expected value and type exists at the given path in the structured content.

Parameters

string $path
mixed $expect

Return Value

TestResponse

at line 200
TestResponse assertStructuredContentPaths(array $paths)

Assert that the expected values and types exist at the given paths in the structured content.

Parameters

array $paths

Return Value

TestResponse

at line 214
TestResponse assertStructuredContentPathCanonicalizing(string $path, array $expect)

Assert that the given path in the structured content contains all of the expected values without looking at the order.

Parameters

string $path
array $expect

Return Value

TestResponse

at line 226
TestResponse assertStructuredContentPathsCanonicalizing(array $paths)

Assert that the given paths in the structured content contain all of the expected values without looking at the order.

Parameters

array $paths

Return Value

TestResponse

at line 240
TestResponse assertExactStructuredContent(array $data)

Assert that the structured content is exactly the given JSON.

Parameters

array $data

Return Value

TestResponse

at line 252
TestResponse assertSimilarStructuredContent(array $data)

Assert that the structured content has the similar JSON as given.

Parameters

array $data

Return Value

TestResponse

at line 264
TestResponse assertStructuredContentFragment(array $data)

Assert that the structured content contains the given JSON fragment.

Parameters

array $data

Return Value

TestResponse

at line 276
TestResponse assertStructuredContentFragments(array $data)

Assert that the structured content contains the given JSON fragments.

Parameters

array $data

Return Value

TestResponse

at line 290
TestResponse assertStructuredContentMissing(array $data, bool $exact = false)

Assert that the structured content does not contain the given JSON fragment.

Parameters

array $data
bool $exact

Return Value

TestResponse

at line 302
TestResponse assertStructuredContentMissingExact(array $data)

Assert that the structured content does not contain the exact JSON fragment.

Parameters

array $data

Return Value

TestResponse

at line 312
TestResponse assertStructuredContentMissingPath(string $path)

Assert that the structured content does not contain the given path.

Parameters

string $path

Return Value

TestResponse

at line 324
TestResponse assertStructuredContentMissingPaths(array $paths)

Assert that the structured content does not contain the given paths.

Parameters

array $paths

Return Value

TestResponse

at line 339
TestResponse assertStructuredContentStructure(array|null $structure = null, array|null $responseData = null)

Assert that the structured content has a given JSON structure.

Parameters

array|null $structure
array|null $responseData

Return Value

TestResponse

at line 352
TestResponse assertExactStructuredContentStructure(array|null $structure = null, array|null $responseData = null)

Assert that the structured content has the exact JSON structure.

Parameters

array|null $structure
array|null $responseData

Return Value

TestResponse

at line 362
TestResponse assertStructuredContentIsArray(string|null $key = null)

Assert that the given key in the structured content is a JSON array.

Parameters

string|null $key

Return Value

TestResponse

at line 375
TestResponse assertStructuredContentIsObject(string|null $key = null)

Assert that the given key in the structured content is a JSON object.

Parameters

string|null $key

Return Value

TestResponse

at line 388
TestResponse assertNotificationCount(int $count)

Assert the number of notifications received.

Parameters

int $count

Return Value

TestResponse

at line 400
TestResponse assertSentNotification(string $method, array|null $params = null)

Assert that the given notification was received.

Parameters

string $method
array|null $params

Return Value

TestResponse

at line 418
TestResponse assertName(string $name)

Assert the primitive's name.

Parameters

string $name

Return Value

TestResponse

at line 432
TestResponse assertTitle(string $title)

Assert the primitive's title.

Parameters

string $title

Return Value

TestResponse

at line 446
TestResponse assertDescription(string $description)

Assert the primitive's description.

Parameters

string $description

Return Value

TestResponse

at line 460
TestResponse assertOk()

Assert that the response has no errors.

Return Value

TestResponse

at line 468
TestResponse assertNotRegistered()

Assert that the primitive is not registered.

Return Value

TestResponse

at line 488
TestResponse assertHasNoErrors()

Assert that the response has no errors.

Return Value

TestResponse

at line 500
TestResponse assertHasErrors(array $messages = [])

Assert that the response contains errors matching the given messages.

Parameters

array $messages

Return Value

TestResponse

at line 522
TestResponse assertAuthenticated(string|null $guard = null)

Assert that the current user is authenticated.

Parameters

string|null $guard

Return Value

TestResponse

at line 532
TestResponse assertGuest(string|null $guard = null)

Assert that the current user is a guest.

Parameters

string|null $guard

Return Value

TestResponse

at line 542
TestResponse assertAuthenticatedAs(Authenticatable $user, string|null $guard = null)

Assert that the current user matches the given user.

Parameters

Authenticatable $user
string|null $guard

Return Value

TestResponse

at line 566
protected bool isAuthenticated(string|null $guard = null)

Determine whether the current user is authenticated.

Parameters

string|null $guard

Return Value

bool

at line 576
TestResponse assertHasCompletions(array $expectedValues = [])

Assert that the response contains the expected completions.

Parameters

array $expectedValues

Return Value

TestResponse

at line 596
TestResponse assertCompletionValues(array $values)

Assert the complete set of completion values.

Parameters

array $values

Return Value

TestResponse

at line 610
TestResponse assertCompletionCount(int $count)

Assert the number of completion values.

Parameters

int $count

Return Value

TestResponse

at line 626
void dd()

Dump the response and end execution.

Return Value

void

at line 634
TestResponse dump()

Dump the response.

Return Value

TestResponse

at line 644
void ddErrors()

Dump the response errors and end execution.

Return Value

void

at line 654
protected array content()

Get the primitive's textual response content.

Return Value

array

at line 673
protected array errors()

Get the response's error messages.

Return Value

array

at line 693
protected array completionValues()

Get the response's completion values.

Return Value

array

at line 710
protected array|null structuredContent()

Get the response's structured content.

Return Value

array|null

at line 727
protected AssertableJsonString assertableStructuredContent()

Get the response's structured content for JSON assertions.

Return Value

AssertableJsonString

at line 743
protected mixed toJsonRepresentation(mixed $value)

Normalize a value through its JSON representation.

Parameters

mixed $value

Return Value

mixed