diff --git a/library/Class/WebService/OAI/Request/ListIdentifiers.php b/library/Class/WebService/OAI/Request/ListIdentifiers.php index fdcae99ca9514462706f6ef06a5d1379ceed5e9e..d2cc9416155e62e07df5cbb77f419f840e57a22d 100644 --- a/library/Class/WebService/OAI/Request/ListIdentifiers.php +++ b/library/Class/WebService/OAI/Request/ListIdentifiers.php @@ -96,6 +96,8 @@ class Class_WebService_OAI_Request_ListIdentifiers { $this->_catalogue->setUntil(substr($this->_until, 0, 10)); $this->_notices = $this->_catalogue->getNotices($page_number, self::IDENTIFIERS_BY_PAGE); + if (empty($this->_notices)) + return $builder->error(array('code' => 'noRecordsMatch')); } diff --git a/tests/application/modules/opac/controllers/OAIControllerListIdentifiersTest.php b/tests/application/modules/opac/controllers/OAIControllerListIdentifiersTest.php index ec5dec5d47acc049854a2fc1e1e4038ed775e3d5..4dc5f167e01df65c5176807860c1b77d52f1d865 100644 --- a/tests/application/modules/opac/controllers/OAIControllerListIdentifiersTest.php +++ b/tests/application/modules/opac/controllers/OAIControllerListIdentifiersTest.php @@ -167,6 +167,8 @@ class OAIControllerListIdentifiersValidTest extends AbstractControllerTestCase { } + + class OAIControllerListIdentifiersWithPaginatorTest extends AbstractControllerTestCase { protected $_xpath; protected $_xml; @@ -225,6 +227,8 @@ class OAIControllerListIdentifiersWithPaginatorTest extends AbstractControllerTe } + + class OAIControllerListIdentifiersInvalidParamsTest extends AbstractControllerTestCase { protected $_xpath; @@ -295,4 +299,49 @@ class OAIControllerListIdentifiersInvalidParamsTest extends AbstractControllerTe '//oai:error[@code="badResumptionToken"]'); } } + + + + +class OAIControllerListIdentifiersWithoutDataFoundTest extends AbstractControllerTestCase { + protected $_xpath; + protected $_xml; + protected $_cache; + + public function setUp() { + parent::setUp(); + $this->_xpath = TestXPathFactory::newOai(); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') + ->whenCalled('countNoticesFor') + ->answers(10) + + ->whenCalled('findAllBy') + ->with(array('oai_spec' => 'zork')) + ->answers([Class_Catalogue::getLoader()->newInstanceWithId(2)]) + + ->whenCalled('loadNoticesFor') + ->answers([]); + + $this->_cache = Storm_Test_ObjectWrapper::mock() + ->whenCalled('save') + ->answers(true); + + Class_WebService_OAI_ResumptionToken::defaultCache($this->_cache); + + $this->dispatch('/opac/oai/request?verb=ListIdentifiers&metadataPrefix=oai_dc&set=zork'); + $this->_xml = $this->_response->getBody(); + } + + + public function tearDown() { + Class_WebService_OAI_ResumptionToken::defaultCache(null); + parent::tearDown(); + } + + + /** @test */ + public function responseShouldCountainsErrorNoRecordMatch() { + $this->_xpath->assertXPath($this->_xml, '//oai:error[@code="noRecordsMatch"]'); + } +} ?> \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/OAIControllerTest.php b/tests/application/modules/opac/controllers/OAIControllerTest.php index d8e124c54f33aa9431d9e324c2ea6e10f423d80d..47c73808e14ed93ab740896e14a725330ea870ce 100644 --- a/tests/application/modules/opac/controllers/OAIControllerTest.php +++ b/tests/application/modules/opac/controllers/OAIControllerTest.php @@ -110,6 +110,7 @@ class OAIControllerRequestWithoutOAIEnabledTest extends AbstractControllerTestCa + class OaiControllerListSetsRequestTest extends OaiControllerRequestTestCase { protected $_xpath;