rspec/rules/S2187/php/rule.adoc
2020-12-21 15:38:52 +01:00

49 lines
920 B
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

There's no point in having a PHPUnit test case without any test methods. Similarly, you shouldn't have a file in the tests directory which extends PHPUnit\Framework\TestCase but no tests in the file. Doing either of these things may lead someone to think that uncovered classes have been tested. Add some test method or make the class abstract if it is used by a real test case class.
== Noncompliant Code Example
----
use PHPUnit\Framework\TestCase;
class MyTest extends TestCase {
protected function setUp() {
doSomethind();
}
private function doSomethind() {
//...
}
}
----
== Compliant Solution
----
use PHPUnit\Framework\TestCase;
class MyTest extends TestCase {
public function testBehaviour() {
//...
}
//...
} 
// or
abstract class MyAbstractTest extends TestCase {
protected function setUp() {
doSomethind();
}
private function doSomethind() {
//...
}
}
----