WordPress.org

Make WordPress Core

Changeset 50449


Ignore:
Timestamp:
02/27/2021 04:54:52 PM (3 months ago)
Author:
johnbillion
Message:

Build/Test Tools: Fix and standardise calls to the setUp() and setUpBeforeClass() methods in the test suite.

The parent methods should always be called before any test-specific functionality is set up, unless there is a specific and documented reason.

See #52625

Location:
trunk/tests/phpunit
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase-ajax.php

    r49696 r50449  
    117117
    118118    public static function setUpBeforeClass() {
     119        parent::setUpBeforeClass();
     120
    119121        remove_action( 'admin_init', '_maybe_update_core' );
    120122        remove_action( 'admin_init', '_maybe_update_plugins' );
     
    127129            }
    128130        }
    129 
    130         parent::setUpBeforeClass();
    131131    }
    132132
  • trunk/tests/phpunit/includes/testcase-block-supports.php

    r49547 r50449  
    1515     */
    1616    private $registered_block_names = array();
    17 
    18     /**
    19      * Sets up each test method.
    20      */
    21     public function setUp() {
    22         parent::setUp();
    23     }
    2417
    2518    /**
  • trunk/tests/phpunit/tests/admin/includesScreen.php

    r49184 r50449  
    157157
    158158    function setUp() {
     159        parent::setUp();
    159160        set_current_screen( 'front' );
    160         parent::setUp();
    161161    }
    162162
  • trunk/tests/phpunit/tests/adminbar.php

    r49603 r50449  
    1616
    1717    public static function setUpBeforeClass() {
     18        parent::setUpBeforeClass();
     19
    1820        require_once ABSPATH . WPINC . '/class-wp-admin-bar.php';
    19 
    20         parent::setUpBeforeClass();
    2121    }
    2222
  • trunk/tests/phpunit/tests/comment/getCommentExcerpt.php

    r48937 r50449  
    22
    33class Tests_Get_Comment_Excerpt extends WP_UnitTestCase {
    4     protected static $bacon_comment;
    5 
    6     public static function setUpBeforeClass() {
    7         parent::setUpBeforeClass();
    8 
    9         self::$bacon_comment = 'Bacon ipsum dolor amet porchetta capicola sirloin prosciutto brisket shankle jerky. Ham hock filet mignon boudin ground round, prosciutto alcatra spare ribs meatball turducken pork beef ribs ham beef. Bacon pastrami short loin, venison tri-tip ham short ribs doner swine. Tenderloin pig tongue pork jowl doner. Pork loin rump t-bone, beef strip steak flank drumstick tri-tip short loin capicola jowl. Cow filet mignon hamburger doner rump. Short loin jowl drumstick, tongue tail beef ribs pancetta flank brisket landjaeger chuck venison frankfurter turkey.
     4    protected static $bacon_comment = 'Bacon ipsum dolor amet porchetta capicola sirloin prosciutto brisket shankle jerky. Ham hock filet mignon boudin ground round, prosciutto alcatra spare ribs meatball turducken pork beef ribs ham beef. Bacon pastrami short loin, venison tri-tip ham short ribs doner swine. Tenderloin pig tongue pork jowl doner. Pork loin rump t-bone, beef strip steak flank drumstick tri-tip short loin capicola jowl. Cow filet mignon hamburger doner rump. Short loin jowl drumstick, tongue tail beef ribs pancetta flank brisket landjaeger chuck venison frankfurter turkey.
    105
    116Brisket shank rump, tongue beef ribs swine fatback turducken capicola meatball picanha chicken cupim meatloaf turkey. Bacon biltong shoulder tail frankfurter boudin cupim turkey drumstick. Porchetta pig shoulder, jerky flank pork tail meatball hamburger. Doner ham hock ribeye tail jerky swine. Leberkas ribeye pancetta, tenderloin capicola doner turducken chicken venison ground round boudin pork chop. Tail pork loin pig spare ribs, biltong ribeye brisket pork chop cupim. Short loin leberkas spare ribs jowl landjaeger tongue kevin flank bacon prosciutto.
    127
    138Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket bacon pork chop. Cupim hamburger pork loin short loin. Boudin ball tip cupim ground round ham shoulder. Sausage rump cow tongue bresaola pork pancetta biltong tail chicken turkey hamburger. Kevin flank pork loin salami biltong. Alcatra landjaeger pastrami andouille kielbasa ham tenderloin drumstick sausage turducken tongue corned beef.';
    14     }
    159
    1610    public function test_get_comment_excerpt() {
  • trunk/tests/phpunit/tests/comment/query.php

    r49603 r50449  
    1212    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
    1313        self::$post_id = $factory->post->create();
    14     }
    15 
    16     function setUp() {
    17         parent::setUp();
    1814    }
    1915
  • trunk/tests/phpunit/tests/dbdelta.php

    r48937 r50449  
    8080        );
    8181
     82        // This has to be called after the `CREATE TABLE` above as the `_create_temporary_tables` filter
     83        // causes it to create a temporary table, and a temporary table cannot use a FULLTEXT index.
    8284        parent::setUp();
    8385    }
  • trunk/tests/phpunit/tests/feed/wp-simplepie-file.php

    r49803 r50449  
    1818class Tests_WP_SimplePie_File extends WP_UnitTestCase {
    1919    public static function setUpBeforeClass() {
     20        parent::setUpBeforeClass();
     21
    2022        require_once ABSPATH . '/wp-includes/class-simplepie.php';
    2123        require_once ABSPATH . '/wp-includes/class-wp-simplepie-file.php';
  • trunk/tests/phpunit/tests/image/editor.php

    r49230 r50449  
    2020        require_once DIR_TESTDATA . '/../includes/mock-image-editor.php';
    2121
     22        // This needs to come after the mock image editor class is loaded.
    2223        parent::setUp();
    2324    }
  • trunk/tests/phpunit/tests/image/editorGd.php

    r49757 r50449  
    1818        require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    1919
     20        // This needs to come after the mock image editor class is loaded.
    2021        parent::setUp();
    2122    }
  • trunk/tests/phpunit/tests/image/editorImagick.php

    r49757 r50449  
    1919        require_once DIR_TESTROOT . '/includes/class-wp-test-stream.php';
    2020
     21        // This needs to come after the mock image editor class is loaded.
    2122        parent::setUp();
    2223    }
  • trunk/tests/phpunit/tests/image/resizeGd.php

    r48937 r50449  
    2222        require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php';
    2323
     24        // This needs to come after the mock image editor class is loaded.
    2425        parent::setUp();
    2526    }
  • trunk/tests/phpunit/tests/image/resizeImagick.php

    r47198 r50449  
    2222        require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php';
    2323
     24        // This needs to come after the mock image editor class is loaded.
    2425        parent::setUp();
    2526    }
  • trunk/tests/phpunit/tests/menu/walker-nav-menu.php

    r49215 r50449  
    2424
    2525        $this->_wp_nav_menu_max_depth = $_wp_nav_menu_max_depth;
    26         parent::setUp();
    2726    }
    2827
  • trunk/tests/phpunit/tests/menu/wpAjaxMenuQuickSearch.php

    r47747 r50449  
    1717     */
    1818    function setUp() {
     19        parent::setUp();
     20
    1921        global $current_screen;
    2022        $this->current_screen = $current_screen;
    21         parent::setUp();
    2223    }
    2324
  • trunk/tests/phpunit/tests/post/formats.php

    r49354 r50449  
    55 */
    66class Tests_Post_Formats extends WP_UnitTestCase {
    7     function setUp() {
    8         parent::setUp();
    9     }
    10 
    117    function test_set_get_post_format_for_post() {
    128        $post_id = self::factory()->post->create();
  • trunk/tests/phpunit/tests/post/getPages.php

    r49327 r50449  
    66
    77class Tests_Post_GetPages extends WP_UnitTestCase {
    8     function setUp() {
    9         parent::setUp();
    10     }
    11 
    128    /**
    139     * @ticket 23167
  • trunk/tests/phpunit/tests/query/setupPostdata.php

    r48937 r50449  
    1111
    1212    protected $pages_global;
    13 
    14     public function setUp() {
    15         parent::setUp();
    16         return;
    17 
    18         foreach ( $this->global_keys as $global_key ) {
    19             if ( isset( $GLOBALS[ $global_key ] ) ) {
    20                 $this->global_data[ $global_key ] = $GLOBALS[ $global_key ];
    21                 unset( $GLOBALS[ $global_key ] );
    22             } else {
    23                 $this->global_data[ $global_key ] = null;
    24             }
    25         }
    26     }
    2713
    2814    public function test_id() {
  • trunk/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php

    r49603 r50449  
    134134     */
    135135    public function setUp() {
     136        parent::setUp();
     137
    136138        $this->register_test_block();
    137139        $this->register_post_context_test_block();
    138140        $this->register_non_dynamic_block();
    139141        $this->register_dynamic_block_with_boolean_attributes();
    140         parent::setUp();
    141142    }
    142143
  • trunk/tests/phpunit/tests/upload.php

    r49184 r50449  
    99
    1010    function setUp() {
     11        parent::setUp();
    1112        $this->_reset_options();
    12         parent::setUp();
    1313    }
    1414
  • trunk/tests/phpunit/tests/walker.php

    r49184 r50449  
    1010
    1111    function setUp() {
     12        parent::setUp();
    1213
    1314        $this->walker = new Walker_Test();
    14 
    15         parent::setUp();
    16 
    1715    }
    1816
Note: See TracChangeset for help on using the changeset viewer.