public function testHookAction() { $this->handler->expects($this->once())->method('handle')->with($this->identicalTo($headers = ['foo' => ['bar']]), $this->identicalTo($body = 'body')); $request = $this->createRequestMock(); $request->headers = $this->createParameterBagMock(); $request->headers->expects($this->once())->method('all')->will($this->returnValue($headers)); $request->expects($this->once())->method('getContent')->will($this->returnValue($body)); $response = $this->controller->hookAction($request); $this->assertInstanceOf(Response::class, $response); $this->assertSame(Response::HTTP_OK, $response->getStatusCode()); $this->assertEmpty($response->getContent()); }
/** * @param Request $request * * @return Response */ public function hookAction(Request $request) { $this->webhookHandler->handle($request->headers->all(), $request->getContent()); return new Response(); }
/** * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException * @expectedExceptionMessage The request json body cannot be decoded. */ public function testHandleWithInvalidJson() { $this->firewall->expects($this->once())->method('authorize')->with($this->identicalTo($headers = ['X-Hub-Signature' => 'sha1=aff354dfbc9e335aaec1e28f2305f34db176db1b']), $this->identicalTo($body = '{"foo":"bar"'))->will($this->returnValue(true)); $this->handler->handle($headers, $body); }