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

with phpunit 9: assertContains is deprecated #1548

Closed
michabbb opened this issue Apr 24, 2020 · 3 comments
Closed

with phpunit 9: assertContains is deprecated #1548

michabbb opened this issue Apr 24, 2020 · 3 comments
Assignees
Milestone

Comments

@michabbb
Copy link

Subject Details
Plugin Php Inspections (EA Extended) 4.0.3
Language level PHP 7.4

Current behaviour

$this->assertTrue(in_array('PNG', $supportedFormats, true));

image

if i follow this suggestion, i end up here:

$this->assertContains('PNG', $supportedFormats);

where phpstorm says: it´s deprecated

image

Expected behaviour

i don´t know, but i guess i shouldn't get a recommendation for a deprecated function

Environment details

PhpStorm 2020.1.1 Preview
Build #PS-201.7223.29, built on April 20, 2020
Runtime version: 11.0.6+8-b765.38 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
phpunit/phpunit: 9.0.1

@kalessil
Copy link
Owner

@michabbb: so, after deep dive I'm pretty sure that my plugin suggests correct replacement which doesn't change behaviour. The suggestion from PhpStorm is probably incorrect, so probably it worth filing a bug in JetBrains bug-tracker.

@kalessil kalessil modified the milestones: C-4.0.3, C-4.0.4 Apr 26, 2020
@michabbb
Copy link
Author

michabbb commented Apr 26, 2020

@kalessil here: sebastianbergmann/phpunit#3426 sebastian says:

Remove support for using assertContains() and assertNotContains() on string haystacks

and my example here shows a "string haystack". when i change my code from:

$this->assertContains('PNG', $supportedFormats);

to

$this->assertContains(['PNG'], $supportedFormats);

phpstorm no longer gives me a warning, because my haystack is no longer a string.
so i´m sure, you have overseen this situation here: phpstorm is 100% right and based on the parameters, you are offering a "deprecated" function, which is not helpful 😏

@kalessil
Copy link
Owner

kalessil commented Apr 26, 2020

Snap, thank you for more input @michabbb. I limited the behavior so it appears only for PhpUnit below v9.0. PhpStorm will take care of migration according to your feedback.

Update: d7cc28f

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

No branches or pull requests

2 participants