19 declare(strict_types=1);
26 class RequestProcessorGetRecordTest
extends RequestProcessorTestCase
28 public function testGetResponseToRequestGetRecord(): void
30 $processor =
new RequestProcessor(
32 $this->getSettings(
'prefix_'),
33 $this->getRepository(
null, 0,
'id+2022-11-27'),
34 $this->getTokenHandler()
37 $expected_response = <<<XML
39 <response_info>
base url:GetRecord:identifier=prefix_id+2022-11-27,metadataPrefix=oai_dc</response_info>
41 <record_info>prefix_id+2022-11-27:2022-11-27</record_info>
42 <md>md
for id+2022-11-27</md>
47 $response = $processor->getResponseToRequest($this->getRequest(
50 [Argument::IDENTIFIER->value =>
'prefix_id+2022-11-27', Argument::MD_PREFIX->value =>
'oai_dc']
53 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
56 public function testGetResponseToRequestGetRecordNoMDFormatError(): void
58 $processor =
new RequestProcessor(
60 $this->getSettings(
'prefix_'),
61 $this->getRepository(
null, 0,
'id+2022-11-27'),
62 $this->getTokenHandler()
65 $expected_response = <<<XML
67 <response_info>
base url:GetRecord:identifier=prefix_id+2022-11-27</response_info>
68 <error>badArgument</error>
72 $response = $processor->getResponseToRequest($this->getRequest(
75 [Argument::IDENTIFIER->value =>
'prefix_id+2022-11-27'],
79 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
82 public function testGetResponseToRequestGetRecordNoIdentifierError(): void
84 $processor =
new RequestProcessor(
86 $this->getSettings(
'prefix_'),
87 $this->getRepository(
null, 0,
'id+2022-11-27'),
88 $this->getTokenHandler()
91 $expected_response = <<<XML
93 <response_info>
base url:GetRecord:metadataPrefix=oai_dc</response_info>
94 <error>badArgument</error>
98 $response = $processor->getResponseToRequest($this->getRequest(
101 [Argument::MD_PREFIX->value =>
'oai_dc'],
105 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
108 public function testGetResponseToRequestGetRecordAdditionalArgumentError(): void
110 $processor =
new RequestProcessor(
112 $this->getSettings(
'prefix_'),
113 $this->getRepository(
null, 0,
'id+2022-11-27'),
114 $this->getTokenHandler()
117 $expected_response = <<<XML
119 <response_info>
base url:GetRecord:identifier=prefix_id+2022-11-27,metadataPrefix=oai_dc,
from=date</response_info>
120 <error>badArgument</error>
124 $response = $processor->getResponseToRequest($this->getRequest(
127 [Argument::IDENTIFIER->value =>
'prefix_id+2022-11-27', Argument::MD_PREFIX->value =>
'oai_dc', Argument::FROM_DATE->value =>
'date'],
132 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
135 public function testGetResponseToRequestGetRecordWrongMDFormatError(): void
137 $processor =
new RequestProcessor(
139 $this->getSettings(
'prefix_'),
140 $this->getRepository(
null, 0,
'id+2022-11-27'),
141 $this->getTokenHandler()
144 $expected_response = <<<XML
146 <response_info>
base url:GetRecord:identifier=prefix_id+2022-11-27,metadataPrefix=invalid</response_info>
147 <error>cannotDisseminateFormat</error>
151 $response = $processor->getResponseToRequest($this->getRequest(
154 [Argument::IDENTIFIER->value =>
'prefix_id+2022-11-27', Argument::MD_PREFIX->value =>
'invalid']
157 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
160 public function testGetResponseToRequestGetRecordInvalidIdentifierError(): void
162 $processor =
new RequestProcessor(
164 $this->getSettings(
'prefix_'),
165 $this->getRepository(
null, 0,
'id+2022-11-27'),
166 $this->getTokenHandler()
169 $expected_response = <<<XML
171 <response_info>
base url:GetRecord:identifier=invalid_id+2022-11-27,metadataPrefix=oai_dc</response_info>
172 <error>idDoesNotExist</error>
176 $response = $processor->getResponseToRequest($this->getRequest(
179 [Argument::IDENTIFIER->value =>
'invalid_id+2022-11-27', Argument::MD_PREFIX->value =>
'oai_dc']
182 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
185 public function testGetResponseToRequestGetRecordNotFoundError(): void
187 $processor =
new RequestProcessor(
189 $this->getSettings(
'prefix_'),
190 $this->getRepository(),
191 $this->getTokenHandler()
194 $expected_response = <<<XML
196 <response_info>
base url:GetRecord:identifier=prefix_id+2022-11-27,metadataPrefix=oai_dc</response_info>
197 <error>idDoesNotExist</error>
201 $response = $processor->getResponseToRequest($this->getRequest(
204 [Argument::IDENTIFIER->value =>
'prefix_id+2022-11-27', Argument::MD_PREFIX->value =>
'oai_dc']
207 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
210 public function testGetResponseToRequestGetRecordMultipleErrors(): void
212 $processor =
new RequestProcessor(
214 $this->getSettings(
'prefix_'),
215 $this->getRepository(),
216 $this->getTokenHandler()
219 $expected_response = <<<XML
221 <response_info>
base url:GetRecord:identifier=prefix_id+2022-11-27,metadataPrefix=invalid,from=date</response_info>
222 <error>badArgument</error>
223 <error>cannotDisseminateFormat</error>
224 <error>idDoesNotExist</error>
228 $response = $processor->getResponseToRequest($this->getRequest(
231 [Argument::IDENTIFIER->value =>
'prefix_id+2022-11-27', Argument::MD_PREFIX->value =>
'invalid', Argument::FROM_DATE->value =>
'date'],
235 $this->assertXmlStringEqualsXmlString($expected_response,
$response->saveXML());
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null