Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Nov 25, 2024
1 parent ce5cef8 commit 20d9fa4
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/phpunit/tests/rest-api/rest-tags-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,55 @@ public function test_get_items_custom_tax_post_args() {
$this->assertSame( 'Cape', $data[0]['name'] );
}

/**
* @ticket 62500
*/
public function test_get_items_custom_tax_without_post_arg_respects_tax_query_args() {
register_taxonomy(
'batman',
'post',
array(
'show_in_rest' => true,
'sort' => true,
'args' => array(
'order' => 'DESC',
'orderby' => 'name',
),
)
);
$controller = new WP_REST_Terms_Controller( 'batman' );
$controller->register_routes();
$term1 = self::factory()->term->create(
array(
'name' => 'Cycle',
'taxonomy' => 'batman',
)
);
$term2 = self::factory()->term->create(
array(
'name' => 'Pod',
'taxonomy' => 'batman',
)
);
$term3 = self::factory()->term->create(
array(
'name' => 'Cave',
'taxonomy' => 'batman',
)
);

$request = new WP_REST_Request( 'GET', '/wp/v2/batman' );
$response = rest_get_server()->dispatch( $request );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertCount( 3, $data );
$this->assertSame(
array( 'Pod', 'Cycle', 'Cave' ),
array_column( $data, 'name' )
);
}

public function test_get_items_search_args() {
$tag1 = self::factory()->tag->create( array( 'name' => 'Apple' ) );
$tag2 = self::factory()->tag->create( array( 'name' => 'Banana' ) );
Expand Down

0 comments on commit 20d9fa4

Please sign in to comment.