Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Nov 15, 2022
1 parent 98f851e commit ae38a3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function register_routes() {
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'get_pattern_categories' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
)
),
),
)
);

parent::register_routes();
Expand Down Expand Up @@ -73,8 +73,8 @@ public function get_pattern_categories( $request ) {
'pattern_directory_api_failed',
sprintf(
/* translators: %s: Support forums URL. */
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
__( 'https://wordpress.org/support/forums/' )
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.', 'gutenberg' ),
__( 'https://wordpress.org/support/forums/', 'gutenberg' )
),
array(
'response' => wp_remote_retrieve_body( $wporg_response ),
Expand Down Expand Up @@ -117,14 +117,14 @@ public function get_pattern_categories( $request ) {
* @param WP_REST_Request $request Request object.
* @return WP_REST_Response
*/
public function prepare_pattern_category_for_response( $item , $request) {
$prepared_pattern_category = array(
public function prepare_pattern_category_for_response( $item, $request ) {
$raw_pattern_category = array(
'id' => absint( $item->id ),
'name' => sanitize_text_field( $item->name ),
'slug' => sanitize_text_field( $item->slug )
'slug' => sanitize_text_field( $item->slug ),
);

$prepared_pattern = $this->add_additional_fields_to_object( $prepared_pattern_category, $request );
$prepared_pattern_category = $this->add_additional_fields_to_object( $raw_pattern_category, $request );

return new WP_REST_Response( $prepared_pattern_category );
}
Expand Down
9 changes: 8 additions & 1 deletion phpunit/class-wp-rest-pattern-directory-controller-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ public function test_prepare_pattern_category_for_response() {
static::$controller->prepare_pattern_category_for_response( $raw_categories[0], new WP_REST_Request() )
);

$this->assertArrayNotHasKey( 'description', $prepared_category );
$this->assertSame(
array(
'id' => 3,
'name' => 'Columns',
'slug' => 'columns',
),
$prepared_category
);
}


Expand Down

0 comments on commit ae38a3f

Please sign in to comment.