Skip to content

Commit 4f0a150

Browse files
Antreesynickvergessen
authored andcommitted
test(navigation): Resolve closure-registered nav entries in OCS requests
ocs/v1.php never called NavigationManager::setup(), so app nav entries registered via a closure (e.g. Talk) never resolved for OCS requests, making them invisible to unified search's app provider. Assisted-by: ClaudeCode:claude-sonnet-5 Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent eac6236 commit 4f0a150

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

tests/lib/NavigationManagerTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,36 @@ public function testAddClosure(array $entry, array $expectedEntry): void {
173173
$this->assertEmpty($this->navigationManager->getAll('all'), 'Expected no navigation entry exists after clear()');
174174
}
175175

176+
/**
177+
* Entry points that never call setup() (e.g. the OCS dispatch in ocs/v1.php)
178+
* must not silently lose closure-registered entries such as an app's nav
179+
* link: getAll() should only resolve what it can, not resolve nothing.
180+
*/
181+
public function testGetAllDoesNotResolveClosureBeforeSetup(): void {
182+
$numberOfCalls = 0;
183+
$this->navigationManager->add(function () use (&$numberOfCalls) {
184+
$numberOfCalls++;
185+
186+
return [
187+
'id' => 'entry id',
188+
'name' => 'link text',
189+
'order' => 1,
190+
'href' => 'url',
191+
];
192+
});
193+
194+
$navigationEntries = $this->navigationManager->getAll('all');
195+
196+
$this->assertEquals(0, $numberOfCalls, 'Expected that the closure is not called by getAll() before setup()');
197+
$this->assertEmpty($navigationEntries, 'Expected no navigation entry exists before setup()');
198+
199+
$this->navigationManager->setup();
200+
$navigationEntries = $this->navigationManager->getAll('all');
201+
202+
$this->assertEquals(1, $numberOfCalls, 'Expected that the closure is called by getAll() once setup() has run');
203+
$this->assertArrayHasKey('entry id', $navigationEntries);
204+
}
205+
176206
public function testAddClosureAfterSetup(): void {
177207
$this->navigationManager->setup();
178208
$this->assertEmpty($this->navigationManager->getAll('all'), 'Expected no navigation entry exists');

0 commit comments

Comments
 (0)