ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LSLearnerItemTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5use PHPUnit\Framework\TestCase;
7
8class LSLearnerItemTest extends TestCase
9{
10 const TYPE = "type";
11 const TITLE = "tile";
12 const DESC = "description";
13 const ICON_PATH = "icon_path";
14 const IS_ONLINE = true;
15 const ORDER_NUMBER = 10;
16 const REF_ID = 30;
17 const USER_ID = 6;
18 const LP_STATUS = 2;
20
24 protected $post_condition;
25
26 public function setUp()
27 {
28 $this->post_condition = new ilLSPostCondition(666, "1");
29 }
30
31 public function testCreate() : LSLearnerItem
32 {
33 $ui_reflection = new ReflectionClass(State::class);
34 $methods = array_map(
35 function ($m) {
36 return $m->getName();
37 },
38 $ui_reflection->getMethods()
39 );
40
41 $kiosk_state = $this->getMockBuilder(State::class)
42 ->setMethods($methods)
43 ->getMock()
44 ;
45
46 $ls_item = new LSItem(
47 self::TYPE,
48 self::TITLE,
49 self::DESC,
50 self::ICON_PATH,
51 self::IS_ONLINE,
52 self::ORDER_NUMBER,
53 $this->post_condition,
54 self::REF_ID
55 );
56
57 $object = new LSLearnerItem(
58 self::USER_ID,
59 function () {
60 return self::LP_STATUS;
61 },
63 $kiosk_state,
64 $ls_item
65 );
66
67 $this->assertEquals($object->getUserId(), self::USER_ID);
68 $this->assertEquals($object->getLearningProgressStatus(), self::LP_STATUS);
69 $this->assertEquals($object->getAvailability(), self::AVAILABILITY_STATUS);
70 $this->assertEquals($object->getState(), $kiosk_state);
71
72 return $object;
73 }
74
78 public function testTurnedOffWithPostCondition(LSItem $object)
79 {
80 $this->expectException(LogicException::class);
81 $object->withPostCondition($this->post_condition);
82 }
83
87 public function testTurnedOffWithOrderNumber(LSItem $object)
88 {
89 $this->expectException(LogicException::class);
90 $object->withOrderNumber(self::ORDER_NUMBER);
91 }
92
96 public function testTurnedOffWithOnline(LSItem $object)
97 {
98 $this->expectException(LogicException::class);
99 $object->withOnline(self::IS_ONLINE);
100 }
101}
An exception for terminatinating execution or to throw for unit testing.
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:10
Data holding class LSItem .
Definition: LSItem.php:12
withPostCondition(ilLSPostCondition $postcondition)
Definition: LSItem.php:122
withOrderNumber(int $order_number)
Definition: LSItem.php:110
withOnline(bool $online)
Definition: LSItem.php:98
testTurnedOffWithOnline(LSItem $object)
@depends testCreate
testTurnedOffWithOrderNumber(LSItem $object)
@depends testCreate
testTurnedOffWithPostCondition(LSItem $object)
@depends testCreate
Add learning progress and availability information to the LSItem.
A PostCondition does restrict the progression of a user through the learning sequence.