public function testPopulateFromModel()
 {
     $form = new Admin_Form_Licence();
     $licence = new Opus_Licence();
     $licence->setActive(true);
     $licence->setCommentInternal('Test Internal Comment');
     $licence->setDescMarkup('<h1>Test Markup</h1>');
     $licence->setDescText('Test Description');
     $licence->setLanguage('rus');
     $licence->setLinkLicence('http://www.example.org/licence');
     $licence->setLinkLogo('http://www.example.org/logo');
     $licence->setMimeType('text/plain');
     $licence->setNameLong('Test Licence');
     $licence->setSortOrder(3);
     $licence->setPodAllowed(false);
     $form->populateFromModel($licence);
     $this->assertTrue($form->getElement('Active')->getValue());
     $this->assertEquals('Test Internal Comment', $form->getElement('CommentInternal')->getValue());
     $this->assertEquals('<h1>Test Markup</h1>', $form->getElement('DescMarkup')->getValue());
     $this->assertEquals('Test Description', $form->getElement('DescText')->getValue());
     $this->assertEquals('rus', $form->getElement('Language')->getValue());
     $this->assertEquals('http://www.example.org/licence', $form->getElement('LinkLicence')->getValue());
     $this->assertEquals('http://www.example.org/logo', $form->getElement('LinkLogo')->getValue());
     $this->assertEquals('text/plain', $form->getElement('MimeType')->getValue());
     $this->assertEquals('Test Licence', $form->getElement('NameLong')->getValue());
     $this->assertEquals(3, $form->getElement('SortOrder')->getValue());
     $this->assertEquals(0, $form->getElement('PodAllowed')->getValue());
 }
 /**
  * Tests 'show' action.
  */
 public function testShowAction()
 {
     $this->createsModels = true;
     $licence = new Opus_Licence();
     $licence->setActive(true);
     $licence->setNameLong('TestNameLong');
     $licence->setLanguage('deu');
     $licence->setLinkLicence('www.example.org/licence');
     $licence->setLinkLogo('www.example.org/licence/logo.png');
     $licence->setLinkSign('TestLinkSign');
     // wird nicht angezeigt (soll später entfernt werden - OPUSVIER-1492)
     $licence->setDescText('TestDescText');
     $licence->setDescMarkup('TestDescMarkup');
     $licence->setCommentInternal('TestCommentInternal');
     $licence->setMimeType('text/plain');
     $licence->setPodAllowed(false);
     $licence->setSortOrder(100);
     $licenceId = $licence->store();
     $this->dispatch('/admin/licence/show/id/' . $licenceId);
     $licence = new Opus_Licence($licenceId);
     $licence->delete();
     $this->assertResponseCode(200);
     $this->assertController('licence');
     $this->assertAction('show');
     $this->assertQueryContentRegex('div#Active', '/Yes|Ja/');
     $this->assertQueryContentContains('div#NameLong', 'TestNameLong');
     $this->assertQueryContentRegex('div#Language', '/German|Deutsch/');
     $this->assertQueryContentContains('div#LinkLicence', 'www.example.org/licence');
     $this->assertQueryContentContains('div#LinkLogo', 'www.example.org/licence/logo.png');
     $this->assertQueryContentContains('div#DescText', 'TestDescText');
     $this->assertQueryContentContains('div#DescMarkup', 'TestDescMarkup');
     $this->assertQueryContentContains('div#CommentInternal', 'TestCommentInternal');
     $this->assertQueryContentContains('div#MimeType', 'text/plain');
     $this->assertQueryContentRegex('div#PodAllowed', '/No|Nein/');
     $this->assertQueryContentContains('div#SortOrder', '100');
     // wird nicht angezeigt - OPUSVIER-1492
     $this->assertQueryCount('div#LinkSign', 0);
     $this->assertNotQueryContentContains('div#content', 'TestLinkSign');
     // TODO $this->validateXHTML();
 }
Beispiel #3
0
 /**
  * transfers any OPUS3-conform classification System into an array
  *
  * @param DOMDocument $data XML-Document to be imported
  * @return array List of documents that have been imported
  */
 protected function transferOpus3Licence($data)
 {
     //$classification = array();
     $doclist = $data->getElementsByTagName('row');
     $licenses = array();
     foreach ($doclist as $document) {
         $lic = new Opus_Licence();
         $shortname = "";
         foreach ($document->getElementsByTagName('field') as $field) {
             if ($field->nodeValue === '') {
                 continue;
             }
             if ($field->getAttribute('name') === 'active') {
                 $lic->setActive($field->nodeValue);
             }
             if ($field->getAttribute('name') === 'comment') {
                 $lic->setCommentInternal($field->nodeValue);
             }
             if ($field->getAttribute('name') === 'desc_html') {
                 $lic->setDescMarkup($field->nodeValue);
             }
             if ($field->getAttribute('name') === 'desc_text') {
                 $lic->setDescText(html_entity_decode($field->nodeValue, ENT_COMPAT, 'UTF-8'));
             }
             if ($field->getAttribute('name') === 'language') {
                 $lic->setLanguage($this->mapLanguage($field->nodeValue));
             }
             if ($field->getAttribute('name') === 'link') {
                 $lic->setLinkLicence($field->nodeValue);
             }
             if ($field->getAttribute('name') === 'logo') {
                 $lic->setLinkLogo($field->nodeValue);
             }
             if ($field->getAttribute('name') === 'link_tosign') {
                 $lic->setLinkSign($field->nodeValue);
             }
             if ($field->getAttribute('name') === 'mime_type') {
                 $lic->setMimeType($field->nodeValue);
             }
             if ($field->getAttribute('name') === 'longname') {
                 $lic->setNameLong(html_entity_decode($field->nodeValue, ENT_COMPAT, 'UTF-8'));
             }
             if ($field->getAttribute('name') === 'pod_allowed') {
                 $lic->setPodAllowed($field->nodeValue);
             }
             //if ($field->getAttribute('name') === 'sort') $lic->setSortOrder($field->nodeValue);
             if ($field->getAttribute('name') === 'shortname') {
                 $shortname = $field->nodeValue;
             }
         }
         $this->checkMandatoryFields($lic, $shortname);
         $this->maxSortOrder++;
         $lic->setSortOrder($this->maxSortOrder);
         $licenses[$shortname] = $lic;
     }
     return $licenses;
 }