Some PHPUnit to test the "happy way"
This commit is contained in:
parent
cef72091cf
commit
96cc74dea6
|
@ -0,0 +1,305 @@
|
|||
<?php
|
||||
|
||||
class OAI2ServerTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
function setUp() {
|
||||
$this->xml = new DomDocument("1.0", "UTF-8");
|
||||
$xml = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OAI-PMH 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">
|
||||
<responseDate>'.date('Y-m-d\TH:i:s\Z').'</responseDate>
|
||||
</OAI-PMH>';
|
||||
$this->xml->loadXML($xml);
|
||||
$this->uri = 'test.oai_pmh';
|
||||
}
|
||||
|
||||
function testIdentify() {
|
||||
$xml = '<request verb="Identify">test.oai_pmh</request>
|
||||
<Identify>
|
||||
<repositoryName>OAI2 PMH Test</repositoryName>
|
||||
<baseURL>http://198.199.108.242/~neis/oai_pmh/oai2.php</baseURL>
|
||||
<protocolVersion>2.0</protocolVersion>
|
||||
<adminEmail>danielneis@gmail.com</adminEmail>
|
||||
<earliestDatestamp>2013-01-01T12:00:00Z</earliestDatestamp>
|
||||
<deletedRecord>no</deletedRecord>
|
||||
<granularity>YYYY-MM-DDThh:mm:ssZ</granularity>
|
||||
</Identify>';
|
||||
|
||||
$f = $this->xml->createDocumentFragment();
|
||||
$f->appendXML($xml);
|
||||
$this->xml->documentElement->appendChild($f);
|
||||
|
||||
$return = true;
|
||||
$uri = $this->uri;
|
||||
$args = array('verb' => 'Identify');
|
||||
|
||||
$response = require('oai2.php');
|
||||
|
||||
$this->assertEqualXMLStructure($this->xml->firstChild, $response->firstChild);
|
||||
}
|
||||
|
||||
function testIdentifyIllegalParameter() {
|
||||
$verb = 'Identify';
|
||||
$args = array('test' => 'test');
|
||||
}
|
||||
|
||||
function testListMetadataFormats() {
|
||||
$xml = '<request verb="ListMetadataFormats">test.oai_pmh</request>
|
||||
<ListMetadataFormats>
|
||||
<metadataFormat>
|
||||
<metadataPrefix>rif</metadataPrefix>
|
||||
<schema>http://services.ands.org.au/sandbox/orca/schemata/registryObjects.xsd</schema>
|
||||
<metadataNamespace>http://ands.org.au/standards/rif-cs/registryObjects/</metadataNamespace>
|
||||
</metadataFormat>
|
||||
<metadataFormat>
|
||||
<metadataPrefix>oai_dc</metadataPrefix>
|
||||
<schema>http://www.openarchives.org/OAI/2.0/oai_dc.xsd</schema>
|
||||
<metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>
|
||||
</metadataFormat>
|
||||
</ListMetadataFormats>';
|
||||
|
||||
$f = $this->xml->createDocumentFragment();
|
||||
$f->appendXML($xml);
|
||||
$this->xml->documentElement->appendChild($f);
|
||||
|
||||
$return = true;
|
||||
$uri = $this->uri;
|
||||
$args = array('verb' => 'ListMetadataFormats');
|
||||
|
||||
$response = require('oai2.php');
|
||||
|
||||
$this->assertEqualXMLStructure($this->xml->firstChild, $response->firstChild);
|
||||
}
|
||||
|
||||
function testListMetadataFormatsIdentifier() {
|
||||
$verb = 'ListMetadataFormats';
|
||||
$args = array('identifier' => 'a.b.c');
|
||||
}
|
||||
|
||||
function testListMetadataFormatsIllegalIdentifier() {
|
||||
$verb = 'ListMetadataFormats';
|
||||
$args = array('identifier' => 'illegalIdentifier');
|
||||
}
|
||||
|
||||
function testListSets() {
|
||||
$xml = '<request verb="ListSets">test.oai_pmh</request>
|
||||
<ListSets>
|
||||
<set>
|
||||
<setSpec>class:collection</setSpec>
|
||||
<setName>Collections</setName>
|
||||
</set>
|
||||
<set>
|
||||
<setSpec>math</setSpec>
|
||||
<setName>Mathematics</setName>
|
||||
</set>
|
||||
<set>
|
||||
<setSpec>phys</setSpec>
|
||||
<setName>Physics</setName>
|
||||
</set>
|
||||
<set>
|
||||
<setSpec>phdthesis</setSpec>
|
||||
<setName>PHD Thesis</setName>
|
||||
<setDescription>
|
||||
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> <dc:description>This set contains metadata describing electronic music recordings made during the 1950ies</dc:description> </oai_dc:dc>
|
||||
</setDescription>
|
||||
</set>
|
||||
</ListSets>';
|
||||
|
||||
$f = $this->xml->createDocumentFragment();
|
||||
$f->appendXML($xml);
|
||||
$this->xml->documentElement->appendChild($f);
|
||||
|
||||
$return = true;
|
||||
$uri = $this->uri;
|
||||
$args = array('verb' => 'ListSets');
|
||||
|
||||
$response = require('oai2.php');
|
||||
|
||||
$this->assertEqualXMLStructure($this->xml->firstChild, $response->firstChild);
|
||||
}
|
||||
|
||||
function testListSetsResumptionToken() {
|
||||
$verb = 'ListSets';
|
||||
$args = array('resumptionToken' => '????');
|
||||
}
|
||||
|
||||
function testListIdentifiersMetadataPrefix() {
|
||||
$xml = '<request verb="ListIdentifiers" metadataPrefix="oai_dc">test.oai_pmh</request>
|
||||
<ListIdentifiers>
|
||||
<header>
|
||||
<identifier>dev.testing.pmh</identifier>
|
||||
<datestamp>2013-05-14T18:41:00Z</datestamp>
|
||||
<setSpec>class:activity</setSpec>
|
||||
</header>
|
||||
</ListIdentifiers>';
|
||||
|
||||
$f = $this->xml->createDocumentFragment();
|
||||
$f->appendXML($xml);
|
||||
$this->xml->documentElement->appendChild($f);
|
||||
|
||||
$return = true;
|
||||
$uri = $this->uri;
|
||||
$args = array('verb' => 'ListIdentifiers', 'metadataPrefix' => 'oai_dc');
|
||||
|
||||
$response = require('oai2.php');
|
||||
|
||||
$this->assertEqualXMLStructure($this->xml->firstChild, $response->firstChild);
|
||||
}
|
||||
|
||||
function testListIdentifiers() {
|
||||
$args = array('verb' => 'ListIdentifiers');
|
||||
}
|
||||
function testListIdentifiersResumptionToken() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'resumptionToken' => '????');
|
||||
}
|
||||
function testListIdentifiersResumptionTokenMetadataPrefix() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'resumptionToken' => '????', 'metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
function testListIdentifiersMetadataPrefixSet() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'metadataPrefix' => 'oai_dc', 'set' => 'someSet');
|
||||
}
|
||||
function testListIdentifiersMetadataPrefixFromUntil() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'metadataPrefix' => 'oai_dc', 'from' => '2000-01-01', 'until' => '2000-01-01');
|
||||
}
|
||||
function testListIdentifiersMetadataPrefixSetFromUntil() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'metadataPrefix' => 'oai_dc',
|
||||
'set' => '????', 'from' => '2000-01-01', 'until' => '2000-01-01');
|
||||
}
|
||||
function testListIdentifiersMetadataPrefixIllegalSetIllegalFromUntil() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'metadataPrefix' => 'oai_dc',
|
||||
'set' => 'really_wrong_set',
|
||||
'from' => 'some_random_from', 'until' => 'some_random_until');
|
||||
}
|
||||
function testListIdentifiersDifferentGranularity() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'resumptionToken' => '????', 'metadataPrefix' => 'oai_dc',
|
||||
'from' => '2000-01-01', 'until' => '2000-01-01T00:00:00Z');
|
||||
}
|
||||
function testListIdentifiersFromGreaterThanUntil() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'resumptionToken' => '????', 'metadataPrefix' => 'oai_dc',
|
||||
'from' => '2013-01-01', 'until' => '2000-01-01T00:00:00Z');
|
||||
}
|
||||
function testListIdentifiersIllegalMetadataPrefix() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'metadataPrefix' => 'illegalPrefix');
|
||||
}
|
||||
function testListIdentifiersMetadataPrefixMetadataPrefix() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'metadataPrefix' => 'oai_dc', 'metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
function testListIdentifiersIllegalResumptionToken() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'resumptionToken' => 'illegalToken');
|
||||
}
|
||||
function testListIdentifiersMetadataPrefixFrom() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'metadataPrefix' => 'oai_dc', 'from' => '2001-01-01T00:00:00Z');
|
||||
}
|
||||
function testListIdentifiersMetadataPrefixFromYear() {
|
||||
$args = array('verb' => 'ListIdentifiers', 'metadataPrefix' => 'oai_dc', 'from' => '2001');
|
||||
}
|
||||
|
||||
function testListRecords() {
|
||||
$verb = 'ListRecords';
|
||||
$args = array('verb' => 'ListRecords');
|
||||
}
|
||||
function testListRecordsMetadataPrefix() {
|
||||
|
||||
$xml = '<request verb="ListRecords" metadataPrefix="oai_dc">test.oai_pmh</request>
|
||||
<ListRecords>
|
||||
<record>
|
||||
<header>
|
||||
<identifier>dev.testing.pmh</identifier>
|
||||
<datestamp>2013-05-14T18:11:00Z</datestamp>
|
||||
<setSpec>class:activity</setSpec>
|
||||
</header>
|
||||
<metadata>
|
||||
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
|
||||
<dc:title>Testing records</dc:title>
|
||||
<dc:author>Neis</dc:author>
|
||||
</oai_dc:dc>
|
||||
</metadata>
|
||||
</record>
|
||||
</ListRecords>';
|
||||
|
||||
$f = $this->xml->createDocumentFragment();
|
||||
$f->appendXML($xml);
|
||||
$this->xml->documentElement->appendChild($f);
|
||||
|
||||
$return = true;
|
||||
$uri = $this->uri;
|
||||
$args = array('verb' => 'ListRecords', 'metadataPrefix' => 'oai_dc');
|
||||
|
||||
$response = require('oai2.php');
|
||||
|
||||
$this->assertEqualXMLStructure($this->xml->firstChild, $response->firstChild);
|
||||
}
|
||||
function testListRecordsMetadataPrefixFromUntil() {
|
||||
$args = array('verb' => 'ListRecords', 'metadataPrefix' => 'oai_dc', 'from' => '2000-01-01', 'until' => '2000-01-01');
|
||||
}
|
||||
function testListRecordsResumptionToken() {
|
||||
$args = array('verb' => 'ListRecords', 'resumptionToken' => '????');
|
||||
}
|
||||
function testListRecordsMetadataPrefixIllegalSetIllegalFromUntil() {
|
||||
$args = array('verb' => 'ListRecords', 'metadataPrefix' => 'oai_dc',
|
||||
'set' => 'illegalSet',
|
||||
'from' => 'some_random_from', 'until' => 'some_random_until');
|
||||
}
|
||||
function testListRecordsDifferentGranularity() {
|
||||
$args = array('verb' => 'ListRecords', 'resumptionToken' => '????', 'metadataPrefix' => 'oai_dc',
|
||||
'from' => '2000-01-01', 'until' => '2000-01-01T00:00:00Z');
|
||||
}
|
||||
function testListRecordsUntilBeforeEarliestDatestamp() {
|
||||
$args = array('verb' => 'ListRecords', 'metadataPrefix' => 'oai_dc', 'until' => '1969-01-01T00:00:00Z');
|
||||
}
|
||||
function testListRecordsIllegalResumptionToken() {
|
||||
$args = array('verb' => 'ListRecords', 'resumptionToken' => 'illegalToken');
|
||||
}
|
||||
|
||||
function testGetRecord() {
|
||||
$args = array('verb' => 'GetRecord');
|
||||
}
|
||||
function testGetRecordIdentifier() {
|
||||
$args = array('verb' => 'GetRecord', 'identifier' => 'a.b.c');
|
||||
}
|
||||
function testGetRecordIdentifierMetadataPrefix() {
|
||||
|
||||
$xml = '<request verb="GetRecord" metadataPrefix="oai_dc" identifier="a.b.c">test.oai_pmh</request>
|
||||
<GetRecord>
|
||||
<record>
|
||||
<header>
|
||||
<identifier>a.b.c</identifier>
|
||||
<datestamp>2013-05-14T18:08:00Z</datestamp>
|
||||
<setSpec>class:activity</setSpec>
|
||||
</header>
|
||||
<metadata>
|
||||
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
|
||||
<dc:title>Testing records</dc:title>
|
||||
<dc:author>Neis</dc:author>
|
||||
</oai_dc:dc>
|
||||
</metadata>
|
||||
</record>
|
||||
</GetRecord>';
|
||||
$f = $this->xml->createDocumentFragment();
|
||||
$f->appendXML($xml);
|
||||
$this->xml->documentElement->appendChild($f);
|
||||
|
||||
$return = true;
|
||||
$uri = $this->uri;
|
||||
$args = array('verb' => 'GetRecord', 'identifier' => 'a.b.c', 'metadataPrefix' => 'oai_dc');
|
||||
|
||||
$response = require('oai2.php');
|
||||
|
||||
$this->assertEqualXMLStructure($this->xml->firstChild, $response->firstChild);
|
||||
}
|
||||
function testGetRecordIdentifierIllegalMetadataPrefix() {
|
||||
$args = array('verb' => 'GetRecord', 'identifier' => 'a.b.c', 'metadataPrefix' => 'illegalPrefix');
|
||||
}
|
||||
function testGetRecordMetadataPrefix() {
|
||||
$args = array('verb' => 'GetRecord', 'metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
function testGetRecordIllegalIdentifierMetadataPrefix() {
|
||||
$args = array('verb' => 'GetRecord', 'identifier' => 'illegalID', 'metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
function testGetRecordInvalidIdentifierMetadataPrefix() {
|
||||
$args = array('verb' => 'GetRecord', 'identifier' => 'invalidID', 'metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
|
||||
function testIllegalVerb() {
|
||||
$args = array('verb' => 'IllegalVerb');
|
||||
}
|
||||
}
|
35
oai2.php
35
oai2.php
|
@ -15,8 +15,8 @@ require_once('oai2server.php');
|
|||
*
|
||||
*/
|
||||
$identifyResponse = array();
|
||||
$identifyResponse["repositoryName"] = 'Moodle Neis';
|
||||
$identifyResponse["baseURL"] = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
|
||||
$identifyResponse["repositoryName"] = 'OAI2 PMH Test';
|
||||
$identifyResponse["baseURL"] = 'http://198.199.108.242/~neis/oai_pmh/oai2.php';
|
||||
$identifyResponse["protocolVersion"] = '2.0';
|
||||
$identifyResponse['adminEmail'] = 'danielneis@gmail.com';
|
||||
$identifyResponse["earliestDatestamp"] = '2013-01-01T12:00:00Z';
|
||||
|
@ -30,7 +30,7 @@ $identifyResponse["deletedRecord"] = 'no'; // How your repository handles deleti
|
|||
// maintained. It MAY reveal a deleted status for records.
|
||||
$identifyResponse["granularity"] = 'YYYY-MM-DDThh:mm:ssZ';
|
||||
|
||||
$example_record = array('identifier' => 'dev.testing.pmh',
|
||||
$example_record = array('identifier' => 'a.b.c',
|
||||
'datestamp' => date('Y-m-d-H:s'),
|
||||
'set' => 'class:activity',
|
||||
'metadata' => array(
|
||||
|
@ -48,11 +48,18 @@ $example_record = array('identifier' => 'dev.testing.pmh',
|
|||
)
|
||||
));
|
||||
|
||||
$oai2 = new OAI2Server('neis.moodle.ufsc.br', $_GET, $identifyResponse,
|
||||
/* unit tests ;) */
|
||||
if (!isset($args)) {
|
||||
$args = $_GET;
|
||||
}
|
||||
if (!isset($uri)) {
|
||||
$uri = 'test.oai_pmh';
|
||||
}
|
||||
$oai2 = new OAI2Server($uri, $args, $identifyResponse,
|
||||
array(
|
||||
'ListMetadataFormats' =>
|
||||
function($identifier = '') {
|
||||
if ($identifier == 'a.b.c') {
|
||||
if (!empty($identifier) && $identifier != 'a.b.c') {
|
||||
throw new OAI2Exception('idDoesNotExist', '', $identifier);
|
||||
}
|
||||
return
|
||||
|
@ -87,8 +94,7 @@ $oai2 = new OAI2Server('neis.moodle.ufsc.br', $_GET, $identifyResponse,
|
|||
},
|
||||
|
||||
'ListRecords' =>
|
||||
function($metadataPrefix, $from = '', $until = '', $set = '', $count = false, $deliveredRecords = 0, $maxItems = 0) {
|
||||
global $example_record;
|
||||
function($metadataPrefix, $from = '', $until = '', $set = '', $count = false, $deliveredRecords = 0, $maxItems = 0) use ($example_record) {
|
||||
// throws new OAI2Exception('noRecordsMatch')
|
||||
// throws new OAI2Exception('noSetHierarchy')
|
||||
if ($count) {
|
||||
|
@ -98,12 +104,21 @@ $oai2 = new OAI2Server('neis.moodle.ufsc.br', $_GET, $identifyResponse,
|
|||
},
|
||||
|
||||
'GetRecord' =>
|
||||
function($identifier, $metadataPrefix) {
|
||||
global $example_record;
|
||||
if ($identifier == 'a.b.c') {
|
||||
function($identifier, $metadataPrefix) use ($example_record) {
|
||||
if ($identifier != 'a.b.c') {
|
||||
throw new OAI2Exception('idDoesNotExist', '', $identifier);
|
||||
}
|
||||
return $example_record;
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
$response = $oai2->response();
|
||||
if (isset($return)) {
|
||||
return $response;
|
||||
} else {
|
||||
$response->formatOutput = true;
|
||||
$response->preserveWhiteSpace = false;
|
||||
header('Content-Type: text/xml');
|
||||
echo $response->saveXML();
|
||||
}
|
||||
|
|
|
@ -46,8 +46,11 @@ class OAI2Server {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function response() {
|
||||
if (empty($this->errors)) {
|
||||
$this->response->display();
|
||||
return $this->response->doc;
|
||||
} else {
|
||||
$errorResponse = new OAI2XMLResponse($this->uri, $this->verb, $this->args);
|
||||
$oai_node = $errorResponse->doc->documentElement;
|
||||
|
@ -55,7 +58,7 @@ class OAI2Server {
|
|||
$node = $errorResponse->addChild($oai_node,"error",$e->getMessage());
|
||||
$node->setAttribute("code",$e->getOAI2Code());
|
||||
}
|
||||
$errorResponse->display();
|
||||
return $errorResponse->doc;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,9 +82,14 @@ class OAI2Server {
|
|||
$this->errors[] = new OAI2Exception('badArgument', $argument, $value);
|
||||
}
|
||||
}
|
||||
if (isset($this->args['identifier'])) {
|
||||
$identifier = $this->args['identifier'];
|
||||
} else {
|
||||
$identifier = '';
|
||||
}
|
||||
if (empty($this->errors)) {
|
||||
try {
|
||||
if ($formats = call_user_func($this->listMetadataFormatsCallback, $this->args['identifier'])) {
|
||||
if ($formats = call_user_func($this->listMetadataFormatsCallback, $identifier)) {
|
||||
foreach($formats as $key => $val) {
|
||||
$cmf = $this->response->addToVerbNode("metadataFormat");
|
||||
$this->response->addChild($cmf,'metadataPrefix',$key);
|
||||
|
@ -111,7 +119,7 @@ class OAI2Server {
|
|||
} else {
|
||||
$resumptionToken = null;
|
||||
}
|
||||
if (!empty($this->errors)) {
|
||||
if (empty($this->errors)) {
|
||||
if ($sets = call_user_func($this->listSetsCallback, $resumptionToken)) {
|
||||
|
||||
foreach($sets as $set) {
|
||||
|
@ -231,7 +239,7 @@ class OAI2Server {
|
|||
}
|
||||
}
|
||||
|
||||
if (!empty($this->errors)) {
|
||||
if (empty($this->errors)) {
|
||||
try {
|
||||
|
||||
$records_count = call_user_func($this->listRecordsCallback, $metadataPrefix, $from, $until, $set, true);
|
||||
|
@ -248,8 +256,8 @@ class OAI2Server {
|
|||
(($this->identifyResponse['deletedRecord'] == 'transient') ||
|
||||
($this->identifyResponse['deletedRecord'] == 'persistent')));
|
||||
|
||||
if($this->args['verb'] == 'ListRecords') {
|
||||
$cur_record = $this->response->createToVerNode('record');
|
||||
if($this->verb == 'ListRecords') {
|
||||
$cur_record = $this->response->addToVerbNode('record');
|
||||
$cur_header = $this->response->createHeader($identifier, $datestamp,$setspec,$cur_record);
|
||||
if (!$status_deleted) {
|
||||
$this->add_metadata($cur_record, $record);
|
||||
|
|
|
@ -24,13 +24,6 @@ class OAI2XMLResponse {
|
|||
$this->verbNode = $this->addChild($this->doc->documentElement,$this->verb);
|
||||
}
|
||||
|
||||
function display() {
|
||||
$this->doc->formatOutput = true;
|
||||
$this->doc->preserveWhiteSpace = false;
|
||||
header('Content-Type: text/xml');
|
||||
echo $this->doc->saveXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a child node to a parent node on a XML Doc: a worker function.
|
||||
*
|
||||
|
|
174
tests.php
174
tests.php
|
@ -1,174 +0,0 @@
|
|||
<?php
|
||||
|
||||
class OAI2ServerTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
function testIdentify() {
|
||||
$verb = 'Identify';
|
||||
}
|
||||
|
||||
function testIdentifyIllegalParameter() {
|
||||
$verb = 'Identify';
|
||||
$args = array('test' => 'test');
|
||||
}
|
||||
|
||||
function testListMetadataFormats() {
|
||||
$verb = 'ListMetadataFormats';
|
||||
}
|
||||
|
||||
function testListMetadataFormatsIdentifier() {
|
||||
$verb = 'ListMetadataFormats';
|
||||
$args = array('identifier' => 'a.b.c');
|
||||
}
|
||||
|
||||
function testListMetadataFormatsIllegalIdentifier() {
|
||||
$verb = 'ListMetadataFormats';
|
||||
$args = array('identifier' => 'illegalIdentifier');
|
||||
}
|
||||
|
||||
function testListSets() {
|
||||
$verb = 'ListSets';
|
||||
}
|
||||
|
||||
function testListSetsResumptionToken() {
|
||||
$verb = 'ListSets';
|
||||
$args = array('resumptionToken' => '????');
|
||||
}
|
||||
|
||||
function testListIdentifiersMetadataPrefix() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
|
||||
function testListIdentifiersResumptionToken() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('resumptionToken' => '????');
|
||||
}
|
||||
|
||||
function testListIdentifiersResumptionTokenMetadataPrefix() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('resumptionToken' => '????', 'metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
|
||||
function testListIdentifiersMetadataPrefixSet() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('metadataPrefix' => 'oai_dc', 'set' => 'someSet');
|
||||
}
|
||||
|
||||
function testListIdentifiersMetadataPrefixFromUntil() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('metadataPrefix' => 'oai_dc', 'from' => '2000-01-01', 'until' => '2000-01-01');
|
||||
}
|
||||
|
||||
function testListIdentifiersMetadataPrefixSetFromUntil() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('metadataPrefix' => 'oai_dc',
|
||||
'set' => '????', 'from' => '2000-01-01', 'until' => '2000-01-01');
|
||||
}
|
||||
|
||||
function testListIdentifiersMetadataPrefixIllegalSetIllegalFromUntil() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('metadataPrefix' => 'oai_dc',
|
||||
'set' => 'really_wrong_set',
|
||||
'from' => 'some_random_from', 'until' => 'some_random_until');
|
||||
}
|
||||
|
||||
function testListIdentifiersDifferentGranularity() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('resumptionToken' => '????', 'metadataPrefix' => 'oai_dc',
|
||||
'from' => '2000-01-01', 'until' => '2000-01-01T00:00:00Z');
|
||||
}
|
||||
|
||||
function testListIdentifiersFromGreaterThanUntil() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('resumptionToken' => '????', 'metadataPrefix' => 'oai_dc',
|
||||
'from' => '2013-01-01', 'until' => '2000-01-01T00:00:00Z');
|
||||
}
|
||||
function testListIdentifiers() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array();
|
||||
}
|
||||
function testListIdentifiersIllegalMetadataPrefix() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('metadataPrefix' => 'illegalPrefix');
|
||||
}
|
||||
function testListIdentifiersMetadataPrefixMetadataPrefix() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('metadataPrefix' => 'oai_dc', 'metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
function testListIdentifiersIllegalResumptionToken() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('resumptionToken' => 'illegalToken');
|
||||
}
|
||||
function testListIdentifiersMetadataPrefixFrom() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('metadataPrefix' => 'oai_dc', 'from' => '2001-01-01T00:00:00Z');
|
||||
}
|
||||
function testListIdentifiersMetadataPrefixFromYear() {
|
||||
$verb = 'ListIdentifiers';
|
||||
$args = array('metadataPrefix' => 'oai_dc', 'from' => '2001');
|
||||
}
|
||||
|
||||
function testListRecords() {
|
||||
$verb = 'ListRecords';
|
||||
$args = array();
|
||||
}
|
||||
function testListRecordsMetadataPrefixFromUntil() {
|
||||
$verb = 'ListRecords';
|
||||
$args = array('metadataPrefix' => 'oai_dc', 'from' => '2000-01-01', 'until' => '2000-01-01');
|
||||
}
|
||||
|
||||
function testListRecordsResumptionToken() {
|
||||
$verb = 'ListRecords';
|
||||
$args = array('resumptionToken' => '????');
|
||||
}
|
||||
|
||||
function testListRecordsMetadataPrefixIllegalSetIllegalFromUntil() {
|
||||
$verb = 'ListRecords';
|
||||
$args = array('metadataPrefix' => 'oai_dc',
|
||||
'set' => 'illegalSet',
|
||||
'from' => 'some_random_from', 'until' => 'some_random_until');
|
||||
}
|
||||
function testListRecordsDifferentGranularity() {
|
||||
$verb = 'ListRecords';
|
||||
$args = array('resumptionToken' => '????', 'metadataPrefix' => 'oai_dc',
|
||||
'from' => '2000-01-01', 'until' => '2000-01-01T00:00:00Z');
|
||||
}
|
||||
function testListRecordsUntilBeforeEarliestDatestamp() {
|
||||
$verb = 'ListRecords';
|
||||
$args = array('metadataPrefix' => 'oai_dc', 'until' => '1969-01-01T00:00:00Z');
|
||||
}
|
||||
function testListRecordsIllegalResumptionToken() {
|
||||
$verb = 'ListRecords';
|
||||
$args = array('resumptionToken' => 'illegalToken');
|
||||
}
|
||||
|
||||
function testGetRecordIdentifier() {
|
||||
$verb = 'GetRecord';
|
||||
$args = array('identifier' => 'a.b.c');
|
||||
}
|
||||
function testGetRecordIdentifierMetadataPrefix() {
|
||||
$verb = 'GetRecord';
|
||||
$args = array('identifier' => 'a.b.c', 'metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
function testGetRecordIdentifierIllegalMetadataPrefix() {
|
||||
$verb = 'GetRecord';
|
||||
$args = array('identifier' => 'a.b.c', 'metadataPrefix' => 'illegalPrefix');
|
||||
}
|
||||
function testGetRecordMetadataPrefix() {
|
||||
$verb = 'GetRecord';
|
||||
$args = array('metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
function testGetRecordIllegalIdentifierMetadataPrefix() {
|
||||
$verb = 'GetRecord';
|
||||
$args = array('identifier' => 'illegalID', 'metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
function testGetRecordInvalidIdentifierMetadataPrefix() {
|
||||
$verb = 'GetRecord';
|
||||
$args = array('identifier' => 'invalidID', 'metadataPrefix' => 'oai_dc');
|
||||
}
|
||||
|
||||
function testIllegalVerb() {
|
||||
$verb = 'IllegalVerb';
|
||||
$args = array();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue