eclipse-pdt / pdt

PHP Development Tools project (PDT)
https://eclipse.org/pdt
Eclipse Public License 2.0
188 stars 46 forks source link

PHPUnitLogger calls method_exists on null object #254

Closed BlairCooper closed 9 months ago

BlairCooper commented 9 months ago

At or about line 814 of PHPUnitLogger.php there is an attempt to get the difference on a comparison failure. If the getComparisonFailure method exists the code immediately tries to check for the existence of the getDiff method on the result of calling the getComparisonFailure method. However, if the comparison failure is not present, getComparisonFailure will return null. This results in a call to method_exists with the first parameter as null.

This results in "_method_exists(): Argument 1 ($object_orclass) must be of type object|string, null given" error being generated and the test case existing immediately.

There should be a check for a null return from getComparisonFailure() before checking if the getDiff method exists.

Describe your system

To Reproduce Steps to reproduce the behavior:

  1. Create a unit test (PHPUnit) with a test that will fail
  2. Run the test
  3. See the error in the console

Expected behavior Test indicates what failed. Test Case does not "unexpectedly terminate"

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

zulus commented 9 months ago

Which PHPUnit version you use?

BlairCooper commented 9 months ago

PHPUnit version 9.6.13