ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateSettingsCourseFormRepositoryTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
9  public function testSaveSettings()
10  {
11  $object = $this->getMockBuilder('ilObject')
12  ->disableOriginalConstructor()
13  ->getMock();
14 
15  $object
16  ->expects($this->atLeastOnce())
17  ->method('getId')
18  ->willReturn(100);
19 
20  $language = $this->getMockBuilder('ilLanguage')
21  ->disableOriginalConstructor()
22  ->getMock();
23 
24  $template = $this->getMockBuilder('ilTemplate')
25  ->disableOriginalConstructor()
26  ->getMock();
27 
28  $controller = $this->getMockBuilder('ilCtrl')
29  ->disableOriginalConstructor()
30  ->getMock();
31 
32  $access = $this->getMockBuilder('ilAccess')
33  ->disableOriginalConstructor()
34  ->getMock();
35 
36  $toolbar = $this->getMockBuilder('ilToolbarGUI')
37  ->disableOriginalConstructor()
38  ->getMock();
39 
40  $placeholderDescriptionObject = $this->getMockBuilder('ilCertificatePlaceholderDescription')
41  ->disableOriginalConstructor()
42  ->getMock();
43 
44  $leaningProgressObject = $this->getMockBuilder('ilObjectLP')
45  ->disableOriginalConstructor()
46  ->getMock();
47 
48  $settingsFormFactory = $this->getMockBuilder('ilCertificateSettingsFormRepository')
49  ->disableOriginalConstructor()
50  ->getMock();
51 
52  $trackingHelper = $this->getMockBuilder('ilCertificateObjUserTrackingHelper')
53  ->disableOriginalConstructor()
54  ->getMock();
55 
56  $objectHelper = $this->getMockBuilder('ilCertificateObjectHelper')
57  ->disableOriginalConstructor()
58  ->getMock();
59 
60  $lpHelper = $this->getMockBuilder('ilCertificateObjectLPHelper')
61  ->disableOriginalConstructor()
62  ->getMock();
63 
64  $lpMock = $this->getMockBuilder('ilObjectLP')
65  ->disableOriginalConstructor()
66  ->getMock();
67 
68  $lpMock->method('getCurrentMode')
69  ->willReturn(100);
70 
71  $lpHelper->method('getInstance')->willReturn($lpMock);
72 
73  $tree = $this->getMockBuilder('ilTree')
74  ->disableOriginalConstructor()
75  ->getMock();
76 
77  $setting = $this->getMockBuilder('ilSetting')
78  ->disableOriginalConstructor()
79  ->getMock();
80 
81  $setting
82  ->expects($this->atLeastOnce())
83  ->method('set');
84 
86  $object,
87  '/some/where',
88  $language,
89  $template,
90  $controller,
91  $access,
92  $toolbar,
93  $placeholderDescriptionObject,
94  $leaningProgressObject,
95  $settingsFormFactory,
96  $trackingHelper,
97  $objectHelper,
98  $lpHelper,
99  $tree,
100  $setting
101  );
102 
103  $repository->save(array('subitems' => array(1, 2, 3)));
104  }
105 
106  public function testFetchFormFieldData()
107  {
108  $object = $this->getMockBuilder('ilObject')
109  ->disableOriginalConstructor()
110  ->getMock();
111 
112  $object
113  ->expects($this->atLeastOnce())
114  ->method('getId')
115  ->willReturn(100);
116 
117  $language = $this->getMockBuilder('ilLanguage')
118  ->disableOriginalConstructor()
119  ->getMock();
120 
121  $template = $this->getMockBuilder('ilTemplate')
122  ->disableOriginalConstructor()
123  ->getMock();
124 
125  $controller = $this->getMockBuilder('ilCtrl')
126  ->disableOriginalConstructor()
127  ->getMock();
128 
129  $access = $this->getMockBuilder('ilAccess')
130  ->disableOriginalConstructor()
131  ->getMock();
132 
133  $toolbar = $this->getMockBuilder('ilToolbarGUI')
134  ->disableOriginalConstructor()
135  ->getMock();
136 
137  $placeholderDescriptionObject = $this->getMockBuilder('ilCertificatePlaceholderDescription')
138  ->disableOriginalConstructor()
139  ->getMock();
140 
141  $leaningProgressObject = $this->getMockBuilder('ilObjectLP')
142  ->disableOriginalConstructor()
143  ->getMock();
144 
145  $settingsFormFactory = $this->getMockBuilder('ilCertificateSettingsFormRepository')
146  ->disableOriginalConstructor()
147  ->getMock();
148 
149  $settingsFormFactory
150  ->expects($this->atLeastOnce())
151  ->method('fetchFormFieldData')
152  ->willReturn(
153  array(
154  'subitems' => array(),
155  'something_else' => 'something'
156  )
157  );
158 
159  $trackingHelper = $this->getMockBuilder('ilCertificateObjUserTrackingHelper')
160  ->disableOriginalConstructor()
161  ->getMock();
162 
163  $objectHelper = $this->getMockBuilder('ilCertificateObjectHelper')
164  ->disableOriginalConstructor()
165  ->getMock();
166 
167  $lpHelper = $this->getMockBuilder('ilCertificateObjectLPHelper')
168  ->disableOriginalConstructor()
169  ->getMock();
170 
171  $tree = $this->getMockBuilder('ilTree')
172  ->disableOriginalConstructor()
173  ->getMock();
174 
175  $setting = $this->getMockBuilder('ilSetting')
176  ->disableOriginalConstructor()
177  ->getMock();
178 
179  $setting
180  ->expects($this->atLeastOnce())
181  ->method('get')
182  ->willReturn('[1, 2, 3]');
183 
185  $object,
186  '/some/where',
187  $language,
188  $template,
189  $controller,
190  $access,
191  $toolbar,
192  $placeholderDescriptionObject,
193  $leaningProgressObject,
194  $settingsFormFactory,
195  $trackingHelper,
196  $objectHelper,
197  $lpHelper,
198  $tree,
199  $setting
200  );
201 
202  $result = $repository->fetchFormFieldData('Some Content');
203 
204  $this->assertEquals(
205  array(
206  'subitems' => array(1, 2, 3),
207  'something_else' => 'something'
208  ),
209  $result
210  );
211  }
212 }
$result
$template