/** * @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); }
/** * Constructs this User object */ public function __construct() { parent::__construct(); $this->preferences = new UserPreferences(); }