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