Tests: Add an assertion to test the WP_REST_Server::add_site_logo_to_index() method.

Additionally:
* Move the test for `WP_REST_Server::add_active_theme_link_to_index()` to a more logical place.
* Replace `assertEquals()` with `assertSame()` in site icon test to also check the type of the value.
* Use a more consistent pattern for the tests.

Follow-up to [51241], [52080].

Props ignatggeorgiev, desrosj, SergeyBiryukov.
Fixes #53516. See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@52381 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2021-12-15 18:06:15 +00:00
parent 424afb85af
commit 2cd907dd63

View File

@ -1025,14 +1025,28 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
$this->assertArrayHasKey( 'help', $index->get_links() );
$this->assertArrayNotHasKey( 'wp:active-theme', $index->get_links() );
// Check site icon.
// Check site logo and icon.
$this->assertArrayHasKey( 'site_logo', $data );
$this->assertArrayHasKey( 'site_icon', $data );
}
/**
* @ticket 50152
*/
public function test_index_includes_link_to_active_theme_if_authenticated() {
$server = new WP_REST_Server();
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
$request = new WP_REST_Request( 'GET', '/' );
$index = $server->dispatch( $request );
$this->assertArrayHasKey( 'https://api.w.org/active-theme', $index->get_links() );
}
/**
* @ticket 52321
*/
public function test_get_index_with_site_icon() {
public function test_index_includes_site_icon() {
$server = new WP_REST_Server();
update_option( 'site_icon', self::$icon_id );
@ -1041,7 +1055,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
$data = $index->get_data();
$this->assertArrayHasKey( 'site_icon', $data );
$this->assertEquals( self::$icon_id, $data['site_icon'] );
$this->assertSame( self::$icon_id, $data['site_icon'] );
}
public function test_get_namespace_index() {
@ -2079,16 +2093,6 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
$this->assertSameSetsWithIndex( $expected, $args['param'] );
}
/**
* @ticket 50152
*/
public function test_index_includes_link_to_active_theme_if_authenticated() {
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
$index = rest_do_request( '/' );
$this->assertArrayHasKey( 'https://api.w.org/active-theme', $index->get_links() );
}
/**
* @ticket 53056
*/