Make WordPress Core

Changeset 52381


Ignore:
Timestamp:
12/15/2021 06:06:15 PM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-server.php

    r52235 r52381  
    10261026                $this->assertArrayNotHasKey( 'wp:active-theme', $index->get_links() );
    10271027
    1028                 // Check site icon.
     1028                // Check site logo and icon.
     1029                $this->assertArrayHasKey( 'site_logo', $data );
    10291030                $this->assertArrayHasKey( 'site_icon', $data );
    10301031        }
    10311032
    10321033        /**
     1034         * @ticket 50152
     1035         */
     1036        public function test_index_includes_link_to_active_theme_if_authenticated() {
     1037                $server = new WP_REST_Server();
     1038                wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     1039
     1040                $request = new WP_REST_Request( 'GET', '/' );
     1041                $index   = $server->dispatch( $request );
     1042
     1043                $this->assertArrayHasKey( 'https://api.w.org/active-theme', $index->get_links() );
     1044        }
     1045
     1046        /**
    10331047         * @ticket 52321
    10341048         */
    1035         public function test_get_index_with_site_icon() {
     1049        public function test_index_includes_site_icon() {
    10361050                $server = new WP_REST_Server();
    10371051                update_option( 'site_icon', self::$icon_id );
    … …  
    10421056
    10431057                $this->assertArrayHasKey( 'site_icon', $data );
    1044                 $this->assertEquals( self::$icon_id, $data['site_icon'] );
     1058                $this->assertSame( self::$icon_id, $data['site_icon'] );
    10451059        }
    10461060
    … …  
    20812095
    20822096        /**
    2083          * @ticket 50152
    2084          */
    2085         public function test_index_includes_link_to_active_theme_if_authenticated() {
    2086                 wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
    2087 
    2088                 $index = rest_do_request( '/' );
    2089                 $this->assertArrayHasKey( 'https://api.w.org/active-theme', $index->get_links() );
    2090         }
    2091 
    2092         /**
    20932097         * @ticket 53056
    20942098         */
Note: See TracChangeset for help on using the changeset viewer.