Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: use non-mocked app manager for router test
The mocked version of IAppManager will return null for getAppPath and thus parts of the tests are not executed.

To avoid more mocking a "partly" mocked IAppManager instanced is used.

Signed-off-by: Daniel Kesselberg <[email protected]>
  • Loading branch information
kesselb committed Jul 10, 2024
commit 02629ef35c660c58aa4c7baeeea098ba3a791d8d
23 changes: 21 additions & 2 deletions tests/lib/Route/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@

namespace Test\Route;

use OC\App\AppManager;
use OC\Route\Router;
use OCP\App\IAppManager;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IRequest;
use OCP\IUserSession;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Test\TestCase;

/**
Expand All @@ -36,13 +41,27 @@ function (string $message, array $data) {
$this->fail('Unexpected info log: '.(string)($data['exception'] ?? $message));
}
);

/**
* The router needs to resolve an app id to an app path.
* A non-mocked AppManager instance is required.
*/
$appManager = new AppManager(
$this->createMock(IUserSession::class),
$this->createMock(IConfig::class),
$this->createMock(IGroupManager::class),
$this->createMock(ICacheFactory::class),
$this->createMock(IEventDispatcher::class),
new NullLogger(),
);

$this->router = new Router(
$logger,
$this->createMock(IRequest::class),
$this->createMock(IConfig::class),
$this->createMock(IEventLogger::class),
$this->createMock(ContainerInterface::class),
$this->createMock(IAppManager::class),
$appManager,
);
}

Expand Down