Make WordPress Core


Ignore:
Timestamp:
09/21/2021 07:04:34 PM (3 years ago)
Author:
desrosj
Message:

Build/Test Tools: Introduce the PHPUnit Polyfills package for easier cross branch testing.

This backports the PHPUnit Polyfills package and related test infrastructure changes to make it easier for developers to continue testing on multiple versions WordPress while adding tests for newer versions of PHP, which require more modern PHPUnit practices.

One of the changes included is the addition of wrappers for the new snake_case fixture methods in PHPUnit. This allows the native camelCase standard in PHPUnit to be used, but allows for developers to transition to the new naming conventions.

Props hellofromTonya, jrf, SergeyBiryukov, johnbillion, netweb, schlessera, jeherve, lucatume, desrosj.
Merges [51559,51560,51810-51813,51828] to the 5.8 branch.
See #53911.

Location:
branches/5.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.8

  • branches/5.8/tests/phpunit/includes/phpunit7/testcase.php

    r50986 r51838  
    11<?php
     2
     3use Yoast\PHPUnitPolyfills\Helpers\AssertAttributeHelper;
     4use Yoast\PHPUnitPolyfills\Polyfills\AssertClosedResource;
     5use Yoast\PHPUnitPolyfills\Polyfills\AssertEqualsSpecializations;
     6use Yoast\PHPUnitPolyfills\Polyfills\AssertFileDirectory;
     7use Yoast\PHPUnitPolyfills\Polyfills\AssertFileEqualsSpecializations;
     8use Yoast\PHPUnitPolyfills\Polyfills\AssertionRenames;
     9use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType;
     10use Yoast\PHPUnitPolyfills\Polyfills\AssertNumericType;
     11use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals;
     12use Yoast\PHPUnitPolyfills\Polyfills\AssertStringContains;
     13use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations;
     14use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
     15use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches;
     16use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject;
     17use Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException;
    218
    319require_once dirname( __DIR__ ) . '/abstract-testcase.php';
     
    1228 * All WordPress unit tests should inherit from this class.
    1329 */
    14 class WP_UnitTestCase extends WP_UnitTestCase_Base {}
     30class WP_UnitTestCase extends WP_UnitTestCase_Base {
     31
     32    use AssertAttributeHelper;
     33    use AssertClosedResource;
     34    use AssertEqualsSpecializations;
     35    use AssertFileDirectory;
     36    use AssertFileEqualsSpecializations;
     37    use AssertionRenames;
     38    use AssertIsType;
     39    use AssertNumericType;
     40    use AssertObjectEquals;
     41    use AssertStringContains;
     42    use EqualToSpecializations;
     43    use ExpectException;
     44    use ExpectExceptionMessageMatches;
     45    use ExpectExceptionObject;
     46    use ExpectPHPException;
     47
     48    /**
     49     * Wrapper method for the `setUpBeforeClass()` method for forward-compatibility with WP 5.9.
     50     */
     51    public static function set_up_before_class() {
     52        static::setUpBeforeClass();
     53    }
     54
     55    /**
     56     * Wrapper method for the `tearDownAfterClass()` method for forward-compatibility with WP 5.9.
     57     */
     58    public static function tear_down_after_class() {
     59        static::tearDownAfterClass();
     60    }
     61
     62    /**
     63     * Wrapper method for the `setUp()` method for forward-compatibility with WP 5.9.
     64     */
     65    public function set_up() {
     66        static::setUp();
     67    }
     68
     69    /**
     70     * Wrapper method for the `tearDown()` method for forward-compatibility with WP 5.9.
     71     */
     72    public function tear_down() {
     73        static::tearDown();
     74    }
     75}
Note: See TracChangeset for help on using the changeset viewer.