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');
 }
 /**
  * @param DeleteLabel $label
  */
 protected function handleDeleteLabel(DeleteLabel $label)
 {
     /** @var Event $event */
     $event = $this->eventRepository->load($label->getItemId());
     $event->deleteLabel($label->getLabel());
     $this->eventRepository->save($event);
 }
 /**
  * @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());
 }
 /**
  * @param StringLiteral $id
  * @param CdbXmlContainerInterface $cdbXml
  */
 private function create(StringLiteral $id, CdbXmlContainerInterface $cdbXml)
 {
     $entity = $this->actorFactory->createFromCdbXml((string) $id, $cdbXml->getCdbXml(), $cdbXml->getCdbXmlNamespaceUri());
     $this->repository->save($entity);
 }
예제 #5
0
 /**
  * Releases lock after saving if there was one.
  * 
  * @param AggregateRoot $aggregate
  * 
  * @return void
  */
 public function save(AggregateRoot $aggregate)
 {
     $this->repository->save($aggregate);
     $this->lockManager->release($aggregate->getAggregateRootId());
 }