-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement specialized alternatives to assertInternalType() and assertNotInternalType() #3368
Comments
can you elaborate on that one, @sebastianbergmann ? I agree that with |
What will happen to same checks just for arrays? $this->assertContainsOnly('string', $types); |
what phpunit min version has the new assertions? |
These assertions were implemented for PHPUnit 7.5. |
what's the replacement for such code: $this->assertInternalType(gettype($algo), $res['algo']); |
@glensc Maybe... $assertIsType = 'assertIs'.gettype($algo);
$this->$assertIsType($res['algo']); But... if you need this dynamic, you may need a redesign of the test. 😅 |
Is there a way to make these available in PHPUnit 6? I'd be tempted to reply to my own question with "just use a modern version of PHPUnit", so here some background of why this change sucks for me. I maintain a number of MediaWiki extensions. The development version of MediaWiki uses PHPUnit 8, so no problems there. However the latest LTS uses PHPUnit 6. Which means I cannot use the new assertion methods introduced in PHPUnit 7.5. So I'm forced to either write instant legacy assertions and live with a pile of warnings, or to drop testing against a very relevant version of MediaWiki from the CI. |
Well... there are the changes in a406c85#diff-9ae7a972d07df5f73629d5d315bf405a Yo can create a |
Thanks for the link. I asked here in the hope there already is a package that provides a copy. |
$this->assertEquals(gettype($algo), gettype($res['algo'])); |
…tIs[Not]Array()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * sebastianbergmann/phpunit#3368
…Is[Not]Bool()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * sebastianbergmann/phpunit#3368
…tIs[Not]Float()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * sebastianbergmann/phpunit#3368
…s[Not]Int()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * sebastianbergmann/phpunit#3368
…tIs[Not]Float()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * sebastianbergmann/phpunit#3368
…s[Not]Int()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * sebastianbergmann/phpunit#3368 Includes removing a few assignments made within function calls.
…rtIs[Not]Object()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * sebastianbergmann/phpunit#3368
…sertIs[Not]Resource()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * sebastianbergmann/phpunit#3368
…rtIs[Not]String()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * sebastianbergmann/phpunit#3368
* Update Dockerfile - Removed PHP 5.5 & Added PHP 7.4 - PHP Redis Extension 4.3.0 is the latest version to support PHP 5 - Update Redis to 6.0.8 and enable TLS support for PHP 7 * Update .travis.yml - Update php-redis to 5.3.0 - Update redis-server to 6.0.8 * Fixes test failures - Use [assertIsArray](sebastianbergmann/phpunit#3368) method since PHPUnit v7.5 - Fixes AUTH error message changed since Redis v6 - `getMock()` is deprecated since PHPUnit v5.4 * Update Client.php - PHP Redis extension support TLS since [5.3.0](https://pecl.php.net/package/redis/5.3.0) - Fixes AUTH may not cleanup last error
As documented here: sebastianbergmann/phpunit#3368
As documented here: sebastianbergmann/phpunit#3368 Signed-off-by: Nathan Boiron <[email protected]>
PHPUnit 8 specializes several assertion methods: - sebastianbergmann/phpunit#3368 - sebastianbergmann/phpunit#3422 (comment)
PHPUnit 8 specializes several assertion methods: - sebastianbergmann/phpunit#3368 - sebastianbergmann/phpunit#3422 (comment)
* Add npm command to run tests in wp-env * Add a base env:tests-cmd script * Run composer install before running tests * Upgrade phpunit to 8.5 (latest 8.* minor release) * Void return type must now be specified in certain test methods See 'Return Type of Template Methods' at https://phpunit.de/announcements/phpunit-8.html * Remove calls to deprecated assertInternalType() See sebastianbergmann/phpunit#3368 * Don't generate test cache file * Don't use depreacated canonicalize parameter of assertEquals() * Using assertContains() with string haystacks is deprecated * Upgrade phpunit to 9.6 (latest 9.* minor release) * assertObjectHasAttribute() is deprecated in favour of assertObjectHasProperty() * assertRegExp() is deprecated in favour of assertMatchesRegularExpression() * Remove commented out code * Only run tests against nightly once * In GitHub actions, test under PHP 8.3 instead of 7.4 * Document jobs * In GitHub actions, also test under PHP 7.4 * Add some PHPUnit workflows with PHP 7.4 * Expand GitHub workflows matrix, instead of specifying each job --------- Co-authored-by: Jesús Amieiro Becerra <[email protected]>
Implement
assertIsArray()
assertIsBool()
assertIsFloat()
assertIsInt()
assertIsNumeric()
assertIsObject()
assertIsResource()
assertIsString()
assertIsScalar()
assertIsCallable()
assertIsIterable()
assertIsNotArray()
assertIsNotBool()
assertIsNotFloat()
assertIsNotInt()
assertIsNotNumeric()
assertIsNotObject()
assertIsNotResource()
assertIsNotString()
assertIsNotScalar()
assertIsNotCallable()
assertIsNotIterable()
The text was updated successfully, but these errors were encountered: