WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/22/2019 12:21:49 AM (2 months ago)
Author:
SergeyBiryukov
Message:

Administration: Adjust [45814] to address a backward compatibility issue for plugins passing multiple CSS classes to add_settings_error().

Only add the notice- prefix for error, success, warning, info CSS classes, keep other classes as is.

Add unit tests for settings_errors().

Props afercia, SergeyBiryukov.
Fixes #44941.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/option/sanitize-option.php

    r42636 r45873  
    159159    }
    160160
    161     /**
    162      * Test calling get_settings_errors() with variations on where it gets errors from.
    163      *
    164      * @ticket 42498
    165      * @covers ::get_settings_errors()
    166      * @global array $wp_settings_errors
    167      */
    168     public function test_get_settings_errors_sources() {
    169         global $wp_settings_errors;
    170 
    171         $blogname_error        = array(
    172             'setting' => 'blogname',
    173             'code'    => 'blogname',
    174             'message' => 'Capital P dangit!',
    175             'type'    => 'error',
    176         );
    177         $blogdescription_error = array(
    178             'setting' => 'blogdescription',
    179             'code'    => 'blogdescription',
    180             'message' => 'Too short',
    181             'type'    => 'error',
    182         );
    183 
    184         $wp_settings_errors = null;
    185         $this->assertSame( array(), get_settings_errors( 'blogname' ) );
    186 
    187         // Test getting errors from transient.
    188         $_GET['settings-updated'] = '1';
    189         set_transient( 'settings_errors', array( $blogname_error ) );
    190         $wp_settings_errors = null;
    191         $this->assertSame( array( $blogname_error ), get_settings_errors( 'blogname' ) );
    192 
    193         // Test getting errors from transient and from global.
    194         $_GET['settings-updated'] = '1';
    195         set_transient( 'settings_errors', array( $blogname_error ) );
    196         $wp_settings_errors = null;
    197         add_settings_error( $blogdescription_error['setting'], $blogdescription_error['code'], $blogdescription_error['message'], $blogdescription_error['type'] );
    198         $this->assertEqualSets( array( $blogname_error, $blogdescription_error ), get_settings_errors() );
    199 
    200         $wp_settings_errors = null;
    201     }
    202161}
Note: See TracChangeset for help on using the changeset viewer.