Make WordPress Core

Changeset 53773


Ignore:
Timestamp:
07/25/2022 01:31:24 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Tests: Add failure messages for site icon and custom logo tests.

This makes the assertions more helpful, as per the ​Writing PHP Tests guidelines:

All PHPUnit assertions, as well as all WordPress custom assertions, allow for a $message parameter to be passed. This message will be displayed when the assertion fails and can help immensely when debugging a test. This parameter should always be used if more than one assertion is used in a test method.

Follow-up to [33181], [36905].

See #55652.

File:
1 edited

Legend:

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

    r52010 r53773  
    3939         */
    4040        public function test_get_site_icon_url() {
    41                 $this->assertEmpty( get_site_icon_url() );
     41                $this->assertEmpty( get_site_icon_url(), 'Site icon URL should not be set initially.' );
    4242
    4343                $this->set_site_icon();
    44                 $this->assertSame( $this->site_icon_url, get_site_icon_url() );
     44                $this->assertSame( $this->site_icon_url, get_site_icon_url(), 'Site icon URL should be set.' );
    4545
    4646                $this->remove_site_icon();
    47                 $this->assertEmpty( get_site_icon_url() );
     47                $this->assertEmpty( get_site_icon_url(), 'Site icon URL should not be set after removal.' );
    4848        }
    4949
    … …  
    6868         */
    6969        public function test_has_site_icon() {
    70                 $this->assertFalse( has_site_icon() );
     70                $this->assertFalse( has_site_icon(), 'Site icon should not be set initially.' );
    7171
    7272                $this->set_site_icon();
    73                 $this->assertTrue( has_site_icon() );
     73                $this->assertTrue( has_site_icon(), 'Site icon should be set.' );
    7474
    7575                $this->remove_site_icon();
    76                 $this->assertFalse( has_site_icon() );
     76                $this->assertFalse( has_site_icon(), 'Site icon should not be set after removal.' );
    7777        }
    7878
    … …  
    262262         */
    263263        public function test_has_custom_logo() {
    264                 $this->assertFalse( has_custom_logo() );
     264                $this->assertFalse( has_custom_logo(), 'Custom logo should not be set initially.' );
    265265
    266266                $this->set_custom_logo();
    267                 $this->assertTrue( has_custom_logo() );
     267                $this->assertTrue( has_custom_logo(), 'Custom logo should be set.' );
    268268
    269269                $this->remove_custom_logo();
    270                 $this->assertFalse( has_custom_logo() );
     270                $this->assertFalse( has_custom_logo(), 'Custom logo should not be set after removal.' );
    271271        }
    272272
    … …  
    305305         */
    306306        public function test_get_custom_logo() {
    307                 $this->assertEmpty( get_custom_logo() );
     307                $this->assertEmpty( get_custom_logo(), 'Custom logo should not be set initially.' );
    308308
    309309                $this->set_custom_logo();
    310310                $custom_logo = get_custom_logo();
    311                 $this->assertNotEmpty( $custom_logo );
    312                 $this->assertIsString( $custom_logo );
     311                $this->assertNotEmpty( $custom_logo, 'Custom logo markup should not be empty.' );
     312                $this->assertIsString( $custom_logo, 'Custom logo markup should be a string.' );
    313313
    314314                $this->remove_custom_logo();
    315                 $this->assertEmpty( get_custom_logo() );
     315                $this->assertEmpty( get_custom_logo(), 'Custom logo should not be set after removal.' );
    316316        }
    317317
    … …  
    403403
    404404        /**
    405          * Sets a site icon in options for testing.
     405         * Sets a custom logo in options for testing.
    406406         *
    407407         * @since 4.5.0
    … …  
    416416
    417417        /**
    418          * Removes the site icon from options.
     418         * Removes the custom logo from options.
    419419         *
    420420         * @since 4.5.0
Note: See TracChangeset for help on using the changeset viewer.