dereuromark/cakephp-ide-helper

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

jamisonbryant opened this issue · 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.

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.

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?

Uses is the one for IDEs and clickable afaik

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