ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LSPlayerTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
23
24class LSPlayerTest extends TestCase
25{
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,
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 = [
75 ];
76 $current = $items[1];
77 $this->assertNull(
78 $this->player->_getNextAvailableItem($items, $current)
79 );
80 }
81
83 {
84 $items = [
86 clone $this->available, //expected
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}
Add learning progress and availability information to the LSItem.
testLearningSequenceNextAvailableIsNull()
LSLearnerItem $available
testLearningSequenceNextAvailableIsSame()
ilLSPlayer $player
testLearningSequenceNextAvailableBackwards()
testLearningSequenceNextAvailableForwards()
LSLearnerItem $unavailable
Implementation of KioskMode Player.
This describes a Workflow Step.
Definition: Step.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc