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();
 }
Exemplo n.º 2
0
 /**
  * Removes a cache entry.
  *
  * @param mixed $documentId
  * @param mixed $xmlVersion
  * @return boolean
  */
 public function remove($documentId, $xmlVersion)
 {
     $rowSet = $this->_table->find($documentId, $xmlVersion);
     if (1 === $rowSet->count()) {
         $result = $rowSet->current()->delete();
         if (1 === $result) {
             return true;
         }
     }
     return false;
 }