ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
DatabasePathsParserTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
39 
40 class DatabasePathsParserTest extends TestCase
41 {
43  {
44  return new class () extends DatabasePathsParser {
45  public function __construct()
46  {
47  }
48 
49  protected function getNavigatorForPath(PathInterface $path): StructureNavigatorInterface
50  {
51  return new class ($path) extends NullStructureNavigator {
52  protected array $steps;
53 
54  public function __construct(PathInterface $path)
55  {
56  $this->steps = iterator_to_array($path->steps());
57  }
58 
59  public function hasNextStep(): bool
60  {
61  return count($this->steps) > 1;
62  }
63 
64  public function nextStep(): ?StructureNavigatorInterface
65  {
66  if (!$this->hasNextStep()) {
67  return null;
68  }
69  $clone = clone $this;
70  array_shift($clone->steps);
71  return $clone;
72  }
73 
74  public function currentStep(): ?StepInterface
75  {
76  return $this->steps[0];
77  }
78  };
79  }
80 
81  protected function getTagForCurrentStepOfNavigator(
83  ): ?TagInterface {
84  return $navigator->currentStep()->tag;
85  }
86 
87  protected function getDataTypeForCurrentStepOfNavigator(StructureNavigatorInterface $navigator): DataType
88  {
89  return $navigator->currentStep()->tag->data_type;
90  }
91 
92  protected function quoteIdentifier(string $identifier): string
93  {
94  return '~identifier:' . $identifier . '~';
95  }
96 
97  protected function quoteText(string $text): string
98  {
99  return '~text:' . $text . '~';
100  }
101 
102  protected function quoteInteger(int $integer): string
103  {
104  return '~int:' . $integer . '~';
105  }
106 
107  protected function checkTable(string $table): void
108  {
109  if ($table === 'WRONG') {
110  throw new \ilMDRepositoryException('Invalid MD table: ' . $table);
111  }
112  }
113 
114  protected function table(string $table): ?string
115  {
116  return $table === 'WRONG' ? null : $table . '_name';
117  }
118 
119  protected function IDName(string $table): ?string
120  {
121  return $table === 'WRONG' ? null : $table . '_id';
122  }
123  };
124  }
125 
126  protected function getPath(TagInterface ...$tags): PathInterface
127  {
128  array_unshift(
129  $tags,
130  $this->getTag('', '', '', 'root'),
131  );
132 
133  return new class ($tags) extends NullPath {
134  public function __construct(protected array $tags)
135  {
136  }
137 
138  public function steps(): \Generator
139  {
140  foreach ($this->tags as $tag) {
141  yield new class ($tag) extends NullStep {
142  public function __construct(public TagInterface $tag)
143  {
144  }
145 
146  public function name(): string|StepToken
147  {
148  return $this->tag->step_name;
149  }
150 
151  public function filters(): \Generator
152  {
153  yield from $this->tag->filters;
154  }
155  };
156  }
157  }
158 
159  public function toString(): string
160  {
161  $string = '@';
162  foreach ($this->tags as $tag) {
163  $step_name = is_string($tag->step_name) ? $tag->step_name : $tag->step_name->value;
164  $string .= '.' . $step_name;
165  foreach ($tag->filters as $filter) {
166  $string .= ':' . $filter->type()->value;
167  foreach ($filter->values() as $value) {
168  $string .= '~' . $value;
169  }
170  }
171  }
172  return $string;
173  }
174  };
175  }
176 
182  protected function getTag(
183  string $table,
184  string $parent,
185  string $data_field,
186  string|StepToken $step_name,
187  DataType $data_type = DataType::STRING,
188  PathFilter ...$filters,
189  ): TagInterface {
190  return new class ($table, $parent, $data_field, $step_name, $data_type, $filters) extends NullTag {
191  public function __construct(
192  protected string $table,
193  protected string $parent,
194  protected string $data_field,
195  public string|StepToken $step_name,
196  public DataType $data_type,
197  public array $filters
198  ) {
199  }
200 
201  public function table(): string
202  {
203  return $this->table;
204  }
205 
206  public function hasParent(): bool
207  {
208  return $this->parent !== '';
209  }
210 
211  public function parent(): string
212  {
213  return $this->parent;
214  }
215 
216  public function hasData(): bool
217  {
218  return $this->data_field !== '';
219  }
220 
221  public function dataField(): string
222  {
223  return $this->data_field;
224  }
225  };
226  }
227 
228  protected function getPathFilter(
229  FilterType $type,
230  string ...$values
231  ): PathFilter {
232  return new class ($type, $values) extends NullPathFilter {
233  public function __construct(
234  protected FilterType $type,
235  protected array $values
236  ) {
237  }
238 
239  public function type(): FilterType
240  {
241  return $this->type;
242  }
243 
244  public function values(): \Generator
245  {
246  yield from $this->values;
247  }
248  };
249  }
250 
251  public function testGetTableAliasForFilters(): void
252  {
253  $parser = $this->getDatabasePathsParser();
254  $parser->addPathAndGetColumn(
255  $this->getPath($this->getTag('table', '', '', 'step')),
256  false
257  );
258 
259  $this->assertSame('p1t1', $parser->getTableAliasForFilters());
260  }
261 
263  {
264  $parser = $this->getDatabasePathsParser();
265 
266  $this->expectException(\ilMDRepositoryException::class);
267  $parser->getTableAliasForFilters();
268  }
269 
271  {
272  $parser = $this->getDatabasePathsParser();
273 
274  $this->expectException(\ilMDRepositoryException::class);
275  $parser->addPathAndGetColumn(
276  $this->getPath($this->getTag('WRONG', '', '', 'step')),
277  false
278  );
279  }
280 
282  {
283  $parser = $this->getDatabasePathsParser();
284 
285  $this->expectException(\ilMDRepositoryException::class);
286  $parser->getSelectForQuery();
287  }
288 
290  {
291  $parser = $this->getDatabasePathsParser();
292  $data_column = $parser->addPathAndGetColumn(
293  $this->getPath(
294  $this->getTag('table', '', '', 'step1'),
295  $this->getTag('table', '', 'data', 'step2')
296  ),
297  false
298  );
299 
300  $this->assertSame(
301  "COALESCE(~identifier:p1t1~.~identifier:data~, '')",
302  $data_column
303  );
304  $this->assertSame(
305  'SELECT ~identifier:p1t1~.rbac_id, ~identifier:p1t1~.obj_id, ~identifier:p1t1~.obj_type ' .
306  'FROM ~identifier:table_name~ AS ~identifier:p1t1~',
307  $parser->getSelectForQuery()
308  );
309  }
310 
312  {
313  $parser = $this->getDatabasePathsParser();
314  $data_column = $parser->addPathAndGetColumn(
315  $this->getPath(
316  $this->getTag('table', '', '', 'step1'),
317  $this->getTag('table', '', 'data', 'step2')
318  ),
319  true
320  );
321 
322  $this->assertSame(
323  "COALESCE(~identifier:p1t1~.~identifier:data~, '')",
324  $data_column
325  );
326  $this->assertSame(
327  'SELECT ~identifier:base~.rbac_id, ~identifier:base~.obj_id, ~identifier:base~.obj_type ' .
328  'FROM il_meta_general AS base LEFT JOIN (~identifier:table_name~ AS ~identifier:p1t1~) ' .
329  'ON ~identifier:base~.rbac_id = ~identifier:p1t1~.rbac_id AND ' .
330  '~identifier:base~.obj_id = ~identifier:p1t1~.obj_id AND ' .
331  '~identifier:base~.obj_type = ~identifier:p1t1~.obj_type',
332  $parser->getSelectForQuery()
333  );
334  }
335 
337  {
338  $parser = $this->getDatabasePathsParser();
339  $data_column = $parser->addPathAndGetColumn(
340  $this->getPath(
341  $this->getTag('table1', '', '', 'step1'),
342  $this->getTag('table1', '', '', 'step2'),
343  $this->getTag('table2', 'table1', '', 'step3'),
344  $this->getTag('table2', 'table1', 'data', 'step4')
345  ),
346  false
347  );
348 
349  $this->assertSame(
350  "COALESCE(~identifier:p1t2~.~identifier:data~, '')",
351  $data_column
352  );
353  $this->assertSame(
354  'SELECT ~identifier:p1t1~.rbac_id, ~identifier:p1t1~.obj_id, ~identifier:p1t1~.obj_type ' .
355  'FROM ~identifier:table1_name~ AS ~identifier:p1t1~ JOIN ' .
356  '~identifier:table2_name~ AS ~identifier:p1t2~ ON ' .
357  '~identifier:p1t1~.rbac_id = ~identifier:p1t2~.rbac_id AND ' .
358  '~identifier:p1t1~.obj_id = ~identifier:p1t2~.obj_id AND ' .
359  '~identifier:p1t1~.obj_type = ~identifier:p1t2~.obj_type AND ' .
360  'p1t1.~identifier:table1_id~ = ~identifier:p1t2~.parent_id AND ' .
361  '~text:table1~ = ~identifier:p1t2~.parent_type',
362  $parser->getSelectForQuery()
363  );
364  }
365 
367  {
368  $parser = $this->getDatabasePathsParser();
369  $data_column = $parser->addPathAndGetColumn(
370  $this->getPath(
371  $this->getTag('table', '', '', 'step1'),
372  $this->getTag('table', '', '', 'step2')
373  ),
374  false
375  );
376 
377  $this->assertSame(
378  '~text:~',
379  $data_column
380  );
381  $this->assertSame(
382  'SELECT ~identifier:p1t1~.rbac_id, ~identifier:p1t1~.obj_id, ~identifier:p1t1~.obj_type ' .
383  'FROM ~identifier:table_name~ AS ~identifier:p1t1~',
384  $parser->getSelectForQuery()
385  );
386  }
387 
389  {
390  $parser = $this->getDatabasePathsParser();
391  $data_column_1 = $parser->addPathAndGetColumn(
392  $this->getPath(
393  $this->getTag('table', '', '', 'step1'),
394  $this->getTag('table', '', 'data', 'step2')
395  ),
396  false
397  );
398  $data_column_2 = $parser->addPathAndGetColumn(
399  $this->getPath(
400  $this->getTag('table', '', '', 'step1'),
401  $this->getTag('table', '', 'data', 'step2')
402  ),
403  false
404  );
405 
406  $this->assertSame(
407  "COALESCE(~identifier:p1t1~.~identifier:data~, '')",
408  $data_column_1
409  );
410  $this->assertSame(
411  "COALESCE(~identifier:p1t1~.~identifier:data~, '')",
412  $data_column_2
413  );
414  $this->assertSame(
415  'SELECT ~identifier:p1t1~.rbac_id, ~identifier:p1t1~.obj_id, ~identifier:p1t1~.obj_type ' .
416  'FROM ~identifier:table_name~ AS ~identifier:p1t1~',
417  $parser->getSelectForQuery()
418  );
419  }
420 
422  {
423  $parser = $this->getDatabasePathsParser();
424  $data_column_1 = $parser->addPathAndGetColumn(
425  $this->getPath(
426  $this->getTag('table1', '', '', 'step1'),
427  $this->getTag('table1', '', '', 'step2'),
428  $this->getTag('table2', 'table2', '', 'step3'),
429  $this->getTag('table2', 'table2', 'data1', 'step4')
430  ),
431  false
432  );
433  $data_column_2 = $parser->addPathAndGetColumn(
434  $this->getPath(
435  $this->getTag('table1', '', '', 'step1'),
436  $this->getTag('table1', '', 'data2', 'step2'),
437  ),
438  false
439  );
440 
441  $this->assertSame(
442  "COALESCE(~identifier:p1t2~.~identifier:data1~, '')",
443  $data_column_1
444  );
445  $this->assertSame(
446  "COALESCE(~identifier:p2t1~.~identifier:data2~, '')",
447  $data_column_2
448  );
449  $this->assertSame(
450  'SELECT ~identifier:base~.rbac_id, ~identifier:base~.obj_id, ~identifier:base~.obj_type ' .
451  'FROM il_meta_general AS base LEFT JOIN (' .
452  '~identifier:table1_name~ AS ~identifier:p1t1~ JOIN ' .
453  '~identifier:table2_name~ AS ~identifier:p1t2~ ON ' .
454  '~identifier:p1t1~.rbac_id = ~identifier:p1t2~.rbac_id AND ' .
455  '~identifier:p1t1~.obj_id = ~identifier:p1t2~.obj_id AND ' .
456  '~identifier:p1t1~.obj_type = ~identifier:p1t2~.obj_type AND ' .
457  'p1t1.~identifier:table1_id~ = ~identifier:p1t2~.parent_id AND ' .
458  '~text:table2~ = ~identifier:p1t2~.parent_type) ON ' .
459  '~identifier:base~.rbac_id = ~identifier:p1t1~.rbac_id AND ' .
460  '~identifier:base~.obj_id = ~identifier:p1t1~.obj_id AND ' .
461  '~identifier:base~.obj_type = ~identifier:p1t1~.obj_type LEFT JOIN ' .
462  '(~identifier:table1_name~ AS ~identifier:p2t1~) ON ' .
463  '~identifier:base~.rbac_id = ~identifier:p2t1~.rbac_id AND ' .
464  '~identifier:base~.obj_id = ~identifier:p2t1~.obj_id AND ' .
465  '~identifier:base~.obj_type = ~identifier:p2t1~.obj_type',
466  $parser->getSelectForQuery()
467  );
468  }
469 
471  {
472  $parser = $this->getDatabasePathsParser();
473  $data_column_1 = $parser->addPathAndGetColumn(
474  $this->getPath(
475  $this->getTag('table1', '', '', 'step1'),
476  $this->getTag('table1', '', '', 'step2'),
477  $this->getTag('table2', 'table2', '', 'step3'),
478  $this->getTag('table2', 'table2', 'data1', 'step4')
479  ),
480  true
481  );
482  $data_column_2 = $parser->addPathAndGetColumn(
483  $this->getPath(
484  $this->getTag('table1', '', '', 'step1'),
485  $this->getTag('table1', '', 'data2', 'step2'),
486  ),
487  false
488  );
489 
490  $this->assertSame(
491  "COALESCE(~identifier:p1t2~.~identifier:data1~, '')",
492  $data_column_1
493  );
494  $this->assertSame(
495  "COALESCE(~identifier:p2t1~.~identifier:data2~, '')",
496  $data_column_2
497  );
498  $this->assertSame(
499  'SELECT ~identifier:base~.rbac_id, ~identifier:base~.obj_id, ~identifier:base~.obj_type ' .
500  'FROM il_meta_general AS base LEFT JOIN (' .
501  '~identifier:table1_name~ AS ~identifier:p1t1~ JOIN ' .
502  '~identifier:table2_name~ AS ~identifier:p1t2~ ON ' .
503  '~identifier:p1t1~.rbac_id = ~identifier:p1t2~.rbac_id AND ' .
504  '~identifier:p1t1~.obj_id = ~identifier:p1t2~.obj_id AND ' .
505  '~identifier:p1t1~.obj_type = ~identifier:p1t2~.obj_type AND ' .
506  'p1t1.~identifier:table1_id~ = ~identifier:p1t2~.parent_id AND ' .
507  '~text:table2~ = ~identifier:p1t2~.parent_type) ON ' .
508  '~identifier:base~.rbac_id = ~identifier:p1t1~.rbac_id AND ' .
509  '~identifier:base~.obj_id = ~identifier:p1t1~.obj_id AND ' .
510  '~identifier:base~.obj_type = ~identifier:p1t1~.obj_type LEFT JOIN ' .
511  '(~identifier:table1_name~ AS ~identifier:p2t1~) ON ' .
512  '~identifier:base~.rbac_id = ~identifier:p2t1~.rbac_id AND ' .
513  '~identifier:base~.obj_id = ~identifier:p2t1~.obj_id AND ' .
514  '~identifier:base~.obj_type = ~identifier:p2t1~.obj_type',
515  $parser->getSelectForQuery()
516  );
517  }
518 
520  {
521  $parser = $this->getDatabasePathsParser();
522  $data_column = $parser->addPathAndGetColumn(
523  $this->getPath(
524  $this->getTag('table1', '', '', 'step1'),
525  $this->getTag('table1', '', '', 'step2'),
526  $this->getTag('table2', 'table1', '', 'step3'),
527  $this->getTag('table1', '', 'data1', StepToken::SUPER),
528  $this->getTag('table2', 'table1', 'data2', 'step5')
529  ),
530  false
531  );
532 
533  $this->assertSame(
534  "COALESCE(~identifier:p1t3~.~identifier:data2~, '')",
535  $data_column
536  );
537  $this->assertSame(
538  'SELECT ~identifier:p1t1~.rbac_id, ~identifier:p1t1~.obj_id, ~identifier:p1t1~.obj_type ' .
539  'FROM ~identifier:table1_name~ AS ~identifier:p1t1~ JOIN ' .
540  '~identifier:table2_name~ AS ~identifier:p1t2~ JOIN ' .
541  '~identifier:table2_name~ AS ~identifier:p1t3~ ON ' .
542  '~identifier:p1t1~.rbac_id = ~identifier:p1t2~.rbac_id AND ' .
543  '~identifier:p1t1~.obj_id = ~identifier:p1t2~.obj_id AND ' .
544  '~identifier:p1t1~.obj_type = ~identifier:p1t2~.obj_type AND ' .
545  'p1t1.~identifier:table1_id~ = ~identifier:p1t2~.parent_id AND ' .
546  '~text:table1~ = ~identifier:p1t2~.parent_type AND ' .
547  '~identifier:p1t1~.rbac_id = ~identifier:p1t3~.rbac_id AND ' .
548  '~identifier:p1t1~.obj_id = ~identifier:p1t3~.obj_id AND ' .
549  '~identifier:p1t1~.obj_type = ~identifier:p1t3~.obj_type AND ' .
550  'p1t1.~identifier:table1_id~ = ~identifier:p1t3~.parent_id AND ' .
551  '~text:table1~ = ~identifier:p1t3~.parent_type',
552  $parser->getSelectForQuery()
553  );
554  }
555 
557  {
558  $parser = $this->getDatabasePathsParser();
559  $filter = $this->getPathFilter(
560  FilterType::MDID,
561  '13'
562  );
563  $data_column = $parser->addPathAndGetColumn(
564  $this->getPath(
565  $this->getTag('table1', '', '', 'step1'),
566  $this->getTag('table1', '', '', 'step2', DataType::STRING, $filter),
567  $this->getTag('table2', 'table1', '', 'step3'),
568  $this->getTag('table2', 'table1', 'data', 'step4')
569  ),
570  false
571  );
572 
573  $this->assertSame(
574  'SELECT ~identifier:p1t1~.rbac_id, ~identifier:p1t1~.obj_id, ~identifier:p1t1~.obj_type ' .
575  'FROM ~identifier:table1_name~ AS ~identifier:p1t1~ JOIN ' .
576  '~identifier:table2_name~ AS ~identifier:p1t2~ ON ' .
577  '~identifier:p1t1~.~identifier:table1_id~ IN (~int:13~) AND ' .
578  '~identifier:p1t1~.rbac_id = ~identifier:p1t2~.rbac_id AND ' .
579  '~identifier:p1t1~.obj_id = ~identifier:p1t2~.obj_id AND ' .
580  '~identifier:p1t1~.obj_type = ~identifier:p1t2~.obj_type AND ' .
581  'p1t1.~identifier:table1_id~ = ~identifier:p1t2~.parent_id AND ' .
582  '~text:table1~ = ~identifier:p1t2~.parent_type',
583  $parser->getSelectForQuery()
584  );
585  }
586 
588  {
589  $parser = $this->getDatabasePathsParser();
590  $filter = $this->getPathFilter(
592  'some data'
593  );
594  $data_column = $parser->addPathAndGetColumn(
595  $this->getPath(
596  $this->getTag('table1', '', '', 'step1'),
597  $this->getTag('table1', '', 'filter_data', 'step2', DataType::STRING, $filter),
598  $this->getTag('table2', 'table1', '', 'step3'),
599  $this->getTag('table2', 'table1', 'data', 'step4')
600  ),
601  false
602  );
603 
604  $this->assertSame(
605  'SELECT ~identifier:p1t1~.rbac_id, ~identifier:p1t1~.obj_id, ~identifier:p1t1~.obj_type ' .
606  'FROM ~identifier:table1_name~ AS ~identifier:p1t1~ JOIN ' .
607  '~identifier:table2_name~ AS ~identifier:p1t2~ ON ' .
608  "COALESCE(~identifier:p1t1~.~identifier:filter_data~, '') IN (~text:some data~) AND " .
609  '~identifier:p1t1~.rbac_id = ~identifier:p1t2~.rbac_id AND ' .
610  '~identifier:p1t1~.obj_id = ~identifier:p1t2~.obj_id AND ' .
611  '~identifier:p1t1~.obj_type = ~identifier:p1t2~.obj_type AND ' .
612  'p1t1.~identifier:table1_id~ = ~identifier:p1t2~.parent_id AND ' .
613  '~text:table1~ = ~identifier:p1t2~.parent_type',
614  $parser->getSelectForQuery()
615  );
616  }
617 
619  {
620  $parser = $this->getDatabasePathsParser();
621  $filter = $this->getPathFilter(
622  FilterType::INDEX,
623  '2'
624  );
625  $data_column = $parser->addPathAndGetColumn(
626  $this->getPath(
627  $this->getTag('table1', '', '', 'step1'),
628  $this->getTag('table1', '', '', 'step2', DataType::STRING, $filter),
629  $this->getTag('table2', 'table1', '', 'step3'),
630  $this->getTag('table2', 'table1', 'data', 'step4')
631  ),
632  false
633  );
634 
635  $this->assertSame(
636  'SELECT ~identifier:p1t1~.rbac_id, ~identifier:p1t1~.obj_id, ~identifier:p1t1~.obj_type ' .
637  'FROM ~identifier:table1_name~ AS ~identifier:p1t1~ JOIN ' .
638  '~identifier:table2_name~ AS ~identifier:p1t2~ ON ' .
639  '~identifier:p1t1~.rbac_id = ~identifier:p1t2~.rbac_id AND ' .
640  '~identifier:p1t1~.obj_id = ~identifier:p1t2~.obj_id AND ' .
641  '~identifier:p1t1~.obj_type = ~identifier:p1t2~.obj_type AND ' .
642  'p1t1.~identifier:table1_id~ = ~identifier:p1t2~.parent_id AND ' .
643  '~text:table1~ = ~identifier:p1t2~.parent_type',
644  $parser->getSelectForQuery()
645  );
646  }
647 
649  {
650  $parser = $this->getDatabasePathsParser();
651  $filter = $this->getPathFilter(
653  'some data',
654  'some other data',
655  'more'
656  );
657  $data_column = $parser->addPathAndGetColumn(
658  $this->getPath(
659  $this->getTag('table1', '', '', 'step1'),
660  $this->getTag('table1', '', 'filter_data', 'step2', DataType::STRING, $filter),
661  $this->getTag('table2', 'table1', '', 'step3'),
662  $this->getTag('table2', 'table1', 'data', 'step4')
663  ),
664  false
665  );
666 
667  $this->assertSame(
668  'SELECT ~identifier:p1t1~.rbac_id, ~identifier:p1t1~.obj_id, ~identifier:p1t1~.obj_type ' .
669  'FROM ~identifier:table1_name~ AS ~identifier:p1t1~ JOIN ' .
670  '~identifier:table2_name~ AS ~identifier:p1t2~ ON ' .
671  "COALESCE(~identifier:p1t1~.~identifier:filter_data~, '') " .
672  'IN (~text:some data~, ~text:some other data~, ~text:more~) AND ' .
673  '~identifier:p1t1~.rbac_id = ~identifier:p1t2~.rbac_id AND ' .
674  '~identifier:p1t1~.obj_id = ~identifier:p1t2~.obj_id AND ' .
675  '~identifier:p1t1~.obj_type = ~identifier:p1t2~.obj_type AND ' .
676  'p1t1.~identifier:table1_id~ = ~identifier:p1t2~.parent_id AND ' .
677  '~text:table1~ = ~identifier:p1t2~.parent_type',
678  $parser->getSelectForQuery()
679  );
680  }
681 
683  {
684  $parser = $this->getDatabasePathsParser();
685  $filter = $this->getPathFilter(
687  'some data'
688  );
689  $data_column = $parser->addPathAndGetColumn(
690  $this->getPath(
691  $this->getTag('table', '', 'filter_data', 'step1', DataType::STRING, $filter),
692  $this->getTag('table', '', 'data', 'step2'),
693  ),
694  false
695  );
696 
697  $this->assertSame(
698  'SELECT ~identifier:p1t1~.rbac_id, ~identifier:p1t1~.obj_id, ~identifier:p1t1~.obj_type ' .
699  'FROM ~identifier:table_name~ AS ~identifier:p1t1~ WHERE ' .
700  "COALESCE(~identifier:p1t1~.~identifier:filter_data~, '') IN (~text:some data~)",
701  $parser->getSelectForQuery()
702  );
703  }
704 
706  {
707  $parser = $this->getDatabasePathsParser();
708  $filter = $this->getPathFilter(
710  'some data'
711  );
712  $data_column_1 = $parser->addPathAndGetColumn(
713  $this->getPath(
714  $this->getTag('table', '', 'filter_data', 'step1', DataType::STRING, $filter),
715  $this->getTag('table', '', 'data', 'step2'),
716  ),
717  false
718  );
719  $data_column_2 = $parser->addPathAndGetColumn(
720  $this->getPath(
721  $this->getTag('table1', '', '', 'step1'),
722  $this->getTag('table1', '', 'data2', 'step2'),
723  ),
724  false
725  );
726 
727  $this->assertSame(
728  'SELECT ~identifier:base~.rbac_id, ~identifier:base~.obj_id, ~identifier:base~.obj_type ' .
729  'FROM il_meta_general AS base LEFT JOIN (' .
730  '~identifier:table_name~ AS ~identifier:p1t1~) ON ' .
731  '~identifier:base~.rbac_id = ~identifier:p1t1~.rbac_id AND ' .
732  '~identifier:base~.obj_id = ~identifier:p1t1~.obj_id AND ' .
733  '~identifier:base~.obj_type = ~identifier:p1t1~.obj_type AND ' .
734  "COALESCE(~identifier:p1t1~.~identifier:filter_data~, '') IN (~text:some data~) LEFT JOIN " .
735  '(~identifier:table1_name~ AS ~identifier:p2t1~) ON ' .
736  '~identifier:base~.rbac_id = ~identifier:p2t1~.rbac_id AND ' .
737  '~identifier:base~.obj_id = ~identifier:p2t1~.obj_id AND ' .
738  '~identifier:base~.obj_type = ~identifier:p2t1~.obj_type',
739  $parser->getSelectForQuery()
740  );
741  }
742 }
steps()
Get all steps in the path.
FilterType
Values should always be all lowercase.
Definition: FilterType.php:26
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
StepToken
The string representation of these tokens must not occur as names of metadata elements.
Definition: StepToken.php:27
getTag(string $table, string $parent, string $data_field, string|StepToken $step_name, DataType $data_type=DataType::STRING, PathFilter ... $filters,)
To build mock-paths I start from the tags I want the mock-dictionary to return at that step...