PHPUnit assertions do throw a _PHPUnit\Framework\ExpectationFailedException_ exception when they fail. This is how PHPUnit internally notices when assertions within testcases fail. However, if such an exception type or one of its parent types is captured within a try-catch block and not rethrown, PHPUnit does not notice the assertion failure.


This check raises an issue on assertions within the _try_ body of a _try-catch_ block that do catch exceptions of the type _PHPUnit\Framework\ExpectationFailedException_, _PHPUnit\Framework\AssertionFailedError_, or _Exception_, and do not handle the variable holding the exception.

== Noncompliant Code Example

----
public function testA() {
    try {
        assertTrue(getValue()); // Noncompliant
    } catch (\PHPUnit\Framework\ExpectationFailedException $e) {

    }
}
----

== Compliant Solution

----
public function testB() {
    try {
        assertTrue(getValue()); // Compliant
    } catch (\PHPUnit\Framework\ExpectationFailedException $e) {
        assertEquals("Some message", $e->getMessage());
    }
}
----
