public function testReleaseLockOnRepositoryError()
 {
     $this->lockManager->expects($this->once())->method('obtain')->with($this->equalTo('foo'));
     $this->repository->expects($this->once())->method('load')->will($this->throwException(new RuntimeException('Runtime')));
     $this->lockManager->expects($this->once())->method('release')->with($this->equalTo('foo'));
     $this->createRepository()->load('foo');
 }
 /**
  * @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());
 }