19 declare(strict_types=1);
26 class RequestProcessorListIdentifiersTest
extends RequestProcessorTestCase
28 public function testGetResponseToRequestListIdentifiers(): void
30 $processor =
new RequestProcessor(
32 $this->getSettings(
'prefix_'),
33 $repo = $this->getRepository(
40 $this->getTokenHandler()
43 $expected_response = <<<XML
45 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc</response_info>
52 $response = $processor->getResponseToRequest($this->getRequest(
54 Verb::LIST_IDENTIFIERS,
55 [Argument::MD_PREFIX->value =>
'oai_dc'],
59 [[
'from' =>
null,
'until' =>
null,
'limit' => 100,
'offset' => 0]],
60 $repo->exposed_parameters
62 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
65 public function testGetResponseToRequestListIdentifiersWithDefaultSet(): void
67 $processor =
new RequestProcessor(
69 $this->getSettings(
'prefix_'),
70 $repo = $this->getRepository(
77 $this->getTokenHandler()
80 $expected_response = <<<XML
82 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc,
set=
default</response_info>
89 $response = $processor->getResponseToRequest($this->getRequest(
91 Verb::LIST_IDENTIFIERS,
92 [Argument::MD_PREFIX->value =>
'oai_dc',
Argument::SET->value =>
'default'],
96 [[
'from' =>
null,
'until' =>
null,
'limit' => 100,
'offset' => 0]],
97 $repo->exposed_parameters
99 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
102 public function testGetResponseToRequestListIdentifiersWithFromDate(): void
104 $processor =
new RequestProcessor(
106 $this->getSettings(
'prefix_'),
107 $repo = $this->getRepository(
114 $this->getTokenHandler()
117 $expected_response = <<<XML
119 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc,
from=2019-01-02</response_info>
126 $response = $processor->getResponseToRequest($this->getRequest(
128 Verb::LIST_IDENTIFIERS,
129 [Argument::MD_PREFIX->value =>
'oai_dc', Argument::FROM_DATE->value =>
'2019-01-02'],
133 [[
'from' =>
'2019-01-02',
'until' =>
null,
'limit' => 100,
'offset' => 0]],
134 $repo->exposed_parameters
136 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
139 public function testGetResponseToRequestListIdentifiersWithUntilDate(): void
141 $processor =
new RequestProcessor(
143 $this->getSettings(
'prefix_'),
144 $repo = $this->getRepository(
151 $this->getTokenHandler()
154 $expected_response = <<<XML
156 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc,until=2033-11-02</response_info>
163 $response = $processor->getResponseToRequest($this->getRequest(
165 Verb::LIST_IDENTIFIERS,
166 [Argument::MD_PREFIX->value =>
'oai_dc', Argument::UNTIL_DATE->value =>
'2033-11-02'],
170 [[
'from' =>
null,
'until' =>
'2033-11-02',
'limit' => 100,
'offset' => 0]],
171 $repo->exposed_parameters
173 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
176 public function testGetResponseToRequestListIdentifiersWithBothDates(): void
178 $processor =
new RequestProcessor(
180 $this->getSettings(
'prefix_'),
181 $repo = $this->getRepository(
188 $this->getTokenHandler()
191 $expected_response = <<<XML
193 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc,until=2033-11-02,from=2019-01-02</response_info>
200 $response = $processor->getResponseToRequest($this->getRequest(
202 Verb::LIST_IDENTIFIERS,
204 Argument::MD_PREFIX->value =>
'oai_dc',
205 Argument::UNTIL_DATE->value =>
'2033-11-02',
206 Argument::FROM_DATE->value =>
'2019-01-02' 211 [[
'from' =>
'2019-01-02',
'until' =>
'2033-11-02',
'limit' => 100,
'offset' => 0]],
212 $repo->exposed_parameters
214 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
217 public function testGetResponseToRequestListIdentifiersIncompleteList(): void
219 $processor =
new RequestProcessor(
221 $this->getSettings(
'prefix_'),
222 $repo = $this->getRepository(
229 $this->getTokenHandler()
232 $expected_response = <<<XML
234 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc</response_info>
238 <token>next_offset=100:from=:until=,fullsize=203,cursor=0</token>
242 $response = $processor->getResponseToRequest($this->getRequest(
244 Verb::LIST_IDENTIFIERS,
245 [Argument::MD_PREFIX->value =>
'oai_dc'],
249 [[
'from' =>
null,
'until' =>
null,
'limit' => 100,
'offset' => 0]],
250 $repo->exposed_parameters
252 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
255 public function testGetResponseToRequestListIdentifiersWithResumptionToken(): void
257 $original_request = $this->getRequest(
259 Verb::LIST_IDENTIFIERS,
260 [Argument::RESUMPTION_TOKEN->value =>
'next_offset=100:from=:until=2024-07-28'],
263 $appended_request = $this->getRequest(
265 Verb::LIST_IDENTIFIERS,
267 Argument::RESUMPTION_TOKEN->value =>
'next_offset=100:from=:until=2024-07-28',
268 Argument::UNTIL_DATE->value =>
'2024-07-28' 272 $processor =
new RequestProcessor(
274 $this->getSettings(
'prefix_'),
275 $repo = $this->getRepository(
282 $this->getTokenHandler(
true, $appended_request)
285 $expected_response = <<<XML
287 <response_info>
base url:ListIdentifiers:resumptionToken=next_offset=100:from=:until=2024-07-28</response_info>
291 <token>next_offset=200:from=:until=2024-07-28,fullsize=203,cursor=100</token>
295 $response = $processor->getResponseToRequest($original_request);
298 [[
'from' =>
null,
'until' =>
'2024-07-28',
'limit' => 100,
'offset' => 100]],
299 $repo->exposed_parameters
301 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
304 public function testGetResponseToRequestListIdentifiersWithResumptionTokenContainingFromDate(): void
306 $original_request = $this->getRequest(
308 Verb::LIST_IDENTIFIERS,
309 [Argument::RESUMPTION_TOKEN->value =>
'next_offset=100:from=1999-01-12:until=2024-07-28'],
312 $appended_request = $this->getRequest(
314 Verb::LIST_IDENTIFIERS,
316 Argument::RESUMPTION_TOKEN->value =>
'next_offset=100:from=1999-01-12:until=2024-07-28',
317 Argument::UNTIL_DATE->value =>
'2024-07-28',
318 Argument::FROM_DATE->value =>
'1999-01-12' 322 $processor =
new RequestProcessor(
324 $this->getSettings(
'prefix_'),
325 $repo = $this->getRepository(
332 $this->getTokenHandler(
true, $appended_request)
335 $expected_response = <<<XML
337 <response_info>
base url:ListIdentifiers:resumptionToken=next_offset=100:from=1999-01-12:until=2024-07-28</response_info>
341 <token>next_offset=200:from=1999-01-12:until=2024-07-28,fullsize=203,cursor=100</token>
345 $response = $processor->getResponseToRequest($original_request);
348 [[
'from' =>
'1999-01-12',
'until' =>
'2024-07-28',
'limit' => 100,
'offset' => 100]],
349 $repo->exposed_parameters
351 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
354 public function testGetResponseToRequestListIdentifiersWithResumptionTokenLastIncompleteList(): void
356 $original_request = $this->getRequest(
358 Verb::LIST_IDENTIFIERS,
359 [Argument::RESUMPTION_TOKEN->value =>
'next_offset=200:from=:until=2024-07-28'],
362 $appended_request = $this->getRequest(
364 Verb::LIST_IDENTIFIERS,
366 Argument::RESUMPTION_TOKEN->value =>
'next_offset=200:from=:until=2024-07-28',
367 Argument::UNTIL_DATE->value =>
'2024-07-28' 371 $processor =
new RequestProcessor(
373 $this->getSettings(
'prefix_'),
374 $repo = $this->getRepository(
381 $this->getTokenHandler(
true, $appended_request)
384 $expected_response = <<<XML
386 <response_info>
base url:ListIdentifiers:resumptionToken=next_offset=200:from=:until=2024-07-28</response_info>
390 <token>,fullsize=203,cursor=200</token>
394 $response = $processor->getResponseToRequest($original_request);
397 [[
'from' =>
null,
'until' =>
'2024-07-28',
'limit' => 100,
'offset' => 200]],
398 $repo->exposed_parameters
400 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
403 public function testGetResponseToRequestListIdentifiersNoMDFormatError(): void
405 $processor =
new RequestProcessor(
407 $this->getSettings(
'prefix_'),
408 $repo = $this->getRepository(
415 $this->getTokenHandler()
418 $expected_response = <<<XML
420 <response_info>
base url:ListIdentifiers:</response_info>
421 <error>badArgument</error>
425 $response = $processor->getResponseToRequest($this->getRequest(
427 Verb::LIST_IDENTIFIERS,
432 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
435 public function testGetResponseToRequestListIdentifiersAdditionalArgumentError(): void
437 $processor =
new RequestProcessor(
439 $this->getSettings(
'prefix_'),
440 $repo = $this->getRepository(
447 $this->getTokenHandler()
450 $expected_response = <<<XML
452 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc,identifier=
id</response_info>
453 <error>badArgument</error>
457 $response = $processor->getResponseToRequest($this->getRequest(
459 Verb::LIST_IDENTIFIERS,
460 [Argument::MD_PREFIX->value =>
'oai_dc', Argument::IDENTIFIER->value =>
'id'],
464 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
467 public function testGetResponseToRequestListIdentifiersBadResumptionTokenError(): void
469 $original_request = $this->getRequest(
471 Verb::LIST_IDENTIFIERS,
472 [Argument::RESUMPTION_TOKEN->value =>
'next_offset=100:from=:until=2024-07-28'],
475 $appended_request = $this->getRequest(
477 Verb::LIST_IDENTIFIERS,
479 Argument::RESUMPTION_TOKEN->value =>
'next_offset=100:from=:until=2024-07-28',
480 Argument::UNTIL_DATE->value =>
'2024-07-28' 484 $processor =
new RequestProcessor(
486 $this->getSettings(
'prefix_'),
487 $repo = $this->getRepository(
494 $this->getTokenHandler(
false, $appended_request)
497 $expected_response = <<<XML
499 <response_info>
base url:ListIdentifiers:resumptionToken=next_offset=100:from=:until=2024-07-28</response_info>
500 <error>badResumptionToken</error>
504 $response = $processor->getResponseToRequest($original_request);
506 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
509 public function testGetResponseToRequestListIdentifiersInvalidFromDateError(): void
511 $processor =
new RequestProcessor(
513 $this->getSettings(
'prefix_'),
514 $repo = $this->getRepository(
521 $this->getTokenHandler()
524 $expected_response = <<<XML
526 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc,from=invalid</response_info>
527 <error>badArgument</error>
531 $response = $processor->getResponseToRequest($this->getRequest(
533 Verb::LIST_IDENTIFIERS,
534 [Argument::MD_PREFIX->value =>
'oai_dc', Argument::FROM_DATE->value =>
'invalid'],
537 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
540 public function testGetResponseToRequestListIdentifiersInvalidUntilDateError(): void
542 $processor =
new RequestProcessor(
544 $this->getSettings(
'prefix_'),
545 $repo = $this->getRepository(
552 $this->getTokenHandler()
555 $expected_response = <<<XML
557 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc,until=invalid</response_info>
558 <error>badArgument</error>
562 $response = $processor->getResponseToRequest($this->getRequest(
564 Verb::LIST_IDENTIFIERS,
565 [Argument::MD_PREFIX->value =>
'oai_dc', Argument::UNTIL_DATE->value =>
'invalid'],
568 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
571 public function testGetResponseToRequestListIdentifiersWrongMDFormatError(): void
573 $processor =
new RequestProcessor(
575 $this->getSettings(
'prefix_'),
576 $repo = $this->getRepository(
583 $this->getTokenHandler()
586 $expected_response = <<<XML
588 <response_info>
base url:ListIdentifiers:metadataPrefix=invalid</response_info>
589 <error>cannotDisseminateFormat</error>
593 $response = $processor->getResponseToRequest($this->getRequest(
595 Verb::LIST_IDENTIFIERS,
596 [Argument::MD_PREFIX->value =>
'invalid'],
599 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
602 public function testGetResponseToRequestListIdentifiersNoRecordsFoundError(): void
604 $processor =
new RequestProcessor(
606 $this->getSettings(
'prefix_'),
607 $repo = $this->getRepository(),
608 $this->getTokenHandler()
611 $expected_response = <<<XML
613 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc</response_info>
614 <error>noRecordsMatch</error>
618 $response = $processor->getResponseToRequest($this->getRequest(
620 Verb::LIST_IDENTIFIERS,
621 [Argument::MD_PREFIX->value =>
'oai_dc'],
625 [[
'from' =>
null,
'until' =>
null,
'limit' => 100,
'offset' => 0]],
626 $repo->exposed_parameters
628 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
631 public function testGetResponseToRequestListIdentifiersNonDefaultSetError(): void
633 $processor =
new RequestProcessor(
635 $this->getSettings(
'prefix_'),
636 $repo = $this->getRepository(
643 $this->getTokenHandler()
646 $expected_response = <<<XML
648 <response_info>
base url:ListIdentifiers:metadataPrefix=oai_dc,
set=
set</response_info>
649 <error>noRecordsMatch</error>
653 $response = $processor->getResponseToRequest($this->getRequest(
655 Verb::LIST_IDENTIFIERS,
656 [Argument::MD_PREFIX->value =>
'oai_dc',
Argument::SET->value =>
'set'],
659 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
662 public function testGetResponseToRequestListIdentifiersMultipleErrors(): void
664 $processor =
new RequestProcessor(
666 $this->getSettings(
'prefix_'),
667 $repo = $this->getRepository(),
668 $this->getTokenHandler()
671 $expected_response = <<<XML
673 <response_info>
base url:ListIdentifiers:metadataPrefix=invalid,until=also invalid,from=
more invalid,
set=
set,identifier=
id</response_info>
674 <error>badArgument</error>
675 <error>noRecordsMatch</error>
676 <error>cannotDisseminateFormat</error>
677 <error>badArgument</error>
678 <error>badArgument</error>
679 <error>noRecordsMatch</error>
683 $response = $processor->getResponseToRequest($this->getRequest(
685 Verb::LIST_IDENTIFIERS,
687 Argument::MD_PREFIX->value =>
'invalid',
688 Argument::UNTIL_DATE->value =>
'also invalid',
689 Argument::FROM_DATE->value =>
'more invalid',
691 Argument::IDENTIFIER->value =>
'id' 697 [[
'from' =>
null,
'until' =>
null,
'limit' => 100,
'offset' => 0]],
698 $repo->exposed_parameters
700 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
more()
description: > Example for rendring a more glyph.