ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilLearningSequenceSettingsDBTest Class Reference
+ Inheritance diagram for ilLearningSequenceSettingsDBTest:
+ Collaboration diagram for ilLearningSequenceSettingsDBTest:

Public Member Functions

 testCreateObject ()
 
 testStoreWithoutUploadsAndDeletionsAndEmptySettings ()
 
 testStoreWithoutUploadsAndDeletionsAndWithSettings ()
 
 testStoreWithUploadsAndWithoutDeletionsAndWithSettings ()
 
 testStoreWithoutUploadsAndWithDeletionsAndWithSettings ()
 
 testGetSettingsForWithNewObject ()
 
 testGetSettingsForWithExistingData ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $db
 
 $ls_filesystem
 

Detailed Description

Definition at line 23 of file ilLearningSequenceSettingsDBTest.php.

Member Function Documentation

◆ setUp()

ilLearningSequenceSettingsDBTest::setUp ( )
protected

Definition at line 35 of file ilLearningSequenceSettingsDBTest.php.

35 : void
36 {
37 $this->db = $this->createMock(ilDBInterface::class);
38 $this->ls_filesystem = $this
39 ->getMockBuilder(ilLearningSequenceFilesystem::class)
40 ->disableOriginalConstructor()
41 ->getMock()
42 ;
43 }

◆ testCreateObject()

ilLearningSequenceSettingsDBTest::testCreateObject ( )

Definition at line 45 of file ilLearningSequenceSettingsDBTest.php.

45 : void
46 {
47 $obj = new ilLearningSequenceSettingsDB($this->db, $this->ls_filesystem);
48
49 $this->assertInstanceOf(ilLearningSequenceSettingsDB::class, $obj);
50 }
Persistence for Settings (like abstract, extro)

◆ testGetSettingsForWithExistingData()

ilLearningSequenceSettingsDBTest::testGetSettingsForWithExistingData ( )

Definition at line 249 of file ilLearningSequenceSettingsDBTest.php.

249 : void
250 {
251 $sql =
252 'SELECT abstract, extro, abstract_image, extro_image, gallery, lso_mod' . PHP_EOL
253 . 'FROM lso_settings' . PHP_EOL
254 . 'WHERE obj_id = 333' . PHP_EOL
255 ;
256
257 $row = [
258 'obj_id' => 333,
259 'abstract' => 'abstract',
260 'extro' => 'extro',
261 'abstract_image' => 'abstract_image',
262 'extro_image' => 'extro_image',
263 'gallery' => true,
265 ];
266
267 $this->db
268 ->expects($this->once())
269 ->method('quote')
270 ->with(333, 'integer')
271 ->willReturn('333')
272 ;
273 $return_statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
274 $this->db
275 ->expects($this->once())
276 ->method('query')
277 ->with($sql)
278 ->willReturn($return_statement)
279 ;
280 $this->db
281 ->expects($this->once())
282 ->method('numRows')
283 ->willReturn(1)
284 ;
285 $this->db
286 ->expects($this->once())
287 ->method('fetchAssoc')
288 ->with($return_statement)
289 ->willReturn($row)
290 ;
291
292 $obj = new ilLearningSequenceSettingsDB($this->db, $this->ls_filesystem);
293 $result = $obj->getSettingsFor(333);
294
295 $this->assertEquals(333, $result->getObjId());
296 $this->assertEquals('abstract', $result->getAbstract());
297 $this->assertEquals('extro', $result->getExtro());
298 $this->assertEquals('abstract_image', $result->getAbstractImage());
299 $this->assertEquals('extro_image', $result->getExtroImage());
300 $this->assertEquals(true, $result->getMembersGallery());
301 $this->assertEquals(ilLearningSequenceSettings::MODE_ADAPTIVE, $result->getMode());
302 }

References ilLearningSequenceSettings\MODE_ADAPTIVE.

◆ testGetSettingsForWithNewObject()

ilLearningSequenceSettingsDBTest::testGetSettingsForWithNewObject ( )

Definition at line 197 of file ilLearningSequenceSettingsDBTest.php.

197 : void
198 {
199 $sql =
200 'SELECT abstract, extro, abstract_image, extro_image, gallery, lso_mod' . PHP_EOL
201 . 'FROM lso_settings' . PHP_EOL
202 . 'WHERE obj_id = 333' . PHP_EOL
203 ;
204
205 $values = [
206 'obj_id' => ['integer', 333],
207 'abstract' => ['text', ''],
208 'extro' => ['text', ''],
209 'gallery' => ['integer', false],
210 'lso_mod' => ['integer', ilLearningSequenceSettings::MODE_LINEAR]
211 ];
212
213 $this->db
214 ->expects($this->once())
215 ->method('quote')
216 ->with(333, 'integer')
217 ->willReturn('333')
218 ;
219 $return_statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
220 $this->db
221 ->expects($this->once())
222 ->method('query')
223 ->with($sql)
224 ->willReturn($return_statement)
225 ;
226 $this->db
227 ->expects($this->once())
228 ->method('numRows')
229 ->willReturn(0)
230 ;
231 $this->db
232 ->expects($this->once())
233 ->method('insert')
234 ->with('lso_settings', $values)
235 ;
236
237 $obj = new ilLearningSequenceSettingsDB($this->db, $this->ls_filesystem);
238 $result = $obj->getSettingsFor(333);
239
240 $this->assertEquals(333, $result->getObjId());
241 $this->assertEquals('', $result->getAbstract());
242 $this->assertEquals('', $result->getExtro());
243 $this->assertEquals('', $result->getAbstractImage());
244 $this->assertEquals('', $result->getExtroImage());
245 $this->assertEquals(false, $result->getMembersGallery());
246 $this->assertEquals(ilLearningSequenceSettings::MODE_LINEAR, $result->getMode());
247 }

References ilLearningSequenceSettings\MODE_LINEAR.

◆ testStoreWithoutUploadsAndDeletionsAndEmptySettings()

ilLearningSequenceSettingsDBTest::testStoreWithoutUploadsAndDeletionsAndEmptySettings ( )

Definition at line 52 of file ilLearningSequenceSettingsDBTest.php.

52 : void
53 {
55
56 $where = [
57 'obj_id' => ['integer', 333]
58 ];
59
60 $values = [
61 'abstract' => ['text', ''],
62 'extro' => ['text', ''],
63 'abstract_image' => ['text', ''],
64 'extro_image' => ['text', ''],
65 'gallery' => ['integer', false],
66 'lso_mod' => ['integer', ilLearningSequenceSettings::MODE_LINEAR]
67 ];
68
69 $this->db
70 ->expects($this->once())
71 ->method('update')
72 ->with('lso_settings', $values, $where)
73 ;
74
75 $obj = new ilLearningSequenceSettingsDB($this->db, $this->ls_filesystem);
76 $obj->store($settings);
77 }
$settings
Definition: index.php:44
Settings for an LSO (like abstract, extro)

References $settings, and ilLearningSequenceSettings\MODE_LINEAR.

◆ testStoreWithoutUploadsAndDeletionsAndWithSettings()

ilLearningSequenceSettingsDBTest::testStoreWithoutUploadsAndDeletionsAndWithSettings ( )

Definition at line 79 of file ilLearningSequenceSettingsDBTest.php.

79 : void
80 {
82 333,
83 'abstract',
84 'extro',
85 'abstract/path',
86 'extro_path',
87 true
88 );
89
90 $where = [
91 'obj_id' => ['integer', 333]
92 ];
93
94 $values = [
95 'abstract' => ['text', 'abstract'],
96 'extro' => ['text', 'extro'],
97 'abstract_image' => ['text', 'abstract/path'],
98 'extro_image' => ['text', 'extro_path'],
99 'gallery' => ['integer', true],
100 'lso_mod' => ['integer', ilLearningSequenceSettings::MODE_LINEAR]
101 ];
102
103 $this->db
104 ->expects($this->once())
105 ->method('update')
106 ->with('lso_settings', $values, $where)
107 ;
108
109 $obj = new ilLearningSequenceSettingsDB($this->db, $this->ls_filesystem);
110 $obj->store($settings);
111 }

References $settings, and ilLearningSequenceSettings\MODE_LINEAR.

◆ testStoreWithoutUploadsAndWithDeletionsAndWithSettings()

ilLearningSequenceSettingsDBTest::testStoreWithoutUploadsAndWithDeletionsAndWithSettings ( )

Definition at line 155 of file ilLearningSequenceSettingsDBTest.php.

155 : void
156 {
158 333,
159 'abstract',
160 'extro',
161 'abstract/path',
162 'extro_path',
163 true
164 );
165 $settings = $settings->withDeletion('test');
166
167 $this->ls_filesystem
168 ->expects($this->once())
169 ->method('delete_image')
170 ->with('test', $settings)
171 ->willReturn($settings)
172 ;
173
174 $where = [
175 'obj_id' => ['integer', 333]
176 ];
177
178 $values = [
179 'abstract' => ['text', 'abstract'],
180 'extro' => ['text', 'extro'],
181 'abstract_image' => ['text', 'abstract/path'],
182 'extro_image' => ['text', 'extro_path'],
183 'gallery' => ['integer', true],
184 'lso_mod' => ['integer', ilLearningSequenceSettings::MODE_LINEAR]
185 ];
186
187 $this->db
188 ->expects($this->once())
189 ->method('update')
190 ->with('lso_settings', $values, $where)
191 ;
192
193 $obj = new ilLearningSequenceSettingsDB($this->db, $this->ls_filesystem);
194 $obj->store($settings);
195 }

References $settings, and ilLearningSequenceSettings\MODE_LINEAR.

◆ testStoreWithUploadsAndWithoutDeletionsAndWithSettings()

ilLearningSequenceSettingsDBTest::testStoreWithUploadsAndWithoutDeletionsAndWithSettings ( )

Definition at line 113 of file ilLearningSequenceSettingsDBTest.php.

113 : void
114 {
116 333,
117 'abstract',
118 'extro',
119 'abstract/path',
120 'extro_path',
121 true
122 );
123 $settings = $settings->withUpload(['upload_info'], 'test');
124
125 $this->ls_filesystem
126 ->expects($this->once())
127 ->method('moveUploaded')
128 ->with('test', ['upload_info'], $settings)
129 ->willReturn($settings)
130 ;
131
132 $where = [
133 'obj_id' => ['integer', 333]
134 ];
135
136 $values = [
137 'abstract' => ['text', 'abstract'],
138 'extro' => ['text', 'extro'],
139 'abstract_image' => ['text', 'abstract/path'],
140 'extro_image' => ['text', 'extro_path'],
141 'gallery' => ['integer', true],
142 'lso_mod' => ['integer', ilLearningSequenceSettings::MODE_LINEAR]
143 ];
144
145 $this->db
146 ->expects($this->once())
147 ->method('update')
148 ->with('lso_settings', $values, $where)
149 ;
150
151 $obj = new ilLearningSequenceSettingsDB($this->db, $this->ls_filesystem);
152 $obj->store($settings);
153 }

References $settings, and ilLearningSequenceSettings\MODE_LINEAR.

Field Documentation

◆ $db

ilLearningSequenceSettingsDBTest::$db
protected

Definition at line 28 of file ilLearningSequenceSettingsDBTest.php.

◆ $ls_filesystem

ilLearningSequenceSettingsDBTest::$ls_filesystem
protected

Definition at line 33 of file ilLearningSequenceSettingsDBTest.php.


The documentation for this class was generated from the following file: