As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.
Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]
In this case, `parse_url()` is called with the `PHP_URL_PATH` as `$component`, but the returned value is subsequently checked against `false`.
In other words, this condition would previously always result in `true` and would lead to `null` potentially being passed to the PHP native `pathinfo()` function which expects a string.
On PHP 8.1, this would result in a test failure with a `pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated` error.
Reference: [https://www.php.net/manual/en/function.pathinfo.php PHP Manual: pathinfo()]
Follow-up to [46175].
Props jrf.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51606
git-svn-id: http://core.svn.wordpress.org/trunk@51217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `WP_UnitTestCase_Base::checkRequirements()` method calls the `parent::checkRequirements()` method, but this method became `private` in PHPUnit 7.0 via commit [932238a6a3sebastianbergmann/phpunit@932238a].
Aside from that, the `TestCase::getAnnotations()` method which is called next is now also removed in PHPUnit 9.5.
WP core does not use the method anymore, and the method only remains to prevent potentially breaking external integration tests relying on the method. However, in effect, the method is not functional anymore in PHPUnit 7.0+.
Follow-up to [893/tests], [894/tests], [896/tests], [918/tests], [30526], [40520], [40564], [43005], [44701], [51559-51577].
Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51605
git-svn-id: http://core.svn.wordpress.org/trunk@51216 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This removes the previously duplicated set of test runs specifically for PHP 8.1 in favor of combining `if` conditions for individual test runs with the `continue-on-error` option.
Follow-up to [51588].
Props desrosj, swissspidy, jrf.
Fixes#53891.
Built from https://develop.svn.wordpress.org/trunk@51604
git-svn-id: http://core.svn.wordpress.org/trunk@51215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `WP_UnitTestCase_Base::checkRequirements()` method calls the `parent::checkRequirements()` method, but this method became `private` in PHPUnit 7.0 via commit [932238a6a3sebastianbergmann/phpunit@932238a].
Aside from that, the `TestCase::getAnnotations()` method which is called next is now also removed in PHPUnit 9.5.
WP core does not use the method anymore, and the method only remains to prevent potentially breaking external integration tests relying on the method. However, in effect, the method is not functional anymore in PHPUnit 7.0+.
Follow-up to [893/tests], [894/tests], [896/tests], [918/tests], [30526], [40520], [40564], [43005], [44701], [51559-51577].
Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51602
git-svn-id: http://core.svn.wordpress.org/trunk@51213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The PHPUnit Polyfills are, since [51559], a required dependency for the WP test suite and, by extension, for plugin/theme integration test suites which are based on and use (parts of) the WP core test suite.
However, plugin/theme integration test suites may not use a full WordPress installation.
This commit:
* Removes the presumption that a full WP install, including `vendor` directory, will be available when the test `bootstrap.php` file is run.
* Makes the loading of the PHPUnit Polyfills autoload file more flexible by:
* Checking if the autoload class contained within the autoload file is already available before attempting to load the file.[[BR]]
This allows for plugin/theme integration test suites to load the `phpunitpolyfills-autoload.php` file from any location, as long as it is loaded before the WP core test `bootstrap.php` file is run.
* Allowing for the path to an arbitrary installation location for the PHPUnit Polyfills to be passed as a constant.[[BR]]
As long as the provided location is a valid file path and the `phpunitpolyfills-autoload.php` file exists in the provided location, that file will be loaded.[[BR]]
The constant can be declared in a plugin/theme integration test suite native test bootstrap file, or in the `wp-tests-config.php` file, or even in a `phpunit.xml[.dist]` file via `<php><const name="WP_TESTS_PHPUNIT_POLYFILLS_PATH" value="path/to/yoast/phpunit-polyfills"/></php>`.
* Adds a version check for the PHPUnit Polyfills to prevent a mismatch between the version of the package expected by WordPress and the version used by plugins/themes.[[BR]]
The version this checks for should be in line with the minimum version requirement for the PHPUnit Polyfills as declared in the `composer.json` file.[[BR]]
This version number should only be updated when new features added in later PHPUnit Polyfills releases are actually used in the WP core test suite.
* Adds appropriate error messages for every possible error condition.
* Upgrades the PHPUnit Polyfills to version 1.0.1, which now includes a version constant.
Follow-up to [51559-51577].
Props jrf, hellofromTonya, swissspidy, jeherve, thomasplevy, SergeyBiryukov.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51598
git-svn-id: http://core.svn.wordpress.org/trunk@51209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
A general security rule is "Sanitize when you save, escape when you echo", and for the most part WordPress has well-named functions like `sanitize_email()` and others, with `esc_url_raw()` being a single exception that does not follow the naming.
This commit restores the previously deprecated `sanitize_url()` function as a valid alias of `esc_url_raw()`.
This better aligns with the naming with other `sanitize_*()` functions:
* `sanitize_bookmark()`
* `sanitize_bookmark_field()`
* `sanitize_category()`
* `sanitize_category_field()`
* `sanitize_comment_cookies()`
* `sanitize_email()`
* `sanitize_file_name()`
* `sanitize_hex_color()`
* `sanitize_hex_color_no_hash()`
* `sanitize_html_class()`
* `sanitize_key()`
* `sanitize_meta()`
* `sanitize_mime_type()`
* `sanitize_option()`
* `sanitize_post()`
* `sanitize_post_field()`
* `sanitize_sql_orderby()`
* `sanitize_term()`
* `sanitize_term_field()`
* `sanitize_text_field()`
* `sanitize_textarea_field()`
* `sanitize_title()`
* `sanitize_title_for_query()`
* `sanitize_title_with_dashes()`
* `sanitize_trackback_urls()`
* `sanitize_user()`
* `sanitize_user_field()`
Follow-up to [11383], [13096].
Props Ipstenu, aadilali.
Fixes#53876.
Built from https://develop.svn.wordpress.org/trunk@51597
git-svn-id: http://core.svn.wordpress.org/trunk@51208 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, the original "404" template key was lost when "Default template" is merged into the available templates array, as the `array_merge()` function renumbers numeric keys. Later, when we merge templates on the client side, this caused duplicate "404" templates to appear in the dropdown.
By replacing the `array_merge()` call with `array_replace()`, we make sure to keep the original numeric keys.
Props Mamaduka, Toro_Unit, youknowriad.
Fixes#53898.
Built from https://develop.svn.wordpress.org/trunk@51595
git-svn-id: http://core.svn.wordpress.org/trunk@51206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This fixes the "Deprecated: Return type of `CountableFake::count()` should be compatible with `Countable::count(): int`" warning on PHP 8.1.
PHP native interfaces now have declared return types and methods in classes implementing these interfaces need to either have the return type declared (in a covariant compatible manner with the PHP native interface method declaration), or need to silence the deprecation warning using the `#[ReturnTypeWillChange]` attribute.
Follow-up to [51517], [51529], [51530], [51531], [51532].
Props jrf.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51594
git-svn-id: http://core.svn.wordpress.org/trunk@51205 1a063a9b-81f0-0310-95a4-ce76da25c4cd
PHP 8.1 is expected to be released at the end of November 2021.
Enabling the tests to run in CI on PHP 8.1 allows us to get WordPress ready in time.
As an interim measure, while working through the PHP 8.1 issues, separate conditional steps are added to run the tests on PHP 8.1 with the `continue-on-error` option. That allows the test builds to show as "successful" if all non-PHP 8.1 test runs pass.
Follow-up to [51517], [51543], [51545], [51574], [51582], [51586].
Props jrf.
Fixes#53891. See #53635.
Built from https://develop.svn.wordpress.org/trunk@51588
git-svn-id: http://core.svn.wordpress.org/trunk@51199 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Since PHP 8.1, the `strftime()` and `gmstrftime()` functions are deprecated:
> The `strftime()` and `gmstrftime()` functions exhibit similar issues as `strptime()`, in that the formats they support, as well as their behavior, is platform-dependent. Unlike `strptime()`, these functions are available on Windows, though with a different feature set than on Linux. Musl-based distributions like Alpine do not support timezone-related format specifiers correctly. These functions are also locale-based, and as such may exhibit thread-safety issues.
>
> `date()` or `DateTime::format()` provide portable alternatives, and `IntlDateFormatter::format()` provides a more sophisticated, localization-aware alternative.
Reference: [https://wiki.php.net/rfc/deprecations_php_8_1#strftime_and_gmstrftime PHP RFC: Deprecations for PHP 8.1: strftime() and gmstrftime()]
> The `strftime()` and `gmstrftime()` functions have been deprecated in favor of
> `date()/DateTime::format()` (for locale-independent formatting) or
> `IntlDateFormatter::format()` (for locale-dependent formatting).
Reference: [1cf4fb739f/UPGRADING (L379-L381) PHP 8.1 Upgrade Notes].
Aside from one instance in SimplePie, the `strftime()` and `gmstrftime()` functions are only used within the test suite of WordPress to create formatted timestamps.
As the function is used in test code, this leads to test warnings like this on PHP 8.1:
{{{
Deprecated: Function strftime() is deprecated in path/to/tests/phpunit/tests/canonical/postStatus.php on line 37
}}}
These calls can all be safely converted to use a pattern along the lines of:
{{{#!php
<?php
date_format( date_create( 'time phrase or timestamp' ), $format )
}}}
Other references:
* [https://www.php.net/manual/en/function.strftime.php PHP Manual: strftime()] (for the old format string characters)
* [https://www.php.net/manual/en/datetime.format.php PHP Manual: DateTime::format()] (for the new format string characters)
* [https://www.php.net/manual/en/datetime.construct.php PHP Manual: DateTime::__construct()] (see Example 2 for a Unix timestamp code sample)
Props jrf, SergeyBiryukov.
Fixes#53897.
Built from https://develop.svn.wordpress.org/trunk@51587
git-svn-id: http://core.svn.wordpress.org/trunk@51198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Since PHP 8.1, `readonly` is a reserved keyword and cannot be used as a function name.
In order to avoid PHP parser errors, the `readonly()` function was extracted to a separate file and is now only included conditionally on PHP < 8.1.
This commit also:
* Moves the tests for the `__checked_selected_helper()` function and all the related functions to their own file.
* Switches to named data providers. This makes the output when using the `--testdox` option more descriptive and is helpful when trying to debug which data set from a data provider failed the test.
* Improves the tests in question to make them feature-complete and expand test coverage.
Props jrf, ayeshrajans, haosun, knutsp, swissspidy, SergeyBiryukov.
Fixes#53858.
Built from https://develop.svn.wordpress.org/trunk@51586
git-svn-id: http://core.svn.wordpress.org/trunk@51197 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Not all CLI tools can handle Unicode characters or non-system specific line endings well, so this type of CLI messaging should always be written with the optimal cross-platform, cross-CLI tool end-user experience in mind.
Follow-up to [51581].
Props jrf.
See #53363.
Built from https://develop.svn.wordpress.org/trunk@51584
git-svn-id: http://core.svn.wordpress.org/trunk@51195 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The current config files validate against the PHPUnit XSD schema for config files for PHPUnit 5.7 – 9.2.
The schema was changed in PHPUnit 9.3, and the `filter` and `logging` settings were deprecated in favor of `coverage` and a different format for `logging`.
This commit explicitly sets the schema against which the files currently validate, for clarity.
Props jrf.
See #53363.
Built from https://develop.svn.wordpress.org/trunk@51583
git-svn-id: http://core.svn.wordpress.org/trunk@51194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Prior to PHP 8.1, the default error handling mode was `MYSQLI_REPORT_OFF`. An error in the extension, database, query, or the database connection returned `false` and emitted a PHP warning:
{{{
$mysqli = new mysqli("localhost", "non-existing-user", "", "");
Warning: mysqli::__construct(): (HY000/2002): No connection could be made because the target machine actively refused it in ... on line ...
}}}
From PHP 8.1 and later, the default error mode is set to `MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT`. An error in the extension, database, query, or the database connection throws an exception:
{{{
$mysqli = new mysqli("localhost", "non-existing-user", "", "");
Fatal error: Uncaught mysqli_sql_exception: Connection refused in ...:...
}}}
WordPress has its own error reporting and gracefully handles the database errors by inspecting the error codes. Setting the MySQLi error reporting to off avoids fatal errors due to uncaught exceptions and maintains the current behavior.
References:
* [https://php.watch/versions/8.1/mysqli-error-mode PHP 8.1: MySQLi: Default error mode set to exceptions]
* [https://wiki.php.net/rfc/mysqli_default_errmode PHP RFC: Change Default mysqli Error Mode]
Props ayeshrajans, jrf.
Fixes#52825.
Built from https://develop.svn.wordpress.org/trunk@51582
git-svn-id: http://core.svn.wordpress.org/trunk@51193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Any messages to the user which are echo-ed out in the test bootstrap will generally display on a command-line interface.
The *nix specific `"\n"` line ending will be ignored on Windows, making the messages less readable.
For new lines in CLI messages, `PHP_EOL` should be used instead.
This was already done in a few places in the script, but not consistently so. Fixed now.
Follow-up to [UT882], [UT890], [44723], [45020], [48592], [49535], [51560].
Props jrf.
See #53363.
Built from https://develop.svn.wordpress.org/trunk@51581
git-svn-id: http://core.svn.wordpress.org/trunk@51192 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This replaces instances of `assertTrue( is_dir( ... ) )` with `assertDirectoryExists()` to use native PHPUnit functionality.
The `assertDirectoryExists()` method was introduced in PHPUnit 5.6. As the minimum supported PHPUnit version has been raised to PHPUnit 5.7.21, it can now be used.
Follow-up to [51543], [51574], [51579].
Props jrf.
See #53363.
Built from https://develop.svn.wordpress.org/trunk@51580
git-svn-id: http://core.svn.wordpress.org/trunk@51191 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This replaces instances of `assertTrue( is_file( ... ) )` followed by `assertTrue( is_readable( ... ) )` with `assertFileIsReadable()` to use native PHPUnit functionality.
The `assertFileIsReadable()` method was introduced in PHPUnit 5.6. As the minimum supported PHPUnit version has been raised to PHPUnit 5.7.21, it can now be used.
Follow-up to [51543], [51574].
Props jrf.
See #53363.
Built from https://develop.svn.wordpress.org/trunk@51579
git-svn-id: http://core.svn.wordpress.org/trunk@51190 1a063a9b-81f0-0310-95a4-ce76da25c4cd
**composer.json**:
Remove the PHPUnit dependency in favor of allowing the PHPUnit Polyfills library to manage the supported PHPUnit version. This automatically now widens the supported PHPUnit versions to 5.7.21 to 9.5.8 (current).
Letting the PHPUnit Polyfills handle the version constraints for PHPUnit prevents potential version conflicts in the future, as well as allows WordPress to benefit straight away when a new PHPUnit version would be released and the PHPUnit Polyfills package adds support for that PHPUnit version.
**Test Bootstrap**
Update the supported version number for PHPUnit 5.x, as the minimum PHPUnit 5.x version supported by the PHPUnit Polyfills is PHPUnit 5.7.21, and remove the PHPUnit maximum.
**.gitignore and svn:ignore:**
Add the PHPUnit cache file to the list of files to be ignored.
Since PHPUnit 8, PHPUnit has a built-in caching feature which creates a `.phpunit.result.cache` file. This file should not be committed.
Follow-up to [40536], [40853], [44701], [51559-51573].
Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51574
git-svn-id: http://core.svn.wordpress.org/trunk@51185 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Now that the tests can run PHPUnit cross-version and Composer will be used to install the test suite in CI, we could switch out the local copies of the [https://github.com/johnkary/phpunit-speedtrap PHPUnit speedtrap] package in favor of using the Composer package, which would prevent us having to make the WP local copies of the class compatible with later PHPUnit versions.
The SpeedTrap test listener was introduced to identify slow tests and take action on these to make them faster.
In practice, however, no notable action was ever taken based on the output of the test listener in all the years it was in place.
With that in mind, it was decided to remove the SpeedTrap test listeners without replacement.
If – at a future date – contributors would want to take action to speed up slow tests anyway, they can:
* Either add the package to their local install and use the output they receive locally to identify slow tests.
* Or use the PHPUnit native `@small` annotations in combination with the PHPUnit `PHP_Invoker` package as described in the PHPUnit documentation to [https://phpunit.readthedocs.io/en/stable/risky-tests.html#test-execution-timeout run tests with time limits].
Follow-up to [35214], [35226], [35767], [44701], [51559-51572].
Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51573
git-svn-id: http://core.svn.wordpress.org/trunk@51184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The PHPUnit native `TestCase::getAnnotations()` method is used to check for WP flavored deprecation notices, however, this method was not covered by the backward compatibility promise for PHPUnit (and was annotated as excluded).
The method has been removed as part of an internal refactor in commit [68582043e1sebastianbergmann/phpunit@6858204], which is included in PHPUnit 9.5.0.
For now, a workaround is put in place, but it is recommended that the WP `expectDeprecated()` method should be reevaluated in a future iteration.
Follow-up to [51559-51571].
Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51572
git-svn-id: http://core.svn.wordpress.org/trunk@51183 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Most of the aliasing in this `compat.php` file is redundant as PHPUnit 5.7.21+ contains a forward compatibility layer for these classes anyway (= PHPUnit provides both the namespaced and underscore named versions of these classes in PHPUnit 5.7.21+).
All the same, the file and the aliases are left in place for the time being, as plugins/themes using the WP test suite as the basis for their integration tests may rely on it, though WP itself should not really need it anymore, save for maybe one or two classes.
Follow-up to [51559-51569].
Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51570
git-svn-id: http://core.svn.wordpress.org/trunk@51181 1a063a9b-81f0-0310-95a4-ce76da25c4cd
> PHPUnit 8.0.0 introduced a `void` return type declaration to the "fixture" methods – `setUpBeforeClass()`, `setUp()`, `tearDown()` and `tearDownAfterClass()`. As the `void` return type was not introduced until PHP 7.1, this makes it more difficult to create cross-version compatible tests when using fixtures, due to signature mismatches.
>
> The `Yoast\PHPUnitPolyfills\TestCases\TestCase` overcomes the signature mismatch by having two versions. The correct one will be loaded depending on the PHPUnit version being used.
>
> When using this TestCase, if an individual test, or another TestCase which extends this TestCase, needs to overload any of the "fixture" methods, it should do so by using a snake_case variant of the original fixture method name, i.e. `set_up_before_class()`, `set_up()`, `assert_pre_conditions()`, `assert_post_conditions()`, `tear_down()`, and `tear_down_after_class()`.
>
> The snake_case methods will automatically be called by PHPUnit.
>
> > IMPORTANT: The snake_case methods should not call the PHPUnit parent, i.e. do not use `parent::setUp()` from within an overloaded `set_up()` method. If necessary, DO call `parent::set_up()`.
Reference: https://github.com/Yoast/PHPUnit-Polyfills#testcases
This commit renames all declared fixture methods, and calls to parent versions of those fixture methods, from camelCase to snake_case.
Follow-up to [51559-51567].
Props jrf, hellofromTonya, johnbillion, netweb, dd32, pputzer, SergeyBiryukov.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51568
git-svn-id: http://core.svn.wordpress.org/trunk@51179 1a063a9b-81f0-0310-95a4-ce76da25c4cd
> PHPUnit 8.0.0 introduced a `void` return type declaration to the "fixture" methods – `setUpBeforeClass()`, `setUp()`, `tearDown()` and `tearDownAfterClass()`. As the `void` return type was not introduced until PHP 7.1, this makes it more difficult to create cross-version compatible tests when using fixtures, due to signature mismatches.
>
> The `Yoast\PHPUnitPolyfills\TestCases\TestCase` overcomes the signature mismatch by having two versions. The correct one will be loaded depending on the PHPUnit version being used.
>
> When using this TestCase, if an individual test, or another TestCase which extends this TestCase, needs to overload any of the "fixture" methods, it should do so by using a snake_case variant of the original fixture method name, i.e. `set_up_before_class()`, `set_up()`, `assert_pre_conditions()`, `assert_post_conditions()`, `tear_down()`, and `tear_down_after_class()`.
>
> The snake_case methods will automatically be called by PHPUnit.
>
> > IMPORTANT: The snake_case methods should not call the PHPUnit parent, i.e. do not use `parent::setUp()` from within an overloaded `set_up()` method. If necessary, DO call `parent::set_up()`.
Reference: https://github.com/Yoast/PHPUnit-Polyfills#testcases
This commit:
* Lets the `PHPUnit_Adapter_TestCase` extend the `Yoast\PHPUnitPolyfills\TestCases\TestCase`, which makes this solution for the `void` return type available to the WordPress test suite.
* Removes the individual import and trait `use` statements for the Polyfill traits. These are no longer necessary as the `Yoast\PHPUnitPolyfills\TestCases\TestCase` already includes those.
Follow-up to [51559-51566].
Props jrf, hellofromTonya, johnbillion, netweb, SergeyBiryukov.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51567
git-svn-id: http://core.svn.wordpress.org/trunk@51178 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The old manner of testing these is soft deprecated as of PHPUnit 8.4, hard deprecated as of PHPUnit 9.0 and will be removed in PHPUnit 10.0.
These dedicated methods introduced in PHPUnit 8.4 should be used as an alternative:
* `expectDeprecation()`
* `expectDeprecationMessage()`
* `expectDeprecationMessageMatches()`
* `expectNotice()`
* `expectNoticeMessage()`
* `expectNoticeMessageMatches()`
* `expectWarning()`
* `expectWarningMessage()`
* `expectWarningMessageMatches()`
* `expectError()`
* `expectErrorMessage()`
* `expectErrorMessageMatches()`
These new PHPUnit methods are all polyfilled by the PHPUnit Polyfills and switching to these will future-proof the tests some more.
References:
* https://github.com/sebastianbergmann/phpunit/blob/8.4.3/ChangeLog-8.4.md#840---2019-10-04
* https://github.com/sebastianbergmann/phpunit/issues/3775
Follow-up to [51559-51562].
Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51563
git-svn-id: http://core.svn.wordpress.org/trunk@51174 1a063a9b-81f0-0310-95a4-ce76da25c4cd
PHPUnit 6 deprecated the `setExpectedException()` method in favor of the `expectException()`, `expectExceptionMessage()`, and `expectExceptionCode()` methods.
`WP_UnitTestCase_Base::setExpectedException()` backfilled the old method. As the PHPUnit Polyfills have a polyfill for the ''new'' method, this backfill can now be simplified.
This backfill ''should'' be removed in a future iteration, but is, for now, left in place so as not to break backward compatibility for plugin/theme test suites which extend the WP native test suite for their integration tests.
Follow-up to [48996], [48997], [51559-51561].
Props jrf.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51562
git-svn-id: http://core.svn.wordpress.org/trunk@51173 1a063a9b-81f0-0310-95a4-ce76da25c4cd
As things were, the inheritance order of the abstract test classes was as follows:
{{{
WP_UnitTestCase (PHPUnit adapter layer)
extends WP_UnitTestCase_Base (base test class)
extends PHPUnit\Framework\TestCase (PHPUnit native class)
}}}
Concrete (child) test classes, as well as more specific abstract TestCases, are/were expected to extend the `WP_UnitTestCase`.
This order is not optimal as it means that the `WP_UnitTestCase_Base` class would not be able to benefit from any polyfills and/or shims in the PHPUnit adapter layer.
With that in mind, this commit changes the inheritance to:
{{{
WP_UnitTestCase (empty class, left in place to not break BC for plugin/theme integration tests)
extends WP_UnitTestCase_Base (base test class)
extends PHPUnit_Adapter_TestCase (PHPUnit adapter layer)
extends PHPUnit\Framework\TestCase (PHPUnit native class)
}}}
The new order allows for the `WP_UnitTestCase_Base` to also benefit from the PHPUnit adapter layer.
For backward compatibility reasons the `WP_UnitTestCase`, which all test classes are (were) expected to extend, is left in place, though it is now an empty class and explicitly `abstract`.
Follow-up to [51559], [51560].
Props jrf, hellofromTonya, johnbillion, netweb, SergeyBiryukov.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51561
git-svn-id: http://core.svn.wordpress.org/trunk@51172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit:
* Removes the PHPUnit 7 specific `TestCase`.
* Removes all existing polyfills from the PHPUnit 5.x `TestCase`.
* Imports all polyfill traits from the PHPUnit Polyfills package into the `WP_UnitTestCase` class and updates the DocBlock to reflect the actual function of the class.
* Note: The list of polyfills needs to be verified and updated after each new release of the PHPUnit Polyfills package. Alternatively (recommended), one of the built-in `TestCase` classes from the PHPUnit Polyfills package can be used instead.
* Moves the `require` for the WP `abstract-testcase.php` to the `bootstrap.php` file.
* Adds a `require_once` for the PHPUnit Polyfills autoloader to the `bootstrap.php` file.
* Note: while this isn't _strictly_ necessary when the tests are run via Composer, having the include in the bootstrap allows for the tests to also be run via a PHPUnit Phar, providing contributors with more flexibility.
Follow-up to [51559].
Props jrf, hellofromTonya, johnbillion, netweb, SergeyBiryukov.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51560
git-svn-id: http://core.svn.wordpress.org/trunk@51171 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The PHPUnit Polyfills package is an add-on for PHPUnit, which works around common issues for writing PHPUnit cross-version compatible tests.
Features:
* It offers a full set of polyfills for assertions and expectations introduced in PHPUnit since PHPUnit 4.8.
* It offers two generic TestCases which include these polyfills, but also solve the `void` return type issue for the fixtures methods.
* It offers a PHPUnit cross-version solution for the changes to the PHPUnit `TestListener` implementation.
* Supports PHPUnit 4.8 – current.
* Supports and is compatible with PHP 5.4 – current.
The package has no outside dependencies, other than PHPUnit, is actively maintained and endorsed by the maintainer of PHPUnit itself (the only package of its kind which has ever been endorsed).
Props jrf, hellofromTonya, johnbillion, netweb, SergeyBiryukov.
See #46149.
Built from https://develop.svn.wordpress.org/trunk@51559
git-svn-id: http://core.svn.wordpress.org/trunk@51170 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Since branch filtering happens prior to the workflow run being created, filtering the branches that `workflow_run` will fire on for this workflow should cut down on the number of skipped “Slack Notifications” runs listed in the Actions section of the repository.
This also removes the check for a `skipped` outcome in the requesting workflow. Workflows for push events resulting from WordPress Core commits are never skipped.
See #52644.
Built from https://develop.svn.wordpress.org/trunk@51558
git-svn-id: http://core.svn.wordpress.org/trunk@51169 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This updates the conditional check for the Slack notifications workflow to check the event of the original workflow and not the one requested through the `workflow_run:completed` event.
The run triggering the event is accessible at `github.event.workflow_run`.
Props Clorith.
See #52644.
Built from https://develop.svn.wordpress.org/trunk@51555
git-svn-id: http://core.svn.wordpress.org/trunk@51166 1a063a9b-81f0-0310-95a4-ce76da25c4cd