jeudi 28 avril 2016

PHPUnit Mock RequestStack of symfony

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;
    }
}

Thank you very much.

Aucun commentaire:

Enregistrer un commentaire