ILIAS  release_8 Revision v8.25
ClipboardSessionRepositoryTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5use PHPUnit\Framework\TestCase;
6
12class ClipboardSessionRepositoryTest extends TestCase
13{
14 protected \ILIAS\Repository\Clipboard\ClipboardSessionRepository $clipboard;
15
16 protected function setUp(): void
17 {
18 parent::setUp();
19 $this->clipboard = new \ILIAS\Repository\Clipboard\ClipboardSessionRepository();
20 $this->clipboard->clear();
21 }
22
23 protected function tearDown(): void
24 {
25 }
26
30 public function testClear(): void
31 {
33 $clipboard->setCmd("test");
34 $clipboard->setRefIds([4]);
35 $clipboard->setParent(5);
36 $clipboard->clear();
37 $this->assertEquals(
38 "",
39 $clipboard->getCmd()
40 );
41 $this->assertEquals(
42 [],
43 $clipboard->getRefIds()
44 );
45 $this->assertEquals(
46 0,
47 $clipboard->getParent()
48 );
49 }
50
54 public function testCmd(): void
55 {
57 $clipboard->setCmd("test");
58 $this->assertEquals(
59 "test",
60 $clipboard->getCmd()
61 );
62 }
63
67 public function testRefIds(): void
68 {
70 $clipboard->setRefIds([4]);
71 $this->assertEquals(
72 [4],
73 $clipboard->getRefIds()
74 );
75 }
76
80 public function testParent(): void
81 {
83 $clipboard->setParent(5);
84 $this->assertEquals(
85 5,
86 $clipboard->getParent()
87 );
88 }
89
93 public function testHasEntriesNoCmd(): void
94 {
96 $clipboard->setRefIds([4]);
97 $this->assertEquals(
98 false,
99 $clipboard->hasEntries()
100 );
101 }
102
106 public function testHasEntriesCmd(): void
107 {
109 $clipboard->setRefIds([4]);
110 $clipboard->setCmd("cut");
111 $this->assertEquals(
112 true,
113 $clipboard->hasEntries()
114 );
115 }
116
120 public function testHasEntriesCmdEmptyRefIds(): void
121 {
123 $clipboard->setRefIds([]);
124 $clipboard->setCmd("cut");
125 $this->assertEquals(
126 false,
127 $clipboard->hasEntries()
128 );
129 }
130}
testHasEntriesCmdEmptyRefIds()
Test hasEntries returns false if empty ref ids array and cmd is given.
ILIAS Repository Clipboard ClipboardSessionRepository $clipboard
testHasEntriesNoCmd()
Test hasEntries returns false if ref ids, but no cmd is given.
testHasEntriesCmd()
Test hasEntries returns true if ref ids and cmd is given.