Skip to content

Commit

Permalink
Closes #3338
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 19, 2018
1 parent eb66a56 commit 915195e
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 761 deletions.
1 change: 1 addition & 0 deletions ChangeLog-8.0.md
Expand Up @@ -7,6 +7,7 @@ All notable changes of the PHPUnit 8.0 release series are documented in this fil
### Changed

* Implemented [#3288](https://github.com/sebastianbergmann/phpunit/issues/3288): The `void_return` fixer of php-cs-fixer is now in effect
* Implemented [#3338](https://github.com/sebastianbergmann/phpunit/issues/3338): Deprecate assertions (and helper methods) that operate on (non-public) attributes
* Implemented [#3341](https://github.com/sebastianbergmann/phpunit/issues/3341): Deprecate optional parameters of `assertEquals()` and `assertNotEquals()`
* Implemented [#3369](https://github.com/sebastianbergmann/phpunit/issues/3369): Deprecate `assertInternalType()` and `assertNotInternalType()`

Expand Down
50 changes: 50 additions & 0 deletions src/Framework/Assert.php
Expand Up @@ -214,6 +214,8 @@ public static function assertContains($needle, $haystack, string $message = '',
*/
public static function assertAttributeContains($needle, string $haystackAttributeName, $haystackClassOrObject, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void
{
self::createWarning('assertAttributeContains() is deprecated and will be removed in PHPUnit 9.');

static::assertContains(
$needle,
static::readAttribute($haystackClassOrObject, $haystackAttributeName),
Expand Down Expand Up @@ -278,6 +280,8 @@ public static function assertNotContains($needle, $haystack, string $message = '
*/
public static function assertAttributeNotContains($needle, string $haystackAttributeName, $haystackClassOrObject, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void
{
self::createWarning('assertAttributeNotContains() is deprecated and will be removed in PHPUnit 9.');

static::assertNotContains(
$needle,
static::readAttribute($haystackClassOrObject, $haystackAttributeName),
Expand Down Expand Up @@ -342,6 +346,8 @@ public static function assertContainsOnlyInstancesOf(string $className, iterable
*/
public static function assertAttributeContainsOnly(string $type, string $haystackAttributeName, $haystackClassOrObject, ?bool $isNativeType = null, string $message = ''): void
{
self::createWarning('assertAttributeContainsOnly() is deprecated and will be removed in PHPUnit 9.');

static::assertContainsOnly(
$type,
static::readAttribute($haystackClassOrObject, $haystackAttributeName),
Expand Down Expand Up @@ -389,6 +395,8 @@ public static function assertNotContainsOnly(string $type, iterable $haystack, ?
*/
public static function assertAttributeNotContainsOnly(string $type, string $haystackAttributeName, $haystackClassOrObject, ?bool $isNativeType = null, string $message = ''): void
{
self::createWarning('assertAttributeNotContainsOnly() is deprecated and will be removed in PHPUnit 9.');

static::assertNotContainsOnly(
$type,
static::readAttribute($haystackClassOrObject, $haystackAttributeName),
Expand Down Expand Up @@ -431,6 +439,8 @@ public static function assertCount(int $expectedCount, $haystack, string $messag
*/
public static function assertAttributeCount(int $expectedCount, string $haystackAttributeName, $haystackClassOrObject, string $message = ''): void
{
self::createWarning('assertAttributeCount() is deprecated and will be removed in PHPUnit 9.');

static::assertCount(
$expectedCount,
static::readAttribute($haystackClassOrObject, $haystackAttributeName),
Expand Down Expand Up @@ -472,6 +482,8 @@ public static function assertNotCount(int $expectedCount, $haystack, string $mes
*/
public static function assertAttributeNotCount(int $expectedCount, string $haystackAttributeName, $haystackClassOrObject, string $message = ''): void
{
self::createWarning('assertAttributeNotCount() is deprecated and will be removed in PHPUnit 9.');

static::assertNotCount(
$expectedCount,
static::readAttribute($haystackClassOrObject, $haystackAttributeName),
Expand Down Expand Up @@ -580,6 +592,8 @@ public static function assertEqualsWithDelta($expected, $actual, float $delta, s
*/
public static function assertAttributeEquals($expected, string $actualAttributeName, $actualClassOrObject, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): void
{
self::createWarning('assertAttributeEquals() is deprecated and will be removed in PHPUnit 9.');

static::assertEquals(
$expected,
static::readAttribute($actualClassOrObject, $actualAttributeName),
Expand Down Expand Up @@ -705,6 +719,8 @@ public static function assertNotEqualsWithDelta($expected, $actual, float $delta
*/
public static function assertAttributeNotEquals($expected, string $actualAttributeName, $actualClassOrObject, string $message = '', float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): void
{
self::createWarning('assertAttributeNotEquals() is deprecated and will be removed in PHPUnit 9.');

static::assertNotEquals(
$expected,
static::readAttribute($actualClassOrObject, $actualAttributeName),
Expand Down Expand Up @@ -740,6 +756,8 @@ public static function assertEmpty($actual, string $message = ''): void
*/
public static function assertAttributeEmpty(string $haystackAttributeName, $haystackClassOrObject, string $message = ''): void
{
self::createWarning('assertAttributeEmpty() is deprecated and will be removed in PHPUnit 9.');

static::assertEmpty(
static::readAttribute($haystackClassOrObject, $haystackAttributeName),
$message
Expand Down Expand Up @@ -770,6 +788,8 @@ public static function assertNotEmpty($actual, string $message = ''): void
*/
public static function assertAttributeNotEmpty(string $haystackAttributeName, $haystackClassOrObject, string $message = ''): void
{
self::createWarning('assertAttributeNotEmpty() is deprecated and will be removed in PHPUnit 9.');

static::assertNotEmpty(
static::readAttribute($haystackClassOrObject, $haystackAttributeName),
$message
Expand Down Expand Up @@ -799,6 +819,8 @@ public static function assertGreaterThan($expected, $actual, string $message = '
*/
public static function assertAttributeGreaterThan($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void
{
self::createWarning('assertAttributeGreaterThan() is deprecated and will be removed in PHPUnit 9.');

static::assertGreaterThan(
$expected,
static::readAttribute($actualClassOrObject, $actualAttributeName),
Expand Down Expand Up @@ -833,6 +855,8 @@ public static function assertGreaterThanOrEqual($expected, $actual, string $mess
*/
public static function assertAttributeGreaterThanOrEqual($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void
{
self::createWarning('assertAttributeGreaterThanOrEqual() is deprecated and will be removed in PHPUnit 9.');

static::assertGreaterThanOrEqual(
$expected,
static::readAttribute($actualClassOrObject, $actualAttributeName),
Expand Down Expand Up @@ -863,6 +887,8 @@ public static function assertLessThan($expected, $actual, string $message = ''):
*/
public static function assertAttributeLessThan($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void
{
self::createWarning('assertAttributeLessThan() is deprecated and will be removed in PHPUnit 9.');

static::assertLessThan(
$expected,
static::readAttribute($actualClassOrObject, $actualAttributeName),
Expand Down Expand Up @@ -893,6 +919,8 @@ public static function assertLessThanOrEqual($expected, $actual, string $message
*/
public static function assertAttributeLessThanOrEqual($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void
{
self::createWarning('assertAttributeLessThanOrEqual() is deprecated and will be removed in PHPUnit 9.');

static::assertLessThanOrEqual(
$expected,
static::readAttribute($actualClassOrObject, $actualAttributeName),
Expand Down Expand Up @@ -1443,6 +1471,8 @@ public static function assertSame($expected, $actual, string $message = ''): voi
*/
public static function assertAttributeSame($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void
{
self::createWarning('assertAttributeSame() is deprecated and will be removed in PHPUnit 9.');

static::assertSame(
$expected,
static::readAttribute($actualClassOrObject, $actualAttributeName),
Expand Down Expand Up @@ -1486,6 +1516,8 @@ public static function assertNotSame($expected, $actual, string $message = ''):
*/
public static function assertAttributeNotSame($expected, string $actualAttributeName, $actualClassOrObject, string $message = ''): void
{
self::createWarning('assertAttributeNotSame() is deprecated and will be removed in PHPUnit 9.');

static::assertNotSame(
$expected,
static::readAttribute($actualClassOrObject, $actualAttributeName),
Expand Down Expand Up @@ -1524,6 +1556,8 @@ public static function assertInstanceOf(string $expected, $actual, string $messa
*/
public static function assertAttributeInstanceOf(string $expected, string $attributeName, $classOrObject, string $message = ''): void
{
self::createWarning('assertAttributeInstanceOf() is deprecated and will be removed in PHPUnit 9.');

static::assertInstanceOf(
$expected,
static::readAttribute($classOrObject, $attributeName),
Expand Down Expand Up @@ -1564,6 +1598,8 @@ public static function assertNotInstanceOf(string $expected, $actual, string $me
*/
public static function assertAttributeNotInstanceOf(string $expected, string $attributeName, $classOrObject, string $message = ''): void
{
self::createWarning('assertAttributeNotInstanceOf() is deprecated and will be removed in PHPUnit 9.');

static::assertNotInstanceOf(
$expected,
static::readAttribute($classOrObject, $attributeName),
Expand Down Expand Up @@ -1602,6 +1638,8 @@ public static function assertInternalType(string $expected, $actual, string $mes
*/
public static function assertAttributeInternalType(string $expected, string $attributeName, $classOrObject, string $message = ''): void
{
self::createWarning('assertAttributeInternalType() is deprecated and will be removed in PHPUnit 9.');

static::assertInternalType(
$expected,
static::readAttribute($classOrObject, $attributeName),
Expand Down Expand Up @@ -1906,6 +1944,8 @@ public static function assertIsNotIterable($actual, string $message = ''): void
*/
public static function assertAttributeNotInternalType(string $expected, string $attributeName, $classOrObject, string $message = ''): void
{
self::createWarning('assertAttributeNotInternalType() is deprecated and will be removed in PHPUnit 9.');

static::assertNotInternalType(
$expected,
static::readAttribute($classOrObject, $attributeName),
Expand Down Expand Up @@ -2535,6 +2575,8 @@ public static function isNan(): IsNan
*/
public static function attribute(Constraint $constraint, string $attributeName): Attribute
{
self::createWarning('attribute() is deprecated and will be removed in PHPUnit 9.');

return new Attribute($constraint, $attributeName);
}

Expand Down Expand Up @@ -2571,6 +2613,8 @@ public static function equalTo($value, float $delta = 0.0, int $maxDepth = 10, b
*/
public static function attributeEqualTo(string $attributeName, $value, float $delta = 0.0, int $maxDepth = 10, bool $canonicalize = false, bool $ignoreCase = false): Attribute
{
self::createWarning('attributeEqualTo() is deprecated and will be removed in PHPUnit 9.');

return static::attribute(
static::equalTo(
$value,
Expand Down Expand Up @@ -2718,6 +2762,8 @@ public static function fail(string $message = ''): void
*/
public static function readAttribute($classOrObject, string $attributeName)
{
self::createWarning('readAttribute() is deprecated and will be removed in PHPUnit 9.');

if (!self::isValidAttributeName($attributeName)) {
throw InvalidArgumentHelper::factory(2, 'valid attribute name');
}
Expand Down Expand Up @@ -2760,6 +2806,8 @@ public static function readAttribute($classOrObject, string $attributeName)
*/
public static function getStaticAttribute(string $className, string $attributeName)
{
self::createWarning('getStaticAttribute() is deprecated and will be removed in PHPUnit 9.');

if (!\class_exists($className)) {
throw InvalidArgumentHelper::factory(1, 'class name');
}
Expand Down Expand Up @@ -2800,6 +2848,8 @@ public static function getStaticAttribute(string $className, string $attributeNa
*/
public static function getObjectAttribute($object, string $attributeName)
{
self::createWarning('getObjectAttribute() is deprecated and will be removed in PHPUnit 9.');

if (!\is_object($object)) {
throw InvalidArgumentHelper::factory(1, 'object');
}
Expand Down
19 changes: 0 additions & 19 deletions tests/end-to-end/regression/Trac/523.phpt

This file was deleted.

23 changes: 0 additions & 23 deletions tests/end-to-end/regression/Trac/523/Issue523Test.php

This file was deleted.

0 comments on commit 915195e

Please sign in to comment.