ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCtrlAbstractPathTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /* Copyright (c) 2021 Thibeau Fuhrer <thf@studer-raimann.ch> Extended GPL, see docs/LICENSE */
6 
7 require_once __DIR__ . '/ilCtrlPathTestBase.php';
8 
15 {
16  public function testAbstractPathGetCidPath(): void
17  {
18  $path = $this->getPath('a:b:c');
19  $this->assertEquals('a:b:c', $path->getCidPath());
20 
21  $path = $this->getPath('0');
22  $this->assertEquals('0', $path->getCidPath());
23 
24  $path = $this->getPath('');
25  $this->assertNull($path->getCidPath());
26 
27  $path = $this->getPath();
28  $this->assertNull($path->getCidPath());
29  }
30 
31  public function testAbstractPathGetCurrentCid(): void
32  {
33  $path = $this->getPath('a:b:c');
34  $this->assertEquals('c', $path->getCurrentCid());
35 
36  $path = $this->getPath('');
37  $this->assertNull($path->getCurrentCid());
38 
39  $path = $this->getPath();
40  $this->assertNull($path->getCurrentCid());
41  }
42 
43  public function testAbstractPathGetNextCid(): void
44  {
45  $path = $this->getPath('1:2:3');
46  $this->assertEquals('2', $path->getNextCid(ilCtrlBaseClass2TestGUI::class));
47  $this->assertEquals('3', $path->getNextCid(ilCtrlCommandClass1TestGUI::class));
48  $this->assertNull($path->getNextCid(ilCtrlCommandClass2TestGUI::class));
49 
50  $path = $this->getPath('');
51  $this->assertNull($path->getNextCid(ilCtrlBaseClass1TestGUI::class));
52 
53  $path = $this->getPath();
54  $this->assertNull($path->getNextCid(ilCtrlBaseClass1TestGUI::class));
55  }
56 
57  public function testAbstractPathGetCidPaths(): void
58  {
59  $path = $this->getPath('0:1:2');
60  $this->assertEquals(
61  [
62  '0',
63  '0:1',
64  '0:1:2',
65  ],
66  $path->getCidPaths(SORT_ASC)
67  );
68 
69  $this->assertEquals(
70  [
71  '0:1:2',
72  '0:1',
73  '0',
74  ],
75  $path->getCidPaths()
76  );
77 
78  $path = $this->getPath('');
79  $this->assertEmpty($path->getCidPaths());
80  }
81 
82  public function testAbstractPathGetCidArray(): void
83  {
84  $path = $this->getPath('a:b:c');
85  $this->assertEquals(['c', 'b', 'a'], $path->getCidArray());
86  $this->assertEquals(['a', 'b', 'c'], $path->getCidArray(SORT_ASC));
87 
88  $path = $this->getPath('');
89  $this->assertEmpty($path->getCidArray());
90 
91  $path = $this->getPath();
92  $this->assertEmpty($path->getCidArray());
93  }
94 }
$path
Definition: ltiservices.php:32
Class ilCtrlPathTestBase.
Class ilCtrlAbstractPathTest.
getPath(string $cid_path=null)