summaryrefslogtreecommitdiffstats
path: root/tests/Core
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-04-12 17:55:01 +0200
committerCarl Schwan <carl@carlschwan.eu>2022-05-20 22:18:06 +0200
commitb70c6a128fe5d0053b7971881696eafce4cb7c26 (patch)
tree641ff76531803c207a92d86f47d46b6dd93ab6d3 /tests/Core
parent2b0d82675f669f00ad90f2750b1832a60ec9f766 (diff)
downloadnextcloud-server-b70c6a128fe5d0053b7971881696eafce4cb7c26.tar.gz
nextcloud-server-b70c6a128fe5d0053b7971881696eafce4cb7c26.zip
Update core to PHP 7.4 standard
- Typed properties - Port to LoggerInterface Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'tests/Core')
-rw-r--r--tests/Core/Command/Preview/RepairTest.php6
-rw-r--r--tests/Core/Controller/AutoCompleteControllerTest.php8
-rw-r--r--tests/Core/Controller/AvatarControllerTest.php18
-rw-r--r--tests/Core/Controller/GuestAvatarControllerTest.php6
-rw-r--r--tests/Core/Controller/LoginControllerTest.php6
-rw-r--r--tests/Core/Controller/LostControllerTest.php14
-rw-r--r--tests/Core/Controller/TwoFactorChallengeControllerTest.php6
-rw-r--r--tests/Core/Service/LoginFlowV2ServiceUnitTest.php7
8 files changed, 30 insertions, 41 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)