19declare(strict_types=1);
23use PHPUnit\Framework\TestCase;
40 $url = $this->createMock(URI::class);
41 $url->method(
'__toString')->willReturn($string);
48 public array $exposed_responses = [];
50 public function sendResponseAndClose(
53 ?\DOMDocument $body =
null
55 $this->exposed_responses[] = [
56 'status' => $status_code,
57 'message' => $message,
58 'body' => $body?->saveXML($body->documentElement)
68 protected bool $activated
72 public function isOAIPMHActive():
bool
74 return $this->activated;
81 return new class ($content) extends
NullParser {
82 public function __construct(
protected string $content)
88 return new class ($this->content, $base_url) extends
NullRequest {
90 protected string $content,
91 protected URI $base_url
95 public function baseURL():
URI
97 return $this->base_url;
100 public function exposeContent():
string
102 return $this->content;
110 bool $throws_exception =
false,
111 bool $throws_error =
false,
112 bool $triggers_error =
false
120 protected bool $throws_exception,
121 protected bool $throws_error,
122 protected bool $triggers_error
126 public function getResponseToRequest(
RequestInterface $request): \DomDocument
128 if ($this->throws_exception) {
129 throw new \ilMDOERExposerException(
'exception message');
131 if ($this->throws_error) {
134 if ($this->triggers_error) {
141 $content = $request->exposeContent();
142 $doc = new \DOMDocument();
143 $doc->appendChild($doc->createElement(
'content',
$url .
'~!~' . $content));
152 HTTPWrapperInterface $http_wrapper,
153 RequestParserInterface $request_parser,
156 $base_url = $this->
getURI($base_url);
164 public array $exposed_logged_errors = [];
168 protected HTTPWrapperInterface $http_wrapper,
169 protected RequestParserInterface $request_parser,
171 protected readonly
URI $base_url
175 protected function logError(
string $message):
void
177 $this->exposed_logged_errors[] = $message;
186 $this->getSettings(
true),
187 $wrapper = $this->getHTTPWrapper(),
188 $this->getRequestParser(
'some content'),
189 $this->getRequestProcessor()
194 $this->assertCount(1, $wrapper->exposed_responses);
196 [
'status' => 200,
'message' =>
'',
'body' =>
'<content>some url~!~some content</content>'],
197 $wrapper->exposed_responses[0] ?? []
205 $this->getSettings(
false),
206 $wrapper = $this->getHTTPWrapper(),
207 $this->getRequestParser(
'some content'),
208 $this->getRequestProcessor()
213 $this->assertCount(1, $wrapper->exposed_responses);
215 [
'status' => 404,
'message' =>
'',
'body' =>
null],
216 $wrapper->exposed_responses[0] ?? []
224 $this->getSettings(
true),
225 $wrapper = $this->getHTTPWrapper(),
226 $this->getRequestParser(
''),
227 $this->getRequestProcessor(
true)
232 $this->assertCount(1, $wrapper->exposed_responses);
234 [
'status' => 500,
'message' =>
'exception message',
'body' =>
null],
235 $wrapper->exposed_responses[0] ?? []
238 [
'exception message'],
247 $this->getSettings(
true),
248 $wrapper = $this->getHTTPWrapper(),
249 $this->getRequestParser(
''),
250 $this->getRequestProcessor(
false,
true)
255 $this->assertCount(1, $wrapper->exposed_responses);
257 [
'status' => 500,
'message' =>
'thrown error message',
'body' =>
null],
258 $wrapper->exposed_responses[0] ?? []
261 [
'thrown error message'],
270 $this->getSettings(
true),
271 $wrapper = $this->getHTTPWrapper(),
272 $this->getRequestParser(
''),
273 $this->getRequestProcessor(
false,
false,
true)
278 $this->assertCount(1, $wrapper->exposed_responses);
280 [
'status' => 500,
'message' =>
'Division by zero',
'body' =>
null],
281 $wrapper->exposed_responses[0] ?? []
284 [
'Division by zero'],
The scope of this class is split ilias-conform URI's into components.
__construct()
Constructor setup ILIAS global object @access public.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if( $request_wrapper->has( 'ui_mainbar')) getURI()