Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ public function test_get_item_default_attributes() {
$data = $response->get_data();

$this->assertSame( $defaults, json_decode( $data['rendered'], true ) );
// Keep assertEquals() because the objects are intentionally compared by value.
$this->assertEquals(
json_decode( $block_type->render( $defaults ) ),
json_decode( $data['rendered'] )
Expand Down
2 changes: 2 additions & 0 deletions tests/phpunit/tests/rest-api/rest-users-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ public function test_get_user_empty_capabilities() {
} else {
$data = $response->get_data();

// Keep assertEquals() because the objects are intentionally compared by value.
$this->assertEquals( $data['capabilities'], new stdClass() );
$this->assertEquals( $data['extra_capabilities'], new stdClass() );
}
Expand Down Expand Up @@ -3355,6 +3356,7 @@ protected function check_user_data( $user, $data, $context, $links ) {
$this->assertSame( $user->last_name, $data['last_name'] );
$this->assertSame( $user->nickname, $data['nickname'] );
$this->assertSame( $user->user_email, $data['email'] );
// Keep assertEquals() because the objects are intentionally compared by value.
$this->assertEquals( (object) $user->allcaps, $data['capabilities'] );
$this->assertEquals( (object) $user->caps, $data['extra_capabilities'] );
$this->assertSame( gmdate( 'c', strtotime( $user->user_registered ) ), $data['registered_date'] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public function test_get_item_public_meta_exposes_in_rest(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/abilities/test/public-ability' );
$response = $this->server->dispatch( $request );

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

$data = $response->get_data();
$this->assertTrue( $data['meta']['public'] );
Expand Down Expand Up @@ -466,7 +466,7 @@ public function test_get_item_public_true_show_in_rest_false_is_hidden(): void {
$request = new WP_REST_Request( 'GET', '/wp-abilities/v1/abilities/test/public-optout' );
$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 Down
16 changes: 8 additions & 8 deletions tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public function test_execute_regular_ability_post(): void {
$response = $this->server->dispatch( $request );

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

/**
Expand All @@ -451,7 +451,7 @@ public function test_execute_readonly_ability_get(): void {

$this->assertSame( 200, $response->get_status() );
$data = $response->get_data();
$this->assertEquals( self::$user_id, $data['id'] );
$this->assertSame( self::$user_id, $data['id'] );
}

/**
Expand Down Expand Up @@ -675,7 +675,7 @@ public function test_run_public_meta_ability_is_executable(): void {

$response = $this->server->dispatch( $request );

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

Expand Down Expand Up @@ -789,7 +789,7 @@ public function test_get_request_with_nested_input_array(): void {

$data = $response->get_data();
$this->assertSame( 'nested', $data['level1']['level2']['value'] );
$this->assertEquals( array( 1, 2, 3 ), $data['array'] );
$this->assertSame( array( 1, 2, 3 ), $data['array'] );
}

/**
Expand Down Expand Up @@ -1297,7 +1297,7 @@ public function test_php_type_strings_in_input(): void {

$this->assertSame( 200, $response->get_status() );
$data = $response->get_data();
$this->assertEquals( $inputs, $data['echo'] );
$this->assertSame( $inputs, $data['echo'] );
}

/**
Expand Down Expand Up @@ -1346,9 +1346,9 @@ public function test_mixed_encoding_in_input(): void {
$data = $response->get_data();

// Input should be preserved exactly
$this->assertEquals( $input['utf8'], $data['echo']['utf8'] );
$this->assertEquals( $input['emoji'], $data['echo']['emoji'] );
$this->assertEquals( $input['html'], $data['echo']['html'] );
$this->assertSame( $input['utf8'], $data['echo']['utf8'] );
$this->assertSame( $input['emoji'], $data['echo']['emoji'] );
$this->assertSame( $input['html'], $data['echo']['html'] );
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/rest-api/wpRestTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ public function test_get_template_fallback_not_found() {
$request->set_param( 'slug', 'not-found' );
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
// Keep assertEquals() because the objects are intentionally compared by value.
$this->assertEquals( new stdClass(), $data, 'Response should be an empty object when a fallback template is not found.' );
}

Expand Down
Loading