diff --git a/config/sets/composer-based.php b/config/sets/composer-based.php index 7e210c47..2e90d7ca 100644 --- a/config/sets/composer-based.php +++ b/config/sets/composer-based.php @@ -23,6 +23,7 @@ use Rector\PHPUnit\PHPUnit100\Rector\Class_\ParentTestClassConstructorRector; use Rector\PHPUnit\PHPUnit100\Rector\Class_\PublicDataProviderClassMethodRector; use Rector\PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector; +use Rector\PHPUnit\PHPUnit100\Rector\MethodCall\PropertyExistsWithoutAssertRector; use Rector\PHPUnit\PHPUnit100\Rector\MethodCall\RemoveSetMethodsMethodCallRector; use Rector\PHPUnit\PHPUnit100\Rector\StmtsAwareInterface\WithConsecutiveRector; use Rector\PHPUnit\PHPUnit110\Rector\CallLike\AssertContainsOnlyMethodCallRector; @@ -148,6 +149,7 @@ AddProphecyTraitRector::class, WithConsecutiveRector::class, RemoveSetMethodsMethodCallRector::class, + PropertyExistsWithoutAssertRector::class, ParentTestClassConstructorRector::class, // PHPUnit 11.0 diff --git a/rules-tests/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector/Fixture/assert_object_has_attribute.php.inc b/rules-tests/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector/Fixture/assert_object_has_attribute.php.inc deleted file mode 100644 index 865ad4ae..00000000 --- a/rules-tests/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector/Fixture/assert_object_has_attribute.php.inc +++ /dev/null @@ -1,31 +0,0 @@ -assertObjectHasAttribute('property', $someObject); - } -} - -?> ------ -assertTrue(property_exists($someObject, 'property')); - } -} - -?> diff --git a/rules-tests/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector/Fixture/skip_assert_object_has_attribute.php.inc b/rules-tests/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector/Fixture/skip_assert_object_has_attribute.php.inc new file mode 100644 index 00000000..446dd0e9 --- /dev/null +++ b/rules-tests/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector/Fixture/skip_assert_object_has_attribute.php.inc @@ -0,0 +1,17 @@ +assertObjectHasAttribute('property', $someObject); + $this->assertObjectNotHasAttribute('property', $someObject); + } +} + +?> diff --git a/rules/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector.php b/rules/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector.php index 2cfcce44..faffda21 100644 --- a/rules/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector.php +++ b/rules/PHPUnit100/Rector/MethodCall/PropertyExistsWithoutAssertRector.php @@ -34,16 +34,18 @@ public function provideComposerPackageConstraint(): ComposerPackageConstraint } /** + * The assertObjectHasAttribute() and assertObjectNotHasAttribute() methods are left out on purpose, + * as they have a direct replacement in assertObjectHasProperty() and assertObjectNotHasProperty(). + * Those renames are handled by RenameMethodRector in the composer-based set. + * * @var array */ private const array RENAME_METHODS_WITH_OBJECT_MAP = [ 'assertClassHasAttribute' => 'assertTrue', - 'assertObjectHasAttribute' => 'assertTrue', 'assertClassHasStaticAttribute' => 'assertTrue', // false 'assertClassNotHasStaticAttribute' => 'assertFalse', 'assertClassNotHasAttribute' => 'assertFalse', - 'assertObjectNotHasAttribute' => 'assertFalse', // no assert 'objectHasAttribute' => 'assertTrue', 'classHasAttribute' => 'assertTrue',