phpstan-phpunit icon indicating copy to clipboard operation
phpstan-phpunit copied to clipboard

Add rules to check @covers and @coversDefaultClass for methods and classes.

Open mad-briller opened this issue 3 years ago • 4 comments

continuation of https://github.com/phpstan/phpstan-phpunit/pull/119 but changed quite a bit

aswell as resolving the PR feedback in 119, i had to rework some of the code due to phpstan 1.6 deprecating the parent attribute, which meant major reworks on the rule itself to become 2 rules as per this discussion: https://github.com/phpstan/phpstan/discussions/7678

as a result this doesn't include any of the commits from the original author @neclimdul, as so much changed from the original PR it was easier to produce a new single commit with all the changes in.

mad-briller avatar Jul 24 '22 15:07 mad-briller

Ouch, those are clearly my tests. Also, looks like you lost one of the test cases.

/**
 * @covers \PHPUnit\Framework\TestCase
 */
class CoversShouldExistTestCase3 extends \PHPUnit\Framework\TestCase
{

	/**
	 * @covers \PHPUnit\Framework\TestCase
	 */
	public function testBadCoversDefault() {}

}

neclimdul avatar Jul 25 '22 16:07 neclimdul

@neclimdul yeah i started from your branch but then completely reworked it due to changes in phpstans core and the above discussion, it was not my intention to "take the credit" so to speak and that is why i mentioned you

this was my first time finishing somebody elses open source PR so i was not aware of the best etiquette, my apologies. i will rebase the work on top of yours now, and re-add the missing test case.

mad-briller avatar Jul 25 '22 17:07 mad-briller

i've rebased the work on your branch and also added a new error message when the @covers is redundant.

sorry about that, i hope you understand i had no ill intent :)

mad-briller avatar Jul 25 '22 17:07 mad-briller

Yeah, didn't expect you did. I don't have any intention of causing problems but seems like someone could be malicious with licensing if their code was committed as authored by someone else. Also just doesn't feel great to loose credit, but that's more a weakness in github only really capturing credit as the author.

neclimdul avatar Jul 25 '22 17:07 neclimdul

Thank you.

ondrejmirtes avatar Oct 17 '22 13:10 ondrejmirtes

Thank you.

ondrejmirtes avatar Oct 17 '22 13:10 ondrejmirtes