diff options
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/AppFramework/Http/RequestTest.php | 26 | ||||
-rw-r--r-- | tests/lib/Collaboration/Collaborators/MailPluginTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Collaboration/Collaborators/RemotePluginTest.php | 4 | ||||
-rw-r--r-- | tests/lib/DB/QueryBuilder/FunctionBuilderTest.php | 1 | ||||
-rw-r--r-- | tests/lib/Federation/CloudIdManagerTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Share20/DefaultShareProviderTest.php | 10 | ||||
-rw-r--r-- | tests/lib/TaskProcessing/TaskProcessingTest.php | 15 |
7 files changed, 49 insertions, 15 deletions
diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index a7ff123fc25..7ea2cb31482 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -777,12 +777,12 @@ class RequestTest extends \Test\TestCase { $this->assertSame($expected, $request->getHttpProtocol()); } - public function testGetServerProtocolWithOverride(): void { + public function testGetServerProtocolWithOverrideValid(): void { $this->config ->expects($this->exactly(3)) ->method('getSystemValueString') ->willReturnMap([ - ['overwriteprotocol', '', 'customProtocol'], + ['overwriteprotocol', '', 'HTTPS'], // should be automatically lowercased ['overwritecondaddr', '', ''], ]); @@ -794,7 +794,27 @@ class RequestTest extends \Test\TestCase { $this->stream ); - $this->assertSame('customProtocol', $request->getServerProtocol()); + $this->assertSame('https', $request->getServerProtocol()); + } + + public function testGetServerProtocolWithOverrideInValid(): void { + $this->config + ->expects($this->exactly(3)) + ->method('getSystemValueString') + ->willReturnMap([ + ['overwriteprotocol', '', 'bogusProtocol'], // should trigger fallback to http + ['overwritecondaddr', '', ''], + ]); + + $request = new Request( + [], + $this->requestId, + $this->config, + $this->csrfTokenManager, + $this->stream + ); + + $this->assertSame('http', $request->getServerProtocol()); } public function testGetServerProtocolWithProtoValid(): void { diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index 502b7844a2a..b38b961a512 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php @@ -64,11 +64,11 @@ class MailPluginTest extends TestCase { $this->userSession = $this->createMock(IUserSession::class); $this->mailer = $this->createMock(IMailer::class); $this->cloudIdManager = new CloudIdManager( + $this->createMock(ICacheFactory::class), + $this->createMock(IEventDispatcher::class), $this->contactsManager, $this->createMock(IURLGenerator::class), $this->createMock(IUserManager::class), - $this->createMock(ICacheFactory::class), - $this->createMock(IEventDispatcher::class) ); $this->searchResult = new SearchResult(); diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php index ea81b1cbcdc..a9a5e05dfe4 100644 --- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php +++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php @@ -49,11 +49,11 @@ class RemotePluginTest extends TestCase { $this->config = $this->createMock(IConfig::class); $this->contactsManager = $this->createMock(IManager::class); $this->cloudIdManager = new CloudIdManager( + $this->createMock(ICacheFactory::class), + $this->createMock(IEventDispatcher::class), $this->contactsManager, $this->createMock(IURLGenerator::class), $this->createMock(IUserManager::class), - $this->createMock(ICacheFactory::class), - $this->createMock(IEventDispatcher::class) ); $this->searchResult = new SearchResult(); } diff --git a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php index fc20af8a841..5a111c91aa7 100644 --- a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php @@ -367,6 +367,7 @@ class FunctionBuilderTest extends TestCase { $result = $query->execute(); $column = $result->fetchOne(); $result->closeCursor(); + $this->assertNotNull($column); $this->assertEquals($bytes, $column); } diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php index 3bd3cf6149d..cf97c895dc1 100644 --- a/tests/lib/Federation/CloudIdManagerTest.php +++ b/tests/lib/Federation/CloudIdManagerTest.php @@ -47,11 +47,11 @@ class CloudIdManagerTest extends TestCase { ->willReturn(new ArrayCache('')); $this->cloudIdManager = new CloudIdManager( + $this->cacheFactory, + $this->createMock(IEventDispatcher::class), $this->contactsManager, $this->urlGenerator, $this->userManager, - $this->cacheFactory, - $this->createMock(IEventDispatcher::class) ); $this->overwriteService(ICloudIdManager::class, $this->cloudIdManager); } diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index eaf17fa1a26..bacf2b61ee3 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -20,6 +20,7 @@ use OCP\Defaults; use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; +use OCP\IConfig; use OCP\IDBConnection; use OCP\IGroup; use OCP\IGroupManager; @@ -79,6 +80,8 @@ class DefaultShareProviderTest extends \Test\TestCase { /** @var LoggerInterface|MockObject */ protected $logger; + protected IConfig&MockObject $config; + protected IShareManager&MockObject $shareManager; protected function setUp(): void { @@ -94,6 +97,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->timeFactory = $this->createMock(ITimeFactory::class); $this->logger = $this->createMock(LoggerInterface::class); $this->shareManager = $this->createMock(IShareManager::class); + $this->config = $this->createMock(IConfig::class); $this->userManager->expects($this->any())->method('userExists')->willReturn(true); $this->timeFactory->expects($this->any())->method('now')->willReturn(new \DateTimeImmutable('2023-05-04 00:00 Europe/Berlin')); @@ -113,6 +117,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->timeFactory, $this->logger, $this->shareManager, + $this->config, ); } @@ -477,6 +482,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->timeFactory, $this->logger, $this->shareManager, + $this->config, ]) ->onlyMethods(['getShareById']) ->getMock(); @@ -574,6 +580,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->timeFactory, $this->logger, $this->shareManager, + $this->config, ]) ->onlyMethods(['getShareById']) ->getMock(); @@ -2566,6 +2573,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->timeFactory, $this->logger, $this->shareManager, + $this->config, ); $password = md5(time()); @@ -2666,6 +2674,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->timeFactory, $this->logger, $this->shareManager, + $this->config, ); $u1 = $userManager->createUser('testShare1', 'test'); @@ -2769,6 +2778,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->timeFactory, $this->logger, $this->shareManager, + $this->config, ); $u1 = $userManager->createUser('testShare1', 'test'); diff --git a/tests/lib/TaskProcessing/TaskProcessingTest.php b/tests/lib/TaskProcessing/TaskProcessingTest.php index db474a00687..fee4e9ba3ba 100644 --- a/tests/lib/TaskProcessing/TaskProcessingTest.php +++ b/tests/lib/TaskProcessing/TaskProcessingTest.php @@ -24,6 +24,7 @@ use OCP\Files\Config\IUserMountCache; use OCP\Files\File; use OCP\Files\IRootFolder; use OCP\Http\Client\IClientService; +use OCP\IAppConfig; use OCP\ICacheFactory; use OCP\IConfig; use OCP\IDBConnection; @@ -535,6 +536,7 @@ class TaskProcessingTest extends \Test\TestCase { private IUserMountCache $userMountCache; private IRootFolder $rootFolder; private IConfig $config; + private IAppConfig $appConfig; public const TEST_USER = 'testuser'; @@ -600,8 +602,9 @@ class TaskProcessingTest extends \Test\TestCase { $this->userMountCache = $this->createMock(IUserMountCache::class); $this->config = Server::get(IConfig::class); + $this->appConfig = Server::get(IAppConfig::class); $this->manager = new Manager( - $this->config, + $this->appConfig, $this->coordinator, $this->serverContainer, Server::get(LoggerInterface::class), @@ -641,7 +644,7 @@ class TaskProcessingTest extends \Test\TestCase { $taskProcessingTypeSettings = [ TextToText::ID => false, ]; - $this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings)); + $this->appConfig->setValueString('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings), lazy: true); self::assertCount(0, $this->manager->getAvailableTaskTypes()); self::assertCount(1, $this->manager->getAvailableTaskTypes(true)); self::assertTrue($this->manager->hasProviders()); @@ -651,7 +654,7 @@ class TaskProcessingTest extends \Test\TestCase { public function testProviderShouldBeRegisteredAndTaskFailValidation(): void { - $this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', ''); + $this->appConfig->setValueString('core', 'ai.taskprocessing_type_preferences', '', lazy: true); $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([ new ServiceRegistration('test', BrokenSyncProvider::class) ]); @@ -797,7 +800,7 @@ class TaskProcessingTest extends \Test\TestCase { $taskProcessingTypeSettings = [ TextToText::ID => true, ]; - $this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings)); + $this->appConfig->setValueString('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings), lazy: true); self::assertCount(1, $this->manager->getAvailableTaskTypes()); @@ -1239,7 +1242,7 @@ class TaskProcessingTest extends \Test\TestCase { private function createManagerInstance(): Manager { // Clear potentially cached config values if needed - $this->config->deleteAppValue('core', 'ai.taskprocessing_type_preferences'); + $this->appConfig->deleteKey('core', 'ai.taskprocessing_type_preferences'); // Re-create Text2ImageManager if its state matters or mocks change $text2imageManager = new \OC\TextToImage\Manager( @@ -1253,7 +1256,7 @@ class TaskProcessingTest extends \Test\TestCase { ); return new Manager( - $this->config, + $this->appConfig, $this->coordinator, $this->serverContainer, Server::get(LoggerInterface::class), |