/** * @test */ public function assignAccountToPartyCachesAssignedParty() { $this->mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue('723e3913-f803-42c8-a44c-fd7115f555c3')); $this->partyService->assignAccountToParty($this->account, $this->party); $assignedParty = $this->partyService->getAssignedPartyOfAccount($this->account); $this->assertSame($this->party, $assignedParty); }
/** * Adds a user whose User object has been created elsewhere * * This method basically "creates" a user like createUser() would, except that it does not create the User * object itself. If you need to create the User object elsewhere, for example in your ActionController, make sure * to call this method for registering the new user instead of adding it to the PartyRepository manually. * * This method also creates a new user workspace for the given user if no such workspace exist. * * @param string $username The username of the user to be created. * @param string $password Password of the user to be created * @param User $user The pre-built user object to start with * @param array $roleIdentifiers A list of role identifiers to assign * @param string $authenticationProviderName Name of the authentication provider to use. Example: "Typo3BackendProvider" * @return User The same user object * @api */ public function addUser($username, $password, User $user, array $roleIdentifiers = null, $authenticationProviderName = null) { if ($roleIdentifiers === null) { $roleIdentifiers = array('Neos.Neos:Editor'); } $roleIdentifiers = $this->normalizeRoleIdentifiers($roleIdentifiers); $account = $this->accountFactory->createAccountWithPassword($username, $password, $roleIdentifiers, $authenticationProviderName ?: $this->defaultAuthenticationProviderName); $this->partyService->assignAccountToParty($account, $user); $this->partyRepository->add($user); $this->accountRepository->add($account); $this->createPersonalWorkspace($user, $account); $this->emitUserCreated($user); return $user; }