ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LSItemTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
7 class LSItemTest extends TestCase
8 {
9  const TYPE = "type";
10  const TITLE = "tile";
11  const DESC = "description";
12  const ICON_PATH = "icon_path";
13  const IS_ONLINE = true;
14  const ORDER_NUMBER = 10;
15  const REF_ID = 30;
16 
20  protected $post_condition;
21 
22  public function setUp()
23  {
24  $this->post_condition = new ilLSPostCondition(666, 'op');
25  }
26 
27  public function testCreate() : LSItem
28  {
29  $object = new LSItem(
30  self::TYPE,
31  self::TITLE,
32  self::DESC,
33  self::ICON_PATH,
34  self::IS_ONLINE,
35  self::ORDER_NUMBER,
36  $this->post_condition,
37  self::REF_ID
38  );
39 
40  $this->assertEquals($object->getType(), self::TYPE);
41  $this->assertEquals($object->getTitle(), self::TITLE);
42  $this->assertEquals($object->getDescription(), self::DESC);
43  $this->assertEquals($object->getIconPath(), self::ICON_PATH);
44  $this->assertEquals($object->isOnline(), self::IS_ONLINE);
45  $this->assertEquals($object->getOrderNumber(), self::ORDER_NUMBER);
46  $this->assertEquals($object->getPostCondition(), $this->post_condition);
47  $this->assertEquals($object->getRefId(), self::REF_ID);
48 
49  return $object;
50  }
51 
55  public function testWithOnline(LSItem $object)
56  {
57  $new_obj = $object->withOnline(false);
58 
59  $this->assertEquals($object->getType(), self::TYPE);
60  $this->assertEquals($object->getTitle(), self::TITLE);
61  $this->assertEquals($object->getDescription(), self::DESC);
62  $this->assertEquals($object->getIconPath(), self::ICON_PATH);
63  $this->assertEquals($object->isOnline(), self::IS_ONLINE);
64  $this->assertEquals($object->getOrderNumber(), self::ORDER_NUMBER);
65  $this->assertEquals($object->getPostCondition(), $this->post_condition);
66  $this->assertEquals($object->getRefId(), self::REF_ID);
67 
68  $this->assertEquals($new_obj->getType(), self::TYPE);
69  $this->assertEquals($new_obj->getTitle(), self::TITLE);
70  $this->assertEquals($new_obj->getDescription(), self::DESC);
71  $this->assertEquals($new_obj->getIconPath(), self::ICON_PATH);
72  $this->assertEquals($new_obj->isOnline(), false);
73  $this->assertEquals($new_obj->getOrderNumber(), self::ORDER_NUMBER);
74  $this->assertEquals($new_obj->getPostCondition(), $this->post_condition);
75  $this->assertEquals($new_obj->getRefId(), self::REF_ID);
76  }
77 
81  public function testWithOrderNumber(LSItem $object)
82  {
83  $new_obj = $object->withOrderNumber(20);
84 
85  $this->assertEquals($object->getType(), self::TYPE);
86  $this->assertEquals($object->getTitle(), self::TITLE);
87  $this->assertEquals($object->getDescription(), self::DESC);
88  $this->assertEquals($object->getIconPath(), self::ICON_PATH);
89  $this->assertEquals($object->isOnline(), self::IS_ONLINE);
90  $this->assertEquals($object->getOrderNumber(), self::ORDER_NUMBER);
91  $this->assertEquals($object->getPostCondition(), $this->post_condition);
92  $this->assertEquals($object->getRefId(), self::REF_ID);
93 
94  $this->assertEquals($new_obj->getType(), self::TYPE);
95  $this->assertEquals($new_obj->getTitle(), self::TITLE);
96  $this->assertEquals($new_obj->getDescription(), self::DESC);
97  $this->assertEquals($new_obj->getIconPath(), self::ICON_PATH);
98  $this->assertEquals($new_obj->isOnline(), self::IS_ONLINE);
99  $this->assertEquals($new_obj->getOrderNumber(), 20);
100  $this->assertEquals($new_obj->getPostCondition(), $this->post_condition);
101  $this->assertEquals($new_obj->getRefId(), self::REF_ID);
102  }
103 
107  public function testWithPostCondition(LSItem $object)
108  {
109  $pc = new ilLSPostCondition(555, "2");
110  $new_obj = $object->withPostCondition($pc);
111 
112  $this->assertEquals($object->getType(), self::TYPE);
113  $this->assertEquals($object->getTitle(), self::TITLE);
114  $this->assertEquals($object->getDescription(), self::DESC);
115  $this->assertEquals($object->getIconPath(), self::ICON_PATH);
116  $this->assertEquals($object->isOnline(), self::IS_ONLINE);
117  $this->assertEquals($object->getOrderNumber(), self::ORDER_NUMBER);
118  $this->assertEquals($object->getPostCondition(), $this->post_condition);
119  $this->assertEquals($object->getRefId(), self::REF_ID);
120 
121  $this->assertEquals($new_obj->getType(), self::TYPE);
122  $this->assertEquals($new_obj->getTitle(), self::TITLE);
123  $this->assertEquals($new_obj->getDescription(), self::DESC);
124  $this->assertEquals($new_obj->getIconPath(), self::ICON_PATH);
125  $this->assertEquals($new_obj->isOnline(), self::IS_ONLINE);
126  $this->assertEquals($new_obj->getOrderNumber(), self::ORDER_NUMBER);
127  $this->assertEquals($new_obj->getPostCondition(), $pc);
128  $this->assertEquals($new_obj->getRefId(), self::REF_ID);
129  }
130 
134  public function testWrongValueInWithOnline(LSItem $object)
135  {
136  $this->expectException(TypeError::class);
137  $object->withOnline("wrong_value");
138  }
139 
143  public function testWrongValueInWithOrderNumber(LSItem $object)
144  {
145  $this->expectException(TypeError::class);
146  $object->withOrderNumber("wrong_value");
147  }
148 
152  public function testWrongValueInWithPostCondition(LSItem $object)
153  {
154  $this->expectException(TypeError::class);
155  $object->withPostCondition("wrong_value");
156  }
157 }
getTitle()
Definition: LSItem.php:78
getOrderNumber()
Definition: LSItem.php:105
getPostCondition()
Definition: LSItem.php:117
const REF_ID
Definition: LSItemTest.php:15
getDescription()
Definition: LSItem.php:83
getRefId()
Definition: LSItem.php:129
withOrderNumber(int $order_number)
Definition: LSItem.php:110
testWrongValueInWithOrderNumber(LSItem $object)
testCreate
Definition: LSItemTest.php:143
const IS_ONLINE
Definition: LSItemTest.php:13
getIconPath()
Definition: LSItem.php:88
testWithOrderNumber(LSItem $object)
testCreate
Definition: LSItemTest.php:81
isOnline()
Definition: LSItem.php:93
const TITLE
Definition: LSItemTest.php:10
Data holding class LSItem .
Definition: LSItem.php:11
const TYPE
Definition: LSItemTest.php:9
const DESC
Definition: LSItemTest.php:11
testWrongValueInWithOnline(LSItem $object)
testCreate
Definition: LSItemTest.php:134
A PostCondition does restrict the progression of a user through the learning sequence.
withPostCondition(ilLSPostCondition $postcondition)
Definition: LSItem.php:122
withOnline(bool $online)
Definition: LSItem.php:98
testWithOnline(LSItem $object)
testCreate
Definition: LSItemTest.php:55
testWithPostCondition(LSItem $object)
testCreate
Definition: LSItemTest.php:107
testWrongValueInWithPostCondition(LSItem $object)
testCreate
Definition: LSItemTest.php:152
const ICON_PATH
Definition: LSItemTest.php:12
getType()
Definition: LSItem.php:73
const ORDER_NUMBER
Definition: LSItemTest.php:14