Changeset 51843
- Timestamp:
- 09/21/2021 10:48:47 PM (3 years ago)
- Location:
- branches/5.5
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.5
- Property svn:mergeinfo changed
/trunk merged: 51559-51560,51810-51813,51828
- Property svn:mergeinfo changed
-
branches/5.5/.github/workflows/phpunit-tests.yml
r50673 r51843 24 24 env: 25 25 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} 26 COMPOSER_INSTALL: ${{ false }}27 26 # Controls which NPM script to use for running PHPUnit tests. Options ar `php` and `php-composer`. 28 27 PHPUNIT_SCRIPT: php … … 140 139 - name: Get composer cache directory 141 140 id: composer-cache 142 if: ${{ env.COMPOSER_INSTALL == true }}143 141 run: echo "::set-output name=dir::$(composer config cache-files-dir)" 144 142 145 143 - name: Cache Composer dependencies 146 if: ${{ env.COMPOSER_INSTALL == true }}147 144 uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 148 145 env: … … 153 150 154 151 - name: Install Composer dependencies 155 if: ${{ env.COMPOSER_INSTALL == true }} 156 run: | 157 docker-compose run --rm php composer --version 158 docker-compose run --rm php composer install 152 run: | 153 if [ ${{ env.LOCAL_PHP }} == '7.1-fpm' ]; then 154 docker-compose run --rm php composer update 155 git checkout -- composer.lock 156 elif [[ ${{ env.LOCAL_PHP }} == '5.6.20-fpm' || ${{ env.LOCAL_PHP }} == '5.6-fpm' || ${{ env.LOCAL_PHP }} == '7.0-fpm' ]]; then 157 docker-compose run --rm php composer require --dev phpunit/phpunit:"^5.7" --update-with-dependencies 158 git checkout -- composer.lock composer.json 159 else 160 docker-compose run --rm php composer install 161 fi 159 162 160 163 - name: Docker debug information -
branches/5.5/composer.json
r49313 r51843 17 17 "wp-coding-standards/wpcs": "~2.3.0", 18 18 "phpcompatibility/phpcompatibility-wp": "^2.1.0", 19 "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5" 19 "phpunit/phpunit": "^5.7.21 || ^6.5 || ^7.5", 20 "yoast/phpunit-polyfills": "^1.0.1" 20 21 }, 21 22 "scripts": { -
branches/5.5/composer.lock
r49313 r51843 5 5 "This file is @generated automatically" 6 6 ], 7 "content-hash": " 463db2b4afb439fb63d93173c0852e27",7 "content-hash": "9e9eda16834511e20c7fef4c012b6744", 8 8 "packages": [], 9 9 "packages-dev": [ … … 72 72 "tests" 73 73 ], 74 "support": {75 "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues",76 "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer"77 },78 74 "time": "2020-06-25T14:57:39+00:00" 79 75 }, … … 132 128 "instantiate" 133 129 ], 130 "funding": [ 131 { 132 "url": "https://www.doctrine-project.org/sponsorship.html", 133 "type": "custom" 134 }, 135 { 136 "url": "https://www.patreon.com/phpdoctrine", 137 "type": "patreon" 138 }, 139 { 140 "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", 141 "type": "tidelift" 142 } 143 ], 134 144 "time": "2020-05-29T17:27:14+00:00" 135 145 }, … … 340 350 "standards" 341 351 ], 352 "support": { 353 "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", 354 "source": "https://github.com/PHPCompatibility/PHPCompatibility" 355 }, 342 356 "time": "2019-12-27T09:44:58+00:00" 343 357 }, … … 905 919 "tokenizer" 906 920 ], 921 "abandoned": true, 907 922 "time": "2019-09-17T06:23:10+00:00" 908 923 }, … … 1664 1679 "portable" 1665 1680 ], 1681 "funding": [ 1682 { 1683 "url": "https://symfony.com/sponsor", 1684 "type": "custom" 1685 }, 1686 { 1687 "url": "https://github.com/fabpot", 1688 "type": "github" 1689 }, 1690 { 1691 "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 1692 "type": "tidelift" 1693 } 1694 ], 1666 1695 "time": "2020-05-12T16:14:59+00:00" 1667 1696 }, … … 1711 1740 "source": { 1712 1741 "type": "git", 1713 "url": "https://github.com/webmozart /assert.git",1742 "url": "https://github.com/webmozarts/assert.git", 1714 1743 "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6" 1715 1744 }, 1716 1745 "dist": { 1717 1746 "type": "zip", 1718 "url": "https://api.github.com/repos/webmozart /assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6",1747 "url": "https://api.github.com/repos/webmozarts/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6", 1719 1748 "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6", 1720 1749 "shasum": "" … … 1798 1827 "wordpress" 1799 1828 ], 1829 "support": { 1830 "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", 1831 "source": "https://github.com/WordPress/WordPress-Coding-Standards", 1832 "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" 1833 }, 1800 1834 "time": "2020-05-13T23:57:56+00:00" 1835 }, 1836 { 1837 "name": "yoast/phpunit-polyfills", 1838 "version": "1.0.1", 1839 "source": { 1840 "type": "git", 1841 "url": "https://github.com/Yoast/PHPUnit-Polyfills.git", 1842 "reference": "f014fb21c2b0038fd329515d59025af42fb98715" 1843 }, 1844 "dist": { 1845 "type": "zip", 1846 "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/f014fb21c2b0038fd329515d59025af42fb98715", 1847 "reference": "f014fb21c2b0038fd329515d59025af42fb98715", 1848 "shasum": "" 1849 }, 1850 "require": { 1851 "php": ">=5.4", 1852 "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0" 1853 }, 1854 "require-dev": { 1855 "php-parallel-lint/php-console-highlighter": "^0.5", 1856 "php-parallel-lint/php-parallel-lint": "^1.3.0", 1857 "yoast/yoastcs": "^2.1.0" 1858 }, 1859 "type": "library", 1860 "extra": { 1861 "branch-alias": { 1862 "dev-main": "1.x-dev", 1863 "dev-develop": "1.x-dev" 1864 } 1865 }, 1866 "autoload": { 1867 "files": [ 1868 "phpunitpolyfills-autoload.php" 1869 ] 1870 }, 1871 "notification-url": "https://packagist.org/downloads/", 1872 "license": [ 1873 "BSD-3-Clause" 1874 ], 1875 "authors": [ 1876 { 1877 "name": "Team Yoast", 1878 "email": "support@yoast.com", 1879 "homepage": "https://yoast.com" 1880 }, 1881 { 1882 "name": "Contributors", 1883 "homepage": "https://github.com/Yoast/PHPUnit-Polyfills/graphs/contributors" 1884 } 1885 ], 1886 "description": "Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests", 1887 "homepage": "https://github.com/Yoast/PHPUnit-Polyfills", 1888 "keywords": [ 1889 "phpunit", 1890 "polyfill", 1891 "testing" 1892 ], 1893 "support": { 1894 "issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues", 1895 "source": "https://github.com/Yoast/PHPUnit-Polyfills" 1896 }, 1897 "time": "2021-08-09T16:28:08+00:00" 1801 1898 } 1802 1899 ], … … 1809 1906 "php": ">=5.6" 1810 1907 }, 1811 "platform-dev": [] 1908 "platform-dev": [], 1909 "plugin-api-version": "1.1.0" 1812 1910 } -
branches/5.5/tests/phpunit/includes/bootstrap.php
r48592 r51843 40 40 $phpunit_version = tests_get_phpunit_version(); 41 41 42 if ( version_compare( $phpunit_version, '5. 4', '<' ) || version_compare( $phpunit_version, '8.0', '>=' ) ) {42 if ( version_compare( $phpunit_version, '5.7.21', '<' ) || version_compare( $phpunit_version, '8.0', '>=' ) ) { 43 43 printf( 44 "Error: Looks like you're using PHPUnit %s. WordPress requires at least PHPUnit 5. 4and is currently only compatible with PHPUnit up to 7.x.\n",44 "Error: Looks like you're using PHPUnit %s. WordPress requires at least PHPUnit 5.7.21 and is currently only compatible with PHPUnit up to 7.x.\n", 45 45 $phpunit_version 46 46 ); … … 53 53 exit( 1 ); 54 54 } 55 56 /* 57 * Load the PHPUnit Polyfills autoloader. 58 * 59 * The PHPUnit Polyfills are a requirement for the WP test suite. 60 * 61 * For running the Core tests, the Make WordPress Core handbook contains step-by-step instructions 62 * on how to get up and running for a variety of supported workflows: 63 * {@link https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/#test-running-workflow-options} 64 * 65 * Plugin/theme integration tests can handle this in any of the following ways: 66 * - When using a full WP install: run `composer install` for the WP install prior to running the tests. 67 * - When using a partial WP test suite install: 68 * - Add a `yoast/phpunit-polyfills` (dev) requirement to the plugin/theme's own `composer.json` file. 69 * - And then: 70 * - Either load the PHPUnit Polyfills autoload file prior to running the WP core bootstrap file. 71 * - Or declare a `WP_TESTS_PHPUNIT_POLYFILLS_PATH` constant containing the absolute path to the 72 * root directory of the PHPUnit Polyfills installation. 73 * If the constant is used, it is strongly recommended to declare this constant in the plugin/theme's 74 * own test bootstrap file. 75 * The constant MUST be declared prior to calling this file. 76 */ 77 if ( ! class_exists( 'Yoast\PHPUnitPolyfills\Autoload' ) ) { 78 // Default location of the autoloader for WP core test runs. 79 $phpunit_polyfills_autoloader = dirname( dirname( dirname( __DIR__ ) ) ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php'; 80 $phpunit_polyfills_error = false; 81 82 // Allow for a custom installation location to be provided for plugin/theme integration tests. 83 if ( defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) { 84 $phpunit_polyfills_path = WP_TESTS_PHPUNIT_POLYFILLS_PATH; 85 86 if ( is_string( WP_TESTS_PHPUNIT_POLYFILLS_PATH ) 87 && '' !== WP_TESTS_PHPUNIT_POLYFILLS_PATH 88 ) { 89 // Be tolerant to the path being provided including the filename. 90 if ( substr( $phpunit_polyfills_path, -29 ) !== 'phpunitpolyfills-autoload.php' ) { 91 $phpunit_polyfills_path = rtrim( $phpunit_polyfills_path, '/\\' ); 92 $phpunit_polyfills_path = $phpunit_polyfills_path . '/phpunitpolyfills-autoload.php'; 93 } 94 95 $phpunit_polyfills_autoloader = $phpunit_polyfills_path; 96 } else { 97 $phpunit_polyfills_error = true; 98 } 99 } 100 101 if ( $phpunit_polyfills_error || ! file_exists( $phpunit_polyfills_autoloader ) ) { 102 echo 'Error: The PHPUnit Polyfills library is a requirement for running the WP test suite.' . PHP_EOL; 103 if ( defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) { 104 printf( 105 'The PHPUnit Polyfills autoload file was not found in "%s"' . PHP_EOL, 106 WP_TESTS_PHPUNIT_POLYFILLS_PATH 107 ); 108 echo 'Please verify that the file path provided in the WP_TESTS_PHPUNIT_POLYFILLS_PATH constant is correct.' . PHP_EOL; 109 echo 'The WP_TESTS_PHPUNIT_POLYFILLS_PATH constant should contain an absolute path to the root directory' 110 . ' of the PHPUnit Polyfills library.' . PHP_EOL; 111 } elseif ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { 112 echo 'You need to run `composer install` before running the tests.' . PHP_EOL; 113 echo 'Once the dependencies are installed, you can run the tests using the Composer-installed version' 114 . ' of PHPUnit or using a PHPUnit phar file, but the dependencies do need to be installed' 115 . ' whichever way the tests are run.' . PHP_EOL; 116 } else { 117 echo 'If you are trying to run plugin/theme integration tests, make sure the PHPUnit Polyfills library' 118 . ' (https://github.com/Yoast/PHPUnit-Polyfills) is available and either load the autoload file' 119 . ' of this library in your own test bootstrap before calling the WP Core test bootstrap file;' 120 . ' or set the absolute path to the PHPUnit Polyfills library in a "WP_TESTS_PHPUNIT_POLYFILLS_PATH"' 121 . ' constant to allow the WP Core bootstrap to load the Polyfills.' . PHP_EOL . PHP_EOL; 122 echo 'If you are trying to run the WP Core tests, make sure to set the "WP_RUN_CORE_TESTS" constant' 123 . ' to 1 and run `composer install` before running the tests.' . PHP_EOL; 124 echo 'Once the dependencies are installed, you can run the tests using the Composer-installed' 125 . ' version of PHPUnit or using a PHPUnit phar file, but the dependencies do need to be' 126 . ' installed whichever way the tests are run.' . PHP_EOL; 127 } 128 exit( 1 ); 129 } 130 131 require_once $phpunit_polyfills_autoloader; 132 } 133 unset( $phpunit_polyfills_autoloader, $phpunit_polyfills_error, $phpunit_polyfills_path ); 134 135 /* 136 * Minimum version of the PHPUnit Polyfills package as declared in `composer.json`. 137 * Only needs updating when new polyfill features start being used in the test suite. 138 */ 139 $phpunit_polyfills_minimum_version = '1.0.1'; 140 if ( class_exists( '\Yoast\PHPUnitPolyfills\Autoload' ) 141 && ( defined( '\Yoast\PHPUnitPolyfills\Autoload::VERSION' ) === false 142 || version_compare( Yoast\PHPUnitPolyfills\Autoload::VERSION, $phpunit_polyfills_minimum_version, '<' ) ) 143 ) { 144 printf( 145 'Error: Version mismatch detected for the PHPUnit Polyfills.' 146 . ' Please ensure that PHPUnit Polyfills %s or higher is loaded. Found version: %s' . PHP_EOL, 147 $phpunit_polyfills_minimum_version, 148 defined( '\Yoast\PHPUnitPolyfills\Autoload::VERSION' ) ? Yoast\PHPUnitPolyfills\Autoload::VERSION : '1.0.0 or lower' 149 ); 150 if ( defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) { 151 printf( 152 'Please ensure that the PHPUnit Polyfill installation in "%s" is updated to version %s or higher.' . PHP_EOL, 153 WP_TESTS_PHPUNIT_POLYFILLS_PATH, 154 $phpunit_polyfills_minimum_version 155 ); 156 } elseif ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { 157 echo 'Please run `composer install` to install the latest version.' . PHP_EOL; 158 } 159 exit( 1 ); 160 } 161 unset( $phpunit_polyfills_minimum_version ); 55 162 56 163 $required_constants = array( -
branches/5.5/tests/phpunit/includes/phpunit7/testcase.php
r47198 r51843 1 1 <?php 2 3 use Yoast\PHPUnitPolyfills\Helpers\AssertAttributeHelper; 4 use Yoast\PHPUnitPolyfills\Polyfills\AssertClosedResource; 5 use Yoast\PHPUnitPolyfills\Polyfills\AssertEqualsSpecializations; 6 use Yoast\PHPUnitPolyfills\Polyfills\AssertFileDirectory; 7 use Yoast\PHPUnitPolyfills\Polyfills\AssertFileEqualsSpecializations; 8 use Yoast\PHPUnitPolyfills\Polyfills\AssertionRenames; 9 use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType; 10 use Yoast\PHPUnitPolyfills\Polyfills\AssertNumericType; 11 use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals; 12 use Yoast\PHPUnitPolyfills\Polyfills\AssertStringContains; 13 use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations; 14 use Yoast\PHPUnitPolyfills\Polyfills\ExpectException; 15 use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches; 16 use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject; 17 use Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException; 2 18 3 19 require_once dirname( __DIR__ ) . '/abstract-testcase.php'; … … 14 30 class WP_UnitTestCase extends WP_UnitTestCase_Base { 15 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 16 48 /** 17 * Asserts that a condition is not false. 18 * 19 * This method has been backported from a more recent PHPUnit version, as tests running on PHP 5.2 use 20 * PHPUnit 3.6.x. 21 * 22 * @since 4.7.4 23 * 24 * @param bool $condition Condition to check. 25 * @param string $message Optional. Message to display when the assertion fails. 26 * 27 * @throws PHPUnit_Framework_AssertionFailedError 49 * Wrapper method for the `setUpBeforeClass()` method for forward-compatibility with WP 5.9. 28 50 */ 29 public static function assertNotFalse( $condition, string $message = '' ): void { 30 self::assertThat( $condition, self::logicalNot( self::isFalse() ), $message ); 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(); 31 74 } 32 75 } -
branches/5.5/tests/phpunit/includes/testcase.php
r47198 r51843 1 1 <?php 2 3 use Yoast\PHPUnitPolyfills\Helpers\AssertAttributeHelper; 4 use Yoast\PHPUnitPolyfills\Polyfills\AssertClosedResource; 5 use Yoast\PHPUnitPolyfills\Polyfills\AssertEqualsSpecializations; 6 use Yoast\PHPUnitPolyfills\Polyfills\AssertFileDirectory; 7 use Yoast\PHPUnitPolyfills\Polyfills\AssertFileEqualsSpecializations; 8 use Yoast\PHPUnitPolyfills\Polyfills\AssertionRenames; 9 use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType; 10 use Yoast\PHPUnitPolyfills\Polyfills\AssertNumericType; 11 use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals; 12 use Yoast\PHPUnitPolyfills\Polyfills\AssertStringContains; 13 use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations; 14 use Yoast\PHPUnitPolyfills\Polyfills\ExpectException; 15 use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches; 16 use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject; 17 use Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException; 2 18 3 19 require_once __DIR__ . '/abstract-testcase.php'; … … 14 30 class WP_UnitTestCase extends WP_UnitTestCase_Base { 15 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 16 48 /** 17 * Asserts that a condition is not false. 18 * 19 * This method has been backported from a more recent PHPUnit version, as tests running on PHP 5.2 use 20 * PHPUnit 3.6.x. 21 * 22 * @since 4.7.4 23 * 24 * @param bool $condition Condition to check. 25 * @param string $message Optional. Message to display when the assertion fails. 26 * 27 * @throws PHPUnit_Framework_AssertionFailedError 49 * Wrapper method for the `setUpBeforeClass()` method for forward-compatibility with WP 5.9. 28 50 */ 29 public static function assertNotFalse( $condition, $message = '' ) { 30 self::assertThat( $condition, self::logicalNot( self::isFalse() ), $message ); 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(); 31 74 } 32 75 }
Note: See TracChangeset
for help on using the changeset viewer.