diff options
author | Joas Schilling <coding@schilljs.com> | 2021-04-19 14:06:34 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-04-27 14:34:32 +0200 |
commit | df47445c014b83d8400bada6dad53d26d24fd803 (patch) | |
tree | c1b46093f33a84209a7b037647888703b31b2e82 | |
parent | 56ae87c281d2f54b23f98acf0e138d8e72196a06 (diff) | |
download | nextcloud-server-df47445c014b83d8400bada6dad53d26d24fd803.tar.gz nextcloud-server-df47445c014b83d8400bada6dad53d26d24fd803.zip |
Fix unit tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
25 files changed, 98 insertions, 93 deletions
diff --git a/apps/files_sharing/tests/TestCase.php b/apps/files_sharing/tests/TestCase.php index f8966e3a83f..d772e6359ec 100644 --- a/apps/files_sharing/tests/TestCase.php +++ b/apps/files_sharing/tests/TestCase.php @@ -187,7 +187,7 @@ abstract class TestCase extends \Test\TestCase { $userObject = $userManager->createUser($user, $password); $group = $groupManager->createGroup('group'); - if ($group and $userObject) { + if ($group && $userObject) { $group->addUser($userObject); } } diff --git a/console.php b/console.php index 88456a9bd77..4aa6e214cb7 100644 --- a/console.php +++ b/console.php @@ -93,7 +93,7 @@ try { \OC::$server->getConfig(), \OC::$server->getEventDispatcher(), \OC::$server->getRequest(), - \OC::$server->getLogger(), + \OC::$server->get(\Psr\Log\LoggerInterface::class), \OC::$server->query(\OC\MemoryInfo::class) ); $application->loadCommands(new ArgvInput(), new ConsoleOutput()); diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php index fc219e79bcd..33bb967f08c 100644 --- a/core/Command/Maintenance/Install.php +++ b/core/Command/Maintenance/Install.php @@ -37,6 +37,7 @@ use OC\Installer; use OC\Setup; use OC\SystemConfig; use OCP\Defaults; +use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; @@ -85,7 +86,7 @@ class Install extends Command { $this->iniGetWrapper, $server->getL10N('lib'), $server->query(Defaults::class), - $server->getLogger(), + $server->get(LoggerInterface::class), $server->getSecureRandom(), \OC::$server->query(Installer::class) ); diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php index 627618f04fa..33b02c0291f 100644 --- a/lib/private/AppFramework/Bootstrap/Coordinator.php +++ b/lib/private/AppFramework/Bootstrap/Coordinator.php @@ -175,13 +175,12 @@ class Coordinator { $application->boot($context); } } catch (QueryException $e) { - $this->logger->logException($e, [ - 'message' => "Could not boot $appId" . $e->getMessage(), + $this->logger->error("Could not boot $appId" . $e->getMessage(), [ + 'exception' => $e, ]); } catch (Throwable $e) { - $this->logger->logException($e, [ - 'message' => "Could not boot $appId" . $e->getMessage(), - 'level' => ILogger::FATAL, + $this->logger->emergency("Could not boot $appId" . $e->getMessage(), [ + 'exception' => $e, ]); } } diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 7395be703d3..db4f3d2c075 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -241,7 +241,7 @@ class DIContainer extends SimpleContainer implements IAppContainer { $c->get(IControllerMethodReflector::class), $c->get(INavigationManager::class), $c->get(IURLGenerator::class), - $server->query(ILogger::class), + $server->get(LoggerInterface::class), $c->get('AppName'), $server->getUserSession()->isLoggedIn(), $this->getUserId() !== null && $server->getGroupManager()->isAdmin($this->getUserId()), diff --git a/lib/private/Server.php b/lib/private/Server.php index c09ec0a8e18..f7eaf9f3591 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -145,6 +145,7 @@ use OC\Template\JSCombiner; use OCA\Theming\ImageManager; use OCA\Theming\ThemingDefaults; use OCA\Theming\Util; +use OCA\WorkflowEngine\Service\Logger; use OCP\Accounts\IAccountManager; use OCP\App\IAppManager; use OCP\Authentication\LoginCredentials\IStore; @@ -731,7 +732,7 @@ class Server extends ServerContainer implements IServerContainer { $c->get(\OC\User\Manager::class), $c->getAppDataDir('avatar'), $c->getL10N('lib'), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), $c->get(\OCP\IConfig::class), $c->get(IAccountManager::class), $c->get(KnownUserService::class) @@ -877,7 +878,7 @@ class Server extends ServerContainer implements IServerContainer { $c->get(IGroupManager::class), $c->get(ICacheFactory::class), $c->get(SymfonyAdapter::class), - $c->get(ILogger::class) + $c->get(LoggerInterface::class) ); }); /** @deprecated 19.0.0 */ @@ -1091,7 +1092,7 @@ class Server extends ServerContainer implements IServerContainer { $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class); $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) { - $manager = new CapabilitiesManager($c->get(ILogger::class)); + $manager = new CapabilitiesManager($c->get(LoggerInterface::class)); $manager->registerCapability(function () use ($c) { return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class)); }); @@ -1334,7 +1335,7 @@ class Server extends ServerContainer implements IServerContainer { $c->get(AppFetcher::class), $c->get(IClientService::class), $c->get(ITempManager::class), - $c->get(ILogger::class), + $c->get(LoggerInterface::class), $c->get(\OCP\IConfig::class), \OC::$CLI ); diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index f1e88166e97..63eaf303759 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -747,10 +747,10 @@ class OC_Util { $config, \OC::$server->get(IniGetWrapper::class), \OC::$server->getL10N('lib'), - \OC::$server->query(\OCP\Defaults::class), - \OC::$server->getLogger(), + \OC::$server->get(\OCP\Defaults::class), + \OC::$server->get(LoggerInterface::class), \OC::$server->getSecureRandom(), - \OC::$server->query(\OC\Installer::class) + \OC::$server->get(\OC\Installer::class) ); $urlGenerator = \OC::$server->getURLGenerator(); diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php index 5b6fedb1cc2..db2f117cb9b 100644 --- a/tests/lib/App/AppManagerTest.php +++ b/tests/lib/App/AppManagerTest.php @@ -20,10 +20,10 @@ use OCP\ICacheFactory; use OCP\IConfig; use OCP\IGroup; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IUser; use OCP\IUserSession; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; @@ -93,7 +93,7 @@ class AppManagerTest extends TestCase { /** @var EventDispatcherInterface|MockObject */ protected $eventDispatcher; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ protected $logger; /** @var IAppManager */ @@ -109,7 +109,7 @@ class AppManagerTest extends TestCase { $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->cache = $this->createMock(ICache::class); $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->cacheFactory->expects($this->any()) ->method('createDistributed') ->with('settings') diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php index f9696cc1b00..840d47ed802 100644 --- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php @@ -34,7 +34,7 @@ use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; use OCP\IConfig; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Test\TestCase; class AppFetcherTest extends TestCase { @@ -48,7 +48,7 @@ class AppFetcherTest extends TestCase { protected $config; /** @var CompareVersion|\PHPUnit\Framework\MockObject\MockObject */ protected $compareVersion; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var AppFetcher */ protected $fetcher; @@ -1848,7 +1848,7 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg== $this->timeFactory = $this->createMock(ITimeFactory::class); $this->config = $this->createMock(IConfig::class); $this->compareVersion = new CompareVersion(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->fetcher = new AppFetcher( $factory, diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php index 531fdf41e78..735df939965 100644 --- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php +++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php @@ -33,7 +33,7 @@ use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; use OCP\IConfig; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Test\TestCase; abstract class FetcherBase extends TestCase { @@ -47,7 +47,7 @@ abstract class FetcherBase extends TestCase { protected $timeFactory; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ protected $config; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var Fetcher */ protected $fetcher; @@ -67,7 +67,7 @@ abstract class FetcherBase extends TestCase { $this->clientService = $this->createMock(IClientService::class); $this->timeFactory = $this->createMock(ITimeFactory::class); $this->config = $this->createMock(IConfig::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); } public function testGetWithAlreadyExistingFileAndUpToDateTimestampAndVersion() { diff --git a/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php b/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php index 1fca34423d5..05442455cb7 100644 --- a/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php +++ b/tests/lib/AppFramework/Bootstrap/CoordinatorTest.php @@ -35,9 +35,9 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\QueryException; use OCP\Dashboard\IManager; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; use OCP\IServerContainer; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; class CoordinatorTest extends TestCase { @@ -57,7 +57,7 @@ class CoordinatorTest extends TestCase { /** @var IEventDispatcher|MockObject */ private $eventDispatcher; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var Coordinator */ @@ -71,7 +71,7 @@ class CoordinatorTest extends TestCase { $this->crashReporterRegistry = $this->createMock(Registry::class); $this->dashboardManager = $this->createMock(IManager::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->coordinator = new Coordinator( $this->serverContainer, diff --git a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php index e304a63cfc4..f97ac92e887 100644 --- a/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php +++ b/tests/lib/AppFramework/Bootstrap/RegistrationContextTest.php @@ -29,13 +29,13 @@ use OC\AppFramework\Bootstrap\RegistrationContext; use OCP\AppFramework\App; use OCP\AppFramework\IAppContainer; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; class RegistrationContextTest extends TestCase { - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var RegistrationContext */ @@ -44,7 +44,7 @@ class RegistrationContextTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->context = new RegistrationContext( $this->logger diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index a3c9efa557c..076f6588d94 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -39,11 +39,11 @@ use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; use OCP\INavigationManager; use OCP\IRequest; use OCP\IURLGenerator; use OCP\Security\ISecureRandom; +use Psr\Log\LoggerInterface; class SecurityMiddlewareTest extends \Test\TestCase { @@ -59,7 +59,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { private $request; /** @var ControllerMethodReflector */ private $reader; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var INavigationManager|\PHPUnit\Framework\MockObject\MockObject */ private $navigationManager; @@ -75,7 +75,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->controller = $this->createMock(Controller::class); $this->reader = new ControllerMethodReflector(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->navigationManager = $this->createMock(INavigationManager::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->request = $this->createMock(IRequest::class); diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index 7ada4ec746a..22fad4ab61f 100644 --- a/tests/lib/AppTest.php +++ b/tests/lib/AppTest.php @@ -13,6 +13,7 @@ use OC\App\AppManager; use OC\App\InfoParser; use OC\AppConfig; use OCP\IAppConfig; +use Psr\Log\LoggerInterface; /** * Class AppTest @@ -477,7 +478,7 @@ class AppTest extends \Test\TestCase { 'appforgroup2' => '["group2"]', 'appforgroup12' => '["group2","group1"]', ] - + ); $apps = \OC_App::getEnabledApps(false, $forceAll); @@ -512,7 +513,7 @@ class AppTest extends \Test\TestCase { 'app3' => 'yes', 'app2' => 'no', ] - + ); $apps = \OC_App::getEnabledApps(); @@ -554,7 +555,7 @@ class AppTest extends \Test\TestCase { \OC::$server->getGroupManager(), \OC::$server->getMemCacheFactory(), \OC::$server->getEventDispatcher(), - \OC::$server->getLogger() + \OC::$server->get(LoggerInterface::class) )); } diff --git a/tests/lib/Avatar/AvatarManagerTest.php b/tests/lib/Avatar/AvatarManagerTest.php index d3bc60efb59..ce6981a2a21 100644 --- a/tests/lib/Avatar/AvatarManagerTest.php +++ b/tests/lib/Avatar/AvatarManagerTest.php @@ -36,9 +36,9 @@ use OCP\Files\IAppData; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; use OCP\IUser; use OCP\IUserSession; +use Psr\Log\LoggerInterface; /** * Class AvatarManagerTest @@ -52,7 +52,7 @@ class AvatarManagerTest extends \Test\TestCase { private $appData; /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ private $l10n; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; @@ -70,7 +70,7 @@ class AvatarManagerTest extends \Test\TestCase { $this->userManager = $this->createMock(Manager::class); $this->appData = $this->createMock(IAppData::class); $this->l10n = $this->createMock(IL10N::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->config = $this->createMock(IConfig::class); $this->accountManager = $this->createMock(IAccountManager::class); $this->knownUserService = $this->createMock(KnownUserService::class); @@ -247,7 +247,7 @@ class AvatarManagerTest extends \Test\TestCase { } if ($expectedPlaceholder) { - $expected = new PlaceholderAvatar($folder, $user, $this->createMock(ILogger::class)); + $expected = new PlaceholderAvatar($folder, $user, $this->createMock(LoggerInterface::class)); } else { $expected = new UserAvatar($folder, $this->l10n, $user, $this->logger, $this->config); } diff --git a/tests/lib/Avatar/GuestAvatarTest.php b/tests/lib/Avatar/GuestAvatarTest.php index 1c424234f10..b8e6d8ae2e8 100644 --- a/tests/lib/Avatar/GuestAvatarTest.php +++ b/tests/lib/Avatar/GuestAvatarTest.php @@ -26,8 +26,8 @@ namespace Test\Avatar; use OC\Avatar\GuestAvatar; use OCP\Files\SimpleFS\InMemoryFile; -use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; /** @@ -48,8 +48,8 @@ class GuestAvatarTest extends TestCase { * @return void */ public function setupGuestAvatar() { - /* @var MockObject|ILogger $logger */ - $logger = $this->getMockBuilder(ILogger::class)->getMock(); + /* @var MockObject|LoggerInterface $logger */ + $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $this->guestAvatar = new GuestAvatar('einstein', $logger); } diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php index 31f2a6ebf5b..3570f2017d5 100644 --- a/tests/lib/Avatar/UserAvatarTest.php +++ b/tests/lib/Avatar/UserAvatarTest.php @@ -16,7 +16,7 @@ use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class UserAvatarTest extends \Test\TestCase { /** @var Folder | \PHPUnit\Framework\MockObject\MockObject */ @@ -309,7 +309,7 @@ class UserAvatarTest extends \Test\TestCase { $this->folder, $l, $user, - $this->createMock(ILogger::class), + $this->createMock(LoggerInterface::class), $this->config ); } diff --git a/tests/lib/CapabilitiesManagerTest.php b/tests/lib/CapabilitiesManagerTest.php index 536355f9697..4909272c4a8 100644 --- a/tests/lib/CapabilitiesManagerTest.php +++ b/tests/lib/CapabilitiesManagerTest.php @@ -25,19 +25,19 @@ use OC\CapabilitiesManager; use OCP\AppFramework\QueryException; use OCP\Capabilities\ICapability; use OCP\Capabilities\IPublicCapability; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class CapabilitiesManagerTest extends TestCase { /** @var CapabilitiesManager */ private $manager; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; protected function setUp(): void { parent::setUp(); - $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); + $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $this->manager = new CapabilitiesManager($this->logger); } @@ -139,7 +139,7 @@ class CapabilitiesManagerTest extends TestCase { ] ] ]; - + $this->assertEquals($expected, $res); } diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php index 81279c4c569..3ec9e6f5efc 100644 --- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php @@ -33,25 +33,26 @@ use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; use OCP\IConfig; -use OCP\ILogger; use OCP\IUser; use OCP\IUserSession; use OCP\Share\IShare; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; class LookupPluginTest extends TestCase { - /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|MockObject */ protected $config; - /** @var IClientService|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IClientService|MockObject */ protected $clientService; - /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IUserSession|MockObject */ protected $userSession; - /** @var ICloudIdManager|\PHPUnit\Framework\MockObject\MockObject */ + /** @var ICloudIdManager|MockObject */ protected $cloudIdManager; /** @var LookupPlugin */ protected $plugin; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|MockObject */ protected $logger; protected function setUp(): void { @@ -60,7 +61,7 @@ class LookupPluginTest extends TestCase { $this->userSession = $this->createMock(IUserSession::class); $this->cloudIdManager = $this->createMock(ICloudIdManager::class); $this->config = $this->createMock(IConfig::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->clientService = $this->createMock(IClientService::class); $cloudId = $this->createMock(ICloudId::class); $cloudId->expects($this->any())->method('getRemote')->willReturn('myNextcloud.net'); @@ -108,7 +109,7 @@ class LookupPluginTest extends TestCase { $this->clientService->expects($this->never()) ->method('newClient'); - /** @var ISearchResult|\PHPUnit\Framework\MockObject\MockObject $searchResult */ + /** @var ISearchResult|MockObject $searchResult */ $searchResult = $this->createMock(ISearchResult::class); $this->plugin->search('foobar', 10, 0, $searchResult); @@ -132,7 +133,7 @@ class LookupPluginTest extends TestCase { $this->clientService->expects($this->never()) ->method('newClient'); - /** @var ISearchResult|\PHPUnit\Framework\MockObject\MockObject $searchResult */ + /** @var ISearchResult|MockObject $searchResult */ $searchResult = $this->createMock(ISearchResult::class); $this->plugin->search('foobar', 10, 0, $searchResult); @@ -145,7 +146,7 @@ class LookupPluginTest extends TestCase { public function testSearch(array $searchParams) { $type = new SearchResultType('lookup'); - /** @var ISearchResult|\PHPUnit\Framework\MockObject\MockObject $searchResult */ + /** @var ISearchResult|MockObject $searchResult */ $searchResult = $this->createMock(ISearchResult::class); $searchResult->expects($this->once()) ->method('addResultSet') @@ -207,7 +208,7 @@ class LookupPluginTest extends TestCase { public function testSearchEnableDisableLookupServer(array $searchParams, $GSEnabled, $LookupEnabled) { $type = new SearchResultType('lookup'); - /** @var ISearchResult|\PHPUnit\Framework\MockObject\MockObject $searchResult */ + /** @var ISearchResult|MockObject $searchResult */ $searchResult = $this->createMock(ISearchResult::class); $this->config->expects($this->once()) @@ -269,7 +270,7 @@ class LookupPluginTest extends TestCase { ->with('files_sharing', 'lookupServerEnabled', 'yes') ->willReturn('no'); - /** @var ISearchResult|\PHPUnit\Framework\MockObject\MockObject $searchResult */ + /** @var ISearchResult|MockObject $searchResult */ $searchResult = $this->createMock(ISearchResult::class); $searchResult->expects($this->never()) ->method('addResultSet'); diff --git a/tests/lib/Collaboration/Resources/ManagerTest.php b/tests/lib/Collaboration/Resources/ManagerTest.php index 092d4ffd39c..01a39660a7c 100644 --- a/tests/lib/Collaboration/Resources/ManagerTest.php +++ b/tests/lib/Collaboration/Resources/ManagerTest.php @@ -27,12 +27,12 @@ use OC\Collaboration\Resources\Manager; use OCP\Collaboration\Resources\IManager; use OCP\Collaboration\Resources\IProviderManager; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Test\TestCase; class ManagerTest extends TestCase { - /** @var ILogger */ + /** @var LoggerInterface */ protected $logger; /** @var IProviderManager */ protected $providerManager; @@ -42,14 +42,14 @@ class ManagerTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->providerManager = $this->createMock(IProviderManager::class); /** @var IDBConnection $connection */ $connection = $this->createMock(IDBConnection::class); $this->manager = new Manager($connection, $this->providerManager, $this->logger); } - + public function testRegisterResourceProvider(): void { $this->logger->expects($this->once()) ->method('debug') diff --git a/tests/lib/Collaboration/Resources/ProviderManagerTest.php b/tests/lib/Collaboration/Resources/ProviderManagerTest.php index 751e2cc1f8d..19a34962a56 100644 --- a/tests/lib/Collaboration/Resources/ProviderManagerTest.php +++ b/tests/lib/Collaboration/Resources/ProviderManagerTest.php @@ -27,15 +27,15 @@ use OC\Collaboration\Resources\ProviderManager; use OCA\Files\Collaboration\Resources\ResourceProvider; use OCP\AppFramework\QueryException; use OCP\Collaboration\Resources\IProviderManager; -use OCP\ILogger; use OCP\IServerContainer; +use Psr\Log\LoggerInterface; use Test\TestCase; class ProviderManagerTest extends TestCase { /** @var IServerContainer */ protected $serverContainer; - /** @var ILogger */ + /** @var LoggerInterface */ protected $logger; /** @var IProviderManager */ protected $providerManager; @@ -44,7 +44,7 @@ class ProviderManagerTest extends TestCase { parent::setUp(); $this->serverContainer = $this->createMock(IServerContainer::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->providerManager = new class($this->serverContainer, $this->logger) extends ProviderManager { public function countProviders(): int { diff --git a/tests/lib/InitialStateServiceTest.php b/tests/lib/InitialStateServiceTest.php index 30eca056206..2a23774baf1 100644 --- a/tests/lib/InitialStateServiceTest.php +++ b/tests/lib/InitialStateServiceTest.php @@ -27,10 +27,10 @@ namespace Test; use OC\AppFramework\Bootstrap\Coordinator; use OCP\IServerContainer; +use Psr\Log\LoggerInterface; use function json_encode; use JsonSerializable; use OC\InitialStateService; -use OCP\ILogger; use stdClass; class InitialStateServiceTest extends TestCase { @@ -42,7 +42,7 @@ class InitialStateServiceTest extends TestCase { parent::setUp(); $this->service = new InitialStateService( - $this->createMock(ILogger::class), + $this->createMock(LoggerInterface::class), $this->createMock(Coordinator::class), $this->createMock(IServerContainer::class) ); diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php index 2626e047c74..c49f8bf76a5 100644 --- a/tests/lib/InstallerTest.php +++ b/tests/lib/InstallerTest.php @@ -14,8 +14,8 @@ use OC\Installer; use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\IConfig; -use OCP\ILogger; use OCP\ITempManager; +use Psr\Log\LoggerInterface; /** * Class InstallerTest @@ -32,7 +32,7 @@ class InstallerTest extends TestCase { private $clientService; /** @var ITempManager|\PHPUnit\Framework\MockObject\MockObject */ private $tempManager; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; @@ -43,7 +43,7 @@ class InstallerTest extends TestCase { $this->appFetcher = $this->createMock(AppFetcher::class); $this->clientService = $this->createMock(IClientService::class); $this->tempManager = $this->createMock(ITempManager::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->config = $this->createMock(IConfig::class); $config = \OC::$server->getConfig(); @@ -53,7 +53,7 @@ class InstallerTest extends TestCase { \OC::$server->getAppFetcher(), \OC::$server->getHTTPClientService(), \OC::$server->getTempManager(), - \OC::$server->getLogger(), + \OC::$server->get(LoggerInterface::class), $config, false ); @@ -76,7 +76,7 @@ class InstallerTest extends TestCase { \OC::$server->getAppFetcher(), \OC::$server->getHTTPClientService(), \OC::$server->getTempManager(), - \OC::$server->getLogger(), + \OC::$server->get(LoggerInterface::class), \OC::$server->getConfig(), false ); @@ -100,7 +100,7 @@ class InstallerTest extends TestCase { \OC::$server->getAppFetcher(), \OC::$server->getHTTPClientService(), \OC::$server->getTempManager(), - \OC::$server->getLogger(), + \OC::$server->get(LoggerInterface::class), \OC::$server->getConfig(), false ); diff --git a/tests/lib/SetupTest.php b/tests/lib/SetupTest.php index 696e1d69fbe..004fc9c866b 100644 --- a/tests/lib/SetupTest.php +++ b/tests/lib/SetupTest.php @@ -14,26 +14,27 @@ use OC\Setup; use OC\SystemConfig; use OCP\Defaults; use OCP\IL10N; -use OCP\ILogger; use OCP\Security\ISecureRandom; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; class SetupTest extends \Test\TestCase { - /** @var SystemConfig|\PHPUnit\Framework\MockObject\MockObject */ + /** @var SystemConfig|MockObject */ protected $config; - /** @var \bantu\IniGetWrapper\IniGetWrapper|\PHPUnit\Framework\MockObject\MockObject */ + /** @var \bantu\IniGetWrapper\IniGetWrapper|MockObject */ private $iniWrapper; - /** @var \OCP\IL10N|\PHPUnit\Framework\MockObject\MockObject */ + /** @var \OCP\IL10N|MockObject */ private $l10n; - /** @var Defaults|\PHPUnit\Framework\MockObject\MockObject */ + /** @var Defaults|MockObject */ private $defaults; - /** @var \OC\Setup|\PHPUnit\Framework\MockObject\MockObject */ + /** @var \OC\Setup|MockObject */ protected $setupClass; - /** @var \OCP\ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|MockObject */ protected $logger; - /** @var \OCP\Security\ISecureRandom|\PHPUnit\Framework\MockObject\MockObject */ + /** @var \OCP\Security\ISecureRandom|MockObject */ protected $random; - /** @var Installer|\PHPUnit\Framework\MockObject\MockObject */ + /** @var Installer|MockObject */ protected $installer; protected function setUp(): void { @@ -43,7 +44,7 @@ class SetupTest extends \Test\TestCase { $this->iniWrapper = $this->createMock(IniGetWrapper::class); $this->l10n = $this->createMock(IL10N::class); $this->defaults = $this->createMock(Defaults::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->random = $this->createMock(ISecureRandom::class); $this->installer = $this->createMock(Installer::class); $this->setupClass = $this->getMockBuilder(Setup::class) diff --git a/tests/lib/UpdaterTest.php b/tests/lib/UpdaterTest.php index 1affd6d020a..5a7422cbad5 100644 --- a/tests/lib/UpdaterTest.php +++ b/tests/lib/UpdaterTest.php @@ -22,22 +22,23 @@ namespace Test; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use OC\Installer; use OC\IntegrityCheck\Checker; use OC\Updater; use OCP\IConfig; -use OCP\ILogger; class UpdaterTest extends TestCase { - /** @var IConfig | \PHPUnit\Framework\MockObject\MockObject */ + /** @var IConfig|MockObject */ private $config; - /** @var ILogger | \PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var Updater */ private $updater; - /** @var Checker | \PHPUnit\Framework\MockObject\MockObject */ + /** @var Checker|MockObject */ private $checker; - /** @var Installer|\PHPUnit\Framework\MockObject\MockObject */ + /** @var Installer|MockObject */ private $installer; protected function setUp(): void { @@ -45,7 +46,7 @@ class UpdaterTest extends TestCase { $this->config = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->getMockBuilder(ILogger::class) + $this->logger = $this->getMockBuilder(LoggerInterface::class) ->disableOriginalConstructor() ->getMock(); $this->checker = $this->getMockBuilder(Checker::class) |