<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[51560] trunk/tests/phpunit/includes: Build/Test Tools: Unify the PHPUnit adapter TestCases.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/51560">51560</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/51560","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-08-06 00:35:01 +0000 (Fri, 06 Aug 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Build/Test Tools: Unify the PHPUnit adapter TestCases.
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 <a href="https://core.trac.wordpress.org/changeset/51559">[51559]</a>.
Props jrf, hellofromTonya, johnbillion, netweb, SergeyBiryukov.
See <a href="https://core.trac.wordpress.org/ticket/46149">#46149</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunitincludesbootstrapphp">trunk/tests/phpunit/includes/bootstrap.php</a></li>
<li><a href="#trunktestsphpunitincludestestcasephp">trunk/tests/phpunit/includes/testcase.php</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunktestsphpunitincludesphpunit7testcasephp">trunk/tests/phpunit/includes/phpunit7/testcase.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunitincludesbootstrapphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/includes/bootstrap.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/includes/bootstrap.php 2021-08-06 00:33:33 UTC (rev 51559)
+++ trunk/tests/phpunit/includes/bootstrap.php 2021-08-06 00:35:01 UTC (rev 51560)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,6 +50,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> require_once __DIR__ . '/class-mockobject-autoload.php';
</span><span class="cx" style="display: block; padding: 0 10px"> spl_autoload_register( 'MockObject_Autoload::load', true, true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Check that the PHPUnit Polyfills autoloader exists.
+$phpunit_polyfills_autoloader = __DIR__ . '/../../../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
+if ( ! file_exists( $phpunit_polyfills_autoloader ) ) {
+ echo "Error: You need to run `composer update` before running the tests.\n";
+ echo "You can still use a PHPUnit phar to run them, but the dependencies do need to be installed.\n";
+ exit( 1 );
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // If running core tests, check if all the required PHP extensions are loaded before running the test suite.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $required_extensions = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -195,13 +203,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> require __DIR__ . '/phpunit6/compat.php';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-// Load separate WP_UnitTestCase classes for PHPUnit 7.5+ and older versions.
-if ( version_compare( tests_get_phpunit_version(), '7.5', '>=' ) ) {
- require __DIR__ . '/phpunit7/testcase.php';
-} else {
- require __DIR__ . '/testcase.php';
-}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Load the PHPUnit Polyfills autoloader (check for existence of the file is done earlier in the script).
+require_once $phpunit_polyfills_autoloader;
+unset( $phpunit_polyfills_autoloader );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+require __DIR__ . '/abstract-testcase.php';
+require __DIR__ . '/testcase.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> require __DIR__ . '/testcase-rest-api.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require __DIR__ . '/testcase-rest-controller.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require __DIR__ . '/testcase-rest-post-type-controller.php';
</span></span></pre></div>
<a id="trunktestsphpunitincludesphpunit7testcasephp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/includes/phpunit7/testcase.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/includes/phpunit7/testcase.php 2021-08-06 00:33:33 UTC (rev 51559)
+++ trunk/tests/phpunit/includes/phpunit7/testcase.php 2021-08-06 00:35:01 UTC (rev 51560)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,14 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-
-require_once dirname( __DIR__ ) . '/abstract-testcase.php';
-
-/**
- * Defines a basic fixture to run multiple tests.
- *
- * Resets the state of the WordPress installation before and after every test.
- *
- * Includes utility functions and assertions useful for testing WordPress.
- *
- * All WordPress unit tests should inherit from this class.
- */
-class WP_UnitTestCase extends WP_UnitTestCase_Base {}
</del></span></pre></div>
<a id="trunktestsphpunitincludestestcasephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/includes/testcase.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/includes/testcase.php 2021-08-06 00:33:33 UTC (rev 51559)
+++ trunk/tests/phpunit/includes/testcase.php 2021-08-06 00:35:01 UTC (rev 51560)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,439 +1,48 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-require_once __DIR__ . '/abstract-testcase.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+use Yoast\PHPUnitPolyfills\Helpers\AssertAttributeHelper;
+use Yoast\PHPUnitPolyfills\Polyfills\AssertClosedResource;
+use Yoast\PHPUnitPolyfills\Polyfills\AssertEqualsSpecializations;
+use Yoast\PHPUnitPolyfills\Polyfills\AssertFileDirectory;
+use Yoast\PHPUnitPolyfills\Polyfills\AssertFileEqualsSpecializations;
+use Yoast\PHPUnitPolyfills\Polyfills\AssertionRenames;
+use Yoast\PHPUnitPolyfills\Polyfills\AssertIsType;
+use Yoast\PHPUnitPolyfills\Polyfills\AssertNumericType;
+use Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals;
+use Yoast\PHPUnitPolyfills\Polyfills\AssertStringContains;
+use Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations;
+use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
+use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionMessageMatches;
+use Yoast\PHPUnitPolyfills\Polyfills\ExpectExceptionObject;
+use Yoast\PHPUnitPolyfills\Polyfills\ExpectPHPException;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Defines a basic fixture to run multiple tests.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Basic abstract test class with PHPUnit cross-version adapter layer.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Resets the state of the WordPress installation before and after every test.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * This adapter layer polyfills all PHPUnit assertion and expectation
+ * methods which were added between PHPUnit 4.8 - 9.5 to allow tests
+ * to benefit from the full range of available PHPUnit methods.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Includes utility functions and assertions useful for testing WordPress.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * See {@link https://github.com/Yoast/PHPUnit-Polyfills} for full
+ * documentation on the available polyfills.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * All WordPress unit tests should inherit from this class.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_UnitTestCase extends WP_UnitTestCase_Base {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Asserts that two variables are equal (with delta).
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.6.0
- *
- * @param mixed $expected First value to compare.
- * @param mixed $actual Second value to compare.
- * @param float $delta Allowed numerical distance between two values to consider them equal.
- * @param string $message Optional. Message to display when the assertion fails.
- *
- * @throws ExpectationFailedException
- * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
- */
- public static function assertEqualsWithDelta( $expected, $actual, $delta, $message = '' ) {
- static::assertEquals( $expected, $actual, $message, $delta );
- }
-
- /**
- * Asserts that a variable is of type array.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsArray( $actual, $message = '' ) {
- static::assertInternalType( 'array', $actual, $message );
- }
-
- /**
- * Asserts that a variable is of type bool.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsBool( $actual, $message = '' ) {
- static::assertInternalType( 'bool', $actual, $message );
- }
-
- /**
- * Asserts that a variable is of type float.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsFloat( $actual, $message = '' ) {
- static::assertInternalType( 'float', $actual, $message );
- }
-
- /**
- * Asserts that a variable is of type int.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsInt( $actual, $message = '' ) {
- static::assertInternalType( 'int', $actual, $message );
- }
-
- /**
- * Asserts that a variable is of type numeric.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNumeric( $actual, $message = '' ) {
- static::assertInternalType( 'numeric', $actual, $message );
- }
-
- /**
- * Asserts that a variable is of type object.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsObject( $actual, $message = '' ) {
- static::assertInternalType( 'object', $actual, $message );
- }
-
- /**
- * Asserts that a variable is of type resource.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsResource( $actual, $message = '' ) {
- static::assertInternalType( 'resource', $actual, $message );
- }
-
- /**
- * Asserts that a variable is of type string.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsString( $actual, $message = '' ) {
- static::assertInternalType( 'string', $actual, $message );
- }
-
- /**
- * Asserts that a variable is of type scalar.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsScalar( $actual, $message = '' ) {
- static::assertInternalType( 'scalar', $actual, $message );
- }
-
- /**
- * Asserts that a variable is of type callable.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsCallable( $actual, $message = '' ) {
- static::assertInternalType( 'callable', $actual, $message );
- }
-
- /**
- * Asserts that a variable is of type iterable.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * Support for `iterable` was only added to `Assert::assertNotInternalType()`
- * in PHPUnit 7.1.0, so this polyfill cannot use a direct fall-through
- * to that functionality until WordPress test suite requires PHPUnit 7.1.0
- * as the minimum version.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsIterable( $actual, $message = '' ) {
- static::assertTrue( is_iterable( $actual ), $message );
- }
-
- /**
- * Asserts that a variable is not of type array.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotArray( $actual, $message = '' ) {
- static::assertNotInternalType( 'array', $actual, $message );
- }
-
- /**
- * Asserts that a variable is not of type bool.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotBool( $actual, $message = '' ) {
- static::assertNotInternalType( 'bool', $actual, $message );
- }
-
- /**
- * Asserts that a variable is not of type float.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotFloat( $actual, $message = '' ) {
- static::assertNotInternalType( 'float', $actual, $message );
- }
-
- /**
- * Asserts that a variable is not of type int.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotInt( $actual, $message = '' ) {
- static::assertNotInternalType( 'int', $actual, $message );
- }
-
- /**
- * Asserts that a variable is not of type numeric.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotNumeric( $actual, $message = '' ) {
- static::assertNotInternalType( 'numeric', $actual, $message );
- }
-
- /**
- * Asserts that a variable is not of type object.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotObject( $actual, $message = '' ) {
- static::assertNotInternalType( 'object', $actual, $message );
- }
-
- /**
- * Asserts that a variable is not of type resource.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotResource( $actual, $message = '' ) {
- static::assertNotInternalType( 'resource', $actual, $message );
- }
-
- /**
- * Asserts that a variable is not of type string.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotString( $actual, $message = '' ) {
- static::assertNotInternalType( 'string', $actual, $message );
- }
-
- /**
- * Asserts that a variable is not of type scalar.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotScalar( $actual, $message = '' ) {
- static::assertNotInternalType( 'scalar', $actual, $message );
- }
-
- /**
- * Asserts that a variable is not of type callable.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotCallable( $actual, $message = '' ) {
- static::assertNotInternalType( 'callable', $actual, $message );
- }
-
- /**
- * Asserts that a variable is not of type iterable.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * Support for `iterable` was only added to `Assert::assertNotInternalType()`
- * in PHPUnit 7.1.0, so this polyfill cannot use a direct fall-through
- * to that functionality until WordPress test suite requires PHPUnit 7.1.0
- * as the minimum version.
- *
- * @since 5.9.0
- *
- * @param mixed $actual The value to check.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertIsNotIterable( $actual, $message = '' ) {
- static::assertFalse( is_iterable( $actual ), $message );
- }
-
- /**
- * Asserts that a string haystack contains a needle.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param string $needle The string to search for.
- * @param string $haystack The string to treat as the haystack.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertStringContainsString( $needle, $haystack, $message = '' ) {
- static::assertContains( $needle, $haystack, $message );
- }
-
- /**
- * Asserts that a string haystack contains a needle (case-insensitive).
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param string $needle The string to search for.
- * @param string $haystack The string to treat as the haystack.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertStringContainsStringIgnoringCase( $needle, $haystack, $message = '' ) {
- static::assertContains( $needle, $haystack, $message, true );
- }
-
- /**
- * Asserts that a string haystack does not contain a needle.
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param string $needle The string to search for.
- * @param string $haystack The string to treat as the haystack.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertStringNotContainsString( $needle, $haystack, $message = '' ) {
- static::assertNotContains( $needle, $haystack, $message );
- }
-
- /**
- * Asserts that a string haystack does not contain a needle (case-insensitive).
- *
- * This method has been backported from a more recent PHPUnit version,
- * as tests running on PHP 5.6 use PHPUnit 5.7.x.
- *
- * @since 5.9.0
- *
- * @param string $needle The string to search for.
- * @param string $haystack The string to treat as the haystack.
- * @param string $message Optional. Message to display when the assertion fails.
- */
- public static function assertStringNotContainsStringIgnoringCase( $needle, $haystack, $message = '' ) {
- static::assertNotContains( $needle, $haystack, $message, true );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ use AssertAttributeHelper;
+ use AssertClosedResource;
+ use AssertEqualsSpecializations;
+ use AssertFileDirectory;
+ use AssertFileEqualsSpecializations;
+ use AssertionRenames;
+ use AssertIsType;
+ use AssertNumericType;
+ use AssertObjectEquals;
+ use AssertStringContains;
+ use EqualToSpecializations;
+ use ExpectException;
+ use ExpectExceptionMessageMatches;
+ use ExpectExceptionObject;
+ use ExpectPHPException;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>