◆ setUp()
| ILIAS\StaticURL\Tests\ContextTest::setUp |
( |
| ) |
|
|
protected |
Definition at line 38 of file ContextTest.php.
38 : void
39 {
40 $this->container = $this->createMock(Container::class);
41 $this->tree = $this->createMock(\ilTree::class);
42 $this->
access = $this->createMock(\ilAccessHandler::class);
43 $this->container->method('repositoryTree')->willReturn($this->tree);
44 $this->container->method(
'access')->willReturn($this->
access);
45 }
References ILIAS\Repository\access().
◆ testFindFirstAccessibleParentHandlesCycle()
| ILIAS\StaticURL\Tests\ContextTest::testFindFirstAccessibleParentHandlesCycle |
( |
| ) |
|
Definition at line 121 of file ContextTest.php.
121 : void
122 {
123 $this->tree->method('isInTree')->willReturn(true);
124 $this->tree->method('getRootId')->willReturn(1);
125 $this->tree->method('getParentId')->willReturnMap([
126 [100, 80],
127 [80, 100],
128 ]);
129 $this->
access->method(
'checkAccess')->willReturn(
false);
130
131 $context = new Context($this->container);
132
133 $this->assertNull($context->findFirstAccessibleParentRefId(100));
134 }
References ILIAS\Repository\access().
◆ testFindFirstAccessibleParentHonoursCustomPermission()
| ILIAS\StaticURL\Tests\ContextTest::testFindFirstAccessibleParentHonoursCustomPermission |
( |
| ) |
|
Definition at line 136 of file ContextTest.php.
136 : void
137 {
138 $this->tree->method('isInTree')->willReturn(true);
139 $this->tree->method('getRootId')->willReturn(1);
140 $this->tree->method('getParentId')->willReturnMap([
141 [100, 80],
142 ]);
143 $this->
access->method(
'checkAccess')->willReturnCallback(
144 static fn(
string $perm,
string $_,
int $ref_id):
bool => $perm ===
'visible' &&
$ref_id === 80
145 );
146
147 $context = new Context($this->container);
148
149 $this->assertNull($context->findFirstAccessibleParentRefId(100));
150 $this->assertSame(80, $context->findFirstAccessibleParentRefId(100, 'visible'));
151 }
References $ref_id, and ILIAS\Repository\access().
◆ testFindFirstAccessibleParentReturnsDirectReadableParent()
| ILIAS\StaticURL\Tests\ContextTest::testFindFirstAccessibleParentReturnsDirectReadableParent |
( |
| ) |
|
Definition at line 57 of file ContextTest.php.
57 : void
58 {
59 $this->tree->method('isInTree')->willReturn(true);
60 $this->tree->method('getRootId')->willReturn(1);
61 $this->tree->method('getParentId')->willReturnMap([
62 [100, 50],
63 ]);
64 $this->
access->method(
'checkAccess')->willReturnCallback(
65 static fn(
string $perm,
string $_,
int $ref_id):
bool => $perm ===
'read' &&
$ref_id === 50
66 );
67
68 $context = new Context($this->container);
69
70 $this->assertSame(50, $context->findFirstAccessibleParentRefId(100));
71 }
References $ref_id, and ILIAS\Repository\access().
◆ testFindFirstAccessibleParentReturnsNullForInvalidRefId()
| ILIAS\StaticURL\Tests\ContextTest::testFindFirstAccessibleParentReturnsNullForInvalidRefId |
( |
| ) |
|
Definition at line 47 of file ContextTest.php.
47 : void
48 {
49 $this->tree->method('isInTree')->willReturn(false);
50 $context = new Context($this->container);
51
52 $this->assertNull($context->findFirstAccessibleParentRefId(0));
53 $this->assertNull($context->findFirstAccessibleParentRefId(-5));
54 $this->assertNull($context->findFirstAccessibleParentRefId(42));
55 }
◆ testFindFirstAccessibleParentReturnsNullWhenNoParentReadable()
| ILIAS\StaticURL\Tests\ContextTest::testFindFirstAccessibleParentReturnsNullWhenNoParentReadable |
( |
| ) |
|
Definition at line 91 of file ContextTest.php.
91 : void
92 {
93 $this->tree->method('isInTree')->willReturn(true);
94 $this->tree->method('getRootId')->willReturn(1);
95 $this->tree->method('getParentId')->willReturnMap([
96 [100, 80],
97 [80, 1],
98 [1, 0],
99 ]);
100 $this->
access->method(
'checkAccess')->willReturn(
false);
101
102 $context = new Context($this->container);
103
104 $this->assertNull($context->findFirstAccessibleParentRefId(100));
105 }
References ILIAS\Repository\access().
◆ testFindFirstAccessibleParentStopsAtRoot()
| ILIAS\StaticURL\Tests\ContextTest::testFindFirstAccessibleParentStopsAtRoot |
( |
| ) |
|
Definition at line 107 of file ContextTest.php.
107 : void
108 {
109 $this->tree->method('isInTree')->willReturn(true);
110 $this->tree->method('getRootId')->willReturn(1);
111 $this->tree->method('getParentId')->willReturnMap([
112 [100, 1],
113 ]);
114 $this->
access->method(
'checkAccess')->willReturn(
false);
115
116 $context = new Context($this->container);
117
118 $this->assertNull($context->findFirstAccessibleParentRefId(100));
119 }
References ILIAS\Repository\access().
◆ testFindFirstAccessibleParentWalksUntilReadPermissionFound()
| ILIAS\StaticURL\Tests\ContextTest::testFindFirstAccessibleParentWalksUntilReadPermissionFound |
( |
| ) |
|
Definition at line 73 of file ContextTest.php.
73 : void
74 {
75 $this->tree->method('isInTree')->willReturn(true);
76 $this->tree->method('getRootId')->willReturn(1);
77 $this->tree->method('getParentId')->willReturnMap([
78 [100, 80],
79 [80, 60],
80 [60, 40],
81 ]);
82 $this->
access->method(
'checkAccess')->willReturnCallback(
83 static fn(
string $perm,
string $_,
int $ref_id):
bool => $perm ===
'read' &&
$ref_id === 40
84 );
85
86 $context = new Context($this->container);
87
88 $this->assertSame(40, $context->findFirstAccessibleParentRefId(100));
89 }
References $ref_id, and ILIAS\Repository\access().
◆ $access
◆ $container
| Container MockObject ILIAS\StaticURL\Tests\ContextTest::$container |
|
private |
◆ $tree
| ilTree MockObject ILIAS\StaticURL\Tests\ContextTest::$tree |
|
private |
The documentation for this class was generated from the following file: