getEntityManager(); $repo = self::getContainer()->get(CCourseSettingRepository::class); $count = $repo->count([]); $course = $this->createCourse('new'); $courseId = $course->getId(); $item = (new CCourseSetting()) ->setTitle('test') ->setVariable('test') ->setCategory('cat') ->setSubkey('subkey') ->setType('type') ->setComment('comment') ->setSubkeytext('text') ->setCId($courseId) ; $this->assertHasNoEntityViolations($item); $em->persist($item); $em->flush(); $this->assertSame($count + 1, $repo->count([])); } }