ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\MetaData\Services\Paths\BuilderTest Class Reference
+ Inheritance diagram for ILIAS\MetaData\Services\Paths\BuilderTest:
+ Collaboration diagram for ILIAS\MetaData\Services\Paths\BuilderTest:

Public Member Functions

 testWithNextStep ()
 
 testWithNextStepToSuperElement ()
 
 testWithAdditionalFilterAtCurrentStep ()
 
 testWithAdditionalFilterAtCurrentStepEmptyPathException ()
 
 testGet ()
 
 testGetException ()
 

Protected Member Functions

 getBuilder ()
 Builder will throw an exception on get if the path contains a step with name INVALID. More...
 

Detailed Description

Definition at line 31 of file BuilderTest.php.

Member Function Documentation

◆ getBuilder()

ILIAS\MetaData\Services\Paths\BuilderTest::getBuilder ( )
protected

Builder will throw an exception on get if the path contains a step with name INVALID.

Definition at line 37 of file BuilderTest.php.

References $path, ILIAS\MetaData\Services\Paths\Paths\__construct(), and ILIAS\GlobalScreen\Provider\__construct().

Referenced by ILIAS\MetaData\Services\Paths\BuilderTest\testGet(), ILIAS\MetaData\Services\Paths\BuilderTest\testGetException(), ILIAS\MetaData\Services\Paths\BuilderTest\testWithAdditionalFilterAtCurrentStep(), ILIAS\MetaData\Services\Paths\BuilderTest\testWithAdditionalFilterAtCurrentStepEmptyPathException(), ILIAS\MetaData\Services\Paths\BuilderTest\testWithNextStep(), and ILIAS\MetaData\Services\Paths\BuilderTest\testWithNextStepToSuperElement().

37  : Builder
38  {
39  $internal_builder = new class ('') extends NullInternalBuilder {
40  public function __construct(public string $path)
41  {
42  }
43 
44  public function withNextStep(string $name, bool $add_as_first = false): BuilderInterface
45  {
46  return new self($this->path . ':' . $name);
47  }
48 
49  public function withNextStepToSuperElement(bool $add_as_first = false): BuilderInterface
50  {
51  return new self($this->path . ':^');
52  }
53 
54  public function withAdditionalFilterAtCurrentStep(
55  FilterType $type,
56  string ...$values
57  ): BuilderInterface {
58  if ($this->path === '') {
59  throw new \ilMDPathException('failed');
60  }
61 
62  $filter = '{' . $type->value . ';' . implode(',', $values) . '}';
63  return new self($this->path . $filter);
64  }
65 
66  public function get(): PathInterface
67  {
68  if (str_contains($this->path, ':INVALID')) {
69  throw new \ilMDPathException('failed');
70  }
71 
72  return new class ($this->path) extends NullPath {
73  public function __construct(public string $path_string)
74  {
75  }
76  };
77  }
78  };
79 
80  return new class ($internal_builder) extends Builder {
81  public function __construct(BuilderInterface $internal_builder)
82  {
83  parent::__construct($internal_builder);
84  }
85 
86  public function exposePath(): string
87  {
88  return $this->internal_builder->path;
89  }
90  };
91  }
FilterType
Values should always be all lowercase.
Definition: FilterType.php:26
$path
Definition: ltiservices.php:29
__construct(PathFactory $path_factory)
Definition: Paths.php:31
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testGet()

ILIAS\MetaData\Services\Paths\BuilderTest::testGet ( )

Definition at line 147 of file BuilderTest.php.

References ILIAS\MetaData\Services\Paths\BuilderTest\getBuilder().

147  : void
148  {
149  $builder = $this->getBuilder()
150  ->withNextStep('step1')
151  ->withNextStepToSuperElement()
152  ->withNextStep('step2')
153  ->withAdditionalFilterAtCurrentStep(FilterType::MDID, '12');
154  $builder3 = $builder
155  ->withNextStep('step3')
156  ->withNextStepToSuperElement();
157 
158  $this->assertSame(
159  ':step1:^:step2{id;12}',
160  $builder->get()->path_string
161  );
162  $this->assertSame(
163  ':step1:^:step2{id;12}:step3:^',
164  $builder3->get()->path_string
165  );
166  }
getBuilder()
Builder will throw an exception on get if the path contains a step with name INVALID.
Definition: BuilderTest.php:37
+ Here is the call graph for this function:

◆ testGetException()

ILIAS\MetaData\Services\Paths\BuilderTest::testGetException ( )

Definition at line 168 of file BuilderTest.php.

References ILIAS\MetaData\Services\Paths\BuilderTest\getBuilder().

168  : void
169  {
170  $builder = $this->getBuilder()->withNextStep('INVALID');
171 
172  $this->expectException(\ilMDServicesException::class);
173  $builder->get();
174  }
getBuilder()
Builder will throw an exception on get if the path contains a step with name INVALID.
Definition: BuilderTest.php:37
+ Here is the call graph for this function:

◆ testWithAdditionalFilterAtCurrentStep()

ILIAS\MetaData\Services\Paths\BuilderTest::testWithAdditionalFilterAtCurrentStep ( )

Definition at line 123 of file BuilderTest.php.

References ILIAS\MetaData\Paths\Filters\DATA, and ILIAS\MetaData\Services\Paths\BuilderTest\getBuilder().

123  : void
124  {
125  $builder = $this->getBuilder();
126  $builder1 = $builder->withNextStep('step')
127  ->withAdditionalFilterAtCurrentStep(FilterType::DATA, 'v1', 'v2');
128 
129  $this->assertSame(
130  '',
131  $builder->exposePath()
132  );
133  $this->assertSame(
134  ':step{data;v1,v2}',
135  $builder1->exposePath()
136  );
137  }
getBuilder()
Builder will throw an exception on get if the path contains a step with name INVALID.
Definition: BuilderTest.php:37
+ Here is the call graph for this function:

◆ testWithAdditionalFilterAtCurrentStepEmptyPathException()

ILIAS\MetaData\Services\Paths\BuilderTest::testWithAdditionalFilterAtCurrentStepEmptyPathException ( )

Definition at line 139 of file BuilderTest.php.

References ILIAS\MetaData\Paths\Filters\DATA, and ILIAS\MetaData\Services\Paths\BuilderTest\getBuilder().

139  : void
140  {
141  $builder = $this->getBuilder();
142 
143  $this->expectException(\ilMDServicesException::class);
144  $builder->withAdditionalFilterAtCurrentStep(FilterType::DATA);
145  }
getBuilder()
Builder will throw an exception on get if the path contains a step with name INVALID.
Definition: BuilderTest.php:37
+ Here is the call graph for this function:

◆ testWithNextStep()

ILIAS\MetaData\Services\Paths\BuilderTest::testWithNextStep ( )

Definition at line 93 of file BuilderTest.php.

References ILIAS\MetaData\Services\Paths\BuilderTest\getBuilder().

93  : void
94  {
95  $builder = $this->getBuilder();
96  $builder1 = $builder->withNextStep('step');
97 
98  $this->assertSame(
99  '',
100  $builder->exposePath()
101  );
102  $this->assertSame(
103  ':step',
104  $builder1->exposePath()
105  );
106  }
getBuilder()
Builder will throw an exception on get if the path contains a step with name INVALID.
Definition: BuilderTest.php:37
+ Here is the call graph for this function:

◆ testWithNextStepToSuperElement()

ILIAS\MetaData\Services\Paths\BuilderTest::testWithNextStepToSuperElement ( )

Definition at line 108 of file BuilderTest.php.

References ILIAS\MetaData\Services\Paths\BuilderTest\getBuilder().

108  : void
109  {
110  $builder = $this->getBuilder();
111  $builder1 = $builder->withNextStepToSuperElement();
112 
113  $this->assertSame(
114  '',
115  $builder->exposePath()
116  );
117  $this->assertSame(
118  ':^',
119  $builder1->exposePath()
120  );
121  }
getBuilder()
Builder will throw an exception on get if the path contains a step with name INVALID.
Definition: BuilderTest.php:37
+ Here is the call graph for this function:

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