/**
  * @testdox findOne() respects given restrictions
  */
 public function testFindOneRestricted()
 {
     $this->dataMapper->expects($this->once())->method('findOne');
     $this->entityFinder->expects($this->once())->method('with')->with('key', Operator::EQUAL, 'value');
     $this->repo->restrictTo('key', Operator::EQUAL, 'value');
     /** @noinspection PhpUnusedLocalVariableInspection */
     $article = $this->repo->findOne()->getItem();
 }
 /**
  * @testdox Entity finder throws EntityNotFoundException, if no result is found
  */
 public function testEntityFinderThrowsExceptionIfNoResult()
 {
     try {
         /** @noinspection PhpUnusedLocalVariableInspection */
         $result = $this->repo->findOne()->with('id', Operator::EQUAL, 0)->getItem();
         $this->fail('Expected EntityNotFoundException not thrown');
     } catch (\Exception $e) {
         $this->assertTrue($e instanceof EntityNotFoundException);
     }
 }
 /**
  * Deletes an entity from the repo
  *
  * @param   object $entity The entity to delete
  *
  * @return  void
  *
  * @throws  OrmException  if the entity could not be deleted
  */
 public function remove($entity)
 {
     $idAccessorRegistry = $this->unitOfWork->getEntityRegistry()->getIdAccessorRegistry();
     $entityId = $idAccessorRegistry->getEntityId($entity);
     $this->updateMap();
     if (!in_array($entityId, $this->map)) {
         throw new EntityNotFoundException();
     }
     $colJoinName = $this->relation->colJoinName();
     $mapObject = $this->mapRepository->findOne()->with($colJoinName, Operator::EQUAL, $entityId)->getItem();
     $this->mapRepository->remove($mapObject);
     $this->map = array_diff($this->map, [$entityId]);
 }