Skip to content

Commit

Permalink
chore: test also element from plugins list as object
Browse files Browse the repository at this point in the history
  • Loading branch information
preda-bogdan committed Mar 30, 2024
1 parent 9315b78 commit 02a8c4e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/featured-plugins-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,34 @@ function( $results, $action, $args ) {
return $results;
},
9,
3
3
);

// This should also pass if the result type properties are mutated.
$filtered_api_result = apply_filters( 'plugins_api_result', $api_result, 'query_plugins', $args );
$this->assertEquals( 1, count( $filtered_api_result->plugins ) );


// Mutate a plugin from list to be an object.
add_filter(
'plugins_api_result',
function( $results, $action, $args ) {
$plugin = $results->plugins[0];
$plugin['name'] = 'Optimole';
$plugin['slug'] = 'optimole-wp';
$plugins = $results->plugins;
$plugins[] = (object) $plugin;
$results->plugins = $plugins;

return $results;
},
11,
3
);

// This should also pass if the plugin array contains a object within the list.
$filtered_api_result = apply_filters( 'plugins_api_result', $api_result, 'query_plugins', $args );
$this->assertEquals( 2, count( $filtered_api_result->plugins ) );
}

}

0 comments on commit 02a8c4e

Please sign in to comment.