ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCtrlAbstractPathTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once __DIR__ . '/ilCtrlPathTestBase.php';
22
29{
30 public function testAbstractPathGetCidPath(): void
31 {
32 $path = $this->getPath('a:b:c');
33 $this->assertEquals('a:b:c', $path->getCidPath());
34
35 $path = $this->getPath('0');
36 $this->assertEquals('0', $path->getCidPath());
37
38 $path = $this->getPath('');
39 $this->assertNull($path->getCidPath());
40
41 $path = $this->getPath();
42 $this->assertNull($path->getCidPath());
43 }
44
45 public function testAbstractPathGetCurrentCid(): void
46 {
47 $path = $this->getPath('a:b:c');
48 $this->assertEquals('c', $path->getCurrentCid());
49
50 $path = $this->getPath('');
51 $this->assertNull($path->getCurrentCid());
52
53 $path = $this->getPath();
54 $this->assertNull($path->getCurrentCid());
55 }
56
57 public function testAbstractPathGetNextCid(): void
58 {
59 $path = $this->getPath('1:2:3');
60 $this->assertEquals('2', $path->getNextCid(ilCtrlBaseClass2TestGUI::class));
61 $this->assertEquals('3', $path->getNextCid(ilCtrlCommandClass1TestGUI::class));
62 $this->assertNull($path->getNextCid(ilCtrlCommandClass2TestGUI::class));
63
64 $path = $this->getPath('');
65 $this->assertNull($path->getNextCid(ilCtrlBaseClass1TestGUI::class));
66
67 $path = $this->getPath();
68 $this->assertNull($path->getNextCid(ilCtrlBaseClass1TestGUI::class));
69 }
70
71 public function testAbstractPathGetCidPaths(): void
72 {
73 $path = $this->getPath('0:1:2');
74 $this->assertEquals(
75 [
76 '0',
77 '0:1',
78 '0:1:2',
79 ],
80 $path->getCidPaths(SORT_ASC)
81 );
82
83 $this->assertEquals(
84 [
85 '0:1:2',
86 '0:1',
87 '0',
88 ],
89 $path->getCidPaths()
90 );
91
92 $path = $this->getPath('');
93 $this->assertEmpty($path->getCidPaths());
94 }
95
96 public function testAbstractPathGetCidArray(): void
97 {
98 $path = $this->getPath('a:b:c');
99 $this->assertEquals(['c', 'b', 'a'], $path->getCidArray());
100 $this->assertEquals(['a', 'b', 'c'], $path->getCidArray(SORT_ASC));
101
102 $path = $this->getPath('');
103 $this->assertEmpty($path->getCidArray());
104
105 $path = $this->getPath();
106 $this->assertEmpty($path->getCidArray());
107 }
108}
Class ilCtrlAbstractPathTest.
Class ilCtrlPathTestBase.
getPath(?string $cid_path=null)
$path
Definition: ltiservices.php:30