I don't understand how mock this : $requestStack->getCurrentRequest()->getContent()
there are 2 methods : getCurrentRequest()->getContent() and it return a json object (POST Response)
I use symfony with RequestStack class.
The entire code is
class MessageReceivedService
{
protected $message;
public function __construct(RequestStack $requestStack)
{
$this->message = json_decode($requestStack->getCurrentRequest()->getContent());
}
public function getMessage()
{
return $this->message;
}
}
parseResponsewhich is called before any other method is executed (in the methods themselves) and caches the returned value.