Make WordPress Core


Ignore:
Timestamp:
08/21/2022 04:55:18 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Remove dynamic properties in theme tests.

Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this particular group of test files, the test classes contain a set_up() method which sets a few dynamic (not explicitly declared) properties.

For those properties which were set using a function call or variable access, the property has been explicitly declared on the class now.

For those properties which were set using a constant scalar expression and for which the value is not changed by any of the tests, the property setting has been removed in favor of declaring a class constant.

Includes removing one unused dynamic property declaration: $this->queries in Test_Block_Supports_Layout, which appears to be a copy/paste from Tests_Theme_wpThemeJsonResolver.

Follow-up to [40/tests], [260/tests], [598/tests], [50960], [52675], [53085], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856].

Props jrf.
See #56033.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesTheme.php

    r52010 r53916  
    55class Tests_Admin_IncludesTheme extends WP_UnitTestCase {
    66
     7    /**
     8     * Theme root directory.
     9     *
     10     * @var string
     11     */
     12    const THEME_ROOT = DIR_TESTDATA . '/themedir1';
     13
     14    /**
     15     * Original theme directory.
     16     *
     17     * @var string
     18     */
     19    private $orig_theme_dir;
     20
    721    public function set_up() {
    822        parent::set_up();
    9         $this->theme_root = DIR_TESTDATA . '/themedir1';
    1023
    1124        $this->orig_theme_dir            = $GLOBALS['wp_theme_directories'];
    12         $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
     25        $GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', self::THEME_ROOT );
    1326
    1427        add_filter( 'theme_root', array( $this, 'filter_theme_root' ) );
     
    3447    // Replace the normal theme root directory with our premade test directory.
    3548    public function filter_theme_root( $dir ) {
    36         return $this->theme_root;
     49        return self::THEME_ROOT;
    3750    }
    3851
Note: See TracChangeset for help on using the changeset viewer.