Skip to content
Snippets Groups Projects
Commit 5f1c1b2d authored by llaffont's avatar llaffont
Browse files

OAI Correction test (39) Testing : ListRecords (illegal_resumptiontoken)

parent 0250c52f
Branches
Tags
No related merge requests found
......@@ -70,19 +70,24 @@ class Class_WebService_OAI_Request_ListIdentifiers {
public function getErrorOn($builder) {
$answer = '';
if ('oai_dc' != $this->_metadataPrefix)
return $builder->error(array('code' => 'cannotDisseminateFormat'));
$answer .= $builder->error(array('code' => 'cannotDisseminateFormat'));
if ($this->_set && !$this->_catalogue)
return $builder->error(array('code' => 'badArgument'), 'Set not found');
if (0 == ($count = $this->_catalogue->getNoticesCount()))
return $builder->error(array('code' => 'noRecordsMatch'));
$answer .= $builder->error(array('code' => 'badArgument'), 'Set not found');
$token = null;
if ($this->_resumptionToken
&& !($token = Class_WebService_OAI_ResumptionToken::find($this->_resumptionToken)))
return $builder->error(array('code' => 'badResumptionToken'));
$answer .= $builder->error(array('code' => 'badResumptionToken'));
if ($answer)
return $answer;
if (0 == ($count = $this->_catalogue->getNoticesCount()))
return $builder->error(array('code' => 'noRecordsMatch'));
$page_number = 1;
if (null != $token) {
......
......@@ -20,7 +20,7 @@
*/
require_once 'AbstractControllerTestCase.php';
class OAIControllerListRecordsInZorkSetTest extends AbstractControllerTestCase {
abstract class OAIControllerListRecordsInZorkSetTestCase extends AbstractControllerTestCase {
protected $_xpath;
public function setUp() {
......@@ -49,6 +49,15 @@ class OAIControllerListRecordsInZorkSetTest extends AbstractControllerTestCase {
->newInstanceWithId(4)
->setClefAlpha('harrypotter-azkaban')
->setDateMaj('2012-04-03 11:42:42')));
}
}
class OAIControllerListRecordsInZorkSetTest extends OAIControllerListRecordsInZorkSetTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/oai/request?verb=ListRecords&metadataPrefix=oai_dc&set=zork');
}
......@@ -99,4 +108,29 @@ class OAIControllerListRecordsInZorkSetTest extends AbstractControllerTestCase {
}
}
class OAIControllerListRecordsInZorkSetWithBadResumptionTokenTest extends OAIControllerListRecordsInZorkSetTestCase {
public function setUp() {
parent::setUp();
$cache = Storm_Test_ObjectWrapper::mock()
->whenCalled('load')
->answers(false);
Class_WebService_OAI_ResumptionToken::defaultCache($cache);
Class_Catalogue::whenCalled('countNoticesFor')->answers(0);
$this->dispatch('/opac/oai/request?verb=ListRecords&metadataPrefix=oai_dc&set=zork&resumptionToken=junktoken');
}
/** @test */
public function withUnknownResumptionTokenErrorCodeShouldBeBadResumptionToken() {
$this->_xpath->assertXPath($this->_response->getBody(),
'//oai:error[@code="badResumptionToken"]');
}
}
?>
\ No newline at end of file
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