ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilIndexTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Export\ImportHandler\Path\Comparison\Handler as ilFilePathComparisonHandler;
24use ILIAS\Export\ImportHandler\Path\Node\Index as ilIndexFilePathNode;
25use PHPUnit\Framework\TestCase;
26
27class ilIndexTest extends TestCase
28{
29 public function testIndexNode(): void
30 {
31 $comp = $this->createMock(ilFilePathComparisonHandler::class);
32 $comp->expects($this->any())->method('toString')->willReturn('<3');
33
34 $node = new ilIndexFilePathNode();
35 $node2 = $node->withIndex(20);
36 $node3 = $node2->withComparison($comp);
37 $node4 = $node2->withIndexingFromEndEnabled(true);
38
39 $this->assertEquals('[0]', $node->toString());
40 $this->assertEquals('[20]', $node2->toString());
41 $this->assertEquals('[position()<3]', $node3->toString());
42 $this->assertEquals('[(last)-20]', $node4->toString());
43
44 $this->assertFalse($node->requiresPathSeparator());
45 $this->assertFalse($node2->requiresPathSeparator());
46 $this->assertFalse($node3->requiresPathSeparator());
47 $this->assertFalse($node4->requiresPathSeparator());
48 }
49}