getEntityManager(); $repo = self::getContainer()->get(CSurveyRepository::class); $course = $this->createCourse('new'); $teacher = $this->createUser('teacher'); $item = (new CSurvey()) ->setTitle('survey') ->setCode('survey') ->setParent($course) ->setCreator($teacher) ; $this->assertHasNoEntityViolations($item); $em->persist($item); $em->flush(); $this->assertSame('survey', (string) $item); $this->assertSame(1, $repo->count([])); } }