19 declare(strict_types=1);
36 return new class ($string) extends
NullPath {
46 public array $executed_actions = [];
48 public function __construct(
protected bool $throw_exception)
57 if ($this->throw_exception) {
58 throw new \ilMDPathException(
'failed');
61 $cloned_set = clone
$set;
62 $cloned_set->actions[] = [
63 'action' =>
'create or update',
64 'path' => $path->string,
75 if ($this->throw_exception) {
76 throw new \ilMDPathException(
'failed');
79 $cloned_set = clone
$set;
80 $cloned_set->actions[] = [
81 'action' =>
'force create',
82 'path' => $path->string,
92 $cloned_set = clone
$set;
93 $cloned_set->actions[] = [
95 'path' => $path->string
102 public array $executed_actions = [];
104 public function __construct(
protected bool $throw_exception)
110 if ($this->throw_exception) {
111 throw new \ilMDRepositoryException(
'failed');
114 $this->executed_actions[] = $set->actions;
119 public array $actions = [];
138 'action' =>
'create or update',
140 'values' => [
'value 1']
143 'action' =>
'create or update',
145 'values' => [
'value 20',
'value 21',
'value 22']
148 $manipulator1 = $manipulator->prepareCreateOrUpdate(
152 $manipulator2 = $manipulator1->prepareCreateOrUpdate(
160 $manipulator->exposeSet()->actions
164 $manipulator1->exposeSet()->actions
168 $manipulator2->exposeSet()->actions
176 $this->expectException(\ilMDServicesException::class);
177 $manipulator->prepareCreateOrUpdate($this->
getPath(
'path'));
183 'action' =>
'force create',
185 'values' => [
'value 1']
188 'action' =>
'force create',
190 'values' => [
'value 20',
'value 21',
'value 22']
193 $manipulator1 = $manipulator->prepareForceCreate(
197 $manipulator2 = $manipulator1->prepareForceCreate(
205 $manipulator->exposeSet()->actions
209 $manipulator1->exposeSet()->actions
213 $manipulator2->exposeSet()->actions
221 $this->expectException(\ilMDServicesException::class);
222 $manipulator->prepareForceCreate($this->
getPath(
'path'));
228 'action' =>
'delete',
232 'action' =>
'delete',
236 $manipulator1 = $manipulator->prepareDelete($this->
getPath($exp1[
'path']));
237 $manipulator2 = $manipulator1->prepareDelete($this->
getPath($exp2[
'path']));
242 $manipulator->exposeSet()->actions
246 $manipulator1->exposeSet()->actions
250 $manipulator2->exposeSet()->actions
257 'action' =>
'delete',
261 'action' =>
'force create',
263 'values' => [
'value 20',
'value 21',
'value 22']
266 'action' =>
'delete',
270 'action' =>
'create or update',
275 'action' =>
'force create',
277 'values' => [
'value 50',
'value 51',
'value 52']
280 'action' =>
'delete',
284 'action' =>
'create or update',
286 'values' => [
'value 7']
290 ->prepareDelete($this->
getPath($exp1[
'path']))
291 ->prepareForceCreate($this->
getPath($exp2[
'path']), ...$exp2[
'values'])
292 ->prepareDelete($this->
getPath($exp3[
'path']))
293 ->prepareCreateOrUpdate($this->
getPath($exp4[
'path']), ...$exp4[
'values']);
294 $manipulator->execute();
295 $manipulator = $manipulator
296 ->prepareForceCreate($this->
getPath($exp5[
'path']), ...$exp5[
'values'])
297 ->prepareDelete($this->
getPath($exp6[
'path']))
298 ->prepareCreateOrUpdate($this->
getPath($exp7[
'path']), ...$exp7[
'values']);
299 $manipulator->execute();
301 $executed_actions = $manipulator->exposeRepository()->executed_actions;
302 $this->assertCount(2, $executed_actions);
304 [$exp1, $exp2, $exp3, $exp4],
308 [$exp1, $exp2, $exp3, $exp4, $exp5, $exp6, $exp7],
317 $this->expectException(\ilMDServicesException::class);
318 $manipulator->execute();