getManager(); $repo = self::getContainer()->get(CLpCategoryRepository::class); $course = $this->createCourse('new'); $teacher = $this->createUser('teacher'); $item = (new CLpCategory()) ->setName('cat') ->setParent($course) ->setCreator($teacher) ; $this->assertHasNoEntityViolations($item); $em->persist($item); $em->flush(); $this->assertSame('cat', (string) $item); $this->assertSame(1, $repo->count([])); } }