I have a service that I need to write a phpunit test for
This service has a method that accepts a Symfony\Component\HttpFoundation\Request object that comes from a JSON POST
I need to somehow mock the Request object with a JSON POST so that I can test this method properly
Here is what the Service method looks like
namespace AppBundle\Service;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
/**
* Class SubscriptionNotificationProcessor
* @package AppBundle\Service
*/
class SubscriptionNotificationProcessor
{
...
public function process(Request $request)
{
$parameterBag = $request->request;
$notification_type = $parameterBag->get('notification_type');
...
}
}
My question is, How do I mock the Request parameter populated with JSON data?