summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests')
-rw-r--r--apps/dav/tests/integration/UserMigration/CalendarMigratorTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php6
-rw-r--r--apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php12
-rw-r--r--apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php6
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php16
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php17
-rw-r--r--apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php6
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php6
-rw-r--r--apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php33
-rw-r--r--apps/dav/tests/unit/CardDAV/SyncServiceTest.php8
-rw-r--r--apps/dav/tests/unit/Comments/CommentsNodeTest.php8
-rw-r--r--apps/dav/tests/unit/Comments/EntityCollectionTest.php6
-rw-r--r--apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php6
-rw-r--r--apps/dav/tests/unit/Comments/RootCollectionTest.php3
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php41
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php5
-rw-r--r--apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php6
18 files changed, 74 insertions, 115 deletions
diff --git a/apps/dav/tests/integration/UserMigration/CalendarMigratorTest.php b/apps/dav/tests/integration/UserMigration/CalendarMigratorTest.php
index cf0b24e9a69..8c23a30e879 100644
--- a/apps/dav/tests/integration/UserMigration/CalendarMigratorTest.php
+++ b/apps/dav/tests/integration/UserMigration/CalendarMigratorTest.php
@@ -85,7 +85,7 @@ class CalendarMigratorTest extends TestCase {
fn (VObjectProperty $property) => $property->serialize(),
array_values(array_filter(
$vCalendar->children(),
- fn (mixed $child) => $child instanceof VObjectProperty,
+ fn ($child) => $child instanceof VObjectProperty,
)),
);
}
diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php
index c659e2ccc6d..ec966248e01 100644
--- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php
+++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php
@@ -34,12 +34,12 @@ use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IGroupManager;
-use OCP\ILogger;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
use OCP\Share\IManager as ShareManager;
+use Psr\Log\LoggerInterface;
use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet;
use Sabre\DAV\Xml\Property\Href;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -70,7 +70,7 @@ abstract class AbstractCalDavBackend extends TestCase {
/** @var ISecureRandom */
private $random;
- /** @var ILogger */
+ /** @var LoggerInterface*/
private $logger;
public const UNIT_TEST_USER = 'principals/users/caldav-unit-test';
@@ -110,7 +110,7 @@ abstract class AbstractCalDavBackend extends TestCase {
$db = \OC::$server->getDatabaseConnection();
$this->random = \OC::$server->getSecureRandom();
- $this->logger = $this->createMock(ILogger::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->config = $this->createMock(IConfig::class);
$this->backend = new CalDavBackend(
$db,
diff --git a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
index f3f53067d0d..80e43d279dc 100644
--- a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
+++ b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
@@ -39,7 +39,6 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IL10N;
-use OCP\ILogger;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use Psr\Log\LoggerInterface;
@@ -72,7 +71,7 @@ class PublicCalendarRootTest extends TestCase {
/** @var ISecureRandom */
private $random;
- /** @var ILogger */
+ /** @var LoggerInterface */
private $logger;
protected function setUp(): void {
@@ -83,8 +82,7 @@ class PublicCalendarRootTest extends TestCase {
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->random = \OC::$server->getSecureRandom();
- $this->logger = $this->createMock(ILogger::class);
- $this->psrLogger = $this->createMock(LoggerInterface::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$dispatcher = $this->createMock(IEventDispatcher::class);
$legacyDispatcher = $this->createMock(EventDispatcherInterface::class);
$config = $this->createMock(IConfig::class);
@@ -113,7 +111,7 @@ class PublicCalendarRootTest extends TestCase {
$this->config = $this->createMock(IConfig::class);
$this->publicCalendarRoot = new PublicCalendarRoot($this->backend,
- $this->l10n, $this->config, $this->psrLogger);
+ $this->l10n, $this->config, $this->logger);
}
protected function tearDown(): void {
@@ -167,11 +165,11 @@ class PublicCalendarRootTest extends TestCase {
$this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', []);
$calendarInfo = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER)[0];
- $calendar = new PublicCalendar($this->backend, $calendarInfo, $this->l10n, $this->config, $this->psrLogger);
+ $calendar = new PublicCalendar($this->backend, $calendarInfo, $this->l10n, $this->config, $this->logger);
$publicUri = $calendar->setPublishStatus(true);
$calendarInfo = $this->backend->getPublicCalendar($publicUri);
- $calendar = new PublicCalendar($this->backend, $calendarInfo, $this->l10n, $this->config, $this->psrLogger);
+ $calendar = new PublicCalendar($this->backend, $calendarInfo, $this->l10n, $this->config, $this->logger);
return $calendar;
}
diff --git a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php
index 2490bdc3639..1367b2741e6 100644
--- a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php
+++ b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php
@@ -36,7 +36,7 @@ use Sabre\HTTP\Request;
use Sabre\HTTP\Response;
use Test\TestCase;
-class PluginTest extends TestCase {
+class PublishingTest extends TestCase {
/** @var PublishPlugin */
private $plugin;
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php
index 8335428c6d5..ae272e6b1a9 100644
--- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php
+++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php
@@ -30,16 +30,16 @@ namespace OCA\DAV\Tests\unit\CalDAV\Reminder\NotificationProvider;
use OCA\DAV\CalDAV\Reminder\NotificationProvider\AbstractProvider;
use OCP\IConfig;
use OCP\IL10N;
-use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\L10N\IFactory as L10NFactory;
+use Psr\Log\LoggerInterface;
use Sabre\VObject\Component\VCalendar;
use Test\TestCase;
abstract class AbstractNotificationProviderTest extends TestCase {
- /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $logger;
/** @var L10NFactory|\PHPUnit\Framework\MockObject\MockObject */
@@ -75,7 +75,7 @@ abstract class AbstractNotificationProviderTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->logger = $this->createMock(ILogger::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->l10nFactory = $this->createMock(L10NFactory::class);
$this->l10n = $this->createMock(IL10N::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
index 0352827aa5c..6428652ccab 100644
--- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
+++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
@@ -34,7 +34,6 @@ namespace OCA\DAV\Tests\unit\CalDAV\Reminder\NotificationProvider;
use OCA\DAV\CalDAV\Reminder\NotificationProvider\EmailProvider;
use OCP\IConfig;
use OCP\IL10N;
-use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\L10N\IFactory as L10NFactory;
@@ -47,21 +46,6 @@ use Sabre\VObject\Component\VCalendar;
class EmailProviderTest extends AbstractNotificationProviderTest {
public const USER_EMAIL = 'frodo@hobb.it';
- /** @var ILogger|MockObject */
- protected $logger;
-
- /** @var L10NFactory|MockObject */
- protected $l10nFactory;
-
- /** @var IL10N|MockObject */
- protected $l10n;
-
- /** @var IURLGenerator|MockObject */
- protected $urlGenerator;
-
- /** @var IConfig|MockObject */
- protected $config;
-
/** @var IMailer|MockObject */
private $mailer;
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php
index 9e9759f5eb8..a62cb98a28f 100644
--- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php
+++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php
@@ -33,7 +33,6 @@ use OCA\DAV\CalDAV\Reminder\NotificationProvider\PushProvider;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IL10N;
-use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\L10N\IFactory as L10NFactory;
@@ -42,21 +41,6 @@ use OCP\Notification\INotification;
class PushProviderTest extends AbstractNotificationProviderTest {
- /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
- protected $logger;
-
- /** @var L10NFactory|\PHPUnit\Framework\MockObject\MockObject */
- protected $l10nFactory;
-
- /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
- protected $l10n;
-
- /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
- protected $urlGenerator;
-
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
- protected $config;
-
/** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
private $manager;
@@ -66,7 +50,6 @@ class PushProviderTest extends AbstractNotificationProviderTest {
protected function setUp(): void {
parent::setUp();
- $this->config = $this->createMock(IConfig::class);
$this->manager = $this->createMock(IManager::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php
index 5f490286347..0fffbc2cd10 100644
--- a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php
@@ -28,9 +28,9 @@ namespace OCA\DAV\Tests\unit\CalDAV\ResourceBooking;
use OCA\DAV\CalDAV\Proxy\Proxy;
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCP\IGroupManager;
-use OCP\ILogger;
use OCP\IUser;
use OCP\IUserSession;
+use Psr\Log\LoggerInterface;
use Sabre\DAV\PropPatch;
use Test\TestCase;
@@ -45,7 +45,7 @@ abstract class AbstractPrincipalBackendTest extends TestCase {
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */
protected $groupManager;
- /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $logger;
/** @var ProxyMapper|\PHPUnit\Framework\MockObject\MockObject */
@@ -71,7 +71,7 @@ abstract class AbstractPrincipalBackendTest extends TestCase {
$this->userSession = $this->createMock(IUserSession::class);
$this->groupManager = $this->createMock(IGroupManager::class);
- $this->logger = $this->createMock(ILogger::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->proxyMapper = $this->createMock(ProxyMapper::class);
}
diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
index a81aac52fbb..0d8076f7aa4 100644
--- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
@@ -36,7 +36,6 @@ use OCP\Defaults;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
-use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
@@ -47,6 +46,7 @@ use OCP\Mail\IMailer;
use OCP\Mail\IMessage;
use OCP\Security\ISecureRandom;
use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\ITip\Message;
use Test\TestCase;
@@ -95,8 +95,8 @@ class IMipPluginTest extends TestCase {
$this->emailAttachment = $this->createMock(IAttachment::class);
$this->mailer->method('createAttachment')->willReturn($this->emailAttachment);
- /** @var ILogger|MockObject $logger */
- $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock();
+ /** @var LoggerInterface|MockObject $logger */
+ $logger = $this->getMockBuilder(LoggerInterface::class)->disableOriginalConstructor()->getMock();
$this->timeFactory = $this->getMockBuilder(ITimeFactory::class)->disableOriginalConstructor()->getMock();
$this->timeFactory->method('getTime')->willReturn(1496912528); // 2017-01-01
diff --git a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
index 12e91345709..6bd1f6b3206 100644
--- a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
+++ b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
@@ -24,7 +24,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-namespace OCA\DAV\Tests\unit\BackgroundJob;
+namespace OCA\DAV\Tests\unit\CalDAV\WebcalCaching;
use GuzzleHttp\HandlerStack;
use OCA\DAV\CalDAV\CalDavBackend;
@@ -34,8 +34,8 @@ use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\Http\Client\LocalServerException;
use OCP\IConfig;
-use OCP\ILogger;
use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
use Sabre\DAV\Exception\BadRequest;
use Sabre\VObject;
use Sabre\VObject\Recur\NoInstancesException;
@@ -53,7 +53,7 @@ class RefreshWebcalServiceTest extends TestCase {
/** @var IConfig | MockObject */
private $config;
- /** @var ILogger | MockObject */
+ /** @var LoggerInterface | MockObject */
private $logger;
protected function setUp(): void {
@@ -62,7 +62,7 @@ class RefreshWebcalServiceTest extends TestCase {
$this->caldavBackend = $this->createMock(CalDavBackend::class);
$this->clientService = $this->createMock(IClientService::class);
$this->config = $this->createMock(IConfig::class);
- $this->logger = $this->createMock(ILogger::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
}
/**
@@ -144,7 +144,7 @@ class RefreshWebcalServiceTest extends TestCase {
$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');
}
-
+
/**
* @param string $body
* @param string $contentType
@@ -209,15 +209,15 @@ class RefreshWebcalServiceTest extends TestCase {
$this->caldavBackend->expects($this->once())
->method('createCalendarObject')
->with(42, 'uri-1.ics', $result, 1);
-
+
$noInstanceException = new NoInstancesException("can't add calendar object");
$this->caldavBackend->expects($this->once())
->method("createCalendarObject")
->willThrowException($noInstanceException);
-
+
$this->logger->expects($this->once())
- ->method('logException')
- ->with($noInstanceException);
+ ->method('error')
+ ->with($noInstanceException->getMessage(), ['exception' => $noInstanceException]);
$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');
}
@@ -286,15 +286,15 @@ class RefreshWebcalServiceTest extends TestCase {
$this->caldavBackend->expects($this->once())
->method('createCalendarObject')
->with(42, 'uri-1.ics', $result, 1);
-
+
$badRequestException = new BadRequest("can't add reach calendar url");
$this->caldavBackend->expects($this->once())
->method("createCalendarObject")
->willThrowException($badRequestException);
-
+
$this->logger->expects($this->once())
- ->method('logException')
- ->with($badRequestException);
+ ->method('error')
+ ->with($badRequestException->getMessage(), ['exception' => $badRequestException]);
$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');
}
@@ -361,13 +361,14 @@ class RefreshWebcalServiceTest extends TestCase {
->with('dav', 'webcalAllowLocalAccess', 'no')
->willReturn('no');
+ $exception = new LocalServerException();
$client->expects($this->once())
->method('get')
- ->willThrowException(new LocalServerException());
+ ->willThrowException($exception);
$this->logger->expects($this->once())
- ->method('logException')
- ->with($this->isInstanceOf(LocalServerException::class), $this->anything());
+ ->method('warning')
+ ->with($this->anything(), ['exception' => $exception]);
$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');
}
diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
index d22a246bbec..58af8a64d0b 100644
--- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
+++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
@@ -30,9 +30,9 @@ namespace OCA\DAV\Tests\unit\CardDAV;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\CardDAV\Converter;
use OCA\DAV\CardDAV\SyncService;
-use OCP\ILogger;
use OCP\IUser;
use OCP\IUserManager;
+use Psr\Log\LoggerInterface;
use Sabre\VObject\Component\VCard;
use Test\TestCase;
@@ -80,7 +80,7 @@ class SyncServiceTest extends TestCase {
/** @var IUserManager $userManager */
$userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock();
- $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock();
+ $logger = $this->getMockBuilder(LoggerInterface::class)->disableOriginalConstructor()->getMock();
$converter = $this->createMock(Converter::class);
$ss = new SyncService($backend, $userManager, $logger, $converter);
@@ -106,7 +106,7 @@ class SyncServiceTest extends TestCase {
public function testUpdateAndDeleteUser($activated, $createCalls, $updateCalls, $deleteCalls) {
/** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $backend */
$backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
- $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock();
+ $logger = $this->getMockBuilder(LoggerInterface::class)->disableOriginalConstructor()->getMock();
$backend->expects($this->exactly($createCalls))->method('createCard');
$backend->expects($this->exactly($updateCalls))->method('updateCard');
@@ -166,7 +166,7 @@ class SyncServiceTest extends TestCase {
*/
private function getSyncServiceMock($backend, $response) {
$userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock();
- $logger = $this->getMockBuilder(ILogger::class)->disableOriginalConstructor()->getMock();
+ $logger = $this->getMockBuilder(LoggerInterface::class)->disableOriginalConstructor()->getMock();
$converter = $this->createMock(Converter::class);
/** @var SyncService | \PHPUnit\Framework\MockObject\MockObject $ss */
$ss = $this->getMockBuilder(SyncService::class)
diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
index f085ace9d89..ea3a1952e45 100644
--- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
@@ -30,10 +30,10 @@ use OCA\DAV\Comments\CommentNode;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
use OCP\Comments\MessageTooLongException;
-use OCP\ILogger;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
+use Psr\Log\LoggerInterface;
use Sabre\DAV\PropPatch;
class CommentsNodeTest extends \Test\TestCase {
@@ -62,7 +62,7 @@ class CommentsNodeTest extends \Test\TestCase {
$this->userSession = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor()
->getMock();
- $this->logger = $this->getMockBuilder(ILogger::class)
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor()
->getMock();
@@ -230,7 +230,7 @@ class CommentsNodeTest extends \Test\TestCase {
->method('save');
$this->logger->expects($this->once())
- ->method('logException');
+ ->method('error');
$this->node->updateComment($msg);
}
@@ -268,7 +268,7 @@ class CommentsNodeTest extends \Test\TestCase {
->method('save');
$this->logger->expects($this->once())
- ->method('logException');
+ ->method('error');
// imagine 'foo' has >1k characters. comment is mocked anyway.
$this->node->updateComment('foo');
diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php
index 4466b0a6307..f95dbf839ee 100644
--- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php
@@ -28,9 +28,9 @@ namespace OCA\DAV\Tests\unit\Comments;
use OCA\DAV\Comments\EntityCollection;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
-use OCP\ILogger;
use OCP\IUserManager;
use OCP\IUserSession;
+use Psr\Log\LoggerInterface;
class EntityCollectionTest extends \Test\TestCase {
@@ -38,7 +38,7 @@ class EntityCollectionTest extends \Test\TestCase {
protected $commentsManager;
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
protected $userManager;
- /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $logger;
/** @var EntityCollection */
protected $collection;
@@ -57,7 +57,7 @@ class EntityCollectionTest extends \Test\TestCase {
$this->userSession = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor()
->getMock();
- $this->logger = $this->getMockBuilder(ILogger::class)
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor()
->getMock();
diff --git a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
index f49b2c39857..89f84fb6ad4 100644
--- a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
@@ -26,9 +26,9 @@ namespace OCA\DAV\Tests\unit\Comments;
use OCA\DAV\Comments\EntityCollection as EntityCollectionImplemantation;
use OCP\Comments\ICommentsManager;
-use OCP\ILogger;
use OCP\IUserManager;
use OCP\IUserSession;
+use Psr\Log\LoggerInterface;
class EntityTypeCollectionTest extends \Test\TestCase {
@@ -36,7 +36,7 @@ class EntityTypeCollectionTest extends \Test\TestCase {
protected $commentsManager;
/** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject */
protected $userManager;
- /** @var \OCP\ILogger|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $logger;
/** @var \OCA\DAV\Comments\EntityTypeCollection */
protected $collection;
@@ -57,7 +57,7 @@ class EntityTypeCollectionTest extends \Test\TestCase {
$this->userSession = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor()
->getMock();
- $this->logger = $this->getMockBuilder(ILogger::class)
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor()
->getMock();
diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php
index 8537eb9ab17..703557c16d6 100644
--- a/apps/dav/tests/unit/Comments/RootCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php
@@ -30,7 +30,6 @@ use OC\EventDispatcher\SymfonyAdapter;
use OCA\DAV\Comments\EntityTypeCollection as EntityTypeCollectionImplementation;
use OCP\Comments\CommentsEntityEvent;
use OCP\Comments\ICommentsManager;
-use OCP\ILogger;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
@@ -87,7 +86,7 @@ class RootCollectionTest extends \Test\TestCase {
$this->userManager,
$this->userSession,
$this->dispatcher,
- $this->createMock(ILogger::class)
+ $this->logger
);
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php
index 83f8c416577..3627a177969 100644
--- a/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php
@@ -9,6 +9,7 @@
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
+ * @author Côme Chilliet <come.chilliet@nextcloud.com>
*
* @license AGPL-3.0
*
@@ -30,31 +31,22 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre;
use OC\Log;
use OC\SystemConfig;
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
-use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin as PluginToTest;
+use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
+use Psr\Log\LoggerInterface;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Exception\ServiceUnavailable;
use Sabre\DAV\Server;
use Test\TestCase;
-class TestLogger extends Log {
- public $message;
- public $level;
-
- public function writeLog(string $app, $entry, int $level) {
- $this->level = $level;
- $this->message = $entry;
- }
-}
-
class ExceptionLoggerPluginTest extends TestCase {
/** @var Server */
private $server;
- /** @var PluginToTest */
+ /** @var ExceptionLoggerPlugin */
private $plugin;
- /** @var TestLogger | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var LoggerInterface | \PHPUnit\Framework\MockObject\MockObject */
private $logger;
private function init() {
@@ -71,29 +63,30 @@ class ExceptionLoggerPluginTest extends TestCase {
});
$this->server = new Server();
- $this->logger = new TestLogger(new Log\File(\OC::$SERVERROOT.'/data/nextcloud.log', '', $config), $config);
- $this->plugin = new PluginToTest('unit-test', $this->logger);
+ $this->logger = $this->createMock(LoggerInterface::class);
+ $this->plugin = new ExceptionLoggerPlugin('unit-test', $this->logger);
$this->plugin->initialize($this->server);
}
/**
* @dataProvider providesExceptions
*/
- public function testLogging($expectedLogLevel, $expectedMessage, $exception) {
+ public function testLogging(string $expectedLogLevel, \Throwable $e) {
$this->init();
- $this->plugin->logException($exception);
- $this->assertEquals($expectedLogLevel, $this->logger->level);
- $this->assertEquals(get_class($exception), $this->logger->message['Exception']);
- $this->assertEquals($expectedMessage, $this->logger->message['Message']);
+ $this->logger->expects($this->once())
+ ->method($expectedLogLevel)
+ ->with($e->getMessage(), ['app' => 'unit-test','exception' => $e]);
+
+ $this->plugin->logException($e);
}
public function providesExceptions() {
return [
- [0, '', new NotFound()],
- [0, 'System in maintenance mode.', new ServiceUnavailable('System in maintenance mode.')],
- [4, 'Upgrade needed', new ServiceUnavailable('Upgrade needed')],
- [4, 'This path leads to nowhere', new InvalidPath('This path leads to nowhere')]
+ ['debug', new NotFound()],
+ ['debug', new ServiceUnavailable('System in maintenance mode.')],
+ ['critical', new ServiceUnavailable('Upgrade needed')],
+ ['critical', new InvalidPath('This path leads to nowhere')]
];
}
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
index 5adfece42e8..f6aa79eb6c4 100644
--- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
+++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php
@@ -32,6 +32,7 @@ use OC\Files\View;
use OCA\DAV\Connector\Sabre\Server;
use OCA\DAV\Connector\Sabre\ServerFactory;
use OCP\IRequest;
+use Psr\Log\LoggerInterface;
use Sabre\HTTP\Request;
use Test\TestCase;
use Test\Traits\MountProviderTrait;
@@ -60,7 +61,7 @@ abstract class RequestTestCase extends TestCase {
$this->serverFactory = new ServerFactory(
\OC::$server->getConfig(),
- \OC::$server->getLogger(),
+ \OC::$server->get(LoggerInterface::class),
\OC::$server->getDatabaseConnection(),
\OC::$server->getUserSession(),
\OC::$server->getMountManager(),
@@ -98,7 +99,7 @@ abstract class RequestTestCase extends TestCase {
$body = $this->getStream($body);
}
$this->logout();
- $exceptionPlugin = new ExceptionPlugin('webdav', null);
+ $exceptionPlugin = new ExceptionPlugin('webdav', \OC::$server->get(LoggerInterface::class));
$server = $this->getSabreServer($view, $user, $password, $exceptionPlugin);
$request = new Request($method, $url, $headers, $body);
diff --git a/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php b/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php
index 478be5b4294..0adabd2388f 100644
--- a/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php
+++ b/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php
@@ -27,8 +27,8 @@ namespace OCA\DAV\Tests\Unit\DAV\Migration;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\Migration\CalDAVRemoveEmptyValue;
-use OCP\ILogger;
use OCP\Migration\IOutput;
+use Psr\Log\LoggerInterface;
use Sabre\VObject\InvalidDataException;
use Test\TestCase;
@@ -40,7 +40,7 @@ use Test\TestCase;
*/
class CalDAVRemoveEmptyValueTest extends TestCase {
- /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
private $logger;
/** @var CalDavBackend|\PHPUnit\Framework\MockObject\MockObject */
@@ -94,7 +94,7 @@ END:VCALENDAR';
protected function setUp(): void {
parent::setUp();
- $this->logger = $this->createMock(ILogger::class);
+ $this->logger = $this->createMock(LoggerInterface::class);
$this->backend = $this->createMock(CalDavBackend::class);
$this->output = $this->createMock(IOutput::class);
}