From b21e86e201934a18fd19d670adad019492eaf5ef Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Mon, 10 Dec 2012 14:23:15 +0000
Subject: [PATCH] OAI: correction ListMetadataFormats validateurs OAI

---
 .../WebService/OAI/Request/ListMetadataFormats.php     |  2 +-
 .../OAIControllerListMetadataFormatsTest.php           | 10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/library/Class/WebService/OAI/Request/ListMetadataFormats.php b/library/Class/WebService/OAI/Request/ListMetadataFormats.php
index 082986ff7d6..7eb11f1bfb6 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 6fca6cd7315..77b5ef7afd9 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);
-- 
GitLab