ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCertificateSettingsScormFormRepositoryTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
25  public function testSave(): void
26  {
27  $object = $this->getMockBuilder(ilObject::class)
28  ->disableOriginalConstructor()
29  ->getMock();
30 
31  $language = $this->getMockBuilder(ilLanguage::class)
32  ->disableOriginalConstructor()
33  ->getMock();
34 
35  $controller = $this->getMockBuilder(ilCtrlInterface::class)
36  ->disableOriginalConstructor()
37  ->getMock();
38 
39  $access = $this->getMockBuilder(ilAccess::class)
40  ->disableOriginalConstructor()
41  ->getMock();
42 
43  $toolbar = $this->getMockBuilder(ilToolbarGUI::class)
44  ->disableOriginalConstructor()
45  ->getMock();
46 
47  $placeholderDescriptionObject = $this->getMockBuilder(ilCertificatePlaceholderDescription::class)
48  ->disableOriginalConstructor()
49  ->getMock();
50 
51  $settingFormRepository = $this->getMockBuilder(ilCertificateSettingsFormRepository::class)
52  ->disableOriginalConstructor()
53  ->getMock();
54 
55  $setting = $this->getMockBuilder(ilSetting::class)
56  ->disableOriginalConstructor()
57  ->getMock();
58 
59  $setting
60  ->expects($this->exactly(2))
61  ->method('set');
62 
64  $object,
65  '/some/where/',
66  false,
67  $language,
68  $controller,
69  $access,
70  $toolbar,
71  $placeholderDescriptionObject,
72  $settingFormRepository,
73  $setting
74  );
75 
76  $repository->save(
77  [
78  'certificate_enabled_scorm' => true,
79  'short_name' => 'something'
80  ]
81  );
82  }
83 
84  public function testFetchFormFieldData(): void
85  {
86  $object = $this->getMockBuilder(ilObject::class)
87  ->disableOriginalConstructor()
88  ->getMock();
89 
90  $language = $this->getMockBuilder(ilLanguage::class)
91  ->disableOriginalConstructor()
92  ->getMock();
93 
94  $controller = $this->getMockBuilder(ilCtrlInterface::class)
95  ->disableOriginalConstructor()
96  ->getMock();
97 
98  $access = $this->getMockBuilder(ilAccess::class)
99  ->disableOriginalConstructor()
100  ->getMock();
101 
102  $toolbar = $this->getMockBuilder(ilToolbarGUI::class)
103  ->disableOriginalConstructor()
104  ->getMock();
105 
106  $placeholderDescriptionObject = $this->getMockBuilder(ilCertificatePlaceholderDescription::class)
107  ->disableOriginalConstructor()
108  ->getMock();
109 
110  $settingFormRepository = $this->getMockBuilder(ilCertificateSettingsFormRepository::class)
111  ->disableOriginalConstructor()
112  ->getMock();
113 
114  $settingFormRepository
115  ->expects($this->once())
116  ->method('fetchFormFieldData')
117  ->willReturn(
118  [
119  'certificate_enabled_scorm' => '',
120  'short_name' => ''
121  ]
122  );
123 
124  $setting = $this->getMockBuilder(ilSetting::class)
125  ->disableOriginalConstructor()
126  ->getMock();
127 
128  $setting
129  ->expects($this->exactly(2))
130  ->method('get')
131  ->willReturnOnConsecutiveCalls('something', 'somethingelse');
132 
134  $object,
135  '/some/where/',
136  false,
137  $language,
138  $controller,
139  $access,
140  $toolbar,
141  $placeholderDescriptionObject,
142  $settingFormRepository,
143  $setting
144  );
145 
146  $result = $repository->fetchFormFieldData('Some Content');
147 
148  $this->assertSame(
149  [
150  'certificate_enabled_scorm' => 'something',
151  'short_name' => 'somethingelse'
152  ],
153  $result
154  );
155  }
156 }