ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 35 of file ilLSItemsDBTest.php.

Member Function Documentation

◆ setUp()

ilLSItemsDBTest::setUp ( )
protected

Definition at line 43 of file ilLSItemsDBTest.php.

43 : void
44 {
45 $this->tree = $this->createMock(ilTree::class);
46 $this->container_sorting = $this->createMock(ilContainerSorting::class);
47 $this->post_conditions_db = $this->createMock(ilLSPostConditionDB::class);
48 $this->ls_item_online_status = $this->createMock(LSItemOnlineStatus::class);
49 $this->sorting_settings = $this->createMock(ilContainerSortingSettings::class);
50 }

◆ testCreateObject()

ilLSItemsDBTest::testCreateObject ( )

Definition at line 52 of file ilLSItemsDBTest.php.

52 : void
53 {
54 $obj = new ilLSItemsDB(
55 $this->tree,
56 $this->container_sorting,
57 $this->post_conditions_db,
58 $this->ls_item_online_status
59 );
60
61 $this->assertInstanceOf(ilLSItemsDB::class, $obj);
62 }
Class ilLSItemsDB.
Definition: ilLSItemsDB.php:25

◆ testGetLSItemsWithData()

ilLSItemsDBTest::testGetLSItemsWithData ( )

Definition at line 104 of file ilLSItemsDBTest.php.

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

References ilContainer\SORT_MANUAL.

◆ testGetLSItemsWithoutData()

ilLSItemsDBTest::testGetLSItemsWithoutData ( )

Definition at line 64 of file ilLSItemsDBTest.php.

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

References ilContainer\SORT_MANUAL.

◆ testStoreItems()

ilLSItemsDBTest::testStoreItems ( )

Definition at line 183 of file ilLSItemsDBTest.php.

183 : void
184 {
185 $condition = $this->createMock(ilLSPostCondition::class);
186
187 $ls_item = new LSItem(
188 'ls_item',
189 'ls_title',
190 'ls_description',
191 '',
192 true,
193 22,
194 $condition,
195 14,
196 1
197 );
198
199 $this->ls_item_online_status
200 ->expects($this->once())
201 ->method('setOnlineStatus')
202 ->with(14, true)
203 ;
204
205 $this->container_sorting
206 ->expects($this->once())
207 ->method('savePost')
208 ->with([14 => 22])
209 ;
210
211 $this->post_conditions_db
212 ->expects($this->once())
213 ->method('upsert')
214 ->with([$condition])
215 ;
216
217 $obj = new ilLSItemsDB(
218 $this->tree,
219 $this->container_sorting,
220 $this->post_conditions_db,
221 $this->ls_item_online_status
222 );
223
224 $obj->storeItems([$ls_item]);
225 }
Data holding class LSItem .
Definition: LSItem.php:25

Field Documentation

◆ $container_sorting

ilContainerSorting ilLSItemsDBTest::$container_sorting
protected

Definition at line 38 of file ilLSItemsDBTest.php.

◆ $ls_item_online_status

LSItemOnlineStatus ilLSItemsDBTest::$ls_item_online_status
protected

Definition at line 40 of file ilLSItemsDBTest.php.

◆ $post_conditions_db

ilLSPostConditionDB ilLSItemsDBTest::$post_conditions_db
protected

Definition at line 39 of file ilLSItemsDBTest.php.

◆ $sorting_settings

ilContainerSortingSettings ilLSItemsDBTest::$sorting_settings
protected

Definition at line 41 of file ilLSItemsDBTest.php.

◆ $tree

ilTree ilLSItemsDBTest::$tree
protected

Definition at line 37 of file ilLSItemsDBTest.php.


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