Skip to content
Snippets Groups Projects
Commit 1441ba0c authored by pbarroca's avatar pbarroca
Browse files

OAI: ajout réponse ListMetadataFormats

parent 072405a8
Branches
Tags
No related merge requests found
......@@ -1766,6 +1766,7 @@ library/Class/WebService/OAI/CatalogueVisitor.php -text
library/Class/WebService/OAI/Response/GetRecord.php -text
library/Class/WebService/OAI/Response/Identify.php -text
library/Class/WebService/OAI/Response/ListIdentifiers.php -text
library/Class/WebService/OAI/Response/ListMetadataFormats.php -text
library/Class/WebService/OAI/Response/ListSets.php -text
library/Class/WebService/OAI/Response/Null.php -text
library/Class/WebService/OAI/ResponseFactory.php -text
......@@ -3493,6 +3494,7 @@ tests/library/Class/WebService/BabelioTest.php -text
tests/library/Class/WebService/OAI/Response/GetRecordTest.php -text
tests/library/Class/WebService/OAI/Response/IdentifyTest.php -text
tests/library/Class/WebService/OAI/Response/ListIdentifiersTest.php -text
tests/library/Class/WebService/OAI/Response/ListMetadataFormatsTest.php -text
tests/library/Class/WebService/OAI/Response/ListSetsTest.php -text
tests/library/Class/WebService/OAIIdentify.xml -text
tests/library/Class/WebService/OAIListIdentifiers.xml -text
......
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* AFI-OPAC 2.0 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_WebService_OAI_Response_ListMetadataFormats extends Class_WebService_OAI_Response_Null {
const OAI_DC_SCHEMA = 'http://www.openarchives.org/OAI/2.0/oai_dc.xsd';
const OAI_DC_NAMESPACE = 'http://www.openarchives.org/OAI/2.0/oai_dc/';
public function buildXmlOn($builder) {
return
$builder->request(array('verb' => 'ListMetadataFormats'),
$this->_baseUrl)
. $this->listMetadataFormats($builder);
}
public function listMetadataFormats($builder) {
return $builder->ListMetadataFormats(
$builder->metadataFormat($builder->metadataPrefix('oai_dc')
. $builder->schema(self::OAI_DC_SCHEMA)
. $builder->metadataNamespace(self::OAI_DC_NAMESPACE)));
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* AFI-OPAC 2.0 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ListMetadataFormatsTest extends Storm_Test_ModelTestCase {
protected $_xpath;
protected $_response;
public function setUp() {
parent::setUp();
$this->_xpath = TestXPathFactory::newOai();
$this->_response = new Class_WebService_OAI_Response_ListMetadataFormats('http://afi-sa.fr/oai2/do');
}
/** @test */
public function requestVerbShouldBeListMetadataFormats() {
$this->_xpath->assertXPathContentContains($this->_response->xml(),
'//oai:request[@verb="ListMetadataFormats"]',
'http://afi-sa.fr/oai2/do');
}
/** @test */
public function shouldHaveOneMetadataFormat() {
$this->_xpath->assertXpathCount($this->_response->xml(),
'//oai:ListMetadataFormats/oai:metadataFormat',
1);
}
/** @test */
public function metadataPrefixShouldBeOaiDublinCore() {
$this->_assertFormatContentAt('metadataPrefix', 'oai_dc', 1);
}
/** @test */
public function schemaShouldbeOaiDublinCore() {
$this->_assertFormatContentAt('schema',
Class_WebService_OAI_Response_ListMetadataFormats::OAI_DC_SCHEMA,
1);
}
/** @test */
public function namespaceShouldBeDublinCore() {
$this->_assertFormatContentAt('metadataNamespace',
Class_WebService_OAI_Response_ListMetadataFormats::OAI_DC_NAMESPACE,
1);
}
protected function _assertFormatContentAt($name, $content, $position) {
$path = sprintf('//oai:ListMetadataFormats/oai:metadataFormat[%s]/oai:%s',
$position, $name);
$this->_xpath->assertXpathContentContains($this->_response->xml(), $path, $content);
}
}
?>
\ 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