ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
CertificateSettingsTestFormRepositoryTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Test\Certificate;
22 
24 
29 {
30  public function testCreate(): void
31  {
32  $form_mock = $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  $placeholder_description_object = $this->getMockBuilder(\ilCertificatePlaceholderDescription::class)
53  ->disableOriginalConstructor()
54  ->getMock();
55 
56  $settings_form_factory = $this->getMockBuilder(\ilCertificateSettingsFormRepository::class)
57  ->disableOriginalConstructor()
58  ->getMock();
59 
60  $settings_form_factory
61  ->expects($this->once())
62  ->method('createForm')
63  ->willReturn($form_mock);
64 
65  $repository = new CertificateSettingsTestFormRepository(
66  100,
67  '/some/where/',
68  false,
69  $language,
70  $controller,
71  $access,
72  $toolbar,
73  $placeholder_description_object,
74  $settings_form_factory
75  );
76 
77  $gui_mock = $this->getMockBuilder(\ilCertificateGUI::class)
78  ->disableOriginalConstructor()
79  ->getMock();
80 
81  $result = $repository->createForm($gui_mock);
82 
83  $this->assertSame($form_mock, $result);
84  }
85 
89  public function testSave(): void
90  {
91  $language = $this->getMockBuilder(\ilLanguage::class)
92  ->disableOriginalConstructor()
93  ->getMock();
94 
95  $controller = $this->getMockBuilder(\ilCtrlInterface::class)
96  ->disableOriginalConstructor()
97  ->getMock();
98 
99  $access = $this->getMockBuilder(\ilAccess::class)
100  ->disableOriginalConstructor()
101  ->getMock();
102 
103  $toolbar = $this->getMockBuilder(\ilToolbarGUI::class)
104  ->disableOriginalConstructor()
105  ->getMock();
106 
107  $placeholderDescriptionObject = $this->getMockBuilder(\ilCertificatePlaceholderDescription::class)
108  ->disableOriginalConstructor()
109  ->getMock();
110 
111  $settingsFormFactory = $this->getMockBuilder(\ilCertificateSettingsFormRepository::class)
112  ->disableOriginalConstructor()
113  ->getMock();
114 
116  100,
117  '/some/where/',
118  false,
119  $language,
120  $controller,
121  $access,
122  $toolbar,
123  $placeholderDescriptionObject,
124  $settingsFormFactory
125  );
126  }
127 
128  public function testFormFieldData(): void
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  $settingsFormFactory = $this->getMockBuilder(\ilCertificateSettingsFormRepository::class)
151  ->disableOriginalConstructor()
152  ->getMock();
153 
154  $settingsFormFactory
155  ->expects($this->once())
156  ->method('fetchFormFieldData')
157  ->willReturn(['something' => 'value']);
158 
159  $repository = new CertificateSettingsTestFormRepository(
160  100,
161  '/some/where/',
162  false,
163  $language,
164  $controller,
165  $access,
166  $toolbar,
167  $placeholderDescriptionObject,
168  $settingsFormFactory
169  );
170 
171  $result = $repository->fetchFormFieldData('SomeContent');
172 
173  $this->assertSame(['something' => 'value'], $result);
174  }
175 }