Exemplo n.º 1
0
 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');
 }
 public function setUp()
 {
     parent::setUp();
     $document = $this->createTestDocument();
     $document->setServerState('published');
     $document->setType('baz');
     $title = new Opus_Title();
     $title->setValue('foobartitle');
     $document->setTitleMain($title);
     $this->documentId = $document->store();
     $this->assertNotNull($this->documentId);
     $document = $this->createTestDocument();
     $document->setServerState('published');
     $document->setType('baz');
     $title = new Opus_Title();
     $title->setValue('foobartitle');
     $document->setTitleMain($title);
     $author = new Opus_Person();
     $author->setFirstName('John');
     $author->setLastName('Doe');
     $author->setEmail('*****@*****.**');
     $this->authorId = $author->store();
     $this->assertNotNull($this->authorId);
     $link_person = $document->addPersonAuthor($author);
     $link_person->setAllowEmailContact('1');
     $this->authorDocumentId = $document->store();
     $this->assertNotNull($this->authorDocumentId);
 }
Exemplo n.º 3
0
 /**
  * Create Opus_Person object for currently logged user.  If no account
  * has been found, return NULL.
  *
  * @return Opus_Person
  */
 public function createPerson()
 {
     if (is_null($this->_account)) {
         return;
     }
     $person = new Opus_Person();
     $person->setFirstName(trim($this->_account->getFirstName()));
     $person->setLastName(trim($this->_account->getLastName()));
     $person->setEmail(trim($this->_account->getEmail()));
     if (!$person->isValid()) {
         $this->_log->err("Created Opus_Person object for user '" . $this->_login . "' is NOT VALID. ");
     }
     return $person;
 }
Exemplo n.º 4
0
 public function setUp()
 {
     parent::setUp();
     $document = $this->createTestDocument();
     $document->setServerState('published');
     $document->setType('testtype');
     $title = new Opus_Title();
     $title->setValue('testtitle');
     $document->setTitleMain($title);
     $author1 = new Opus_Person();
     $author1->setFirstName('John');
     $author1->setLastName('Doe');
     $author1->setEmail('*****@*****.**');
     $this->author1Id = $author1->store();
     $link_person1 = $document->addPersonAuthor($author1);
     $link_person1->setAllowEmailContact('1');
     $author2 = new Opus_Person();
     $author2->setFirstName('Jane');
     $author2->setLastName('Doe');
     $this->author2Id = $author2->store();
     $link_person2 = $document->addPersonAuthor($author2);
     $link_person2->setAllowEmailContact('0');
     $author3 = new Opus_Person();
     $author3->setFirstName('Jimmy');
     $author3->setLastName('Doe');
     $this->author3Id = $author3->store();
     $link_person3 = $document->addPersonAuthor($author3);
     $link_person3->setAllowEmailContact('1');
     $author4 = new Opus_Person();
     $author4->setFirstName('Foo');
     $author4->setLastName('Bar');
     $author4->setEmail('*****@*****.**');
     $this->author4Id = $author4->store();
     $link_person4 = $document->addPersonAuthor($author4);
     $link_person4->setAllowEmailContact('1');
     $this->documentId = $document->store();
     $this->assertNotNull($this->documentId);
     $this->assertNotNull($this->author1Id);
     $this->assertNotEquals('', $this->author1Id);
     $this->assertNotNull($this->author2Id);
     $this->assertNotEquals('', $this->author2Id);
     $this->assertNotNull($this->author3Id);
     $this->assertNotEquals('', $this->author3Id);
     $this->assertNotNull($this->author4Id);
     $this->assertNotEquals('', $this->author4Id);
     $document = $this->createTestDocument();
     $document->setServerState('unpublished');
     $this->unpublishedDocumentId = $document->store();
     $this->assertNotNull($this->unpublishedDocumentId);
 }
Exemplo n.º 5
0
 public function testGetRecipientsForPublicationContextWithoutSubmitter()
 {
     $doc = $this->createTestDocument();
     $doc->setLanguage("eng");
     $title = new Opus_Title();
     $title->setValue("Test Document");
     $title->setLanguage("eng");
     $doc->addTitleMain($title);
     $submitter = new Opus_Person();
     $submitter->setFirstName("John");
     $submitter->setLastName("Submitter");
     $submitter->setEmail("*****@*****.**");
     $doc->addPersonSubmitter($submitter);
     $doc->store();
     $method = $this->getMethod('getRecipients');
     $recipients = $method->invokeArgs($this->notification, array(Application_Util_Notification::PUBLICATION, array(array("name" => "foo", "address" => "foo@localhost")), $doc, false));
     $this->assertEquals(2, count($recipients));
     $this->assertEquals("published@localhost", $recipients[0]["name"]);
     $this->assertEquals("published@localhost", $recipients[0]["address"]);
     $this->assertEquals("foo", $recipients[1]["name"]);
     $this->assertEquals("foo@localhost", $recipients[1]["address"]);
 }
Exemplo n.º 6
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');
     }
 }
 public function testAuthorNotificationForMultipleAuthors()
 {
     $this->enablePublishNotification();
     $doc = $this->createDocWithSubmitterAndAuthor('*****@*****.**', '*****@*****.**');
     $author = new Opus_Person();
     $author->setFirstName("AFN");
     $author->setLastName("ALN");
     $author->setEmail("*****@*****.**");
     $doc->addPersonAuthor($author);
     $author = new Opus_Person();
     $author->setFirstName("BFN");
     $author->setLastName("BLN");
     $doc->addPersonAuthor($author);
     $author = new Opus_Person();
     $author->setFirstName("CFN");
     $author->setLastName("CLN");
     $author->setEmail("*****@*****.**");
     $doc->addPersonAuthor($author);
     $doc->store();
     $this->dispatch('/admin/workflow/changestate/docId/' . $doc->getId() . '/targetState/published');
     $this->assertContains('*****@*****.**', $this->getResponse()->getBody());
     $this->assertContains('*****@*****.**', $this->getResponse()->getBody());
     $this->assertContains('*****@*****.**', $this->getResponse()->getBody());
     $this->assertContains('*****@*****.**', $this->getResponse()->getBody());
     $this->assertContains('<input type="checkbox" name="submitter" id="submitter" value="1" checked="checked"', $this->getResponse()->getBody());
     $this->assertContains('<input type="checkbox" name="author_1" id="author_1" value="1" checked="checked"', $this->getResponse()->getBody());
     $this->assertContains('<input type="checkbox" name="author_2" id="author_2" value="1" checked="checked"', $this->getResponse()->getBody());
     $this->assertContains('<input type="checkbox" name="author_3" id="author_3" value="1" disabled="1"', $this->getResponse()->getBody());
     $this->assertContains('<input type="checkbox" name="author_4" id="author_4" value="1" checked="checked"', $this->getResponse()->getBody());
 }