Skip to main content

GravityKit\GravityView\Request\MockRequest

A mock for testing.

Since:

  • 2.0
  • 3.0.0 (Migrated to GravityKit\GravityView\Request namespace.)

Source: src/Request/MockRequest.php:17

Details

  • Kind: class
  • Namespace: GravityKit\GravityView\Request
  • Extends: Request

Properties

PropertyTypeDescription
$returnsarrayThe return values.

Methods

MethodDescription
is_view()The current $post is a View, no?
is_entry()Checks whether this is a single entry request
is_edit_entry()Checks whether this an edit entry request.
is_search()Checks whether this an entry search request.
get_arguments()Returns the arguments this request carries.
__call()Returns the configured value for the called method.

Method Reference

is_view()

public function is_view( $return_view=true )

The current $post is a View, no?

Parameters

NameTypeDefaultDescription
$return_viewbooltrueWhether to return a View object or boolean.

Returns

  • \GV\View | bool — If the global $post is a View, returns the View or true, depending on $return_view. If not a View, returns false.

Since: 2.0

Source: src/Request/MockRequest.php:34

is_entry()

public function is_entry( $form_id=0 )

Checks whether this is a single entry request

Parameters

NameTypeDefaultDescription
$form_idint0The form ID, since slugs can be non-unique. Default: 0.

Returns

  • \GV\GF_Entry | false — The entry requested or false.

Since: 2.0

Source: src/Request/MockRequest.php:43

is_edit_entry()

public function is_edit_entry( $form_id=0 )

Checks whether this an edit entry request.

Parameters

NameTypeDefaultDescription
$form_idint0The form ID, since slugs can be non-unique. Default: 0.

Returns

  • \GV\Entry | false — The entry requested or false.

Since: 2.0

Source: src/Request/MockRequest.php:52

public function is_search( $view=null )

Checks whether this an entry search request.

Parameters

NameTypeDefaultDescription
$view\GravityKit\GravityView\View\View | int | nullnullThe View (or its ID) to scope the answer to, if known.

Returns

  • boolean — True if this is a search request.

Since: 2.0

Source: src/Request/MockRequest.php:61

get_arguments()

public function get_arguments(): array

Returns the arguments this request carries.

A mock stands in for a request that is not being routed, such as a View rendered by shortcode. Unless arguments were given to it, the ones the visitor actually sent still apply.

Returns

  • array<string, — mixed> The arguments.

Since: $ver$

Source: src/Request/MockRequest.php:73

__call()

public function __call( $function, $args )

Returns the configured value for the called method.

Parameters

NameTypeDefaultDescription
$functionstringThe method name.
$argsarrayThe call arguments.

Returns

  • mixed — The configured value.

Since: 2.0

Source: src/Request/MockRequest.php:89