Make WordPress Core


Ignore:
Timestamp:
11/09/2021 08:36:37 PM (3 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Expose the site icon in the REST API index.

Props spacedmonkey, palmiak.
Fixes #52321.

File:
1 edited

Legend:

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

    r52068 r52080  
    1111 */
    1212class Tests_REST_Server extends WP_Test_REST_TestCase {
     13    protected static $icon_id;
     14
     15    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     16        $filename      = DIR_TESTDATA . '/images/test-image-large.jpg';
     17        self::$icon_id = $factory->attachment->create_upload_object( $filename );
     18    }
     19
    1320    public function set_up() {
    1421        parent::set_up();
     
    10081015        $this->assertArrayHasKey( 'help', $index->get_links() );
    10091016        $this->assertArrayNotHasKey( 'wp:active-theme', $index->get_links() );
     1017
     1018        // Check site icon.
     1019        $this->assertArrayHasKey( 'site_icon', $data );
     1020    }
     1021
     1022    /**
     1023     * @ticket 52321
     1024     */
     1025    public function test_get_index_with_site_icon() {
     1026        $server = new WP_REST_Server();
     1027        update_option( 'site_icon', self::$icon_id );
     1028
     1029        $request = new WP_REST_Request( 'GET', '/' );
     1030        $index   = $server->dispatch( $request );
     1031        $data    = $index->get_data();
     1032
     1033        $this->assertArrayHasKey( 'site_icon', $data );
     1034        $this->assertEquals( self::$icon_id, $data['site_icon'] );
    10101035    }
    10111036
Note: See TracChangeset for help on using the changeset viewer.