public function testPopulateFromModel() { $this->useEnglish(); $form = new Admin_Form_Person(); $person = new Opus_Person(); $person->setFirstName('John'); $person->setLastName('Doe'); $person->setAcademicTitle('PhD'); $person->setPlaceOfBirth('Berlin'); $datesHelper = $form->getDatesHelper(); $person->setDateOfBirth($datesHelper->getOpusDate('1990/01/01')); $person->setEmail('*****@*****.**'); $person->setIdentifierGnd('1234'); $person->setIdentifierOrcid('3456'); $person->setIdentifierMisc('5678'); $person->store(); $form->populateFromModel($person); $personId = $person->getId(); $person->delete(); $this->assertEquals($personId, $form->getElement('PersonId')->getValue()); $this->assertEquals($person->getLastName(), $form->getElement('LastName')->getValue()); $this->assertEquals($person->getFirstName(), $form->getElement('FirstName')->getValue()); $this->assertEquals($person->getAcademicTitle(), $form->getElement('AcademicTitle')->getValue()); $this->assertEquals($person->getEmail(), $form->getElement('Email')->getValue()); $this->assertEquals($person->getPlaceOfBirth(), $form->getElement('PlaceOfBirth')->getValue()); $this->assertEquals('1990/01/01', $form->getElement('DateOfBirth')->getValue()); $this->assertEquals($form->getElement('IdentifierGnd')->getValue(), '1234'); $this->assertEquals($form->getElement('IdentifierOrcid')->getValue(), '3456'); $this->assertEquals($form->getElement('IdentifierMisc')->getValue(), '5678'); }
/** * Setzt die Felder einer Opus_Person Instanz entsprechend dem Formularinhalt. * @param Opus_Person $model */ public function updateModel($model) { if ($model instanceof Opus_Person) { $model->setAcademicTitle($this->getElementValue(self::ELEMENT_ACADEMIC_TITLE)); $model->setLastName($this->getElementValue(self::ELEMENT_LAST_NAME)); $model->setFirstName($this->getElementValue(self::ELEMENT_FIRST_NAME)); $model->setEmail($this->getElementValue(self::ELEMENT_EMAIL)); $model->setPlaceOfBirth($this->getElementValue(self::ELEMENT_PLACE_OF_BIRTH)); $model->setIdentifierGnd($this->getElementValue(self::ELEMENT_IDENTIFIER_GND)); $model->setIdentifierOrcid($this->getElementValue(self::ELEMENT_IDENTIFIER_ORCID)); $model->setIdentifierMisc($this->getElementValue(self::ELEMENT_IDENTIFIER_MISC)); $datesHelper = $this->getDatesHelper(); $model->setDateOfBirth($datesHelper->getOpusDate($this->getElementValue(self::ELEMENT_DATE_OF_BIRTH))); } else { $this->getLog()->err(__METHOD__ . ' called with object that is not instance of Opus_Person'); } }