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
2 changes: 1 addition & 1 deletion tests/phpunit/tests/admin/includesPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function test_bulk_edit_posts_stomping() {

// Check that the first post's values don't stomp the second post.
$this->assertSame( 'draft', $post->post_status );
$this->assertEquals( self::$author_ids[1], $post->post_author );
$this->assertSame( self::$author_ids[1], (int) $post->post_author );
$this->assertSame( 'closed', $post->comment_status );
$this->assertSame( 'closed', $post->ping_status );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3028,7 +3028,7 @@ public function test_edit_image_updates_attachment_fields() {
$response = rest_do_request( $request );

// The edit endpoint creates a new attachment, so we expect a 201 status.
$this->assertEquals( 201, $response->get_status() );
$this->assertSame( 201, $response->get_status() );

$data = $response->get_data();
$new_attachment_id = $data['id'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ public function test_global_styles_route_accepts_integer_id() {
$request = new WP_REST_Request( 'GET', '/wp/v2/global-styles/' . self::$global_styles_id );
$response = rest_get_server()->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertIsInt( $data['id'] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function test_get_items(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/categories' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertIsArray( $data );
Expand All @@ -168,7 +168,7 @@ public function test_get_item(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/categories/test-data-retrieval' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertSame( 'test-data-retrieval', $data['slug'] );
Expand All @@ -186,7 +186,7 @@ public function test_get_item_with_meta(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/categories/test-communication' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertSame( 'test-communication', $data['slug'] );
Expand All @@ -208,7 +208,7 @@ public function test_get_item_with_selected_fields(): void {
$response = apply_filters( 'rest_post_dispatch', $response, $this->server, $request );
remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertCount( 2, $data, 'Response should only contain the requested fields.' );
Expand All @@ -227,7 +227,7 @@ public function test_get_item_not_found(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/categories/non-existent' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 404, $response->get_status() );
$this->assertSame( 404, $response->get_status() );

$data = $response->get_data();
$this->assertSame( 'rest_ability_category_not_found', $data['code'] );
Expand All @@ -244,7 +244,7 @@ public function test_get_items_permission_denied(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/categories' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 401, $response->get_status() );
$this->assertSame( 401, $response->get_status() );
}

/**
Expand All @@ -258,7 +258,7 @@ public function test_get_item_permission_denied(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/categories/test-data-retrieval' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 401, $response->get_status() );
$this->assertSame( 401, $response->get_status() );
}

/**
Expand All @@ -271,15 +271,15 @@ public function test_pagination_headers(): void {
$request->set_param( 'per_page', 10 );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$headers = $response->get_headers();
$this->assertArrayHasKey( 'X-WP-Total', $headers );
$this->assertArrayHasKey( 'X-WP-TotalPages', $headers );

$total_categories = count( wp_get_ability_categories() );
$this->assertEquals( $total_categories, (int) $headers['X-WP-Total'] );
$this->assertEquals( ceil( $total_categories / 10 ), (int) $headers['X-WP-TotalPages'] );
$this->assertSame( $total_categories, (int) $headers['X-WP-Total'] );
$this->assertSame( (int) ceil( $total_categories / 10 ), (int) $headers['X-WP-TotalPages'] );
}

/**
Expand Down Expand Up @@ -352,7 +352,7 @@ public function test_collection_params(): void {
$request->set_param( 'page', 2 );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );
$data = $response->get_data();
$this->assertCount( 5, $data );

Expand Down Expand Up @@ -450,7 +450,7 @@ public function test_get_schema(): void {
public function test_ability_category_slug_with_valid_format(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/categories/test-data-retrieval' );
$response = $this->server->dispatch( $request );
$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );
}

/**
Expand Down
32 changes: 16 additions & 16 deletions tests/phpunit/tests/rest-api/wpRestAbilitiesV1ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function test_get_items(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/abilities' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertIsArray( $data );
Expand All @@ -303,7 +303,7 @@ public function test_get_item(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/abilities/test/calculator' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertCount( 7, $data, 'Response should contain all fields.' );
Expand All @@ -330,7 +330,7 @@ public function test_get_item_with_selected_fields(): void {
$response = apply_filters( 'rest_post_dispatch', $response, $this->server, $request );
remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertCount( 2, $data, 'Response should only contain the requested fields.' );
Expand All @@ -351,7 +351,7 @@ public function test_get_item_with_embed_context(): void {
$response = apply_filters( 'rest_post_dispatch', $response, $this->server, $request );
remove_filter( 'rest_post_dispatch', 'rest_filter_response_fields', 10 );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertCount( 3, $data, 'Response should only contain the fields for embed context.' );
Expand All @@ -371,7 +371,7 @@ public function test_get_item_not_found(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/abilities/non/existent' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 404, $response->get_status() );
$this->assertSame( 404, $response->get_status() );

$data = $response->get_data();
$this->assertSame( 'rest_ability_not_found', $data['code'] );
Expand All @@ -386,7 +386,7 @@ public function test_get_item_not_show_in_rest(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/abilities/test/not-show-in-rest' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 404, $response->get_status() );
$this->assertSame( 404, $response->get_status() );

$data = $response->get_data();
$this->assertSame( 'rest_ability_not_found', $data['code'] );
Expand All @@ -404,7 +404,7 @@ public function test_get_items_permission_denied(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/abilities' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 401, $response->get_status() );
$this->assertSame( 401, $response->get_status() );
}

/**
Expand All @@ -417,15 +417,15 @@ public function test_pagination_headers(): void {
$request->set_param( 'per_page', 10 );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$headers = $response->get_headers();
$this->assertArrayHasKey( 'X-WP-Total', $headers );
$this->assertArrayHasKey( 'X-WP-TotalPages', $headers );

$total_abilities = count( wp_get_abilities() ) - 1; // Exclude the one that doesn't show in REST.
$this->assertEquals( $total_abilities, (int) $headers['X-WP-Total'] );
$this->assertEquals( ceil( $total_abilities / 10 ), (int) $headers['X-WP-TotalPages'] );
$this->assertSame( $total_abilities, (int) $headers['X-WP-Total'] );
$this->assertSame( (int) ceil( $total_abilities / 10 ), (int) $headers['X-WP-TotalPages'] );
}

/**
Expand Down Expand Up @@ -507,7 +507,7 @@ public function test_collection_params(): void {
$request->set_param( 'page', 2 );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );
$data = $response->get_data();
$this->assertCount( 5, $data );

Expand Down Expand Up @@ -629,7 +629,7 @@ public function test_ability_name_with_valid_special_characters(): void {

wp_unregister_ability( 'test-hyphen/ability' );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );
}

/**
Expand Down Expand Up @@ -663,7 +663,7 @@ public function test_ability_name_with_invalid_special_characters( string $name
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/abilities/' . $name );
$response = $this->server->dispatch( $request );
// Should return 404 as the regex pattern won't match
$this->assertEquals( 404, $response->get_status() );
$this->assertSame( 404, $response->get_status() );
}

/**
Expand All @@ -681,7 +681,7 @@ public function test_extremely_long_ability_names(): void {
$response = $this->server->dispatch( $request );

// Should return 404 as ability doesn't exist
$this->assertEquals( 404, $response->get_status() );
$this->assertSame( 404, $response->get_status() );
}

/**
Expand Down Expand Up @@ -738,7 +738,7 @@ public function test_filter_by_category(): void {
$request->set_param( 'category', 'math' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertIsArray( $data );
Expand Down Expand Up @@ -770,7 +770,7 @@ public function test_filter_by_nonexistent_category(): void {
$request->set_param( 'category', 'nonexistent' );
$response = $this->server->dispatch( $request );

$this->assertEquals( 200, $response->get_status() );
$this->assertSame( 200, $response->get_status() );

$data = $response->get_data();
$this->assertIsArray( $data );
Expand Down
Loading
Loading