ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCertificateSettingsCourseFormRepositoryTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
26  public function testSaveSettings(): void
27  {
28  $object = $this->getMockBuilder(ilObjCourse::class)
29  ->disableOriginalConstructor()
30  ->getMock();
31 
32  $object
33  ->expects($this->atLeastOnce())
34  ->method('getId')
35  ->willReturn(100);
36 
37  $language = $this->getMockBuilder(ilLanguage::class)
38  ->disableOriginalConstructor()
39  ->getMock();
40 
41  $controller = $this->getMockBuilder(ilCtrlInterface::class)
42  ->disableOriginalConstructor()
43  ->getMock();
44 
45  $access = $this->getMockBuilder(ilAccess::class)
46  ->disableOriginalConstructor()
47  ->getMock();
48 
49  $toolbar = $this->getMockBuilder(ilToolbarGUI::class)
50  ->disableOriginalConstructor()
51  ->getMock();
52 
53  $placeholderDescriptionObject = $this->getMockBuilder(ilCertificatePlaceholderDescription::class)
54  ->disableOriginalConstructor()
55  ->getMock();
56 
57  $leaningProgressObject = $this->getMockBuilder(ilObjectLP::class)
58  ->disableOriginalConstructor()
59  ->getMock();
60 
61  $settingsFormFactory = $this->getMockBuilder(ilCertificateSettingsFormRepository::class)
62  ->disableOriginalConstructor()
63  ->getMock();
64 
65  $trackingHelper = $this->getMockBuilder(ilCertificateObjUserTrackingHelper::class)
66  ->disableOriginalConstructor()
67  ->getMock();
68 
69  $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
70  ->disableOriginalConstructor()
71  ->getMock();
72 
73  $lpHelper = $this->getMockBuilder(ilCertificateObjectLPHelper::class)
74  ->disableOriginalConstructor()
75  ->getMock();
76 
77  $lpMock = $this->getMockBuilder(ilObjectLP::class)
78  ->disableOriginalConstructor()
79  ->getMock();
80 
81  $lpMock->method('getCurrentMode')
82  ->willReturn(100);
83 
84  $lpHelper->method('getInstance')->willReturn($lpMock);
85 
86  $tree = $this->getMockBuilder(ilTree::class)
87  ->disableOriginalConstructor()
88  ->getMock();
89 
90  $setting = $this->getMockBuilder(ilSetting::class)
91  ->disableOriginalConstructor()
92  ->getMock();
93 
94  $setting
95  ->expects($this->atLeastOnce())
96  ->method('set');
97 
99  $object,
100  '/some/where',
101  false,
102  $language,
103  $controller,
104  $access,
105  $toolbar,
106  $placeholderDescriptionObject,
107  $leaningProgressObject,
108  $settingsFormFactory,
109  $trackingHelper,
110  $objectHelper,
111  $lpHelper,
112  $tree,
113  $setting
114  );
115 
116  $repository->save(['subitems' => [1, 2, 3]]);
117  }
118 
119  public function testFetchFormFieldData(): void
120  {
121  $object = $this->getMockBuilder(ilObjCourse::class)
122  ->disableOriginalConstructor()
123  ->getMock();
124 
125  $object
126  ->expects($this->atLeastOnce())
127  ->method('getId')
128  ->willReturn(100);
129 
130  $language = $this->getMockBuilder(ilLanguage::class)
131  ->disableOriginalConstructor()
132  ->getMock();
133 
134  $controller = $this->getMockBuilder(ilCtrlInterface::class)
135  ->disableOriginalConstructor()
136  ->getMock();
137 
138  $access = $this->getMockBuilder(ilAccess::class)
139  ->disableOriginalConstructor()
140  ->getMock();
141 
142  $toolbar = $this->getMockBuilder(ilToolbarGUI::class)
143  ->disableOriginalConstructor()
144  ->getMock();
145 
146  $placeholderDescriptionObject = $this->getMockBuilder(ilCertificatePlaceholderDescription::class)
147  ->disableOriginalConstructor()
148  ->getMock();
149 
150  $leaningProgressObject = $this->getMockBuilder(ilObjectLP::class)
151  ->disableOriginalConstructor()
152  ->getMock();
153 
154  $settingsFormFactory = $this->getMockBuilder(ilCertificateSettingsFormRepository::class)
155  ->disableOriginalConstructor()
156  ->getMock();
157 
158  $settingsFormFactory
159  ->expects($this->atLeastOnce())
160  ->method('fetchFormFieldData')
161  ->willReturn(
162  [
163  'subitems' => [],
164  'something_else' => 'something'
165  ]
166  );
167 
168  $trackingHelper = $this->getMockBuilder(ilCertificateObjUserTrackingHelper::class)
169  ->disableOriginalConstructor()
170  ->getMock();
171 
172  $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
173  ->disableOriginalConstructor()
174  ->getMock();
175 
176  $lpHelper = $this->getMockBuilder(ilCertificateObjectLPHelper::class)
177  ->disableOriginalConstructor()
178  ->getMock();
179 
180  $tree = $this->getMockBuilder(ilTree::class)
181  ->disableOriginalConstructor()
182  ->getMock();
183 
184  $setting = $this->getMockBuilder(ilSetting::class)
185  ->disableOriginalConstructor()
186  ->getMock();
187 
188  $setting
189  ->expects($this->atLeastOnce())
190  ->method('get')
191  ->willReturn('[1, 2, 3]');
192 
194  $object,
195  '/some/where',
196  false,
197  $language,
198  $controller,
199  $access,
200  $toolbar,
201  $placeholderDescriptionObject,
202  $leaningProgressObject,
203  $settingsFormFactory,
204  $trackingHelper,
205  $objectHelper,
206  $lpHelper,
207  $tree,
208  $setting
209  );
210 
211  $result = $repository->fetchFormFieldData('Some Content');
212 
213  $this->assertSame(
214  [
215  'subitems' => [1, 2, 3],
216  'something_else' => 'something'
217  ],
218  $result
219  );
220  }
221 }
Class ilCertificateBaseTestCase.