/**
  * Test list document ids, metadataPrefix=XMetaDissPlus, different intervals
  * list possible intervals *NOT* containing "2010-06-05"
  */
 public function testIntervalOAIPMHQueryWithoutTestDoc()
 {
     $doc = $this->createTestDocument();
     $doc->setServerState('published');
     $this->docId = $doc->store();
     $doc = new Opus_Document($this->docId);
     $serverDateModified = $doc->getServerDateModified();
     $today = new DateTime();
     $today->setDate($serverDateModified->getYear(), $serverDateModified->getMonth(), $serverDateModified->getDay());
     $yesterday = clone $today;
     $yesterday->modify('-1 day');
     $dayBeforeYesterday = clone $yesterday;
     $dayBeforeYesterday->modify('-1 day');
     $tomorrow = clone $today;
     $tomorrow->modify('+1 day');
     $dayAfterTomorrow = clone $tomorrow;
     $dayAfterTomorrow->modify('+1 day');
     $yesterdayStr = date_format($yesterday, 'Y-m-d');
     $dayBeforeYesterdayStr = date_format($dayBeforeYesterday, 'Y-m-d');
     $tomorrowStr = date_format($tomorrow, 'Y-m-d');
     $dayAfterTomorrowStr = date_format($dayAfterTomorrow, 'Y-m-d');
     $intervals = array(array('from' => $tomorrowStr), array('until' => $yesterdayStr), array('from' => $tomorrowStr, 'until' => $dayAfterTomorrowStr), array('from' => $dayBeforeYesterdayStr, 'until' => $yesterdayStr));
     foreach ($intervals as $interval) {
         $oaiRequest = array('verb' => 'ListRecords', 'metadataPrefix' => 'XMetaDissPlus');
         $oaiRequest = array_merge($interval, $oaiRequest);
         $docListModel = new Oai_Model_DocumentList();
         $docListModel->deliveringDocumentStates = array('published', 'deleted');
         $docListModel->xMetaDissRestriction = array();
         $docIds = $docListModel->query($oaiRequest);
         $this->assertFalse(in_array($this->docId, $docIds), "Response must NOT contain document id {$this->docId}: " . var_export($interval, true));
     }
 }
 /**
  * Helper method for handling lists.
  *
  * @param array &$oaiRequest
  * @param mixed $maxRecords
  * @return void
  */
 private function _handlingOfLists(array &$oaiRequest, $maxRecords)
 {
     if (true === empty($maxRecords)) {
         $maxRecords = 100;
     }
     $repIdentifier = $this->_configuration->getRepositoryIdentifier();
     $tempPath = $this->_configuration->getResumptionTokenPath();
     $this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
     $this->_xml->appendChild($this->_xml->createElement('Documents'));
     // do some initialisation
     $cursor = 0;
     $totalIds = 0;
     $start = $maxRecords + 1;
     $reldocIds = array();
     $metadataPrefix = null;
     if (true === array_key_exists('metadataPrefix', $oaiRequest)) {
         $metadataPrefix = $oaiRequest['metadataPrefix'];
     }
     $tokenWorker = new Oai_Model_Resumptiontokens();
     $tokenWorker->setResumptionPath($tempPath);
     // parameter resumptionToken is given
     if (false === empty($oaiRequest['resumptionToken'])) {
         $resParam = $oaiRequest['resumptionToken'];
         $token = $tokenWorker->getResumptionToken($resParam);
         if (true === is_null($token)) {
             throw new Oai_Model_Exception("file could not be read.", Oai_Model_Error::BADRESUMPTIONTOKEN);
         }
         $cursor = $token->getStartPosition() - 1;
         $start = $token->getStartPosition() + $maxRecords;
         $totalIds = $token->getTotalIds();
         $reldocIds = $token->getDocumentIds();
         $metadataPrefix = $token->getMetadataPrefix();
         $this->_proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix);
         // no resumptionToken is given
     } else {
         $docListModel = new Oai_Model_DocumentList();
         $docListModel->deliveringDocumentStates = $this->_deliveringDocumentStates;
         $docListModel->xMetaDissRestriction = $this->_xMetaDissRestriction;
         $reldocIds = $docListModel->query($oaiRequest);
         $totalIds = count($reldocIds);
     }
     // handling of document ids
     $restIds = $reldocIds;
     $workIds = array_splice($restIds, 0, $maxRecords);
     foreach ($workIds as $docId) {
         $document = new Opus_Document($docId);
         $this->createXmlRecord($document);
     }
     // no records returned
     if (true === empty($workIds)) {
         throw new Oai_Model_Exception("The combination of the given values results in an empty list.", Oai_Model_Error::NORECORDSMATCH);
     }
     // store the further Ids in a resumption-file
     $countRestIds = count($restIds);
     if ($countRestIds > 0) {
         $token = new Oai_Model_Resumptiontoken();
         $token->setStartPosition($start);
         $token->setTotalIds($totalIds);
         $token->setDocumentIds($restIds);
         $token->setMetadataPrefix($metadataPrefix);
         $tokenWorker->storeResumptionToken($token);
         // set parameters for the resumptionToken-node
         $res = $token->getResumptionId();
         $this->setParamResumption($res, $cursor, $totalIds);
     }
 }