Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnitLogger calls method_exists on null object #254

Closed
BlairCooper opened this issue Oct 5, 2023 · 2 comments
Closed

PHPUnitLogger calls method_exists on null object #254

BlairCooper opened this issue Oct 5, 2023 · 2 comments
Labels

Comments

@BlairCooper
Copy link

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_or_class) 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

  • OS: Windows 10
  • Eclipse 2023-09
  • Eclipse PDT 8.1.0.202307170929
  • PHP Version 8.2

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.

@BlairCooper BlairCooper added the bug label Oct 5, 2023
@zulus
Copy link
Member

zulus commented Oct 7, 2023

Which PHPUnit version you use?

@zulus zulus closed this as completed in 955484f Oct 7, 2023
@BlairCooper
Copy link
Author

PHPUnit version 9.6.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants