moodlehq / moodle-cs

Moodle Coding Style
https://github.com/moodlehq/moodle-cs
GNU General Public License v3.0
18 stars 16 forks source link

Make the TestCaseCovers sniff to detect multiple @coversDefaultClass cases #166

Closed stronk7 closed 5 months ago

stronk7 commented 5 months ago

Recently I was playing with code-coverage generation and when running PHPUnit it was detected that we have a few unit tests having multiple @coversDefaultClass annotations.

That's plain wrong, only one is allowed (in fact PHPUnit stops when that happens). Such an annotation is about to define the default class to apply when the @covers annotations do no specify a class. Just that.

So we should start erroring in the Sniff when multiple are detected. Of course, only that annotation, classes and methods are allowed to have multiple @covers ones.

Ciao :-)

stronk7 commented 5 months ago

Cross-linking with MDL-82148 that is the one going to fix current cases.