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

OAI: complément réponse Identify

parent 301a0342
No related merge requests found
......@@ -21,10 +21,40 @@
class Class_WebService_OAI_Response_Identify extends Class_WebService_OAI_Response_Null {
const GRANULARITY = 'YYYY-MM-DD';
const DELETED_RECORD = 'no';
protected $_earliestDatestamp;
protected $_adminEmail;
public function buildXmlOn($builder) {
return
$builder->request(array('verb' => 'Identify'),
$this->_baseUrl);
$this->_baseUrl)
. $this->identify($builder);
}
public function identify($builder) {
return $builder->Identify($builder->repositoryName('Afi OPAC 3 Oai repository')
. $builder->baseURL($this->_baseUrl)
. $builder->protocolVersion($this->_protocolVersion)
. $builder->earliestDatestamp($this->_earliestDatestamp)
. $builder->granularity(self::GRANULARITY)
. $builder->deletedRecord(self::DELETED_RECORD)
. $builder->adminEmail($this->_adminEmail));
}
public function setEarliestDatestamp($datestamp) {
$this->_earliestDatestamp = $datestamp;
return $this;
}
public function setAdminEmail($mail) {
$this->_adminEmail = $mail;
return $this;
}
}
......
......@@ -21,6 +21,7 @@
class Class_WebService_OAI_Response_Null {
const PROLOG = '<?xml version="1.0" encoding="UTF-8"?>';
protected $_baseUrl;
protected $_protocolVersion = '2.0';
public function __construct($baseUrl) {
$this->_baseUrl = $baseUrl;
......
......@@ -18,17 +18,16 @@
* 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 OAIIdentifyTest extends Storm_Test_ModelTestCase {
protected $_xpath;
protected $_response;
public function setUp() {
parent::setUp();
$this->_xpath = new Storm_Test_XPathXML();
$this->_xpath->registerNameSpace('oai', 'http://www.openarchives.org/OAI/2.0/');
$this->_xpath = TestXPathFactory::newOai();
$this->_response = new Class_WebService_OAI_Response_Identify('http://moulins.fr/oai2/do');
$this->_response->setEarliestDatestamp('2011-07-11')
->setAdminEmail('user@server.fr');
}
......@@ -37,7 +36,6 @@ class OAIIdentifyTest extends Storm_Test_ModelTestCase {
$this->_xpath->assertXPathContentContains($this->_response->xml(),
'//oai:responseDate',
date('Y-m-d'));
}
......@@ -47,5 +45,62 @@ class OAIIdentifyTest extends Storm_Test_ModelTestCase {
'//oai:request[@verb="Identify"]',
'http://moulins.fr/oai2/do');
}
/** @test */
public function repositoryNameShouldBeAfiOpac3OaiRepository() {
$this->_xpath->assertXPathContentContains($this->_response->xml(),
'//oai:Identify/oai:repositoryName',
'Afi OPAC 3 Oai repository');
}
/** @test */
public function baseUrlShouldBeMoulinsDotFr() {
$this->_xpath->assertXpathContentContains($this->_response->xml(),
'//oai:Identify/oai:baseURL',
'http://moulins.fr/oai2/do');
}
/** @test */
public function protocolVersionShouldBeTwoDotZero() {
$this->_xpath->assertXPathContentContains($this->_response->xml(),
'//oai:Identify/oai:protocolVersion',
'2.0');
}
/** @test */
public function earliestDateStampShouldBeJulyEleven2011() {
$this->_xpath->assertXPathContentContains($this->_response->xml(),
'//oai:Identify/oai:earliestDatestamp',
'2011-07-11');
}
/** @test */
public function granularityShouldBeYearMonthDay() {
$this->_xpath->assertXPathContentContains($this->_response->xml(),
'//oai:Identify/oai:granularity',
'YYYY-MM-DD');
}
/** @test */
public function deletedRecordShouldBeNo() {
$this->_xpath->assertXPathContentContains($this->_response->xml(),
'//oai:Identify/oai:deletedRecord',
'no');
}
/** @test */
public function adminEmailShouldBeUserAtServerDotfr() {
$this->_xpath->assertXPathContentContains($this->_response->xml(),
'//oai:Identify/oai:adminEmail',
'user@server.fr');
}
}
?>
\ 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