ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilModulesOrgUnitTypeTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 
27 {
28  public function __construct(
29  protected ILIAS\Refinery\Factory $refinery,
30  protected ILIAS\UI\Factory $ui_factory,
31  protected ilLanguage $lng,
32  ) {
33  $this->lng = $lng;
34  }
35 
36  public function mockGetAmdForm(array $available_records, ilOrgUnitType $type): StandardForm
37  {
38  return $this->getAmdForm('#', $available_records, $type);
39  }
40 }
41 
43 {
44  public function getRefinery(): \ILIAS\Refinery\Factory
45  {
46  $data_factory = new \ILIAS\Data\Factory();
47  $language = $this->createMock(ilLanguage::class);
48  $refinery = new \ILIAS\Refinery\Factory($data_factory, $language);
49  return $refinery;
50  }
51 
52  public function getUIFactory(): NoUIFactory
53  {
54  $node_factory = $this->createMock(\ILIAS\UI\Implementation\Component\Input\Field\Node\Factory::class);
55  $language = $this->createMock(ilLanguage::class);
56  $filter_factory = $this->createMock(Component\Input\Container\Filter\Factory::class);
57  $view_control_factory = $this->createMock(Component\Input\Container\ViewControl\Factory::class);
58  $control_factory = $this->createMock(Component\Input\ViewControl\Factory::class);
59  $upload_limit_resolver = $this->createMock(Component\Input\UploadLimitResolver::class);
60  $refinery = $this->getRefinery();
61 
62  $factory = new class (
63  $node_factory,
64  $language,
65  $filter_factory,
66  $view_control_factory,
67  $control_factory,
68  $upload_limit_resolver,
69  $refinery
70  ) extends NoUIFactory {
71  public function __construct(
72  protected $node_factory,
73  protected $language,
74  protected $filter_factory,
75  protected $view_control_factory,
76  protected $control_factory,
77  protected $upload_limit_resolver,
78  protected $refinery
79  ) {
80  }
81 
82  public function input(): Component\Input\Factory
83  {
84  $signal_generator = new Component\SignalGenerator();
85  $data_factory = new \ILIAS\Data\Factory();
86 
87  $field_factory = new Component\Input\Field\Factory(
88  $this->node_factory,
89  $this->upload_limit_resolver,
90  $signal_generator,
92  $this->refinery,
93  $this->language
94  );
95 
96  $form_factory = new Component\Input\Container\Form\Factory(
97  $field_factory,
98  $signal_generator
99  );
100  $container_factory = new Component\Input\Container\Factory(
101  $form_factory,
102  $this->filter_factory,
103  $this->view_control_factory
104  );
105 
106  return new Component\Input\Factory(
107  $signal_generator,
108  $field_factory,
109  $container_factory,
110  $this->control_factory,
111  );
112  }
113  };
114  return $factory;
115  }
116 
117  public function testOrgUnitTypeGuiAMDForm(): void
118  {
119  $amdr1 = $this->createMock(ilAdvancedMDRecord::class);
120  $amdr1
121  ->method('getRecordId')
122  ->willReturn(1);
123  $amdr1
124  ->method('getTitle')
125  ->willReturn('title 1');
126 
127  $amdr2 = $this->createMock(ilAdvancedMDRecord::class);
128  $amdr2
129  ->method('getRecordId')
130  ->willReturn(2);
131  $amdr2
132  ->method('getTitle')
133  ->willReturn('title 2');
134 
135  $type = $this->createMock(ilOrgUnitType::class);
136  $type
137  ->method('getAssignedAdvancedMDRecordIds')
138  ->willReturn([1]);
139 
140  $gui = new mock_ilOrgUnitTypeGUI(
141  $this->getRefinery(),
142  $this->getUIFactory(),
143  $this->createMock(ilLanguage::class)
144  );
145 
146  $form = $gui->mockGetAmdForm([$amdr1, $amdr2], $type);
147  $this->assertInstanceOf(StandardForm::class, $form);
148 
149  $section = current($form->getInputs());
150  $this->assertInstanceOf(Section::class, $section);
151 
152  $inputs = $section->getInputs();
153  $this->assertEquals(1, count($inputs));
154  $this->assertEquals(
155  [
156  1 => 'title 1',
157  2 => 'title 2',
158  ],
159  current($inputs)->getOptions()
160  );
161  }
162 }
__construct(protected ILIAS\Refinery\Factory $refinery, protected ILIAS\UI\Factory $ui_factory, protected ilLanguage $lng,)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer Contains several chained tasks and infos about them.
mockGetAmdForm(array $available_records, ilOrgUnitType $type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAmdForm(string $action, array $available_records, ilOrgUnitType $type)
Class ilOrgUnitTypeGUI.
language()
description: > Example for rendring a language glyph.
Definition: language.php:41