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');
 }
 /**
  * Regression test for OPUSVIER-1841.
  */
 public function testWarningDisplayingDateOfBirth()
 {
     $doc = $this->createTestDocument();
     $person = new Opus_Person();
     $person->setFirstName("Johnny");
     $person->setLastName("Test");
     $dateOfBirth = new Opus_Date(new Zend_Date('1.1.2010', 'dd/MM/yyyy'));
     $person->setDateOfBirth($dateOfBirth);
     $doc->addPersonAuthor($person);
     $doc->store();
     $docId = $doc->getId();
     $this->dispatch('/admin/document/index/id/' . $docId);
     $body = $this->getResponse()->getBody();
     $this->assertTrue(substr_count($body, 'exception \'PHPUnit_Framework_Error_Warning\' with message \'htmlspecialchars() expects parameter 1 to be string, array given\' in /home/jens/opus4dev/opus4/server/modules/admin/views/scripts/document/index.phtml:145') == 0);
     $this->assertTrue(substr_count($body, 'Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/jens/opus4dev/opus4/server/modules/admin/views/scripts/document/index.phtml on line 145') == 0);
 }
 /**
  * Regression test for OPUSVIER-2607
  */
 public function testXMetaDissPlusOmitPersonSurnameIfEmpty()
 {
     $document = $this->createTestDocument();
     $document->setServerState('published');
     $author = new Opus_Person();
     $author->setLastName('Foo');
     $author->setDateOfBirth('1900-01-01');
     $author->setPlaceOfBirth('Berlin');
     //      $authorId = $author->store();
     $document->addPersonAuthor($author);
     $advisor = new Opus_Person();
     $advisor->setLastName('Bar');
     $advisor->setDateOfBirth('1900-01-01');
     $advisor->setPlaceOfBirth('Berlin');
     //      $advisorId = $advisor->store();
     $document->addPersonAdvisor($advisor);
     $referee = new Opus_Person();
     $referee->setLastName('Baz');
     $referee->setDateOfBirth('1900-01-01');
     $referee->setPlaceOfBirth('Berlin');
     //      $refereeId = $referee->store();
     $document->addPersonReferee($referee);
     $this->docIds[] = $document->store();
     $this->dispatch('/oai?verb=GetRecord&metadataPrefix=xMetaDissPlus&identifier=oai::' . $document->getId());
     $author->delete();
     $advisor->delete();
     $referee->delete();
     $this->assertResponseCode(200);
     $response = $this->getResponse();
     $xpath = $this->prepareXpathFromResultString($response->getBody());
     $authorName = $xpath->query('//xMetaDiss:xMetaDiss/dc:creator/pc:person/pc:name');
     $this->assertEquals(1, $authorName->length);
     $authorFirstName = $xpath->query('//xMetaDiss:xMetaDiss/dc:creator/pc:person/pc:name/pc:foreName');
     $this->assertEquals(0, $authorFirstName->length);
     $authorLastName = $xpath->query('//xMetaDiss:xMetaDiss/dc:creator/pc:person/pc:name/pc:surName');
     $this->assertEquals(1, $authorLastName->length);
     $advisorName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="advisor"]/pc:person/pc:name');
     $this->assertEquals(1, $advisorName->length);
     $advisorFirstName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="advisor"]/pc:person/pc:name/pc:foreName');
     $this->assertEquals(0, $advisorFirstName->length);
     $advisorLastName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="advisor"]/pc:person/pc:name/pc:surName');
     $this->assertEquals(1, $advisorLastName->length);
     $refereeName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="referee"]/pc:person/pc:name');
     $this->assertEquals(1, $refereeName->length);
     $refereeFirstName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="referee"]/pc:person/pc:name/pc:foreName');
     $this->assertEquals(0, $refereeFirstName->length);
     $refereeLastName = $xpath->query('//xMetaDiss:xMetaDiss/dc:contributor[@thesis:role="referee"]/pc:person/pc:name/pc:surName');
     $this->assertEquals(1, $refereeLastName->length);
 }
Exemple #4
0
 /**
  * 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');
     }
 }