Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 2 additions & 5 deletions apps/appstore/tests/Controller/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
use OC\Installer;
use OCA\Appstore\Controller\ApiController;
use OCP\AppFramework\Http\DataResponse;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IRequest;
use OCP\L10N\IFactory;
use OCP\Support\Subscription\IRegistry;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\FakeAppConfig;
use Test\TestCase;

#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
Expand All @@ -31,8 +31,6 @@

private IConfig&MockObject $config;

private IAppConfig&MockObject $appConfig;

private AppManager&MockObject $appManager;

private DependencyAnalyzer&MockObject $dependencyAnalyzer;
Expand All @@ -59,7 +57,6 @@

$this->request = $this->createMock(IRequest::class);
$this->config = $this->createMock(IConfig::class);
$this->appConfig = $this->createMock(IAppConfig::class);
$this->appManager = $this->createMock(AppManager::class);
$this->dependencyAnalyzer = $this->createMock(DependencyAnalyzer::class);
$this->categoryFetcher = $this->createMock(CategoryFetcher::class);
Expand All @@ -73,7 +70,7 @@
$this->apiController = new ApiController(
$this->request,
$this->config,
$this->appConfig,
new FakeAppConfig(),

Check failure on line 73 in apps/appstore/tests/Controller/ApiControllerTest.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedClass

apps/appstore/tests/Controller/ApiControllerTest.php:73:8: UndefinedClass: Class, interface or enum named Test\FakeAppConfig does not exist (see https://psalm.dev/019)
$this->appManager,
$this->dependencyAnalyzer,
$this->categoryFetcher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudIdManager;
use OCP\IAppConfig;
use OCP\IGroupManager;
use OCP\IRequest;
use OCP\IURLGenerator;
Expand All @@ -29,6 +28,7 @@
use OCP\OCM\IOCMDiscoveryService;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Test\FakeAppConfig;
use Test\TestCase;

class RequestHandlerControllerTest extends TestCase {
Expand All @@ -41,7 +41,6 @@ class RequestHandlerControllerTest extends TestCase {
private Config&MockObject $config;
private IEventDispatcher&MockObject $eventDispatcher;
private FederatedInviteMapper&MockObject $federatedInviteMapper;
private IAppConfig&MockObject $appConfig;

private ICloudFederationFactory&MockObject $cloudFederationFactory;
private ICloudIdManager&MockObject $cloudIdManager;
Expand All @@ -62,7 +61,6 @@ protected function setUp(): void {
$this->config = $this->createMock(Config::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->federatedInviteMapper = $this->createMock(FederatedInviteMapper::class);
$this->appConfig = $this->createMock(IAppConfig::class);
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
$this->cloudIdManager = $this->createMock(ICloudIdManager::class);
$this->discoveryService = $this->createMock(IOCMDiscoveryService::class);
Expand All @@ -79,7 +77,7 @@ protected function setUp(): void {
$this->config,
$this->eventDispatcher,
$this->federatedInviteMapper,
$this->appConfig,
new FakeAppConfig(),
$this->cloudFederationFactory,
$this->cloudIdManager,
$this->discoveryService,
Expand Down
9 changes: 4 additions & 5 deletions apps/dashboard/tests/DashboardServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
use Test\FakeAppConfig;
use Test\FakeFrameworkAppConfig;

class DashboardServiceTest extends TestCase {

private IUserConfig&MockObject $userConfig;
private IAppConfig&MockObject $appConfig;
private IAppConfig $appConfig;
private IUserManager&MockObject $userManager;
private IAccountManager&MockObject $accountManager;
private DashboardService $service;
Expand All @@ -31,7 +33,7 @@ protected function setUp(): void {
parent::setUp();

$this->userConfig = $this->createMock(IUserConfig::class);
$this->appConfig = $this->createMock(IAppConfig::class);
$this->appConfig = new FakeFrameworkAppConfig('dashboard');
$this->userManager = $this->createMock(IUserManager::class);
$this->accountManager = $this->createMock(IAccountManager::class);

Expand All @@ -45,9 +47,6 @@ protected function setUp(): void {
}

public function testGetLayoutRemovesEmptyAndDuplicateEntries(): void {
$this->appConfig->method('getAppValueString')
->with('layout', 'recommendations,spreed,mail,calendar')
->willReturn('recommendations,spreed,mail,calendar');
$this->userConfig->method('getValueString')
->with('alice', 'dashboard', 'layout', 'recommendations,spreed,mail,calendar')
->willReturn('spreed,,mail,mail,calendar,spreed');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@
use OCA\DAV\CalDAV\Federation\CalendarFederationConfig;
use OCP\AppFramework\Services\IAppConfig;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use Test\FakeFrameworkAppConfig;
use Test\TestCase;

class CalendarFederationConfigTest extends TestCase {
private CalendarFederationConfig $config;

private IAppConfig&MockObject $appConfig;
private IAppConfig $appConfig;

protected function setUp(): void {
parent::setUp();

$this->appConfig = $this->createMock(IAppConfig::class);

$this->config = new CalendarFederationConfig(
$this->appConfig,
);
$this->appConfig = new FakeFrameworkAppConfig('dav');
$this->config = new CalendarFederationConfig($this->appConfig);
}

public static function provideIsFederationEnabledData(): array {
Expand All @@ -39,11 +36,7 @@ public static function provideIsFederationEnabledData(): array {

#[DataProvider(methodName: 'provideIsFederationEnabledData')]
public function testIsFederationEnabled(bool $configValue): void {
$this->appConfig->expects(self::once())
->method('getAppValueBool')
->with('enableCalendarFederation', true)
->willReturn($configValue);

$this->appConfig->setAppValueBool('enableCalendarFederation', $configValue);
$this->assertEquals($configValue, $this->config->isFederationEnabled());
}
}
Loading
Loading