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

When a mocked method throws a Throwable the call to the method is not recorded #595

Open
BladeMF opened this issue Apr 8, 2023 · 0 comments

Comments

@BladeMF
Copy link

BladeMF commented Apr 8, 2023

Given this code:

$this->prophesize(Publisher::class)
	->processChanges($interval)
		->shouldBeCalled()
		->willThrow(new TypeError())
		->getObjectProphecy()
	->reveal();

when the processChanges method is called, it throws the specified TypeError, but the call is not recorded.

The reason for this are that:

  1. CallCenter catches Exception, not Throwable
  2. Call class requires an ?Exception in the constructor, not Throwable.

IMO it is a perfectly valid assumption that a piece of code can cause a type error. It's not often, but it is a valid case specifically with generated code. I checked that if I just change Exception to Throwable in the two places, it works. Not sure if that breaks some other cases though.

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

No branches or pull requests

1 participant