ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ViewControlInputGenericTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 use ILIAS\Data;
28 
29 require_once('ViewControlBaseTest.php');
30 
32 {
33  protected function getViewControl(): Control\ViewControlInput
34  {
35  return new class (
36  $this->buildDataFactory(),
37  $this->buildRefinery(),
38  ''
39  ) extends Control\ViewControlInput {
40  public function isClientSideValueOk($value): bool
41  {
42  return true;
43  }
44  protected function getDefaultValue(): string
45  {
46  return 'default';
47  }
48  };
49  }
50 
51  public function testViewControlSortationMutators(): void
52  {
53  $vc = $this->getViewControl();
54  $v = 'some value';
55  $l = 'some label';
56  $s = (new SignalGenerator())->create();
57  $this->assertEquals($v, $vc->withValue($v)->getValue());
58  $this->assertEquals($s, $vc->withOnChange($s)->getOnChangeSignal());
59  }
60 
61  public function testViewControlWithInput(): void
62  {
63  $v = 'some input value';
64 
65  $input = $this->createMock(InputData::class);
66  $input->expects($this->exactly(2))
67  ->method("getOr")
68  ->willReturn($v);
69 
70  $vc = $this->getViewControl()
71  ->withNameFrom($this->getNamesource())
72  ->withInput($input);
73 
74  $df = $this->buildDataFactory();
75  $this->assertEquals(
76  $df->ok($v),
77  $vc->getContent()
78  );
79  $this->assertEquals($v, $vc->getValue());
80 
81  $transform = $this->buildRefinery()->custom()->transformation(
82  fn ($v) => ['mod' => $v]
83  );
84  $vc = $vc->withAdditionalTransformation($transform);
85  $this->assertEquals(
86  ['mod' => $v],
87  $vc->withInput($input)->getContent()->value()
88  );
89  }
90 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21