ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateSettingsScormFormRepositoryTest.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 testSave()
10  {
11  $object = $this->getMockBuilder('ilObject')
12  ->disableOriginalConstructor()
13  ->getMock();
14 
15  $language = $this->getMockBuilder('ilLanguage')
16  ->disableOriginalConstructor()
17  ->getMock();
18 
19  $template = $this->getMockBuilder('ilTemplate')
20  ->disableOriginalConstructor()
21  ->getMock();
22 
23  $controller = $this->getMockBuilder('ilCtrl')
24  ->disableOriginalConstructor()
25  ->getMock();
26 
27  $access = $this->getMockBuilder('ilAccess')
28  ->disableOriginalConstructor()
29  ->getMock();
30 
31  $toolbar = $this->getMockBuilder('ilToolbarGUI')
32  ->disableOriginalConstructor()
33  ->getMock();
34 
35  $placeholderDescriptionObject = $this->getMockBuilder('ilCertificatePlaceholderDescription')
36  ->disableOriginalConstructor()
37  ->getMock();
38 
39  $settingFormRepository = $this->getMockBuilder('ilCertificateSettingsFormRepository')
40  ->disableOriginalConstructor()
41  ->getMock();
42 
43  $setting = $this->getMockBuilder('ilSetting')
44  ->disableOriginalConstructor()
45  ->getMock();
46 
47  $setting
48  ->expects($this->exactly(2))
49  ->method('set');
50 
52  $object,
53  '/some/where/',
54  $language,
55  $template,
56  $controller,
57  $access,
58  $toolbar,
59  $placeholderDescriptionObject,
60  $settingFormRepository,
61  $setting
62  );
63 
64  $repository->save(
65  array(
66  'certificate_enabled_scorm' => true,
67  'short_name' => 'something'
68  )
69  );
70  }
71 
72  public function testFetchFormFieldData()
73  {
74  $object = $this->getMockBuilder('ilObject')
75  ->disableOriginalConstructor()
76  ->getMock();
77 
78  $language = $this->getMockBuilder('ilLanguage')
79  ->disableOriginalConstructor()
80  ->getMock();
81 
82  $template = $this->getMockBuilder('ilTemplate')
83  ->disableOriginalConstructor()
84  ->getMock();
85 
86  $controller = $this->getMockBuilder('ilCtrl')
87  ->disableOriginalConstructor()
88  ->getMock();
89 
90  $access = $this->getMockBuilder('ilAccess')
91  ->disableOriginalConstructor()
92  ->getMock();
93 
94  $toolbar = $this->getMockBuilder('ilToolbarGUI')
95  ->disableOriginalConstructor()
96  ->getMock();
97 
98  $placeholderDescriptionObject = $this->getMockBuilder('ilCertificatePlaceholderDescription')
99  ->disableOriginalConstructor()
100  ->getMock();
101 
102  $settingFormRepository = $this->getMockBuilder('ilCertificateSettingsFormRepository')
103  ->disableOriginalConstructor()
104  ->getMock();
105 
106  $settingFormRepository
107  ->expects($this->once())
108  ->method('fetchFormFieldData')
109  ->willReturn(
110  array(
111  'certificate_enabled_scorm' => '',
112  'short_name' => ''
113  )
114  );
115 
116  $setting = $this->getMockBuilder('ilSetting')
117  ->disableOriginalConstructor()
118  ->getMock();
119 
120  $setting
121  ->expects($this->exactly(2))
122  ->method('get')
123  ->willReturnOnConsecutiveCalls('something', 'somethingelse');
124 
126  $object,
127  '/some/where/',
128  $language,
129  $template,
130  $controller,
131  $access,
132  $toolbar,
133  $placeholderDescriptionObject,
134  $settingFormRepository,
135  $setting
136  );
137 
138  $result = $repository->fetchFormFieldData('Some Content');
139 
140  $this->assertEquals(
141  array(
142  'certificate_enabled_scorm' => 'something',
143  'short_name' => 'somethingelse'
144  ),
145  $result
146  );
147  }
148 }
$result
$template
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.