-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix redis not being used properly in imapClientFactoryTest
Signed-off-by: Richard Steinmetz <[email protected]>
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Mail\Tests\Integration\Framework; | ||
|
||
use OC\Memcache\Factory; | ||
use OCA\Mail\Cache\HordeCacheFactory; | ||
use OCA\Mail\IMAP\IMAPClientFactory; | ||
use OCP\AppFramework\Utility\ITimeFactory; | ||
use OCP\EventDispatcher\IEventDispatcher; | ||
use OCP\IConfig; | ||
use OCP\Profiler\IProfiler; | ||
use OCP\Security\ICrypto; | ||
use OCP\Server; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class Caching { | ||
/** | ||
* Force usage of a real cache as configured in system config. The original ICacheFactory | ||
* service closure is hard-coded to always return an instance of ArrayCache when the global | ||
* PHPUNIT_RUN is defined. | ||
*/ | ||
public static function getImapClientFactoryAndConfiguredCacheFactory(?ICrypto $crypto = null): array { | ||
$config = Server::get(IConfig::class); | ||
$cacheFactory = new Factory( | ||
static fn () => 'mail-integration-tests', | ||
Server::get(LoggerInterface::class), | ||
Server::get(IProfiler::class), | ||
$config->getSystemValue('memcache.local', null), | ||
$config->getSystemValue('memcache.distributed', null), | ||
$config->getSystemValue('memcache.locking', null), | ||
$config->getSystemValueString('redis_log_file') | ||
); | ||
$imapClient = new IMAPClientFactory( | ||
$crypto ?? Server::get(ICrypto::class), | ||
$config, | ||
$cacheFactory, | ||
Server::get(IEventDispatcher::class), | ||
Server::get(ITimeFactory::class), | ||
Server::get(HordeCacheFactory::class), | ||
); | ||
return [$imapClient, $cacheFactory]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters