public function testUpdateOnLicenceChange()
 {
     $document = $this->createTestDocument();
     $document->store();
     $documentCacheTable = new Opus_Db_DocumentXmlCache();
     $docXmlCache = $documentCacheTable->find($document->getId(), '1')->current()->xml_data;
     $domDoc = new DomDocument();
     $domDoc->loadXML($docXmlCache);
     $licences = $domDoc->getElementsByTagName('Licence');
     $this->assertTrue($licences->length == 0, 'Expected no Licence element in dom.');
     $licence = new Opus_Licence();
     $licence->setNameLong('TestLicence');
     $licence->setLinkLicence('http://example.org/licence');
     $licenceId = $licence->store();
     $document->setServerState('published');
     $document->setLicence($licence);
     $docId = $document->store();
     $licence = new Opus_Licence($licenceId);
     $licence->setNameLong('TestLicenceAltered');
     $licence->store();
     $docXmlCacheResult = $documentCacheTable->find($document->getId(), '1');
     $this->assertTrue($docXmlCacheResult->count() == 0, 'Expected empty document xml cache');
     $this->executeScript('cron-update-document-cache.php');
     $docXmlCacheAfter = $documentCacheTable->find($docId, '1')->current()->xml_data;
     $domDocAfter = new DomDocument();
     $domDocAfter->loadXML($docXmlCacheAfter);
     $licencesAfter = $domDocAfter->getElementsByTagName('Licence');
     $this->assertTrue($licencesAfter->length == 1, 'Expected one Licence element in dom.');
     $licences = $document->getLicence();
     $licences[0]->delete();
 }
$doc->setThesisPublisher($dnbInstitute);
//
// Subjects
//
$doc->addSubject()->setType('swd')->setValue(randString($counter++));
foreach (array('uncontrolled', 'msc', 'ddc') as $type) {
    $doc->addSubject()->setType($type)->setLanguage(randString($counter++))->setValue(randString($counter++))->setExternalKey(randString($counter++));
    $doc->addSubject()->setType($type)->setLanguage("eng" . randString($counter++))->setValue(randString($counter++))->setExternalKey(randString($counter++));
    $doc->addSubject()->setType($type)->setLanguage("deu")->setValue(randString($counter++))->setExternalKey(randString($counter++));
    $doc->addSubject()->setType($type)->setLanguage("eng")->setValue(randString($counter++))->setExternalKey(randString($counter++));
}
//
// Notes
//
$doc->addNote()->setVisibility('public')->setMessage(randString($counter++));
$doc->addNote()->setVisibility('private')->setMessage(randString($counter++));
//
// Licenses
//
$lic = new Opus_Licence();
$lic->setActive(1);
$lic->setLanguage('deu' . randString($counter++));
$lic->setLinkLicence(randString($counter++));
$lic->setNameLong(randString($counter++));
$lic->store();
$doc->setLicence($lic);
//
// Storing...
//
$doc->store();
print "Document stored. ID: " . $doc->getId() . "\n";
 public function createNewModel()
 {
     $licence = new Opus_Licence();
     $licence->setNameLong('Test Licence (LicenceControllerTest::testDeleteAction)');
     $licence->setLinkLicence('testlink');
     $licence->setLanguage('rus');
     return $licence->store();
 }
Ejemplo n.º 4
0
 public function testHandleConfirmationPostYes()
 {
     $licence = new Opus_Licence();
     $licence->setNameLong(__METHOD__);
     $licence->setLanguage('deu');
     $licence->setLinkLicence('www.example.org/licence');
     $licenceId = $licence->store();
     $result = $this->controller->handleConfirmationPost(array('Id' => $licenceId, 'ConfirmYes' => 'Ja'));
     $this->assertNotNull($result);
     $this->assertInternalType('array', $result);
     $this->assertEquals(1, count($result));
     $this->assertArrayHasKey('message', $result);
     $this->assertEquals(Application_Controller_ActionCRUD::DELETE_SUCCESS, $result['message']);
 }