Skip to content
Snippets Groups Projects
Commit 9b871893 authored by efalcy's avatar efalcy
Browse files

Gallica validation XML

parent 5f1c1b2d
No related merge requests found
......@@ -55,15 +55,20 @@ class Class_WebService_OAI_Request_ListIdentifiers {
$this->_from = $token->getParam('from');
$this->_until = $token->getParam('until');
}
if (!strtotime($this->_until))
$this->_until = null;
if (!strtotime($this->_from))
$this->_from = null;
$this->checkUntilAndFromValidity();
$this->_catalogue = $this->getCatalogueFromSetSpec($this->_set);
}
public function checkUntilAndFromValidity() {
if ($this->_until && !strtotime($this->_until))
$this->_until = null;
if ($this->_from && !strtotime($this->_from))
$this->_from = null;
}
public function getNotices() {
return $this->_notices;
}
......@@ -78,6 +83,12 @@ class Class_WebService_OAI_Request_ListIdentifiers {
if ($this->_set && !$this->_catalogue)
$answer .= $builder->error(array('code' => 'badArgument'), 'Set not found');
if ($this->_until && $this->_from) {
if (strlen($this->_until) != strlen($this->_from))
return $builder->error(array('code' => 'badArgument'), 'Set not found');
}
$token = null;
if ($this->_resumptionToken
&& !($token = Class_WebService_OAI_ResumptionToken::find($this->_resumptionToken)))
......
......@@ -299,6 +299,7 @@ class OAIControllerListIdentifiersInvalidParamsTest extends AbstractControllerTe
'//oai:error[@code="badResumptionToken"]');
}
/** @test */
public function withBadFromAndUntilResponseShouldNotContainsAttributes() {
$this->dispatch('/opac/oai/request?verb=ListIdentifiers&metadataPrefix=oai_dc&set=really_wrong_set&from=some_random_date&until=some_random_date');
......@@ -308,6 +309,12 @@ class OAIControllerListIdentifiersInvalidParamsTest extends AbstractControllerTe
}
/** @test */
public function withFromAndUntilDifferentGranularityResponseShouldNotContainsAttributes() {
$this->dispatch('/opac/oai/request?verb=ListIdentifiers&metadataPrefix=oai_dc&from=2001-01-01&until=2002-01-01T00:00:00Z');
$this->_xpath->assertXPath($this->_response->getBody(),
'//oai:error[@code="badArgument"]');
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment