Skip to content

Instantly share code, notes, and snippets.

@ubermuda
Created September 1, 2017 14:52
Show Gist options
  • Save ubermuda/4e352a065871edd139acb47b6d849aba to your computer and use it in GitHub Desktop.
Save ubermuda/4e352a065871edd139acb47b6d849aba to your computer and use it in GitHub Desktop.
<?php
$event->setResponse(Argument::any())->will(function($args) use ($event) {
$event->getResponse()->willReturn($args[0]);
});
// ->setResponse() happens inside ->onKernelException()
$subscriber->onKernelException($event->reveal());
$event->getResponse(); // returns a MethodProphecy?!
@ubermuda
Copy link
Author

ubermuda commented Sep 1, 2017

I am trying to mock a ->setResponse($response) call so that I can later retrieve the $response object (via ->getResponse()) and do a few tests on it. As per the prophecy documentation, I use ->will() + closure to make ->getResponse() return the argument passed to ->setResponse(), but after the ->reveal() and ->setResponse(), ->getResponse() returns a MethodProphecy instance...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment