Exemple #1
0
 private function guardValueWithdrawnResponseIsSuccessful(Rsp $rsp)
 {
     $validCodes = [self::VALUE_WITHDRAWN];
     if (!in_array($rsp->getCode(), $validCodes)) {
         throw new UpdateEventErrorException($rsp);
     }
 }
 public function __construct(Rsp $rsp)
 {
     $this->rsp = $rsp;
     parent::__construct('Deleting keyword failed with code: ' . $rsp->getCode());
 }
 /**
  * @test
  * @dataProvider exceptionResponseProvider
  *
  * @param \Exception $exception
  * @param Rsp $expectedResponse
  */
 public function it_can_convert_exceptions_into_responses(\Exception $exception, Rsp $expectedResponse)
 {
     // Technically it's not the EventRepository that throws these
     // exceptions, but it's the easiest to mock and the code doesn't care
     // where the exception was thrown exactly.
     $this->eventRepository->expects($this->once())->method('save')->willThrowException($exception);
     // Mocking any supported request will cause the controller to check
     // for any exceptions. Deleting a keyword is easiest at the moment.
     $cdbid = '004aea08-e13d-48c9-b9eb-a18f20e6d44e';
     $request = Request::create("/event/{$cdbid}/keywords", Request::METHOD_DELETE);
     $request->query->set('keyword', 'foo');
     $response = $this->controller->deleteKeyword($request, $cdbid);
     // Make sure we get the expected response for the given exception.
     $this->assertEquals($expectedResponse->toXml(), $response->getContent());
 }
 public function __construct(Rsp $rsp)
 {
     parent::__construct($rsp->getMessage());
 }
 /**
  * @param Rsp $rsp
  * @return int
  */
 private function statusForRsp(Rsp $rsp)
 {
     if ($rsp->isError()) {
         return Response::HTTP_BAD_REQUEST;
     }
     return Response::HTTP_OK;
 }
 public function __construct(Rsp $rsp)
 {
     $this->rsp = $rsp;
     parent::__construct('Pushing translation to UDB2 collaboration services failed with code: ' . $rsp->getCode());
 }