Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/phpunit/includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function get_events() {
}

/**
* Returns a count of the number of times the action was called since the last reset.
* Returns a count of the number of times the hook was called since the last reset.
*
* @since UT (3.7.0)
*/
Expand All @@ -232,7 +232,7 @@ public function get_call_count( $hook_name = '' ) {
$count = 0;

foreach ( $this->events as $e ) {
if ( $e['action'] === $hook_name ) {
if ( $e['hook_name'] === $hook_name ) {
++$count;
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/phpunit/tests/rest-api/rest-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,13 @@ public function test_get_fields_for_response_filters_by_context() {

$controller->prepare_item_for_response( array(), $request );

$this->assertSame( 0, $listener->get_call_count( $method ) );
$this->assertSame( 0, $listener->get_call_count() );

$request->set_param( 'context', 'embed' );

$controller->prepare_item_for_response( array(), $request );

$this->assertGreaterThan( 0, $listener->get_call_count( $method ) );
$this->assertGreaterThan( 0, $listener->get_call_count() );
}

public function test_filtering_fields_for_response_by_context_returns_fields_with_no_context() {
Expand Down Expand Up @@ -501,7 +501,7 @@ public function test_filtering_fields_for_response_by_context_returns_fields_wit

$controller->prepare_item_for_response( array(), $request );

$this->assertGreaterThan( 0, $listener->get_call_count( $method ) );
$this->assertGreaterThan( 0, $listener->get_call_count() );
}

public function test_filtering_fields_for_response_by_context_returns_fields_with_no_schema() {
Expand All @@ -526,7 +526,7 @@ public function test_filtering_fields_for_response_by_context_returns_fields_wit

$controller->prepare_item_for_response( array(), $request );

$this->assertGreaterThan( 0, $listener->get_call_count( $method ) );
$this->assertGreaterThan( 0, $listener->get_call_count() );
}

/**
Expand Down Expand Up @@ -586,21 +586,21 @@ public function test_add_additional_fields_to_object_respects_fields_param() {

$controller->prepare_item_for_response( $item, $request );

$first_call_count = $listener->get_call_count( $method );
$first_call_count = $listener->get_call_count();

$this->assertGreaterThan( 0, $first_call_count );

$request->set_param( '_fields', 'somestring' );

$controller->prepare_item_for_response( $item, $request );

$this->assertSame( $first_call_count, $listener->get_call_count( $method ) );
$this->assertSame( $first_call_count, $listener->get_call_count() );

$request->set_param( '_fields', $field );

$controller->prepare_item_for_response( $item, $request );

$this->assertGreaterThan( $first_call_count, $listener->get_call_count( $method ) );
$this->assertGreaterThan( $first_call_count, $listener->get_call_count() );
}

/**
Expand Down
Loading