public function testFromInvalidReference()
 {
     $object = new \stdClass();
     $metadata = $this->getMock(ClassMetadata::class);
     $metadata->expects(self::any())->method('getName')->willReturn('Foo');
     $metadata->expects(self::any())->method('getIdentifierValues')->with($object)->willReturn(['abc' => 'def']);
     $exception = MissingBatchItemException::fromInvalidReference($metadata, $object);
     $this->assertInstanceOf(MissingBatchItemException::class, $exception);
     $this->assertInstanceOf(UnexpectedValueException::class, $exception);
     $this->assertInstanceOf(ExceptionInterface::class, $exception);
     self::assertSame('Requested batch item stdClass#' . spl_object_hash($object) . ' (of type Foo) with identifier "{"abc":"def"}" could not be found', $exception->getMessage());
 }
 /**
  * @param object $object
  *
  * @return object
  */
 private function reFetchObject($object)
 {
     $metadata = $this->entityManager->getClassMetadata(get_class($object));
     $freshValue = $this->entityManager->find($metadata->getName(), $metadata->getIdentifierValues($object));
     if (!$freshValue) {
         throw MissingBatchItemException::fromInvalidReference($metadata, $object);
     }
     return $freshValue;
 }