ILIAS  release_8 Revision v8.24
ilLSItemsDBTest Class Reference
+ Inheritance diagram for ilLSItemsDBTest:
+ Collaboration diagram for ilLSItemsDBTest:

Public Member Functions

 testCreateObject ()
 
 testGetLSItemsWithoutData ()
 
 testGetLSItemsWithData ()
 
 testStoreItems ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

ilTree $tree
 
ilContainerSorting $container_sorting
 
ilLSPostConditionDB $post_conditions_db
 
LSItemOnlineStatus $ls_item_online_status
 
ilContainerSortingSettings $sorting_settings
 

Detailed Description

Definition at line 31 of file ilLSItemsDBTest.php.

Member Function Documentation

◆ setUp()

ilLSItemsDBTest::setUp ( )
protected

Definition at line 39 of file ilLSItemsDBTest.php.

39 : void
40 {
41 $this->tree = $this->createMock(ilTree::class);
42 $this->container_sorting = $this->createMock(ilContainerSorting::class);
43 $this->post_conditions_db = $this->createMock(ilLSPostConditionDB::class);
44 $this->ls_item_online_status = $this->createMock(LSItemOnlineStatus::class);
45 $this->sorting_settings = $this->createMock(ilContainerSortingSettings::class);
46 }

◆ testCreateObject()

ilLSItemsDBTest::testCreateObject ( )

Definition at line 48 of file ilLSItemsDBTest.php.

48 : void
49 {
50 $obj = new ilLSItemsDB(
51 $this->tree,
52 $this->container_sorting,
53 $this->post_conditions_db,
54 $this->ls_item_online_status
55 );
56
57 $this->assertInstanceOf(ilLSItemsDB::class, $obj);
58 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: ilLSItemsDB.php:25

◆ testGetLSItemsWithData()

ilLSItemsDBTest::testGetLSItemsWithData ( )

Definition at line 100 of file ilLSItemsDBTest.php.

100 : void
101 {
102 $value = [
103 '22' => [
104 'child' => 14,
105 'type' => 'lsitem',
106 'title' => 'ls_title',
107 'description' => 'tiny_description'
108 ]
109 ];
110
111 $this->tree
112 ->expects($this->once())
113 ->method('getChilds')
114 ->with(22)
115 ->willReturn($value)
116 ;
117
118 $this->sorting_settings
119 ->expects($this->once())
120 ->method('setSortMode')
122 ;
123
124 $this->container_sorting
125 ->expects($this->once())
126 ->method('getSortingSettings')
127 ->willReturn($this->sorting_settings)
128 ;
129 $this->container_sorting
130 ->expects($this->once())
131 ->method('sortItems')
132 ->with(['lsitems' => $value])
133 ->willReturn(['lsitems' => $value])
134 ;
135
136 $condition = $this->createMock(ilLSPostCondition::class);
137 $condition
138 ->expects($this->once())
139 ->method('getRefId')
140 ->willReturn(14)
141 ;
142
143 $this->post_conditions_db
144 ->expects($this->once())
145 ->method('select')
146 ->with([22 => 14])
147 ->willReturn(['14' => $condition])
148 ;
149
150 $this->ls_item_online_status
151 ->expects($this->once())
152 ->method('getOnlineStatus')
153 ->with(14)
154 ->willReturn(true)
155 ;
156
157 $obj = new ilLSItemsDBStub(
158 $this->tree,
159 $this->container_sorting,
160 $this->post_conditions_db,
161 $this->ls_item_online_status
162 );
163
164 $result = $obj->getLSItems(22);
165
166 foreach ($result as $ls_item) {
167 $this->assertEquals('lsitem', $ls_item->getType());
168 $this->assertEquals('ls_title', $ls_item->getTitle());
169 $this->assertEquals('tiny_description', $ls_item->getDescription());
170 $this->assertEquals('./image/tester/myimage.png', $ls_item->getIconPath());
171 $this->assertTrue($ls_item->isOnline());
172 $this->assertEquals(22, $ls_item->getOrderNumber());
173 $this->assertInstanceOf(ilLSPostCondition::class, $ls_item->getPostCondition());
174 $this->assertEquals(14, $ls_item->getRefId());
175 }
176 }

References ilContainer\SORT_MANUAL.

◆ testGetLSItemsWithoutData()

ilLSItemsDBTest::testGetLSItemsWithoutData ( )

Definition at line 60 of file ilLSItemsDBTest.php.

60 : void
61 {
62 $this->tree
63 ->expects($this->once())
64 ->method('getChilds')
65 ->with(22)
66 ->willReturn([])
67 ;
68
69 $this->sorting_settings
70 ->expects($this->once())
71 ->method('setSortMode')
73 ;
74
75 $this->container_sorting
76 ->expects($this->once())
77 ->method('getSortingSettings')
78 ->willReturn($this->sorting_settings)
79 ;
80 $this->container_sorting
81 ->expects($this->once())
82 ->method('sortItems')
83 ->with(['lsitems' => []])
84 ->willReturn(['lsitems' => []])
85 ;
86
87 $obj = new ilLSItemsDB(
88 $this->tree,
89 $this->container_sorting,
90 $this->post_conditions_db,
91 $this->ls_item_online_status
92 );
93
94 $result = $obj->getLSItems(22);
95
96 $this->assertIsArray($result);
97 $this->assertEmpty($result);
98 }

References ilContainer\SORT_MANUAL.

◆ testStoreItems()

ilLSItemsDBTest::testStoreItems ( )

Definition at line 178 of file ilLSItemsDBTest.php.

178 : void
179 {
180 $condition = $this->createMock(ilLSPostCondition::class);
181
182 $ls_item = new LSItem(
183 'ls_item',
184 'ls_title',
185 'ls_description',
186 '',
187 true,
188 22,
189 $condition,
190 14
191 );
192
193 $this->ls_item_online_status
194 ->expects($this->once())
195 ->method('setOnlineStatus')
196 ->with(14, true)
197 ;
198
199 $this->container_sorting
200 ->expects($this->once())
201 ->method('savePost')
202 ->with([14 => 22])
203 ;
204
205 $this->post_conditions_db
206 ->expects($this->once())
207 ->method('upsert')
208 ->with([$condition])
209 ;
210
211 $obj = new ilLSItemsDB(
212 $this->tree,
213 $this->container_sorting,
214 $this->post_conditions_db,
215 $this->ls_item_online_status
216 );
217
218 $obj->storeItems([$ls_item]);
219 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: LSItem.php:25

Field Documentation

◆ $container_sorting

ilContainerSorting ilLSItemsDBTest::$container_sorting
protected

Definition at line 34 of file ilLSItemsDBTest.php.

◆ $ls_item_online_status

LSItemOnlineStatus ilLSItemsDBTest::$ls_item_online_status
protected

Definition at line 36 of file ilLSItemsDBTest.php.

◆ $post_conditions_db

ilLSPostConditionDB ilLSItemsDBTest::$post_conditions_db
protected

Definition at line 35 of file ilLSItemsDBTest.php.

◆ $sorting_settings

ilContainerSortingSettings ilLSItemsDBTest::$sorting_settings
protected

Definition at line 37 of file ilLSItemsDBTest.php.

◆ $tree

ilTree ilLSItemsDBTest::$tree
protected

Definition at line 33 of file ilLSItemsDBTest.php.


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