ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilStudyProgrammeTypeSettingsTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
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\Field\Node\Factory::class),
53 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
54 new ILIAS\UI\Implementation\Component\SignalGenerator(),
55 $df,
57 $lng
58 );
59
60 $obj = new ilStudyProgrammeTypeSettings(self::VALID_TYPE_1);
61
62 $lng_consecutive_calls = [];
63 $lng->expects($this->atLeastOnce())
64 ->method('txt')
65 ->willReturnCallback(
66 function ($txt) use (&$lng_consecutive_calls) {
67 $lng_consecutive_calls[] = $txt;
68 return $txt;
69 }
70 );
71
72 $expected_consecutive_calls = [
73 'type',
74 'prg_type_byline',
75 'prg_type',
76 ];
77
78 $field = $obj->toFormInput(
79 $f,
80 $lng,
82 [
83 self::VALID_TYPE_1 => 'first',
84 self::VALID_TYPE_2 => 'second'
85 ]
86 );
87
88 $this->assertEquals($expected_consecutive_calls, $lng_consecutive_calls);
89
91 $select = $field->getInputs()['type'];
92
93 $this->assertInstanceOf(
94 ILIAS\UI\Implementation\Component\Input\Field\Select::class,
95 $select
96 );
97 $this->assertEquals(self::VALID_TYPE_1, $select->getValue());
98 }
99}
Factory for Date Formats.
Definition: Factory.php:27
Builds data types.
Definition: Factory.php:36
$txt
Definition: error.php:31
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:31