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);
 }
 protected function getTestDocument()
 {
     $document = $this->createTestDocument();
     $document->setLanguage('deu');
     $title1 = new Opus_Title();
     $title1->setLanguage('deu');
     $title1->setValue('Deutscher Titel');
     $title2 = new Opus_Title();
     $title2->setLanguage('eng');
     $title2->setValue('English Title');
     $document->setTitleMain(array($title1, $title2));
     return $document;
 }
示例#3
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);
 }
 public function testXmlPreparationForFrontdoor()
 {
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $title = new Opus_Title();
     $title->setLanguage('deu');
     $title->setValue('Deutscher Titel');
     $doc->setTitleMain($title);
     $docId = $doc->store();
     $this->getRequest()->setMethod('POST')->setPost(array('docId' => $docId, 'searchtype' => 'id'));
     $this->plugin->prepareXml();
     $xpath = new DOMXPath($this->plugin->getXml());
     $result = $xpath->query('//Opus_Document');
     $count = $result->length;
     $this->assertEquals('Deutscher Titel', $result->item(--$count)->childNodes->item(3)->attributes->item(2)->nodeValue);
 }
示例#5
0
 /**
  * Set textarea flag for Value field.
  *
  * @return void
  */
 protected function _init()
 {
     parent::_init();
     $this->getField('Value')->setTextarea(true);
     $type = $this->getField('Type');
     $type->setMandatory(false);
     $type->setSelection(true);
     $type->setDefault(array('abstract' => 'abstract'));
 }
 public function testTranslationOfOpusTitleFields()
 {
     $model = new Opus_Title();
     $fieldNames = $model->describe();
     foreach ($fieldNames as $name) {
         $key = $this->helper->getKeyForField('Opus_Title', $name);
         $this->assertTrue($this->translate->isTranslated($key), 'Translation key \'' . $key . '\' is missing.');
     }
 }
 public function testCreateWorkerJobIfAsyncEnabled()
 {
     $this->config->merge(new Zend_Config(array('runjobs' => array('asynchronous' => 1))));
     $this->assertEquals(0, Opus_Job::getCount(), 'test data changed.');
     $doc = $this->createTestDocument();
     $doc->setLanguage("eng");
     $title = new Opus_Title();
     $title->setValue("Test Document");
     $title->setLanguage("eng");
     $doc->addTitleMain($title);
     $doc->store();
     $this->notification->prepareMail($doc, Application_Util_Notification::SUBMISSION, 'http://localhost/foo/1');
     $mailJobs = Opus_Job::getByLabels(array(Opus_Job_Worker_MailNotification::LABEL));
     $this->assertEquals(1, count($mailJobs), 'Expected 1 mail job');
     $jobs = Opus_Job::getAll();
     if (!empty($jobs)) {
         foreach ($jobs as $job) {
             $job->delete();
         }
     }
 }
示例#8
0
文件: Title.php 项目: alexukua/opus4
 /**
  * Aktualisiert Modell mit den Werten im Formular.
  * 
  * @param \Opus_Title $title
  */
 public function updateModel($title)
 {
     $title->setLanguage($this->getElementValue(self::ELEMENT_LANGUAGE));
     $title->setType($this->getElementValue(self::ELEMENT_TYPE));
     $title->setValue($this->getElementValue(self::ELEMENT_VALUE));
 }
 public function testOddEvenAfterRemove()
 {
     $form = new Admin_Form_Document_MultiSubForm('Admin_Form_Document_Title', 'TitleParent');
     $document = $this->createTestDocument();
     $title = new Opus_Title();
     $title->setValue('Titel1');
     $title->setLanguage('deu');
     $document->addTitleParent($title);
     $title = new Opus_Title();
     $title->setValue('Titel2');
     $title->setLanguage('eng');
     $document->addTitleParent($title);
     $title = new Opus_Title();
     $title->setValue('Titel3');
     $title->setLanguage('rus');
     $document->addTitleParent($title);
     $form->populateFromModel($document);
     $post = array('TitleParent1' => array('Remove' => 'Entfernen'));
     $form->processPost($post, $post);
     $this->assertEquals(2, count($form->getSubForms()));
     $this->assertEquals('multiple-wrapper even', $form->getSubform('TitleParent0')->getDecorator('multiWrapper')->getOption('class'));
     $this->assertEquals('multiple-wrapper odd', $form->getSubform('TitleParent1')->getDecorator('multiWrapper')->getOption('class'));
 }
 /**
  * helper function for tests related to OPUSVIER-2488
  */
 private function helperForOPUSVIER2488($url, $numOfTestDocs, $rows, $start = 0)
 {
     $docs = array();
     for ($i = 0; $i < $numOfTestDocs; $i++) {
         $doc = $this->createTestDocument();
         $doc->setServerState('published');
         $doc->setLanguage('eng');
         $title = new Opus_Title();
         $title->setValue('OPUSVIER-2488');
         $title->setLanguage('eng');
         $doc->setTitleMain($title);
         $doc->store();
         array_push($docs, $doc);
     }
     $this->dispatch($url);
     $body = $this->getResponse()->getBody();
     $docIds = array();
     // perform cleanup before asserting anything
     foreach ($docs as $doc) {
         array_push($docIds, $doc->getId());
         $doc->deletePermanent();
     }
     $this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
     $this->assertContains('doccount="' . $rows . '"', $body);
     $this->assertContains('queryhits="' . $numOfTestDocs . '"', $body);
     $this->assertEquals($rows, substr_count($body, 'Language="eng" Value="OPUSVIER-2488" Type="main"'));
     $this->assertNotContains('Application_Exception', $body);
     for ($i = $start; $i < $rows; $i++) {
         $this->assertContains('<Opus_Document Id="' . $docIds[$i] . '"', $body);
     }
 }
 /**
  * Tests, that the sortfields in browsing are still working.
  * see Opusvier-3334.
  */
 public function testSortOrderOfDocumentsInBrowsingWithSortfield()
 {
     $olderDoc = $this->createTestDocument();
     $olderDoc->setServerState('published');
     $olderDoc->setLanguage('eng');
     $date = new Opus_Date();
     $date->setNow();
     $date->setDay($date->getDay() - 1);
     $olderDoc->setServerDatePublished($date);
     $olderDoc->setType('article');
     $title = new Opus_Title();
     $title->setValue('zzzOlderDoc');
     // 'zzz' to show the document at the first page
     $title->setLanguage('eng');
     $olderDoc->addTitleMain($title);
     $olderDocId = $olderDoc->store();
     $newerDoc = $this->createTestDocument();
     $newerDoc->setServerState('published');
     $newerDoc->setLanguage('eng');
     $newerDoc->setType('article');
     $title = new Opus_Title();
     $title->setValue('zzzNewerDoc');
     $title->setLanguage('eng');
     $newerDoc->addTitleMain($title);
     $newerDocId = $newerDoc->store();
     $this->dispatch('/solrsearch/index/search/searchtype/simple/query/*%3A*/browsing/true/doctypefq/article/sortfield/title/sortorder/desc');
     $responseBody = $this->getResponse()->getBody();
     preg_match("\$/frontdoor/index/index.*/docId/{$olderDocId}\$", $responseBody, $matches, PREG_OFFSET_CAPTURE);
     $this->assertNotEmpty($matches, "Document {$olderDocId} not found!");
     $olderDocPosition = $matches[0][1];
     preg_match("\$/frontdoor/index/index.*/docId/{$newerDocId}\$", $responseBody, $matches, PREG_OFFSET_CAPTURE);
     $this->assertNotEmpty($matches, "Document {$newerDocId} not found!");
     $newerDocPosition = $matches[0][1];
     $this->assertTrue($newerDocPosition > $olderDocPosition, "Documents are not sorted by sortfield (title).");
 }
 public function testGetDocumentTitle()
 {
     $document = $this->createTestDocument();
     $document->setLanguage('deu');
     $title = new Opus_Title();
     $title->setLanguage('deu');
     $title->setValue('01234567890123456789012345678901234567890123456789');
     // 50 Zeichen lang
     $document->addTitleMain($title);
     $this->assertEquals('0123456789012345678901234567890123456789 ...', $this->helper->getDocumentTitle($document));
 }
 public function testPreserveNewlinesForAbstract()
 {
     $this->markTestIncomplete("Muss fuer OPUS 4.4 angepasst werden.");
     // TODO OPUSVIER-2794
     $doc = $this->createTestDocument();
     $doc->setLanguage("eng");
     $abstract = new Opus_Title();
     $abstract->setLanguage("eng");
     $abstract->setValue("foo\nbar\n\nbaz");
     $doc->addTitleAbstract($abstract);
     $doc->store();
     $this->dispatch('/admin/document/index/id/' . $doc->getId());
     $this->assertContains('<pre class="abstractTextContainer preserve-spaces">' . "foo\nbar\n\nbaz" . '</pre>', $this->getResponse()->getBody());
 }
 public function testGetDocTitle()
 {
     $view = Zend_Registry::get('Opus_View');
     $doc = $this->createTestDocument();
     $title = new Opus_Title();
     $title->setLanguage('deu');
     $title->setValue('Deutscher Titel');
     $doc->addTitleMain($title);
     $title = new Opus_Title();
     $title->setLanguage('eng');
     $title->setValue('Englischer Titel');
     $doc->addTitleMain($title);
     $doc->setLanguage('eng');
     $docAdapter = new Application_Util_DocumentAdapter($view, $doc);
     $this->assertEquals($docAdapter->getDocTitle(), 'Deutscher Titel');
 }
 /**
  * Checks, whether the document language title is printed before other titles.
  * OPUSVIER-1752
  * OPUSVIER-3316
  */
 public function testTitleSortOrderEnglishFirst()
 {
     $functions = array('addTitleMain', 'addTitleParent', 'addTitleSub', 'addTitleAdditional', 'addTitleAbstract');
     foreach ($functions as $function) {
         $doc = $this->createTestDocument();
         $title = new Opus_Title();
         $title->setLanguage('deu');
         $title->setValue('deutscher Titel');
         $doc->{$function}($title);
         $title = new Opus_Title();
         $title->setLanguage('eng');
         $title->setValue('englischer Titel');
         $doc->{$function}($title);
         $doc->setLanguage('eng');
         $doc->setServerState('published');
         $docId = $doc->store();
         $this->dispatch('/frontdoor/index/index/docId/' . $docId);
         // Absicherung gegen HTML Aenderungen;  in Meta-Tags steht Text in Attribut
         $this->assertEquals(1, substr_count($this->getResponse()->getBody(), '>deutscher Titel<'), 'Teststring is found more than once; test is not reliable anymore');
         $this->assertEquals(1, substr_count($this->getResponse()->getBody(), '>englischer Titel<'), 'Teststring is found more than once; test is not reliable anymore');
         $title1 = strpos($this->getResponse()->getBody(), '>englischer Titel<');
         $title2 = strpos($this->getResponse()->getBody(), '>deutscher Titel<');
         $this->assertTrue($title1 < $title2);
         $this->getResponse()->clearBody();
     }
 }
 /**
  * Regression test for OPUSVIER-1726
  */
 public function testSolrIndexIsNotUpToDate()
 {
     // add a document to the search index that is not stored in database
     $doc1 = $this->createTestDocument();
     $doc1->setServerState('published');
     $doc1->setLanguage('eng');
     $title = new Opus_Title();
     $title->setValue('test document for OPUSVIER-1726');
     $title->setLanguage('eng');
     $doc1->setTitleMain($title);
     // unregister index plugin: database changes are not reflected in search index
     $doc1->unregisterPlugin('Opus_Document_Plugin_Index');
     $doc1->store();
     $docId1 = $doc1->getId();
     $date = new Zend_Date($doc1->getServerDatePublished());
     $dateValue1 = $date->get(Zend_Date::RFC_2822);
     $indexer = Opus_Search_Service::selectIndexingService(null, 'solr');
     $indexer->addDocumentsToIndex($doc1);
     // delete document from database
     $doc1->deletePermanent();
     sleep(2);
     // make sure $doc2 do not get the same value for server_date_published
     $doc2 = $this->createTestDocument();
     $doc2->setServerState('published');
     $doc2->setLanguage('eng');
     $title = new Opus_Title();
     $title->setValue('another test document for OPUSVIER-1726');
     $title->setLanguage('eng');
     $doc2->setTitleMain($title);
     $doc2->store();
     $docId2 = $doc2->getId();
     $date = new Zend_Date($doc2->getServerDatePublished());
     $dateValue2 = $date->get(Zend_Date::RFC_2822);
     $this->dispatch('/rss/index/index/searchtype/all');
     // make search index up to date
     $indexer->removeDocumentsFromIndexById($docId1);
     $doc2->deletePermanent();
     $body = $this->getResponse()->getBody();
     $this->assertNotContains("No Opus_Db_Documents with id {$docId1} in database.", $body);
     $this->assertNotContains('<title>test document for OPUSVIER-1726</title>', $body);
     $this->assertContains('<title>another test document for OPUSVIER-1726</title>', $body);
     $this->assertNotContains("frontdoor/index/index/docId/{$docId1}</link>", $body);
     $this->assertContains("frontdoor/index/index/docId/{$docId2}</link>", $body);
     $this->assertNotContains("<pubDate>{$dateValue1}</pubDate>", $body);
     $this->assertNotContains("<lastBuildDate>{$dateValue1}</lastBuildDate>", $body);
     $this->assertContains("<pubDate>{$dateValue2}</pubDate>", $body);
     $this->assertContains("<lastBuildDate>{$dateValue2}</lastBuildDate>", $body);
     $this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
 }