/** * Test date functionality. * * @return void */ public function testDate() { $tmp = sys_get_temp_dir() . '/'; $manager = new StateManager($tmp); $date = '2016-07-12'; $manager->saveDate($date); $this->assertEquals($date, $manager->loadDate()); unlink($tmp . 'last_harvest.txt'); }
/** * Harvest records using OAI-PMH. * * @param array $params GET parameters for ListRecords method. * * @return mixed Resumption token if provided, false if finished */ protected function getRecords($params) { // Make the OAI-PMH request: $response = $this->sendRequest('ListRecords', $params); // Save the records from the response: if ($response->ListRecords->record) { $this->writeLine('Processing ' . count($response->ListRecords->record) . " records..."); $endDate = $this->writer->write($response->ListRecords->record); } // If we have a resumption token, keep going; otherwise, we're done -- save // the end date. if (isset($response->ListRecords->resumptionToken) && !empty($response->ListRecords->resumptionToken)) { return $response->ListRecords->resumptionToken; } else { if (isset($endDate) && $endDate > 0) { $dateFormat = $this->granularity == 'YYYY-MM-DD' ? 'Y-m-d' : 'Y-m-d\\TH:i:s\\Z'; $this->stateManager->saveDate(date($dateFormat, $endDate)); } } return false; }