Make WordPress Core


Ignore:
Timestamp:
04/02/2019 10:14:19 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Widgets: Make sure changes to media widgets' instance schema via widget_{$this->id_base}_instance_schema filter are not overridden by subclasses.

Add unit tests missed in [45100].

Props Toro_Unit, birgire.
See #45029.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/widgets/media-audio-widget.php

    r43571 r45101  
    5252
    5353    /**
     54     * Test get_instance_schema filtering.
     55     *
     56     * @covers WP_Widget_Media_Audio::get_instance_schema
     57     *
     58     * @ticket 45029
     59     */
     60    function test_get_instance_schema_filtering() {
     61        $wp_widget_audio = new WP_Widget_Media_Audio();
     62        $schema          = $wp_widget_audio->get_instance_schema();
     63
     64        add_filter( 'widget_media_audio_instance_schema', array( $this, 'filter_instance_schema' ), 10, 2 );
     65        $schema = $wp_widget_audio->get_instance_schema();
     66
     67        $this->assertTrue( $schema['loop']['default'] );
     68    }
     69
     70    /**
     71     * Filters instance schema.
     72     *
     73     * @since 5.2.0
     74     *
     75     * @param array                 $schema Schema.
     76     * @param WP_Widget_Media_Audio $widget Widget.
     77     *
     78     * @return array
     79     */
     80    public function filter_instance_schema( $schema, $widget ) {
     81        // Override the default loop value (false).
     82        $schema['loop']['default'] = true;
     83        return $schema;
     84    }
     85
     86    /**
    5487     * Test constructor.
    5588     *
Note: See TracChangeset for help on using the changeset viewer.