Пример #1
0
 public function init()
 {
     parent::init();
     $identifier = new Opus_Identifier();
     $types = $identifier->getField('Type')->getDefault();
     foreach ($types as $type) {
         $this->addMultiOption($type, 'Opus_Identifier_Type_Value_' . ucfirst($type));
     }
 }
Пример #2
0
 public function testOptions()
 {
     $element = $this->getElement();
     $translator = $element->getTranslator();
     $identifier = new Opus_Identifier();
     $types = $identifier->getField('Type')->getDefault();
     $this->assertEquals(count($types), count($element->getMultiOptions()));
     foreach ($element->getMultiOptions() as $type => $label) {
         $this->assertContains($type, $types);
         $translationKey = 'Opus_Identifier_Type_Value_' . ucfirst($type);
         $this->assertTrue($translator->isTranslated($translationKey));
         $this->assertEquals($translator->translate($translationKey), $label);
     }
 }
Пример #3
0
 public function testTranslationOfIdentifierTypeValues()
 {
     $model = new Opus_Identifier();
     $values = $model->getField('Type')->getDefault();
     foreach ($values as $value) {
         $key = $this->helper->getKeyForValue('Opus_Identifier', 'Type', $value);
         $this->assertNotEquals($key, $this->translate->translate($key), 'Translation key \'' . $key . '\' is missing.');
     }
 }
 /**
  * test for OPUSVIER-2475
  */
 public function testCatchAllSearchConsidersIdentifiers()
 {
     $this->requireSolrConfig();
     // create a test doc with all available identifier types
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $doc->setLanguage('eng');
     $title = new Opus_Title();
     $title->setValue('test document for OPUSVIER-2475');
     $title->setLanguage('eng');
     $doc->setTitleMain($title);
     $id = new Opus_Identifier();
     $field = $id->getField('Type');
     $identifierTypes = array_keys($field->getDefault());
     foreach ($identifierTypes as $identifierType) {
         $doc->addIdentifier()->setType($identifierType)->setValue($identifierType . '-opusvier-2475');
     }
     $doc->store();
     // search for document based on identifiers
     foreach ($identifierTypes as $identifierType) {
         $searchString = $identifierType . '-opusvier-2475';
         $this->dispatch('/solrsearch/index/search/searchtype/simple/query/' . $searchString);
         $this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
         $this->assertContains('test document for OPUSVIER-2475', $this->getResponse()->getBody());
         $this->getResponse()->clearAllHeaders();
         $this->getResponse()->clearBody();
     }
 }