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');
 }
 /**
  * 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());
 }