ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
LSPlayerTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
24 class LSPlayerTest extends TestCase
25 {
28  protected ilLSPlayer $player;
29 
30  protected function setUp(): void
31  {
32  $this->available = $this->createMock(LSLearnerItem::class);
33  $this->available->method('getAvailability')
34  ->willReturn(Step::AVAILABLE);
35  $this->unavailable = $this->createMock(LSLearnerItem::class);
36  $this->unavailable->method('getAvailability')
37  ->willReturn(Step::NOT_AVAILABLE);
38 
39  $this->player = new class () extends ilLSPlayer {
40  public function __construct()
41  {
42  }
43  public function _getNextAvailableItem(
44  array $items,
45  LSLearnerItem $current_item
46  ): ?LSLearnerItem {
47  return parent::getNextAvailableItem($items, $current_item);
48  }
49  };
50  }
51 
53  {
54  $items = [
55  clone $this->available,
56  clone $this->available,
57  clone $this->available,
58  clone $this->unavailable,
59  ];
60  $this->assertNotSame($items[0], $items[2]);
61  $this->assertEquals(Step::AVAILABLE, $items[1]->getAvailability());
62  $this->assertEquals(Step::NOT_AVAILABLE, $items[3]->getAvailability());
63 
64  $current = $items[1];
65  $next = $this->player->_getNextAvailableItem($items, $current);
66  $this->assertSame($current, $next);
67  }
68 
70  {
71  $items = [
72  clone $this->unavailable,
73  clone $this->unavailable,
74  clone $this->unavailable,
75  ];
76  $current = $items[1];
77  $this->assertNull(
78  $this->player->_getNextAvailableItem($items, $current)
79  );
80  }
81 
83  {
84  $items = [
85  clone $this->unavailable,
86  clone $this->available, //expected
87  clone $this->unavailable,
88  clone $this->unavailable, //current
89  clone $this->available,
90  ];
91  $current = $items[3];
92  $this->assertEquals(
93  1,
94  array_search($this->player->_getNextAvailableItem($items, $current), $items)
95  );
96  }
97 
99  {
100  $items = [
101  clone $this->unavailable,
102  clone $this->unavailable, //current
103  clone $this->unavailable,
104  clone $this->available, //expected
105  clone $this->available,
106  ];
107  $current = $items[1];
108  $this->assertEquals(
109  3,
110  array_search($this->player->_getNextAvailableItem($items, $current), $items)
111  );
112  }
113 
114 }
LSLearnerItem $available
testLearningSequenceNextAvailableIsSame()
LSLearnerItem $unavailable
testLearningSequenceNextAvailableBackwards()
testLearningSequenceNextAvailableIsNull()
ilLSPlayer $player
Implementation of KioskMode Player.
__construct(Container $dic, ilPlugin $plugin)
testLearningSequenceNextAvailableForwards()
Add learning progress and availability information to the LSItem.