Skip to content

[PHPUnit 10] Rename assertObjectHasAttribute() to assertObjectHasProperty(), add AssertIssetToAssertObjectHasPropertyRector#338

Merged
TomasVotruba merged 6 commits intomainfrom
tv-test-provider
Jun 22, 2024
Merged

[PHPUnit 10] Rename assertObjectHasAttribute() to assertObjectHasProperty(), add AssertIssetToAssertObjectHasPropertyRector#338
TomasVotruba merged 6 commits intomainfrom
tv-test-provider

Conversation

@TomasVotruba
Copy link
Copy Markdown
Member

@TomasVotruba TomasVotruba commented Jun 22, 2024

PHPUnit 10 removed assertObjectHasAttribute(), with no replacement.
Then PHPUnit 10.1 introduced assertObjectHasProperty() as 1:1 replacement.

Instead of migrating methods twice back and forth, we'll simple rename it.

See sebastianbergmann/phpunit#5220


Closes https://github.com/rectorphp/rector-phpunit/issues/336

@TomasVotruba TomasVotruba changed the title tv test provider [PHPUnit 10] Rename assertObjectHasAttribute() to assertObjectHasProperty() Jun 22, 2024
@TomasVotruba TomasVotruba force-pushed the tv-test-provider branch 2 times, most recently from 1e207dd to 4d06c8a Compare June 22, 2024 05:25
@TomasVotruba TomasVotruba force-pushed the tv-test-provider branch 2 times, most recently from 3f83aab to 0dcfb32 Compare June 22, 2024 05:28
@TomasVotruba TomasVotruba changed the title [PHPUnit 10] Rename assertObjectHasAttribute() to assertObjectHasProperty() [PHPUnit 10] Rename assertObjectHasAttribute() to assertObjectHasProperty(), add AssertIssetToAssertObjectHasPropertyRector Jun 22, 2024
@TomasVotruba TomasVotruba enabled auto-merge (squash) June 22, 2024 05:31
@TomasVotruba TomasVotruba merged commit cfeae6a into main Jun 22, 2024
@TomasVotruba TomasVotruba deleted the tv-test-provider branch June 22, 2024 05:31
@samsonasik
Copy link
Copy Markdown
Member

@TomasVotruba I tried in CodeIgniter4 project,it got error: undefined assertObjectHasNotProperty()

➜  CodeIgniter4 git:(develop) ✗ vendor/bin/phpunit tests/system/Config/BaseConfigTest.php
PHPUnit 10.5.24 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.4 with PCOV 1.0.11
Configuration: /Users/samsonasik/www/CodeIgniter4/phpunit.xml.dist

....E.............                                                                                                                                                                                                                                                                                          18 / 18 (100%)

Time: 00:00.306, Memory: 14.00 MB

There was 1 error:

1) CodeIgniter\Config\BaseConfigTest::testEnvironmentOverrides
Error: Call to undefined method CodeIgniter\Config\BaseConfigTest::assertObjectHasNotProperty()

It uses PHPUnit 10.5.24

➜  CodeIgniter4 git:(develop) ✗ composer show phpunit/phpunit
name     : phpunit/phpunit
descrip. : The PHP Unit Testing framework.
keywords : phpunit, testing, xunit
versions : * 10.5.24

Looking on the repo, it seems there is no method named assertObjectHasNotProperty

https://github.com/search?q=repo%3Asebastianbergmann%2Fphpunit%20assertObjectHasNotProperty&type=code


// https://github.com/sebastianbergmann/phpunit/issues/5220
new MethodCallRename('PHPUnit\Framework\Assert', 'assertObjectHasAttribute', 'assertObjectHasProperty'),
new MethodCallRename('PHPUnit\Framework\Assert', 'assertObjectNotHasAttribute', 'assertObjectHasNotProperty'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set PHPUNIT_100 and AssertIssetToSpecificMethodRector::refactorPropertyFetchNode() should be mutually exclusive

2 participants