diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-05-30 14:37:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-30 14:37:37 +0200 |
commit | 1164c762eb2c120ca0d2d8da83dfe9f925ed652f (patch) | |
tree | 5c5dfd39c7e750a45e4f963951c10f953837d7e8 /tests | |
parent | e86bcc8953eb4cefbd069aac1ff9913669ebaf0f (diff) | |
parent | b70c6a128fe5d0053b7971881696eafce4cb7c26 (diff) | |
download | nextcloud-server-1164c762eb2c120ca0d2d8da83dfe9f925ed652f.tar.gz nextcloud-server-1164c762eb2c120ca0d2d8da83dfe9f925ed652f.zip |
Merge pull request #31948 from nextcloud/core-cleanup-74
Update core to PHP 7.4 standard
Diffstat (limited to 'tests')
9 files changed, 31 insertions, 43 deletions
diff --git a/tests/Core/Command/Preview/RepairTest.php b/tests/Core/Command/Preview/RepairTest.php index a6591745817..d235c0d0aea 100644 --- a/tests/Core/Command/Preview/RepairTest.php +++ b/tests/Core/Command/Preview/RepairTest.php @@ -8,20 +8,20 @@ use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\IConfig; -use OCP\ILogger; use OCP\Lock\ILockingProvider; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Console\Formatter\OutputFormatterInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; +use Psr\Log\LoggerInterface; class RepairTest extends TestCase { /** @var IConfig|MockObject */ private $config; /** @var IRootFolder|MockObject */ private $rootFolder; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var IniGetWrapper|MockObject */ private $iniGetWrapper; @@ -40,7 +40,7 @@ class RepairTest extends TestCase { ->getMock(); $this->rootFolder = $this->getMockBuilder(IRootFolder::class) ->getMock(); - $this->logger = $this->getMockBuilder(ILogger::class) + $this->logger = $this->getMockBuilder(LoggerInterface::class) ->getMock(); $this->iniGetWrapper = $this->getMockBuilder(IniGetWrapper::class) ->getMock(); diff --git a/tests/Core/Controller/AutoCompleteControllerTest.php b/tests/Core/Controller/AutoCompleteControllerTest.php index 0775fbbd818..6b2f9a4f163 100644 --- a/tests/Core/Controller/AutoCompleteControllerTest.php +++ b/tests/Core/Controller/AutoCompleteControllerTest.php @@ -171,15 +171,9 @@ class AutoCompleteControllerTest extends TestCase { } /** - * @param $searchResults - * @param $expected - * @param $searchTerm - * @param $itemType - * @param $itemId - * @param $sorter * @dataProvider searchDataProvider */ - public function testGet($searchResults, $expected, $searchTerm, $itemType, $itemId, $sorter) { + public function testGet(array $searchResults, array $expected, string $searchTerm, ?string $itemType, ?string $itemId, ?string $sorter) { $this->collaboratorSearch->expects($this->once()) ->method('search') ->willReturn([$searchResults, false]); diff --git a/tests/Core/Controller/AvatarControllerTest.php b/tests/Core/Controller/AvatarControllerTest.php index 8d3cd73a656..5c0814dbf86 100644 --- a/tests/Core/Controller/AvatarControllerTest.php +++ b/tests/Core/Controller/AvatarControllerTest.php @@ -42,10 +42,10 @@ use OCP\IAvatar; use OCP\IAvatarManager; use OCP\ICache; use OCP\IL10N; -use OCP\ILogger; use OCP\IRequest; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Class AvatarControllerTest @@ -72,7 +72,7 @@ class AvatarControllerTest extends \Test\TestCase { private $userManager; /** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */ private $rootFolder; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */ private $request; @@ -90,7 +90,7 @@ class AvatarControllerTest extends \Test\TestCase { $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->request = $this->getMockBuilder(IRequest::class)->getMock(); $this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock(); - $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); + $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $this->timeFactory = $this->getMockBuilder('OC\AppFramework\Utility\TimeFactory')->getMock(); $this->avatarMock = $this->getMockBuilder('OCP\IAvatar')->getMock(); @@ -293,8 +293,8 @@ class AvatarControllerTest extends \Test\TestCase { $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $this->logger->expects($this->once()) - ->method('logException') - ->with(new \Exception("foo")); + ->method('error') + ->with('foo', ['exception' => new \Exception("foo"), 'app' => 'core']); $expectedResponse = new Http\JSONResponse(['data' => ['message' => 'An error occurred. Please contact your admin.']], Http::STATUS_BAD_REQUEST); $this->assertEquals($expectedResponse, $this->avatarController->deleteAvatar()); } @@ -485,8 +485,8 @@ class AvatarControllerTest extends \Test\TestCase { $userFolder->method('get')->willReturn($file); $this->logger->expects($this->once()) - ->method('logException') - ->with(new \Exception("foo")); + ->method('error') + ->with('foo', ['exception' => new \Exception("foo"), 'app' => 'core']); $expectedResponse = new Http\JSONResponse(['data' => ['message' => 'An error occurred. Please contact your admin.']], Http::STATUS_OK); $this->assertEquals($expectedResponse, $this->avatarController->postAvatar('avatar.jpg')); } @@ -545,8 +545,8 @@ class AvatarControllerTest extends \Test\TestCase { $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $this->logger->expects($this->once()) - ->method('logException') - ->with(new \Exception('foo')); + ->method('error') + ->with('foo', ['exception' => new \Exception("foo"), 'app' => 'core']); $expectedResponse = new Http\JSONResponse(['data' => ['message' => 'An error occurred. Please contact your admin.']], Http::STATUS_BAD_REQUEST); $this->assertEquals($expectedResponse, $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 11])); } diff --git a/tests/Core/Controller/GuestAvatarControllerTest.php b/tests/Core/Controller/GuestAvatarControllerTest.php index b5682d2d716..8688f531519 100644 --- a/tests/Core/Controller/GuestAvatarControllerTest.php +++ b/tests/Core/Controller/GuestAvatarControllerTest.php @@ -7,8 +7,8 @@ use OCP\AppFramework\Http\FileDisplayResponse; use OCP\Files\SimpleFS\ISimpleFile; use OCP\IAvatar; use OCP\IAvatarManager; -use OCP\ILogger; use OCP\IRequest; +use Psr\Log\LoggerInterface; /** * This class provides tests for the guest avatar controller. @@ -41,7 +41,7 @@ class GuestAvatarControllerTest extends \Test\TestCase { private $file; /** - * @var ILogger|\PHPUnit\Framework\MockObject\MockObject + * @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; @@ -51,7 +51,7 @@ class GuestAvatarControllerTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); + $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $this->request = $this->getMockBuilder(IRequest::class)->getMock(); $this->avatar = $this->getMockBuilder(IAvatar::class)->getMock(); $this->avatarManager = $this->getMockBuilder(IAvatarManager::class)->getMock(); diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php index 30a625a612b..551e8917482 100644 --- a/tests/Core/Controller/LoginControllerTest.php +++ b/tests/Core/Controller/LoginControllerTest.php @@ -34,7 +34,6 @@ use OCP\Defaults; use OCP\IConfig; use OCP\IInitialStateService; use OCP\IL10N; -use OCP\ILogger; use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; @@ -67,9 +66,6 @@ class LoginControllerTest extends TestCase { /** @var IURLGenerator|MockObject */ private $urlGenerator; - /** @var ILogger|MockObject */ - private $logger; - /** @var Manager|MockObject */ private $twoFactorManager; @@ -102,7 +98,6 @@ class LoginControllerTest extends TestCase { $this->session = $this->createMock(ISession::class); $this->userSession = $this->createMock(Session::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); - $this->logger = $this->createMock(ILogger::class); $this->twoFactorManager = $this->createMock(Manager::class); $this->defaults = $this->createMock(Defaults::class); $this->throttler = $this->createMock(Throttler::class); @@ -134,7 +129,6 @@ class LoginControllerTest extends TestCase { $this->session, $this->userSession, $this->urlGenerator, - $this->logger, $this->defaults, $this->throttler, $this->chain, diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index e860c808014..8252e38b568 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -32,7 +32,6 @@ use OCP\Encryption\IManager; use OCP\IConfig; use OCP\IInitialStateService; use OCP\IL10N; -use OCP\ILogger; use OCP\IRequest; use OCP\IURLGenerator; use OCP\IUser; @@ -41,6 +40,7 @@ use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; use OCP\Security\VerificationToken\InvalidTokenException; use OCP\Security\VerificationToken\IVerificationToken; +use Psr\Log\LoggerInterface; /** * Class LostControllerTest @@ -69,7 +69,7 @@ class LostControllerTest extends \Test\TestCase { private $encryptionManager; /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */ private $request; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var Manager|\PHPUnit\Framework\MockObject\MockObject */ private $twofactorManager; @@ -125,7 +125,7 @@ class LostControllerTest extends \Test\TestCase { $this->encryptionManager->expects($this->any()) ->method('isEnabled') ->willReturn(true); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->twofactorManager = $this->createMock(Manager::class); $this->initialStateService = $this->createMock(IInitialStateService::class); $this->verificationToken = $this->createMock(IVerificationToken::class); @@ -196,7 +196,7 @@ class LostControllerTest extends \Test\TestCase { ]); $this->logger->expects($this->exactly(0)) - ->method('logException'); + ->method('error'); $this->logger->expects($this->exactly(2)) ->method('warning'); @@ -397,7 +397,7 @@ class LostControllerTest extends \Test\TestCase { ->will($this->throwException(new \Exception())); $this->logger->expects($this->exactly(1)) - ->method('logException'); + ->method('error'); $response = $this->lostController->email('ExistingUser'); $expectedResponse = new JSONResponse(['status' => 'success']); @@ -549,7 +549,7 @@ class LostControllerTest extends \Test\TestCase { ->willReturn($user); $this->logger->expects($this->exactly(0)) - ->method('logException'); + ->method('error'); $this->logger->expects($this->once()) ->method('warning'); @@ -632,7 +632,7 @@ class LostControllerTest extends \Test\TestCase { ->willReturn([$user1, $user2]); $this->logger->expects($this->exactly(0)) - ->method('logException'); + ->method('error'); $this->logger->expects($this->once()) ->method('warning'); diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php index 561f243eb4b..94bb959fbbc 100644 --- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php +++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php @@ -31,13 +31,13 @@ use OCP\Authentication\TwoFactorAuth\IActivatableAtLogin; use OCP\Authentication\TwoFactorAuth\ILoginSetupProvider; use OCP\Authentication\TwoFactorAuth\IProvider; use OCP\Authentication\TwoFactorAuth\TwoFactorException; -use OCP\ILogger; use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserSession; use OCP\Template; +use Psr\Log\LoggerInterface; use Test\TestCase; class TwoFactorChallengeControllerTest extends TestCase { @@ -57,7 +57,7 @@ class TwoFactorChallengeControllerTest extends TestCase { /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */ private $urlGenerator; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var TwoFactorChallengeController|\PHPUnit\Framework\MockObject\MockObject */ @@ -71,7 +71,7 @@ class TwoFactorChallengeControllerTest extends TestCase { $this->userSession = $this->createMock(IUserSession::class); $this->session = $this->createMock(ISession::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->controller = $this->getMockBuilder(TwoFactorChallengeController::class) ->setConstructorArgs([ diff --git a/tests/Core/Service/LoginFlowV2ServiceUnitTest.php b/tests/Core/Service/LoginFlowV2ServiceUnitTest.php index 18b2f370fb3..c3128dca334 100644 --- a/tests/Core/Service/LoginFlowV2ServiceUnitTest.php +++ b/tests/Core/Service/LoginFlowV2ServiceUnitTest.php @@ -34,9 +34,10 @@ use OC\Core\Service\LoginFlowV2Service; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; /** @@ -49,7 +50,7 @@ class LoginFlowV2ServiceUnitTest extends TestCase { /** @var \OCP\Security\ICrypto */ private $crypto; - /** @var \OCP\ILogger */ + /** @var LoggerInterface|MockObject */ private $logger; /** @var \OC\Core\Db\LoginFlowV2Mapper */ @@ -88,7 +89,7 @@ class LoginFlowV2ServiceUnitTest extends TestCase { $this->mapper = $this->getMockBuilder(LoginFlowV2Mapper::class) ->disableOriginalConstructor()->getMock(); - $this->logger = $this->getMockBuilder(ILogger::class) + $this->logger = $this->getMockBuilder(LoggerInterface::class) ->disableOriginalConstructor()->getMock(); $this->tokenProvider = $this->getMockBuilder(IProvider::class) diff --git a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php index cc04992ae18..7dfcfe22261 100644 --- a/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/BruteForceMiddlewareTest.php @@ -36,8 +36,7 @@ class BruteForceMiddlewareTest extends TestCase { private $throttler; /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */ private $request; - /** @var BruteForceMiddleware */ - private $bruteForceMiddleware; + private BruteForceMiddleware $bruteForceMiddleware; protected function setUp(): void { parent::setUp(); |