entityManager = self::$container->get('doctrine.orm.default_entity_manager'); $this->sourceRepository = $this->entityManager->getRepository(PureSource::class); $this->pureSource = new PureSource(); } public function testDatabaseProcess(): void { $this->entityManager->persist($this->pureSource); $this->entityManager->flush(); $this->assertGreaterThan(0, $this->pureSource->getId()); $this->entityManager->remove($this->pureSource); $this->entityManager->flush(); $this->expectException(\TypeError::class); $this->pureSource->getId(); } }