From b6a2329d541a38d8a4b96164121fac26c7fd21d7 Mon Sep 17 00:00:00 2001 From: pbarroca <pbarroca@git-test.afi-sa.fr> Date: Tue, 24 Apr 2012 10:15:16 +0000 Subject: [PATCH] =?UTF-8?q?OAI:=20compl=C3=A9ment=20r=C3=A9ponse=20Identif?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WebService/OAI/Response/Identify.php | 32 ++++++++- .../Class/WebService/OAI/Response/Null.php | 1 + .../WebService/OAI/Response/IdentifyTest.php | 65 +++++++++++++++++-- 3 files changed, 92 insertions(+), 6 deletions(-) diff --git a/library/Class/WebService/OAI/Response/Identify.php b/library/Class/WebService/OAI/Response/Identify.php index 0b76e560d00..90c7bcc807f 100644 --- a/library/Class/WebService/OAI/Response/Identify.php +++ b/library/Class/WebService/OAI/Response/Identify.php @@ -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; } } diff --git a/library/Class/WebService/OAI/Response/Null.php b/library/Class/WebService/OAI/Response/Null.php index fff17ca425e..d35df11cfdd 100644 --- a/library/Class/WebService/OAI/Response/Null.php +++ b/library/Class/WebService/OAI/Response/Null.php @@ -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; diff --git a/tests/library/Class/WebService/OAI/Response/IdentifyTest.php b/tests/library/Class/WebService/OAI/Response/IdentifyTest.php index 92e873dae82..70deedc0e8b 100644 --- a/tests/library/Class/WebService/OAI/Response/IdentifyTest.php +++ b/tests/library/Class/WebService/OAI/Response/IdentifyTest.php @@ -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 -- GitLab