ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\MetaData\Copyright\Search\SearcherTest Class Reference
+ Inheritance diagram for ILIAS\MetaData\Copyright\Search\SearcherTest:
+ Collaboration diagram for ILIAS\MetaData\Copyright\Search\SearcherTest:

Public Member Functions

 testSearch ()
 
 testSearchWithMultipleEntries ()
 
 testSearchRestrictedToRepositoryObjects ()
 
 testSearchRestrictedToObjectType ()
 
 testSearchRestrictedToMultipleObjectTypes ()
 
 testSearchRestrictedToMultipleObjectTypesAndRepositoryObjects ()
 

Protected Member Functions

 getRessourceID (int $idx)
 
 assertCorrectSearchResults (RessourceIDInterface ... $ids)
 
 getLOMRepository ()
 
 getSearchFilterFactory ()
 
 getSearchClauseFactory ()
 
 getPathFactory ()
 
 getIdentifierHandler ()
 

Detailed Description

Definition at line 48 of file SearcherTest.php.

Member Function Documentation

◆ assertCorrectSearchResults()

ILIAS\MetaData\Copyright\Search\SearcherTest::assertCorrectSearchResults ( RessourceIDInterface ...  $ids)
protected

◆ getIdentifierHandler()

ILIAS\MetaData\Copyright\Search\SearcherTest::getIdentifierHandler ( )
protected

◆ getLOMRepository()

ILIAS\MetaData\Copyright\Search\SearcherTest::getLOMRepository ( )
protected

Definition at line 67 of file SearcherTest.php.

References ILIAS\__construct(), ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from(), and ILIAS\MetaData\Copyright\Search\SearcherTest\getRessourceID().

Referenced by ILIAS\MetaData\Copyright\Search\SearcherTest\testSearch(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToMultipleObjectTypes(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToMultipleObjectTypesAndRepositoryObjects(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToObjectType(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToRepositoryObjects(), and ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchWithMultipleEntries().

67  : RepositoryInterface
68  {
69  $returns = [
70  $this->getRessourceID(1),
71  $this->getRessourceID(2),
72  $this->getRessourceID(3)
73  ];
74 
75  return new class ($returns) extends NullRepository {
76  public array $exposed_searches = [];
77 
78  public function __construct(protected array $returns)
79  {
80  }
81 
82  public function searchMD(
83  ClauseInterface $clause,
84  ?int $limit,
85  ?int $offset,
86  FilterInterface ...$filters
87  ): \Generator {
88  $filter_data = [];
89  foreach ($filters as $filter) {
90  $filter_data[] = $filter->exposed_data;
91  }
92  $this->exposed_searches[] = [
93  'clause' => $clause->exposed_data,
94  'limit' => $limit,
95  'offset' => $offset,
96  'filters' => $filter_data
97  ];
98 
99  yield from $this->returns;
100  }
101  };
102  }
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPathFactory()

ILIAS\MetaData\Copyright\Search\SearcherTest::getPathFactory ( )
protected

Definition at line 166 of file SearcherTest.php.

References $path, ILIAS\__construct(), ILIAS\UI\examples\Chart\Bar\Horizontal\custom(), and ILIAS\Export\ImportHandler\File\XML\Manifest\toString.

Referenced by ILIAS\MetaData\Copyright\Search\SearcherTest\testSearch(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToMultipleObjectTypes(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToMultipleObjectTypesAndRepositoryObjects(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToObjectType(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToRepositoryObjects(), and ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchWithMultipleEntries().

166  : PathFactory
167  {
168  return new class () extends NullPathFactory {
169  public function custom(): BuilderInterface
170  {
171  return new class () extends NullBuilder {
172  protected array $path = [];
173 
174  public function withNextStep(string $name, bool $add_as_first = false): BuilderInterface
175  {
176  $clone = clone $this;
177  $clone->path[] = $name;
178  return $clone;
179  }
180 
181  public function get(): PathInterface
182  {
183  $string = implode('>', $this->path);
184  return new class ($string) extends NullPath {
185  public function __construct(protected string $string)
186  {
187  }
188 
189  public function toString(): string
190  {
191  return $this->string;
192  }
193  };
194  }
195  };
196  }
197  };
198  }
$path
Definition: ltiservices.php:29
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
custom()
expected output: > ILIAS shows a base horizontal bar chart but customized with e.g.
Definition: custom.php:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRessourceID()

ILIAS\MetaData\Copyright\Search\SearcherTest::getRessourceID ( int  $idx)
protected

Definition at line 50 of file SearcherTest.php.

References ILIAS\__construct().

Referenced by ILIAS\MetaData\Copyright\Search\SearcherTest\getLOMRepository().

50  : RessourceIDInterface
51  {
52  return new class ($idx) extends NullRessourceID {
53  public function __construct(public int $idx)
54  {
55  }
56  };
57  }
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSearchClauseFactory()

ILIAS\MetaData\Copyright\Search\SearcherTest::getSearchClauseFactory ( )
protected

Definition at line 122 of file SearcherTest.php.

References $path, ILIAS\__construct(), and ILIAS\MetaData\Paths\PathInterface\toString().

Referenced by ILIAS\MetaData\Copyright\Search\SearcherTest\testSearch(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToMultipleObjectTypes(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToMultipleObjectTypesAndRepositoryObjects(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToObjectType(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToRepositoryObjects(), and ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchWithMultipleEntries().

122  : ClauseFactory
123  {
124  return new class () extends NullClauseFactory {
125  public function getBasicClause(
126  PathInterface $path,
127  Mode $mode,
128  string $value,
129  bool $is_mode_negated = false
130  ): ClauseInterface {
131  $exposed = [
132  'path' => $path->toString(),
133  'mode' => $mode,
134  'value' => $value,
135  'is_mode_negated' => $is_mode_negated,
136  ];
137  return new class ($exposed) extends NullClause {
138  public function __construct(public array $exposed_data)
139  {
140  }
141  };
142  }
143 
144  public function getJoinedClauses(
145  Operator $operator,
146  ClauseInterface $first_clause,
147  ClauseInterface ...$further_clauses
148  ): ClauseInterface {
149  $clause_data = [];
150  foreach ([$first_clause, ...$further_clauses] as $clause) {
151  $clause_data[] = $clause->exposed_data;
152  }
153  $exposed = [
154  'operator' => $operator,
155  'subclauses' => $clause_data
156  ];
157  return new class ($exposed) extends NullClause {
158  public function __construct(public array $exposed_data)
159  {
160  }
161  };
162  }
163  };
164  }
$path
Definition: ltiservices.php:29
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSearchFilterFactory()

ILIAS\MetaData\Copyright\Search\SearcherTest::getSearchFilterFactory ( )
protected

Definition at line 104 of file SearcherTest.php.

References ILIAS\__construct(), and ILIAS\File\Capabilities\ANY.

Referenced by ILIAS\MetaData\Copyright\Search\SearcherTest\testSearch(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToMultipleObjectTypes(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToMultipleObjectTypesAndRepositoryObjects(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToObjectType(), ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchRestrictedToRepositoryObjects(), and ILIAS\MetaData\Copyright\Search\SearcherTest\testSearchWithMultipleEntries().

104  : FilterFactory
105  {
106  return new class () extends NullFilterFactory {
107  public function get(
108  Placeholder|int $obj_id = Placeholder::ANY,
109  Placeholder|int $sub_id = Placeholder::ANY,
110  Placeholder|string $type = Placeholder::ANY
111  ): FilterInterface {
112  $exposed = ['obj_id' => $obj_id, 'sub_id' => $sub_id, 'type' => $type];
113  return new class ($exposed) extends NullFilter {
114  public function __construct(public array $exposed_data)
115  {
116  }
117  };
118  }
119  };
120  }
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testSearch()

ILIAS\MetaData\Copyright\Search\SearcherTest::testSearch ( )

Definition at line 210 of file SearcherTest.php.

References $results, ILIAS\MetaData\Copyright\Search\SearcherTest\assertCorrectSearchResults(), ILIAS\MetaData\Copyright\Search\SearcherTest\getIdentifierHandler(), ILIAS\MetaData\Copyright\Search\SearcherTest\getLOMRepository(), ILIAS\MetaData\Copyright\Search\SearcherTest\getPathFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchClauseFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchFilterFactory(), null, and ILIAS\MetaData\Search\Clauses\OR.

210  : void
211  {
212  $searcher = new Searcher(
213  $this->getSearchFilterFactory(),
214  $this->getSearchClauseFactory(),
215  $this->getPathFactory(),
216  $this->getIdentifierHandler()
217  );
218 
219  $results = $searcher->search($repo = $this->getLOMRepository(), 32);
220 
222  $this->assertEquals(
223  [[
224  'clause' => [
225  'operator' => Operator::OR,
226  'subclauses' => [[
227  'path' => 'rights>description>string',
228  'mode' => Mode::EQUALS,
229  'value' => 'identifier_32',
230  'is_mode_negated' => false
231  ]]
232  ],
233  'limit' => null,
234  'offset' => null,
235  'filters' => []
236  ]],
237  $repo->exposed_searches
238  );
239  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
assertCorrectSearchResults(RessourceIDInterface ... $ids)
$results
+ Here is the call graph for this function:

◆ testSearchRestrictedToMultipleObjectTypes()

ILIAS\MetaData\Copyright\Search\SearcherTest::testSearchRestrictedToMultipleObjectTypes ( )

Definition at line 362 of file SearcherTest.php.

References $results, ILIAS\File\Capabilities\ANY, ILIAS\MetaData\Copyright\Search\SearcherTest\assertCorrectSearchResults(), ILIAS\MetaData\Copyright\Search\SearcherTest\getIdentifierHandler(), ILIAS\MetaData\Copyright\Search\SearcherTest\getLOMRepository(), ILIAS\MetaData\Copyright\Search\SearcherTest\getPathFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchClauseFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchFilterFactory(), null, and ILIAS\MetaData\Search\Clauses\OR.

362  : void
363  {
364  $searcher = new Searcher(
365  $this->getSearchFilterFactory(),
366  $this->getSearchClauseFactory(),
367  $this->getPathFactory(),
368  $this->getIdentifierHandler()
369  );
370 
371  $results = $searcher->withAdditionalTypeFilter('some type')
372  ->withAdditionalTypeFilter('some other type')
373  ->withAdditionalTypeFilter('a third type')
374  ->search($repo = $this->getLOMRepository(), 32);
375 
377  $this->assertEquals(
378  [[
379  'clause' => [
380  'operator' => Operator::OR,
381  'subclauses' => [[
382  'path' => 'rights>description>string',
383  'mode' => Mode::EQUALS,
384  'value' => 'identifier_32',
385  'is_mode_negated' => false
386  ]]
387  ],
388  'limit' => null,
389  'offset' => null,
390  'filters' => [
391  [
392  'obj_id' => Placeholder::ANY,
393  'sub_id' => Placeholder::ANY,
394  'type' => 'some type'
395  ],
396  [
397  'obj_id' => Placeholder::ANY,
398  'sub_id' => Placeholder::ANY,
399  'type' => 'some other type'
400  ],
401  [
402  'obj_id' => Placeholder::ANY,
403  'sub_id' => Placeholder::ANY,
404  'type' => 'a third type'
405  ]
406  ]
407  ]],
408  $repo->exposed_searches
409  );
410  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
assertCorrectSearchResults(RessourceIDInterface ... $ids)
$results
+ Here is the call graph for this function:

◆ testSearchRestrictedToMultipleObjectTypesAndRepositoryObjects()

ILIAS\MetaData\Copyright\Search\SearcherTest::testSearchRestrictedToMultipleObjectTypesAndRepositoryObjects ( )

Definition at line 412 of file SearcherTest.php.

References $results, ILIAS\File\Capabilities\ANY, ILIAS\MetaData\Copyright\Search\SearcherTest\assertCorrectSearchResults(), ILIAS\MetaData\Copyright\Search\SearcherTest\getIdentifierHandler(), ILIAS\MetaData\Copyright\Search\SearcherTest\getLOMRepository(), ILIAS\MetaData\Copyright\Search\SearcherTest\getPathFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchClauseFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchFilterFactory(), null, and ILIAS\MetaData\Search\Clauses\OR.

412  : void
413  {
414  $searcher = new Searcher(
415  $this->getSearchFilterFactory(),
416  $this->getSearchClauseFactory(),
417  $this->getPathFactory(),
418  $this->getIdentifierHandler()
419  );
420 
421  $results = $searcher->withAdditionalTypeFilter('some type')
422  ->withAdditionalTypeFilter('some other type')
423  ->withAdditionalTypeFilter('a third type')
424  ->withRestrictionToRepositoryObjects(true)
425  ->search($repo = $this->getLOMRepository(), 32);
426 
428  $this->assertEquals(
429  [[
430  'clause' => [
431  'operator' => Operator::OR,
432  'subclauses' => [[
433  'path' => 'rights>description>string',
434  'mode' => Mode::EQUALS,
435  'value' => 'identifier_32',
436  'is_mode_negated' => false
437  ]]
438  ],
439  'limit' => null,
440  'offset' => null,
441  'filters' => [
442  [
443  'obj_id' => Placeholder::ANY,
444  'sub_id' => Placeholder::OBJ_ID,
445  'type' => 'some type'
446  ],
447  [
448  'obj_id' => Placeholder::ANY,
449  'sub_id' => Placeholder::OBJ_ID,
450  'type' => 'some other type'
451  ],
452  [
453  'obj_id' => Placeholder::ANY,
454  'sub_id' => Placeholder::OBJ_ID,
455  'type' => 'a third type'
456  ]
457  ]
458  ]],
459  $repo->exposed_searches
460  );
461  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
assertCorrectSearchResults(RessourceIDInterface ... $ids)
$results
+ Here is the call graph for this function:

◆ testSearchRestrictedToObjectType()

ILIAS\MetaData\Copyright\Search\SearcherTest::testSearchRestrictedToObjectType ( )

Definition at line 324 of file SearcherTest.php.

References $results, ILIAS\File\Capabilities\ANY, ILIAS\MetaData\Copyright\Search\SearcherTest\assertCorrectSearchResults(), ILIAS\MetaData\Copyright\Search\SearcherTest\getIdentifierHandler(), ILIAS\MetaData\Copyright\Search\SearcherTest\getLOMRepository(), ILIAS\MetaData\Copyright\Search\SearcherTest\getPathFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchClauseFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchFilterFactory(), null, and ILIAS\MetaData\Search\Clauses\OR.

324  : void
325  {
326  $searcher = new Searcher(
327  $this->getSearchFilterFactory(),
328  $this->getSearchClauseFactory(),
329  $this->getPathFactory(),
330  $this->getIdentifierHandler()
331  );
332 
333  $results = $searcher->withAdditionalTypeFilter('some type')
334  ->search($repo = $this->getLOMRepository(), 32);
335 
337  $this->assertEquals(
338  [[
339  'clause' => [
340  'operator' => Operator::OR,
341  'subclauses' => [[
342  'path' => 'rights>description>string',
343  'mode' => Mode::EQUALS,
344  'value' => 'identifier_32',
345  'is_mode_negated' => false
346  ]]
347  ],
348  'limit' => null,
349  'offset' => null,
350  'filters' => [
351  [
352  'obj_id' => Placeholder::ANY,
353  'sub_id' => Placeholder::ANY,
354  'type' => 'some type'
355  ]
356  ]
357  ]],
358  $repo->exposed_searches
359  );
360  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
assertCorrectSearchResults(RessourceIDInterface ... $ids)
$results
+ Here is the call graph for this function:

◆ testSearchRestrictedToRepositoryObjects()

ILIAS\MetaData\Copyright\Search\SearcherTest::testSearchRestrictedToRepositoryObjects ( )

Definition at line 286 of file SearcherTest.php.

References $results, ILIAS\File\Capabilities\ANY, ILIAS\MetaData\Copyright\Search\SearcherTest\assertCorrectSearchResults(), ILIAS\MetaData\Copyright\Search\SearcherTest\getIdentifierHandler(), ILIAS\MetaData\Copyright\Search\SearcherTest\getLOMRepository(), ILIAS\MetaData\Copyright\Search\SearcherTest\getPathFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchClauseFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchFilterFactory(), null, and ILIAS\MetaData\Search\Clauses\OR.

286  : void
287  {
288  $searcher = new Searcher(
289  $this->getSearchFilterFactory(),
290  $this->getSearchClauseFactory(),
291  $this->getPathFactory(),
292  $this->getIdentifierHandler()
293  );
294 
295  $results = $searcher->withRestrictionToRepositoryObjects(true)
296  ->search($repo = $this->getLOMRepository(), 32);
297 
299  $this->assertEquals(
300  [[
301  'clause' => [
302  'operator' => Operator::OR,
303  'subclauses' => [[
304  'path' => 'rights>description>string',
305  'mode' => Mode::EQUALS,
306  'value' => 'identifier_32',
307  'is_mode_negated' => false
308  ]]
309  ],
310  'limit' => null,
311  'offset' => null,
312  'filters' => [
313  [
314  'obj_id' => Placeholder::ANY,
315  'sub_id' => Placeholder::OBJ_ID,
316  'type' => Placeholder::ANY
317  ]
318  ]
319  ]],
320  $repo->exposed_searches
321  );
322  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
assertCorrectSearchResults(RessourceIDInterface ... $ids)
$results
+ Here is the call graph for this function:

◆ testSearchWithMultipleEntries()

ILIAS\MetaData\Copyright\Search\SearcherTest::testSearchWithMultipleEntries ( )

Definition at line 241 of file SearcherTest.php.

References $results, ILIAS\MetaData\Copyright\Search\SearcherTest\assertCorrectSearchResults(), ILIAS\MetaData\Copyright\Search\SearcherTest\getIdentifierHandler(), ILIAS\MetaData\Copyright\Search\SearcherTest\getLOMRepository(), ILIAS\MetaData\Copyright\Search\SearcherTest\getPathFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchClauseFactory(), ILIAS\MetaData\Copyright\Search\SearcherTest\getSearchFilterFactory(), null, and ILIAS\MetaData\Search\Clauses\OR.

241  : void
242  {
243  $searcher = new Searcher(
244  $this->getSearchFilterFactory(),
245  $this->getSearchClauseFactory(),
246  $this->getPathFactory(),
247  $this->getIdentifierHandler()
248  );
249 
250  $results = $searcher->search($repo = $this->getLOMRepository(), 32, 9, 1234);
251 
253  $this->assertEquals(
254  [[
255  'clause' => [
256  'operator' => Operator::OR,
257  'subclauses' => [
258  [
259  'path' => 'rights>description>string',
260  'mode' => Mode::EQUALS,
261  'value' => 'identifier_32',
262  'is_mode_negated' => false
263  ],
264  [
265  'path' => 'rights>description>string',
266  'mode' => Mode::EQUALS,
267  'value' => 'identifier_9',
268  'is_mode_negated' => false
269  ],
270  [
271  'path' => 'rights>description>string',
272  'mode' => Mode::EQUALS,
273  'value' => 'identifier_1234',
274  'is_mode_negated' => false
275  ]
276  ]
277  ],
278  'limit' => null,
279  'offset' => null,
280  'filters' => []
281  ]],
282  $repo->exposed_searches
283  );
284  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
assertCorrectSearchResults(RessourceIDInterface ... $ids)
$results
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: