ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilStudyProgrammeTypeInfoTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
25  private const VALID_TITLE_1 = 'Title 1';
26  private const VALID_TITLE_2 = 'Title 2';
27  private const VALID_TITLE_N = null;
28  private const VALID_DESCRIPTION_1 = 'Description 1';
29  private const VALID_DESCRIPTION_2 = 'Description 2';
30  private const VALID_DESCRIPTION_N = null;
31  private const VALID_LNG_CODE_1 = 'de';
32  private const VALID_LNG_CODE_2 = 'en';
33  private const VALID_LNG_CODE_N = null;
34 
35  public function testSuccessCreate(): void
36  {
37  $obj = new ilStudyProgrammeTypeInfo();
38 
39  $this->assertNull($obj->getTitle());
40  $this->assertNull($obj->getDescription());
41  $this->assertNull($obj->getLanguageCode());
42 
43  $obj = new ilStudyProgrammeTypeInfo(
44  self::VALID_TITLE_N,
45  self::VALID_DESCRIPTION_N,
46  self::VALID_LNG_CODE_N
47  );
48 
49  $this->assertNull($obj->getTitle());
50  $this->assertNull($obj->getDescription());
51  $this->assertNull($obj->getLanguageCode());
52 
53  $obj = new ilStudyProgrammeTypeInfo(
54  self::VALID_TITLE_1,
55  self::VALID_DESCRIPTION_1,
56  self::VALID_LNG_CODE_1
57  );
58 
59  $this->assertEquals(self::VALID_TITLE_1, $obj->getTitle());
60  $this->assertEquals(self::VALID_DESCRIPTION_1, $obj->getDescription());
61  $this->assertEquals(self::VALID_LNG_CODE_1, $obj->getLanguageCode());
62  }
63 
64  public function testSuccessfulWithTitle(): void
65  {
66  $obj = new ilStudyProgrammeTypeInfo(
67  self::VALID_TITLE_1,
68  self::VALID_DESCRIPTION_1,
69  self::VALID_LNG_CODE_1
70  );
71 
72  $new = $obj->withTitle(self::VALID_TITLE_2);
73 
74  $this->assertEquals(self::VALID_TITLE_1, $obj->getTitle());
75  $this->assertEquals(self::VALID_DESCRIPTION_1, $obj->getDescription());
76  $this->assertEquals(self::VALID_LNG_CODE_1, $obj->getLanguageCode());
77 
78  $this->assertEquals(self::VALID_TITLE_2, $new->getTitle());
79  $this->assertEquals(self::VALID_DESCRIPTION_1, $new->getDescription());
80  $this->assertEquals(self::VALID_LNG_CODE_1, $new->getLanguageCode());
81  }
82 
83  public function testSuccessfulWithDescription(): void
84  {
85  $obj = new ilStudyProgrammeTypeInfo(
86  self::VALID_TITLE_1,
87  self::VALID_DESCRIPTION_1,
88  self::VALID_LNG_CODE_1
89  );
90 
91  $new = $obj->withDescription(self::VALID_DESCRIPTION_2);
92 
93  $this->assertEquals(self::VALID_TITLE_1, $obj->getTitle());
94  $this->assertEquals(self::VALID_DESCRIPTION_1, $obj->getDescription());
95  $this->assertEquals(self::VALID_LNG_CODE_1, $obj->getLanguageCode());
96 
97  $this->assertEquals(self::VALID_TITLE_1, $new->getTitle());
98  $this->assertEquals(self::VALID_DESCRIPTION_2, $new->getDescription());
99  $this->assertEquals(self::VALID_LNG_CODE_1, $new->getLanguageCode());
100  }
101 
102  public function testSuccessfulWithLanguageCode(): void
103  {
104  $obj = new ilStudyProgrammeTypeInfo(
105  self::VALID_TITLE_1,
106  self::VALID_DESCRIPTION_1,
107  self::VALID_LNG_CODE_1
108  );
109 
110  $new = $obj->withLanguageCode(self::VALID_LNG_CODE_2);
111 
112  $this->assertEquals(self::VALID_TITLE_1, $obj->getTitle());
113  $this->assertEquals(self::VALID_DESCRIPTION_1, $obj->getDescription());
114  $this->assertEquals(self::VALID_LNG_CODE_1, $obj->getLanguageCode());
115 
116  $this->assertEquals(self::VALID_TITLE_1, $new->getTitle());
117  $this->assertEquals(self::VALID_DESCRIPTION_1, $new->getDescription());
118  $this->assertEquals(self::VALID_LNG_CODE_2, $new->getLanguageCode());
119  }
120 
121 
122  public function testToFormInput(): void
123  {
124  $lng = $this->createMock(ilLanguage::class);
125  $df = new ILIAS\Data\Factory();
127 
129  $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
130  new ILIAS\UI\Implementation\Component\SignalGenerator(),
131  $df,
132  $refinery,
133  $lng
134  );
135 
136  $obj = new ilStudyProgrammeTypeInfo(
137  self::VALID_TITLE_1,
138  self::VALID_DESCRIPTION_1,
139  self::VALID_LNG_CODE_1
140  );
141 
142  $lng_consecutive_calls = [];
143  $lng->expects($this->atLeastOnce())
144  ->method('txt')
145  ->willReturnCallback(
146  function ($txt) use (&$lng_consecutive_calls) {
147  $lng_consecutive_calls[] = $txt;
148  return $txt;
149  }
150  );
151 
152  $expected_consecutive_calls = [
153  'title',
154  'description',
155  'meta_l_de',
156  ];
157 
158  $field = $obj->toFormInput(
159  $f,
160  $lng,
161  $refinery
162  );
163 
164  $this->assertEquals($expected_consecutive_calls, $lng_consecutive_calls);
165 
167  $text = $field->getInputs()['title'];
168 
169  $this->assertInstanceOf(
170  ILIAS\UI\Implementation\Component\Input\Field\Text::class,
171  $text
172  );
173 
175  $textarea = $field->getInputs()['description'];
176 
177  $this->assertInstanceOf(
178  ILIAS\UI\Implementation\Component\Input\Field\Textarea::class,
179  $textarea
180  );
181  }
182 }
Interface Observer Contains several chained tasks and infos about them.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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