getEntityManager(); $repo = self::getContainer()->get(CGroupCategoryRepository::class); $course = $this->createCourse('new'); $teacher = $this->createUser('teacher'); $item = (new CGroupCategory()) ->setTitle('category') ->setParent($course) ->setCreator($teacher) ->setMaxStudent(100) ; $this->assertHasNoEntityViolations($item); $em->persist($item); $em->flush(); $this->assertSame(1, $repo->count([])); } }