Beispiel #1
0
 /**
  * Gets the Party having an Account assigned
  *
  * @param Account $account
  * @return AbstractParty
  */
 public function getAssignedPartyOfAccount(Account $account)
 {
     $accountIdentifier = $this->persistenceManager->getIdentifierByObject($account);
     if (!isset($this->accountsInPartyRuntimeCache[$accountIdentifier])) {
         $party = $this->partyRepository->findOneHavingAccount($account);
         $this->accountsInPartyRuntimeCache[$accountIdentifier] = $party;
     }
     return $this->accountsInPartyRuntimeCache[$accountIdentifier];
 }
Beispiel #2
0
 /**
  * @test
  */
 public function getAssignedPartyOfAccountCachesParty()
 {
     $this->mockPersistenceManager->expects($this->any())->method('getIdentifierByObject')->will($this->returnValue('723e3913-f803-42c8-a44c-fd7115f555c3'));
     $this->mockPartyRepository->expects($this->once())->method('findOneHavingAccount')->with($this->account)->will($this->returnValue($this->party));
     $this->party->addAccount($this->account);
     $assignedParty = $this->partyService->getAssignedPartyOfAccount($this->account);
     $this->assertSame($this->party, $assignedParty);
     $assignedParty = $this->partyService->getAssignedPartyOfAccount($this->account);
     $this->assertSame($this->party, $assignedParty);
 }
Beispiel #3
0
 /**
  * @dataProvider personsDataProvider
  * @test
  */
 public function personsAndAccountPersistingAndRetrievingWorksCorrectly($firstName, $middleName, $lastName, $emailAddress)
 {
     $person = new Person();
     $person->setName(new PersonName('', $firstName, $middleName, $lastName));
     $electronicAddress = new ElectronicAddress();
     $electronicAddress->setType(ElectronicAddress::TYPE_EMAIL);
     $electronicAddress->setIdentifier($emailAddress);
     $person->setPrimaryElectronicAddress($electronicAddress);
     $account = $this->accountFactory->createAccountWithPassword($emailAddress, $this->persistenceManager->getIdentifierByObject($person));
     $this->accountRepository->add($account);
     $person->addAccount($account);
     $this->partyRepository->add($person);
     $this->persistenceManager->persistAll();
     $this->assertEquals(1, $this->partyRepository->countAll());
     $this->persistenceManager->clearState();
     $foundPerson = $this->partyRepository->findByIdentifier($this->persistenceManager->getIdentifierByObject($person));
     $this->assertEquals($foundPerson->getName()->getFullName(), $person->getName()->getFullName());
     $this->assertEquals($foundPerson->getName()->getFullName(), $firstName . ' ' . $middleName . ' ' . $lastName);
     $this->assertEquals($foundPerson->getPrimaryElectronicAddress()->getIdentifier(), $emailAddress);
 }
 /**
  * Updates the given user in the respective repository and potentially executes further actions depending on what
  * has been changed.
  *
  * Note: changes to the user's account will not be committed for persistence. Please use addRoleToAccount(), removeRoleFromAccount(),
  * setRolesForAccount() and setUserPassword() for changing account properties.
  *
  * @param User $user The modified user
  * @return void
  * @api
  */
 public function updateUser(User $user)
 {
     $this->partyRepository->update($user);
     $this->emitUserUpdated($user);
 }