ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCertificateSettingsTestFormRepositoryTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
26  public function testCreate(): void
27  {
28  $object = $this->getMockBuilder(ilObjTest::class)
29  ->disableOriginalConstructor()
30  ->getMock();
31 
32  $formMock = $this->getMockBuilder(ilPropertyFormGUI::class)
33  ->disableOriginalConstructor()
34  ->getMock();
35 
36  $language = $this->getMockBuilder(ilLanguage::class)
37  ->disableOriginalConstructor()
38  ->getMock();
39 
40  $controller = $this->getMockBuilder(ilCtrlInterface::class)
41  ->disableOriginalConstructor()
42  ->getMock();
43 
44  $access = $this->getMockBuilder(ilAccess::class)
45  ->disableOriginalConstructor()
46  ->getMock();
47 
48  $toolbar = $this->getMockBuilder(ilToolbarGUI::class)
49  ->disableOriginalConstructor()
50  ->getMock();
51 
52  $placeholderDescriptionObject = $this->getMockBuilder(ilCertificatePlaceholderDescription::class)
53  ->disableOriginalConstructor()
54  ->getMock();
55 
56  $settingsFormFactory = $this->getMockBuilder(ilCertificateSettingsFormRepository::class)
57  ->disableOriginalConstructor()
58  ->getMock();
59 
60  $settingsFormFactory
61  ->expects($this->once())
62  ->method('createForm')
63  ->willReturn($formMock);
64 
66  100,
67  '/some/where/',
68  false,
69  $object,
70  $language,
71  $controller,
72  $access,
73  $toolbar,
74  $placeholderDescriptionObject,
75  $settingsFormFactory
76  );
77 
78  $guiMock = $this->getMockBuilder(ilCertificateGUI::class)
79  ->disableOriginalConstructor()
80  ->getMock();
81 
82  $result = $repository->createForm($guiMock);
83 
84  $this->assertSame($formMock, $result);
85  }
86 
90  public function testSave(): void
91  {
92  $object = $this->getMockBuilder(ilObjTest::class)
93  ->disableOriginalConstructor()
94  ->getMock();
95 
96  $object
97  ->method('getId')
98  ->willReturn(100);
99 
100  $language = $this->getMockBuilder(ilLanguage::class)
101  ->disableOriginalConstructor()
102  ->getMock();
103 
104  $controller = $this->getMockBuilder(ilCtrlInterface::class)
105  ->disableOriginalConstructor()
106  ->getMock();
107 
108  $access = $this->getMockBuilder(ilAccess::class)
109  ->disableOriginalConstructor()
110  ->getMock();
111 
112  $toolbar = $this->getMockBuilder(ilToolbarGUI::class)
113  ->disableOriginalConstructor()
114  ->getMock();
115 
116  $placeholderDescriptionObject = $this->getMockBuilder(ilCertificatePlaceholderDescription::class)
117  ->disableOriginalConstructor()
118  ->getMock();
119 
120  $settingsFormFactory = $this->getMockBuilder(ilCertificateSettingsFormRepository::class)
121  ->disableOriginalConstructor()
122  ->getMock();
123 
124  $repository = new ilCertificateSettingsTestFormRepository(
125  100,
126  '/some/where/',
127  false,
128  $object,
129  $language,
130  $controller,
131  $access,
132  $toolbar,
133  $placeholderDescriptionObject,
134  $settingsFormFactory
135  );
136 
137  $repository->save([1, 2, 3]);
138  }
139 
140  public function testFormFieldData(): void
141  {
142  $object = $this->getMockBuilder(ilObjTest::class)
143  ->disableOriginalConstructor()
144  ->getMock();
145 
146  $object
147  ->method('getId')
148  ->willReturn(100);
149 
150  $language = $this->getMockBuilder(ilLanguage::class)
151  ->disableOriginalConstructor()
152  ->getMock();
153 
154  $controller = $this->getMockBuilder(ilCtrlInterface::class)
155  ->disableOriginalConstructor()
156  ->getMock();
157 
158  $access = $this->getMockBuilder(ilAccess::class)
159  ->disableOriginalConstructor()
160  ->getMock();
161 
162  $toolbar = $this->getMockBuilder(ilToolbarGUI::class)
163  ->disableOriginalConstructor()
164  ->getMock();
165 
166  $placeholderDescriptionObject = $this->getMockBuilder(ilCertificatePlaceholderDescription::class)
167  ->disableOriginalConstructor()
168  ->getMock();
169 
170  $settingsFormFactory = $this->getMockBuilder(ilCertificateSettingsFormRepository::class)
171  ->disableOriginalConstructor()
172  ->getMock();
173 
174  $settingsFormFactory
175  ->expects($this->once())
176  ->method('fetchFormFieldData')
177  ->willReturn(['something' => 'value']);
178 
179  $repository = new ilCertificateSettingsTestFormRepository(
180  100,
181  '/some/where/',
182  false,
183  $object,
184  $language,
185  $controller,
186  $access,
187  $toolbar,
188  $placeholderDescriptionObject,
189  $settingsFormFactory
190  );
191 
192  $result = $repository->fetchFormFieldData('SomeContent');
193 
194  $this->assertSame(['something' => 'value'], $result);
195  }
196 }
Class ilCertificateBaseTestCase.