phpinspectionsea
phpinspectionsea copied to clipboard
False-positive: @covers referencing to a non-existing entity
While it works fine in general cases (eg. @covers MyClass::method), it give a false-positive when you try to cover an entire class, for instance @covers MyClass. According to phpunit doc, it should be valid.
We should take care about another all supported cases on this fix:
-
[x] ClassName::methodName: covers a specific method from class. Currently, the unique supported.
-
[ ] ClassName: covers all methods from class. Should fix that first, because is the most common usage. Class should have at least one method.
-
[ ] ClassName<extended>: covers all methods from class and parents. Class should be extended. Class and/or parent should declares at least one method.
-
[ ] ClassName::<public>: covers all public methods from class. Class should have at least one public method.
-
[ ] ClassName::<protected>: covers all protected methods from class. Class should have at least one protected method.
-
[ ] ClassName::<private>: covers all private methods from class. Class should have at least one private method.
-
[ ] ClassName::: covers all methods, except public from class. Class should have at least one protected or private method.
-
[ ] ClassName::: covers all methods, except protected from class. Class should have at least one public or private method.
-
[ ] ClassName::: covers all methods, except private from class. Class should have at least one public or protected method.
-
[ ] ::functionName: covers a specific global function or the
@coversDefaultClass. If no@coversDefaultClass, check if global function exists. If@coversDefaultClassis defined, check if method exists on class.
Note: you can mixes <extended> with <public>, for instace (eg. MyClass<extended>::<public>).
At this point, I guess that this inspection should be created apart of phpunit-related inspection, because it involves a lot of tests.
Should think about create a new related inspection to suggests the using only the first one (eg. "don't uses generalized cover, try specific the tested method").
I’d suggest to give the last one a high priority (@coversDefaultClass).
Namepaced functions seem to not be covered by the above.
I have a project where the following notation is used, and properly supported by PHPStorm and PHPUnit:
@covers \Namespace\function()
Thanks for reporting @rentalhost! Looks like PhpStorm did some work in this direction, hence closing this issue.
Sorry, we thought about data provider verification. This tag seems not well covered yet. Re-opening.