diff --git a/library/Class/WebService/OAI/Request/ListMetadataFormats.php b/library/Class/WebService/OAI/Request/ListMetadataFormats.php index 082986ff7d6f7e05bd15488394789860e2fefea7..7eb11f1bfb66c242ec4f80152fa1c7b846c18019 100644 --- a/library/Class/WebService/OAI/Request/ListMetadataFormats.php +++ b/library/Class/WebService/OAI/Request/ListMetadataFormats.php @@ -30,7 +30,7 @@ class Class_WebService_OAI_Request_ListMetadataFormats { public function getErrorOn($builder) { - if (!Class_Notice::getNoticeByOAIIdentifier($this->_identifier)) + if ($this->_identifier && !Class_Notice::getNoticeByOAIIdentifier($this->_identifier)) return $builder->error(['code' => 'idDoesNotExist']); } diff --git a/tests/application/modules/opac/controllers/OAIControllerListMetadataFormatsTest.php b/tests/application/modules/opac/controllers/OAIControllerListMetadataFormatsTest.php index 6fca6cd7315b7b32b3781910e97e51e5e8f45fcc..77b5ef7afd9e43dc9ad69bfa4ebfb67c1eb6cc5c 100644 --- a/tests/application/modules/opac/controllers/OAIControllerListMetadataFormatsTest.php +++ b/tests/application/modules/opac/controllers/OAIControllerListMetadataFormatsTest.php @@ -32,7 +32,7 @@ abstract class OAIControllerListMetadataFormatsTestCase extends AbstractControll -class OAIControllerListMetadataFormatsValidTest extends OAIControllerListMetadataFormatsTest { +class OAIControllerListMetadataFormatsValidTest extends OAIControllerListMetadataFormatsTestCase { public function setUp() { parent::setUp(); $this->dispatch('/opac/oai/request?verb=ListMetadataFormats'); @@ -89,12 +89,18 @@ class OAIControllerListMetadataFormatsValidTest extends OAIControllerListMetadat $position, $name); $this->_xpath->assertXpathContentContains($this->_response->getBody(), $path, $content); } + + + /** @test */ + public function shouldReturnErrorIdDoesNotExist() { + $this->_xpath->assertNotXPath($this->_response->getBody(), '//oai:error'); + } } -class OAIControllerListMetadataFormatsTest extends OAIControllerListMetadataFormatsTestCase { +class OAIControllerListMetadataFormatsErrorsTest extends OAIControllerListMetadataFormatsTestCase { /** @test */ public function withWrongIdentifierShouldReturnErrorIdDoesNotExist() { $this->dispatch('/opac/oai/request?verb=ListMetadataFormats&identifier=really_wrong_id', true);