getEntityManager(); $repo = self::getContainer()->get(SettingsCurrentRepository::class); $count = $repo->count([]); $item = (new SettingsCurrent()) ->setTitle('test') ->setVariable('test') ->setUrl($this->getAccessUrl()) ->setCategory('cat') ->setAccessUrlChangeable(1) ; $this->assertHasNoEntityViolations($item); $em->persist($item); $em->flush(); // By default, there's a root branch. $this->assertSame($count + 1, $repo->count([])); } }