Make WordPress Core


Ignore:
Timestamp:
11/04/2021 03:22:47 PM (3 years ago)
Author:
hellofromTonya
Message:

Coding Standards: Add visibility to methods in tests/phpunit/tests/.

Adds a public visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a private visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a _ prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/widgets/wpWidgetMedia.php

    r51569 r52010  
    2020     * @global WP_Styles $wp_styles
    2121     */
    22     function clean_up_global_scope() {
     22    public function clean_up_global_scope() {
    2323        global $wp_scripts, $wp_styles;
    2424        parent::clean_up_global_scope();
     
    3636     * @return PHPUnit_Framework_MockObject_MockObject|WP_Widget_Media Mocked instance.
    3737     */
    38     function get_mocked_class_instance( $id_base = 'mocked', $name = 'Mocked', $widget_options = array(), $control_options = array() ) {
     38    private function get_mocked_class_instance( $id_base = 'mocked', $name = 'Mocked', $widget_options = array(), $control_options = array() ) {
    3939        $original_class_name       = 'WP_Widget_Media';
    4040        $arguments                 = array( $id_base, $name, $widget_options, $control_options );
     
    5454     * @covers WP_Widget_Media::_register
    5555     */
    56     function test_constructor() {
     56    public function test_constructor() {
    5757        $widget = $this->get_mocked_class_instance();
    5858        $widget->_register();
     
    114114     * @covers WP_Widget_Media::_register
    115115     */
    116     function test_constructor_in_customize_preview() {
     116    public function test_constructor_in_customize_preview() {
    117117        global $wp_customize;
    118118        wp_set_current_user(
     
    142142     * @requires function imagejpeg
    143143     */
    144     function test_is_attachment_with_mime_type() {
     144    public function test_is_attachment_with_mime_type() {
    145145
    146146        $test_image = get_temp_dir() . 'canola.jpg';
     
    171171     * @covers WP_Widget_Media::sanitize_token_list
    172172     */
    173     function test_sanitize_token_list_string() {
     173    public function test_sanitize_token_list_string() {
    174174        $widget = $this->get_mocked_class_instance();
    175175
     
    208208     * @covers WP_Widget_Media::get_instance_schema
    209209     */
    210     function test_get_instance_schema() {
     210    public function test_get_instance_schema() {
    211211        $widget = $this->get_mocked_class_instance();
    212212        $schema = $widget->get_instance_schema();
     
    236236     * @covers WP_Widget_Media::update
    237237     */
    238     function test_update() {
     238    public function test_update() {
    239239        $widget   = $this->get_mocked_class_instance();
    240240        $instance = array();
     
    297297        $this->assertSame( $result, $instance );
    298298
    299         add_filter( 'sanitize_text_field', array( $this, '_return_wp_error' ) );
     299        add_filter( 'sanitize_text_field', array( $this, 'return_wp_error' ) );
    300300        $result = $widget->update(
    301301            array(
     
    304304            $instance
    305305        );
    306         remove_filter( 'sanitize_text_field', array( $this, '_return_wp_error' ) );
     306        remove_filter( 'sanitize_text_field', array( $this, 'return_wp_error' ) );
    307307        $this->assertSame( $result, $instance );
    308308    }
     
    313313     * @return \WP_Error
    314314     */
    315     function _return_wp_error() {
     315    public function return_wp_error() {
    316316        return new WP_Error( 'some-error', 'This is not valid!' );
    317317    }
     
    323323     * @covers WP_Widget_Media::render_media
    324324     */
    325     function test_widget() {
     325    public function test_widget() {
    326326        $args     = array(
    327327            'before_title'  => '<h2>',
     
    387387     * @return array Instance.
    388388     */
    389     function filter_widget_mocked_instance( $instance, $args, $object ) {
     389    public function filter_widget_mocked_instance( $instance, $args, $object ) {
    390390        $this->widget_instance_filter_args = func_get_args();
    391391        return $instance;
     
    397397     * @covers WP_Widget_Media::form
    398398     */
    399     function test_form() {
     399    public function test_form() {
    400400        $widget = $this->get_mocked_class_instance();
    401401
     
    414414     * @covers WP_Widget_Media::display_media_state
    415415     */
    416     function test_display_media_state() {
     416    public function test_display_media_state() {
    417417        $widget        = $this->get_mocked_class_instance();
    418418        $attachment_id = self::factory()->attachment->create_object(
     
    456456     * @covers WP_Widget_Media::enqueue_admin_scripts
    457457     */
    458     function test_enqueue_admin_scripts() {
     458    public function test_enqueue_admin_scripts() {
    459459        set_current_screen( 'widgets.php' );
    460460        $widget = $this->get_mocked_class_instance();
     
    469469     * @covers WP_Widget_Media::render_control_template_scripts
    470470     */
    471     function test_render_control_template_scripts() {
     471    public function test_render_control_template_scripts() {
    472472        $widget = $this->get_mocked_class_instance();
    473473
     
    484484     * @covers WP_Widget_Media::has_content
    485485     */
    486     function test_has_content() {
     486    public function test_has_content() {
    487487        $attachment_id = self::factory()->attachment->create_object(
    488488            array(
Note: See TracChangeset for help on using the changeset viewer.