client = static::createClient(); // Access the container to get the EntityManager $this->entityManager = static::getContainer()->get(EntityManagerInterface::class); } protected function createUser(string $email, array $roles = ['ROLE_USER']): User { $user = new User(); $user->setEmail($email); $user->setRoles($roles); $user->setName('Test'); $user->setSurname('User'); $user->setPassword('$2y$13$...'); // Dummy hash, logic typically bypassed by loginUser $this->entityManager->persist($user); $this->entityManager->flush(); return $user; } protected function createApp(string $name): Apps { // Based on your Entity, these fields are NOT nullable, so we must fill them $app = new Apps(); $app->setName($name); $app->setTitle($name . ' Title'); $app->setSubDomain(strtolower($name)); // Assuming valid subdomain logic $app->setLogoUrl('https://example.com/logo.png'); // $app->setDescription() is nullable, so we can skip or set it $this->entityManager->persist($app); $this->entityManager->flush(); return $app; } protected function createOrganization(string $name): Organizations { // I am assuming the Organizations entity structure here based on context $org = new Organizations(); $org->setName($name); $org->setEmail('contact@' . strtolower($name) . '.com'); $org->setNumber(100 + rand(1, 900)); // Example number $org->setAddress('123 ' . $name . ' St'); // Example address $org->setLogoUrl('https://example.com/org_logo.png'); // Add other required fields if Organizations has non-nullable columns $this->entityManager->persist($org); $this->entityManager->flush(); return $org; } protected function createUOLink(User $user, Organizations $organization): UsersOrganizations{ $uo = new UsersOrganizations(); $uo->setUsers($user); $uo->setOrganization($organization); $this->entityManager->persist($uo); $this->entityManager->flush(); return $uo; } protected function createUOALink(UsersOrganizations $uo, Apps $app, Roles $role): UserOrganizatonApp{ $uoa = new UserOrganizatonApp(); $uoa->setUserOrganization($uo); $uoa->setApplication($app); $uoa->setRole($role); $this->entityManager->persist($uoa); $this->entityManager->flush(); return $uoa; } protected function createRole(string $name): Roles{ $role = new Roles(); $role->setName($name); $this->entityManager->persist($role); $this->entityManager->flush(); return $role; } }