Пример #1
0
 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());
 }
Пример #2
0
 /**
  * @param Request $request
  *
  * @return Response
  */
 public function hookAction(Request $request)
 {
     $this->webhookHandler->handle($request->headers->all(), $request->getContent());
     return new Response();
 }
Пример #3
0
 /**
  * @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);
 }