From fbe72bc97fb9f624111c28c5f8d43f72ec13fa22 Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@git-test.afi-sa.fr>
Date: Mon, 10 Dec 2012 11:17:55 +0000
Subject: [PATCH] Gallica : validation XML error14

---
 library/Class/WebService/OAI/Request/ListIdentifiers.php | 9 +++++++--
 .../controllers/OAIControllerListIdentifiersTest.php     | 8 ++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/library/Class/WebService/OAI/Request/ListIdentifiers.php b/library/Class/WebService/OAI/Request/ListIdentifiers.php
index 6ed67385d10..95066d53f32 100644
--- a/library/Class/WebService/OAI/Request/ListIdentifiers.php
+++ b/library/Class/WebService/OAI/Request/ListIdentifiers.php
@@ -35,7 +35,7 @@ class Class_WebService_OAI_Request_ListIdentifiers {
 	
 	public function __construct($params, $baseUrl) {
 		$this->_baseUrl = $baseUrl;
-		$this->_params = array_merge(array('metadataPrefix' => 'oai_dc',
+		$this->_params = array_merge(array('metadataPrefix' => null,
 																			 'set' => null,
 																			 'from' => null,
 																			 'until' => null,
@@ -75,18 +75,23 @@ class Class_WebService_OAI_Request_ListIdentifiers {
 
 
 	public function getErrorOn($builder) {
+
 		$answer = '';
 
+		if (null == $this->_metadataPrefix)
+			$answer.=$builder->error(array('code' => 'badArgument'), 'Set not found');
+
 		if ('oai_dc' != $this->_metadataPrefix) 
 			$answer .= $builder->error(array('code' => 'cannotDisseminateFormat'));
 
+
 		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');
+				return $builder->error(array('code' => 'badArgument'), 'from granularity != until granularity');
 		}
 
 		$token = null;
diff --git a/tests/application/modules/opac/controllers/OAIControllerListIdentifiersTest.php b/tests/application/modules/opac/controllers/OAIControllerListIdentifiersTest.php
index 08c0af8ce12..5d8f8b38f2f 100644
--- a/tests/application/modules/opac/controllers/OAIControllerListIdentifiersTest.php
+++ b/tests/application/modules/opac/controllers/OAIControllerListIdentifiersTest.php
@@ -315,6 +315,14 @@ class OAIControllerListIdentifiersInvalidParamsTest extends AbstractControllerTe
 		$this->_xpath->assertXPath($this->_response->getBody(), 
 															 '//oai:error[@code="badArgument"]');
 	}
+
+	/** @test */
+	public function withListIdentifiersWithoutMetadataPrefixResponseShouldResponseBadArgument() {
+		$this->dispatch('opac/oai/request?verb=ListIdentifiers');
+		$this->_xpath->assertXPath($this->_response->getBody(), 
+															 '//oai:error[@code="badArgument"]');
+		
+	}
 }
 
 
-- 
GitLab