Skip to content
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

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

Merged
merged 6 commits into from
Jun 22, 2024

Conversation

TomasVotruba
Copy link
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 #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
5 checks passed
@TomasVotruba TomasVotruba deleted the tv-test-provider branch June 22, 2024 05:31
@samsonasik
Copy link
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

@@ -29,6 +29,10 @@
// https://github.com/sebastianbergmann/phpunit/issues/4087
new MethodCallRename('PHPUnit\Framework\Assert', 'assertRegExp', 'assertMatchesRegularExpression'),

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

Choose a reason for hiding this comment

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

Copy link
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
2 participants