Make WordPress Core


Ignore:
Timestamp:
11/08/2015 02:03:34 AM (10 years ago)
Author:
jeremyfelt
Message:

Site Icon: Wrap site icon retrieval with switch_to_blog() as needed.

When the site icon for another site is requested, retrieving its ID via get_blog_option() is not enough. switch_to_blog() is used to set proper context when required.

Adds multsite tests for has_site_icon().

Props imath.
Fixes #34312.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/template.php

    r35309 r35572  
    5656        $this->_remove_site_icon();
    5757        $this->assertFalse( has_site_icon() );
     58    }
     59
     60    /**
     61     * @group site_icon
     62     * @group multisite
     63     */
     64    function test_has_site_icon_returns_true_when_called_for_other_site_with_site_icon_set() {
     65        if ( ! is_multisite() ) {
     66            $this->markTestSkipped( 'This test requires multisite.' );
     67        }
     68
     69        $blog_id = $this->factory->blog->create();
     70        switch_to_blog( $blog_id );
     71        $this->_set_site_icon();
     72        restore_current_blog();
     73
     74        $this->assertTrue( has_site_icon( $blog_id ) );
     75    }
     76
     77    /**
     78     * @group site_icon
     79     * @group multisite
     80     */
     81    function test_has_site_icon_returns_false_when_called_for_other_site_without_site_icon_set() {
     82        if ( ! is_multisite() ) {
     83            $this->markTestSkipped( 'This test requires multisite.' );
     84        }
     85
     86        $blog_id = $this->factory->blog->create();
     87
     88        $this->assertFalse( has_site_icon( $blog_id ) );
    5889    }
    5990
Note: See TracChangeset for help on using the changeset viewer.