get(EntityManagerInterface::class); $serializerFactory = self::$container->get(ClassMetadataFactoryInterface::class); $this->normalizer = new DoctrineExistingEntityNormalizer($em, $serializerFactory); } public function dataProviderUserId() { self::bootKernel(); $userIds = self::$container->get(EntityManagerInterface::class) ->getRepository(User::class) ->createQueryBuilder('u') ->select('u.id') ->setMaxResults(1) ->getQuery() ->getResult(); yield [$userIds[0]['id']]; } /** * @dataProvider dataProviderUserId * * @param mixed $userId */ public function testGetMappedClass($userId) { $data = ['type' => 'user', 'id' => $userId]; $supports = $this->normalizer->supportsDenormalization($data, User::class); $this->assertTrue($supports); } }