ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilStudyProgrammeTypeSettingsTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
25  private const VALID_TYPE_1 = 11;
26  private const VALID_TYPE_2 = 22;
27 
28  public function testSuccessCreate(): void
29  {
30  $obj = new ilStudyProgrammeTypeSettings(self::VALID_TYPE_1);
31 
32  $this->assertEquals(self::VALID_TYPE_1, $obj->getTypeId());
33  }
34 
35  public function testSuccessfulWithTypeId(): void
36  {
37  $obj = new ilStudyProgrammeTypeSettings(self::VALID_TYPE_1);
38 
39  $new = $obj->withTypeId(self::VALID_TYPE_2);
40 
41  $this->assertEquals(self::VALID_TYPE_1, $obj->getTypeId());
42  $this->assertEquals(self::VALID_TYPE_2, $new->getTypeId());
43  }
44 
45  public function testToFormInput(): void
46  {
47  $lng = $this->createMock(ilLanguage::class);
48  $df = new ILIAS\Data\Factory();
50 
52  $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
53  new ILIAS\UI\Implementation\Component\SignalGenerator(),
54  $df,
55  $refinery,
56  $lng
57  );
58 
59  $obj = new ilStudyProgrammeTypeSettings(self::VALID_TYPE_1);
60 
61  $lng_consecutive_calls = [];
62  $lng->expects($this->atLeastOnce())
63  ->method('txt')
64  ->willReturnCallback(
65  function ($txt) use (&$lng_consecutive_calls) {
66  $lng_consecutive_calls[] = $txt;
67  return $txt;
68  }
69  );
70 
71  $expected_consecutive_calls = [
72  'type',
73  'prg_type_byline',
74  'prg_type',
75  ];
76 
77  $field = $obj->toFormInput(
78  $f,
79  $lng,
80  $refinery,
81  [
82  self::VALID_TYPE_1 => 'first',
83  self::VALID_TYPE_2 => 'second'
84  ]
85  );
86 
87  $this->assertEquals($expected_consecutive_calls, $lng_consecutive_calls);
88 
90  $select = $field->getInputs()['type'];
91 
92  $this->assertInstanceOf(
93  ILIAS\UI\Implementation\Component\Input\Field\Select::class,
94  $select
95  );
96  $this->assertEquals(self::VALID_TYPE_1, $select->getValue());
97  }
98 }
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$txt
Definition: error.php:31
global $lng
Definition: privfeed.php:31