cakephp-ide-helper icon indicating copy to clipboard operation
cakephp-ide-helper copied to clipboard

Add option for `@covers` alt annotation for Test Classes

Open jamisonbryant opened this issue 1 year ago • 5 comments

Right now only @uses is supported, and it's my understanding that the semantics between @covers and @uses are different in PHPUnit. See: https://edorian.github.io/2011-11-04-An-introduction-to-phpunits-covers-annotation/

I don't believe you can have both...which means every time we run 'bin/cake annotate' we have to remove lots of @uses statements from our tests which already have @covers annotations.

Would also need to update the logic to check for either @uses or @covers already on the class, and not add a new unnecessary annotation.

jamisonbryant avatar Apr 11 '24 19:04 jamisonbryant

According to the docs it can be both though: https://docs.phpunit.de/en/9.6/annotations.html#uses

Bear in mind that currently @uses is not used for PHPUnit but for IDE traceability. @covers should probably be used for PHPUnit exclusively here. As long as you don't run it in strict coverage mode, it should work fine.

dereuromark avatar Apr 16 '24 10:04 dereuromark

I'm not really sure why, but running annotate all on my current codebase only adds the annotation to three Command tests:

/**
 * MyServiceProviderCommand Test
 *
 * @covers \App\Command\Bake\MyServiceProviderCommand       <-- I put this here
 * @uses \App\Command\Bake\MyServiceProviderCommand         <-- the plugin put this here
 */

As a developer, I would rather not have both of those annotations in my header, though they may both be valid.

@covers should probably be used for PHPUnit exclusively here.

Are you saying the plugin should use @covers only and not @uses when annotating unit tests?

jamisonbryant avatar Apr 29 '24 19:04 jamisonbryant

Uses is the one for IDEs and clickable afaik

dereuromark avatar Apr 29 '24 20:04 dereuromark

So since this plugin is the “IDE Helper” then it’s only responsibility should be the @uses tags and not the @covers?

I’m pretty sure that’s the current behavior, which is logical in a certain sense, but I do think that @covers is a very common use case for test annotations.

On Mon, Apr 29, 2024 at 16:33 Mark Scherer @.***> wrote:

Uses is the one for IDEs and clickable afaik

— Reply to this email directly, view it on GitHub https://github.com/dereuromark/cakephp-ide-helper/issues/351#issuecomment-2083613757, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTV2XWJ677XBTSNMWP2HD3Y72VDDAVCNFSM6AAAAABGC5LKP6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBTGYYTGNZVG4 . You are receiving this because you authored the thread.Message ID: @.***>

jamisonbryant avatar Apr 29 '24 22:04 jamisonbryant

We can add it on top or configure the Covers instead of uses. But uses should probably stay default

dereuromark avatar Apr 29 '24 23:04 dereuromark