ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
HandlerTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Export\ImportHandler\Path\Handler as ilFilePathHandler;
24use ILIAS\Export\ImportHandler\Path\Node\Simple as ilSimpleFilePathNode;
25use PHPUnit\Framework\TestCase;
26
27class HandlerTest extends TestCase
28{
29 protected function setUp(): void
30 {
31
32 }
33
34 public function testPath(): void
35 {
36 $node1 = $this->createMock(ilSimpleFilePathNode::class);
37 $node1->expects($this->any())->method('toString')->willReturn('Node1');
38 $node1->expects($this->any())->method('requiresPathSeparator')->willReturn(true);
39 $node2 = $this->createMock(ilSimpleFilePathNode::class);
40 $node2->expects($this->any())->method('toString')->willReturn('Node2');
41 $node2->expects($this->any())->method('requiresPathSeparator')->willReturn(true);
42 $node3 = $this->createMock(ilSimpleFilePathNode::class);
43 $node3->expects($this->any())->method('toString')->willReturn('Node3');
44 $node3->expects($this->any())->method('requiresPathSeparator')->willReturn(true);
45 $nodes = [$node1, $node2, $node3];
46
47 $path = new ilFilePathHandler();
48 $path = $path
49 ->withNode($node1)
50 ->withNode($node2)
51 ->withNode($node3);
52 $path_at_root = $path
53 ->withStartAtRoot(true);
54 $sub_path = $path->subPath(1);
55 $sub_path2 = $path->subPath(0, 2);
56
57 $this->assertCount(3, $path);
58 $this->assertEquals('//Node1/Node2/Node3', $path->toString());
59 $this->assertEquals('/Node1/Node2/Node3', $path_at_root->toString());
60 $this->assertEquals('//Node2/Node3', $sub_path->toString());
61 $this->assertEquals('//Node1/Node2', $sub_path2->toString());
62 }
63}
$path
Definition: ltiservices.php:30