Skip to content

Commit 2095622

Browse files
committed
fix: Fix debug mode and tests mocking IAppManager
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 7df7d5c commit 2095622

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

apps/files/tests/Controller/ViewControllerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ protected function setUp(): void {
104104
$this->appManager->expects($this->any())
105105
->method('isAppLoaded')
106106
->willReturn(true);
107+
$this->appManager->expects($this->any())
108+
->method('getAppNamespace')
109+
->with('files')
110+
->willReturn('OCA\\Files');
107111

108112
$this->cacheFactory = $this->createMock(ICacheFactory::class);
109113
$this->logger = $this->createMock(LoggerInterface::class);

lib/public/AppFramework/App.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public function __construct(string $appName, array $urlParams = []) {
5858
$setUpViaQuery = false;
5959

6060
$classNameParts = explode('\\', trim($applicationClassName, '\\'));
61-
6261
foreach ($e->getTrace() as $step) {
6362
if (isset($step['class'], $step['function'], $step['args'][0])
6463
&& $step['class'] === ServerContainer::class
@@ -69,7 +68,7 @@ public function __construct(string $appName, array $urlParams = []) {
6968
} elseif (isset($step['class'], $step['function'], $step['args'][0])
7069
&& $step['class'] === ServerContainer::class
7170
&& $step['function'] === 'getAppContainer'
72-
&& $step['args'][1] === $classNameParts[1]) {
71+
&& $step['args'][0] === $classNameParts[0] . '\\' . $classNameParts[1]) {
7372
$setUpViaQuery = true;
7473
break;
7574
} elseif (isset($step['class'], $step['function'], $step['args'][0])

tests/lib/AppFramework/Bootstrap/CoordinatorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ protected function setUp(): void {
4747
$this->eventLogger = $this->createMock(IEventLogger::class);
4848
$this->logger = $this->createMock(LoggerInterface::class);
4949

50+
$this->appManager->expects($this->any())
51+
->method('getAppNamespace')
52+
->with('settings')
53+
->willReturn('OCA\\Settings');
54+
5055
$this->coordinator = new Coordinator(
5156
$this->serverContainer,
5257
$this->crashReporterRegistry,

0 commit comments

Comments
 (0)