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

Oai: Ajout et test du prologue XML

parent c8a38d94
No related merge requests found
......@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_WebService_OAI_Response_Null {
const PROLOG = '<?xml version="1.0" encoding="UTF-8"?>';
protected $_baseUrl;
public function __construct($baseUrl) {
......@@ -29,11 +30,12 @@ class Class_WebService_OAI_Response_Null {
public function xml() {
$builder = new Class_Xml_Builder();
return $builder->_tag(array('OAI-PMH' => array('xmlns' => 'http://www.openarchives.org/OAI/2.0/',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd')),
$builder->responseDate(date('c')).
$this->buildXmlOn($builder));
return self::PROLOG . "\n"
. $builder->_tag(array('OAI-PMH' => array('xmlns' => 'http://www.openarchives.org/OAI/2.0/',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd')),
$builder->responseDate(date('c')).
$this->buildXmlOn($builder));
}
public function buildXmlOn($builder) {
......
......@@ -28,18 +28,6 @@ abstract class OaiControllerListSetsRequestTestCase extends AbstractControllerTe
$this->_xpath = new Storm_Test_XPathXML();
$this->_xpath->registerNameSpace('oai', 'http://www.openarchives.org/OAI/2.0/');
}
}
class OaiControllerIndentifyRequestTest extends OaiControllerListSetsRequestTestCase {
protected $_xpath;
public function setUp() {
parent::setUp();
$this->dispatch('/opac/oai/request?verb=Identify');
}
/** @test */
......@@ -54,11 +42,35 @@ class OaiControllerIndentifyRequestTest extends OaiControllerListSetsRequestTest
$this->assertAction('request');
}
/** @test */
public function xmlVersionShouldOneDotZero() {
$this->_xpath->assertXmlVersion($this->_response->getBody(), "1.0");
}
/** @test */
public function xmlEncodingShouldBeUtf8() {
$this->_xpath->assertXmlEncoding($this->_response->getBody(), "UTF-8");
}
}
class OaiControllerIndentifyRequestTest extends OaiControllerListSetsRequestTestCase {
protected $_xpath;
public function setUp() {
parent::setUp();
$this->dispatch('/opac/oai/request?verb=Identify');
}
/** @test */
public function identifyShouldReturnIdentifyResponse() {
$this->_xpath->assertXPath($this->_response->getBody(),
'//oai:request[@verb="Identify"]');
'//oai:request[@verb="Identify"]');
}
}
......
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