19 declare(strict_types=1);
35 protected function setUp(): void
37 $this->db = $this->createMock(ilDBInterface::class);
38 $this->ls_filesystem = $this
39 ->getMockBuilder(ilLearningSequenceFilesystem::class)
40 ->disableOriginalConstructor()
49 $this->assertInstanceOf(ilLearningSequenceSettingsDB::class, $obj);
57 'obj_id' => [
'integer', 333]
61 'abstract' => [
'text',
''],
62 'extro' => [
'text',
''],
63 'abstract_image' => [
'text',
''],
64 'extro_image' => [
'text',
''],
65 'gallery' => [
'integer',
false]
69 ->expects($this->once())
71 ->with(
'lso_settings', $values, $where)
75 $obj->store($settings);
90 'obj_id' => [
'integer', 333]
94 'abstract' => [
'text',
'abstract'],
95 'extro' => [
'text',
'extro'],
96 'abstract_image' => [
'text',
'abstract/path'],
97 'extro_image' => [
'text',
'extro_path'],
98 'gallery' => [
'integer',
true]
102 ->expects($this->once())
104 ->with(
'lso_settings', $values, $where)
108 $obj->store($settings);
121 $settings = $settings->withUpload([
'upload_info'],
'test');
124 ->expects($this->once())
125 ->method(
'moveUploaded')
126 ->with(
'test', [
'upload_info'], $settings)
127 ->willReturn($settings)
131 'obj_id' => [
'integer', 333]
135 'abstract' => [
'text',
'abstract'],
136 'extro' => [
'text',
'extro'],
137 'abstract_image' => [
'text',
'abstract/path'],
138 'extro_image' => [
'text',
'extro_path'],
139 'gallery' => [
'integer',
true]
143 ->expects($this->once())
145 ->with(
'lso_settings', $values, $where)
149 $obj->store($settings);
162 $settings = $settings->withDeletion(
'test');
165 ->expects($this->once())
166 ->method(
'delete_image')
167 ->with(
'test', $settings)
168 ->willReturn($settings)
172 'obj_id' => [
'integer', 333]
176 'abstract' => [
'text',
'abstract'],
177 'extro' => [
'text',
'extro'],
178 'abstract_image' => [
'text',
'abstract/path'],
179 'extro_image' => [
'text',
'extro_path'],
180 'gallery' => [
'integer',
true]
184 ->expects($this->once())
186 ->with(
'lso_settings', $values, $where)
190 $obj->store($settings);
196 'SELECT abstract, extro, abstract_image, extro_image, gallery' . PHP_EOL
197 .
'FROM lso_settings' . PHP_EOL
198 .
'WHERE obj_id = 333' . PHP_EOL
202 'obj_id' => [
'integer', 333],
203 'abstract' => [
'text',
''],
204 'extro' => [
'text',
''],
205 'gallery' => [
'integer',
false]
209 ->expects($this->once())
211 ->with(333,
'integer')
214 $return_statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
216 ->expects($this->once())
219 ->willReturn($return_statement)
222 ->expects($this->once())
227 ->expects($this->once())
229 ->with(
'lso_settings', $values)
233 $result = $obj->getSettingsFor(333);
235 $this->assertEquals(333, $result->getObjId());
236 $this->assertEquals(
'', $result->getAbstract());
237 $this->assertEquals(
'', $result->getExtro());
238 $this->assertEquals(
'', $result->getAbstractImage());
239 $this->assertEquals(
'', $result->getExtroImage());
240 $this->assertEquals(
false, $result->getMembersGallery());
246 'SELECT abstract, extro, abstract_image, extro_image, gallery' . PHP_EOL
247 .
'FROM lso_settings' . PHP_EOL
248 .
'WHERE obj_id = 333' . PHP_EOL
253 'abstract' =>
'abstract',
255 'abstract_image' =>
'abstract_image',
256 'extro_image' =>
'extro_image',
261 ->expects($this->once())
263 ->with(333,
'integer')
266 $return_statement = $this->getMockBuilder(ilDBStatement::class)->getMock();
268 ->expects($this->once())
271 ->willReturn($return_statement)
274 ->expects($this->once())
279 ->expects($this->once())
280 ->method(
'fetchAssoc')
281 ->with($return_statement)
286 $result = $obj->getSettingsFor(333);
288 $this->assertEquals(333, $result->getObjId());
289 $this->assertEquals(
'abstract', $result->getAbstract());
290 $this->assertEquals(
'extro', $result->getExtro());
291 $this->assertEquals(
'abstract_image', $result->getAbstractImage());
292 $this->assertEquals(
'extro_image', $result->getExtroImage());
293 $this->assertEquals(
true, $result->getMembersGallery());
testStoreWithUploadsAndWithoutDeletionsAndWithSettings()
testStoreWithoutUploadsAndWithDeletionsAndWithSettings()
testStoreWithoutUploadsAndDeletionsAndWithSettings()
Settings for an LSO (like abstract, extro)
testStoreWithoutUploadsAndDeletionsAndEmptySettings()
Persistence for Settings (like abstract, extro)
testGetSettingsForWithExistingData()
testGetSettingsForWithNewObject()