ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateSettingsExerciseRepositoryTest.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 testCreate()
10  {
11  $formMock = $this->getMockBuilder('ilPropertyFormGUI')
12  ->disableOriginalConstructor()
13  ->getMock();
14 
15  $object = $this->getMockBuilder('ilObject')
16  ->disableOriginalConstructor()
17  ->getMock();
18 
19  $language = $this->getMockBuilder('ilLanguage')
20  ->disableOriginalConstructor()
21  ->getMock();
22 
23  $template = $this->getMockBuilder('ilTemplate')
24  ->disableOriginalConstructor()
25  ->getMock();
26 
27  $controller = $this->getMockBuilder('ilCtrl')
28  ->disableOriginalConstructor()
29  ->getMock();
30 
31  $access = $this->getMockBuilder('ilAccess')
32  ->disableOriginalConstructor()
33  ->getMock();
34 
35  $toolbar = $this->getMockBuilder('ilToolbarGUI')
36  ->disableOriginalConstructor()
37  ->getMock();
38 
39  $placeholderDescriptionObject = $this->getMockBuilder('ilCertificatePlaceholderDescription')
40  ->disableOriginalConstructor()
41  ->getMock();
42 
43  $settingsFormFactory = $this->getMockBuilder('ilCertificateSettingsFormRepository')
44  ->disableOriginalConstructor()
45  ->getMock();
46 
47  $settingsFormFactory
48  ->expects($this->once())
49  ->method('createForm')
50  ->willReturn($formMock);
51 
53  $object,
54  '/some/where/',
55  $language,
56  $template,
57  $controller,
58  $access,
59  $toolbar,
60  $placeholderDescriptionObject,
61  $settingsFormFactory
62  );
63 
64  $guiMock = $this->getMockBuilder('ilCertificateGUI')
65  ->disableOriginalConstructor()
66  ->getMock();
67 
68  $certificateMock = $this->getMockBuilder('ilCertificate')
69  ->disableOriginalConstructor()
70  ->getMock();
71 
72  $result = $repository->createForm($guiMock, $certificateMock);
73 
74  $this->assertEquals($formMock, $result);
75  }
76 
77  public function testSave()
78  {
79  $object = $this->getMockBuilder('ilObject')
80  ->disableOriginalConstructor()
81  ->getMock();
82 
83  $object
84  ->method('getId')
85  ->willReturn(100);
86 
87  $language = $this->getMockBuilder('ilLanguage')
88  ->disableOriginalConstructor()
89  ->getMock();
90 
91  $template = $this->getMockBuilder('ilTemplate')
92  ->disableOriginalConstructor()
93  ->getMock();
94 
95  $controller = $this->getMockBuilder('ilCtrl')
96  ->disableOriginalConstructor()
97  ->getMock();
98 
99  $access = $this->getMockBuilder('ilAccess')
100  ->disableOriginalConstructor()
101  ->getMock();
102 
103  $toolbar = $this->getMockBuilder('ilToolbarGUI')
104  ->disableOriginalConstructor()
105  ->getMock();
106 
107  $placeholderDescriptionObject = $this->getMockBuilder('ilCertificatePlaceholderDescription')
108  ->disableOriginalConstructor()
109  ->getMock();
110 
111  $settingsFormFactory = $this->getMockBuilder('ilCertificateSettingsFormRepository')
112  ->disableOriginalConstructor()
113  ->getMock();
114 
115  $repository = new ilCertificateSettingsExerciseRepository(
116  $object,
117  '/some/where/',
118  $language,
119  $template,
120  $controller,
121  $access,
122  $toolbar,
123  $placeholderDescriptionObject,
124  $settingsFormFactory
125  );
126 
127  $repository->save(array(1, 2, 3));
128  }
129 
130  public function testFormFieldData()
131  {
132  $object = $this->getMockBuilder('ilObject')
133  ->disableOriginalConstructor()
134  ->getMock();
135 
136  $object
137  ->method('getId')
138  ->willReturn(100);
139 
140  $language = $this->getMockBuilder('ilLanguage')
141  ->disableOriginalConstructor()
142  ->getMock();
143 
144  $template = $this->getMockBuilder('ilTemplate')
145  ->disableOriginalConstructor()
146  ->getMock();
147 
148  $controller = $this->getMockBuilder('ilCtrl')
149  ->disableOriginalConstructor()
150  ->getMock();
151 
152  $access = $this->getMockBuilder('ilAccess')
153  ->disableOriginalConstructor()
154  ->getMock();
155 
156  $toolbar = $this->getMockBuilder('ilToolbarGUI')
157  ->disableOriginalConstructor()
158  ->getMock();
159 
160  $placeholderDescriptionObject = $this->getMockBuilder('ilCertificatePlaceholderDescription')
161  ->disableOriginalConstructor()
162  ->getMock();
163 
164  $settingsFormFactory = $this->getMockBuilder('ilCertificateSettingsFormRepository')
165  ->disableOriginalConstructor()
166  ->getMock();
167 
168  $settingsFormFactory
169  ->expects($this->once())
170  ->method('fetchFormFieldData')
171  ->willReturn(array('something' => 'value'));
172 
173  $repository = new ilCertificateSettingsExerciseRepository(
174  $object,
175  '/some/where/',
176  $language,
177  $template,
178  $controller,
179  $access,
180  $toolbar,
181  $placeholderDescriptionObject,
182  $settingsFormFactory
183  );
184 
185  $result = $repository->fetchFormFieldData('SomeContent');
186 
187  $this->assertEquals(array('something' => 'value'), $result);
188  }
189 }
$result
$template
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.