summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2022-03-18 18:07:24 +0100
committerThomas Citharel <tcit@tcit.fr>2022-05-17 15:11:58 +0200
commit741c44385f388c01ba77b55401b2bec8bbbfe955 (patch)
treea627361addeddb99538b2b9af77dfd91197edcb2 /apps/dav/tests
parent07c9bf1adff8a2d10ff774da32c2ddd54fd01923 (diff)
downloadnextcloud-server-741c44385f388c01ba77b55401b2bec8bbbfe955.tar.gz
nextcloud-server-741c44385f388c01ba77b55401b2bec8bbbfe955.zip
Increase loglevel of Webcal parsing errors and modernize code
Closes #31612 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r--apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php21
1 files changed, 10 insertions, 11 deletions
diff --git a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
index 6bd1f6b3206..71d93bf851e 100644
--- a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
+++ b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
@@ -74,7 +74,7 @@ class RefreshWebcalServiceTest extends TestCase {
*/
public function testRun(string $body, string $contentType, string $result) {
$refreshWebcalService = $this->getMockBuilder(RefreshWebcalService::class)
- ->setMethods(['getRandomCalendarObjectUri'])
+ ->onlyMethods(['getRandomCalendarObjectUri'])
->setConstructorArgs([$this->caldavBackend, $this->clientService, $this->config, $this->logger])
->getMock();
@@ -156,7 +156,7 @@ class RefreshWebcalServiceTest extends TestCase {
$client = $this->createMock(IClient::class);
$response = $this->createMock(IResponse::class);
$refreshWebcalService = $this->getMockBuilder(RefreshWebcalService::class)
- ->setMethods(['getRandomCalendarObjectUri', 'getSubscription', 'queryWebcalFeed'])
+ ->onlyMethods(['getRandomCalendarObjectUri', 'getSubscription', 'queryWebcalFeed'])
->setConstructorArgs([$this->caldavBackend, $this->clientService, $this->config, $this->logger])
->getMock();
@@ -217,7 +217,7 @@ class RefreshWebcalServiceTest extends TestCase {
$this->logger->expects($this->once())
->method('error')
- ->with($noInstanceException->getMessage(), ['exception' => $noInstanceException]);
+ ->with('Unable to create calendar object from subscription {subscriptionId}', ['exception' => $noInstanceException, 'subscriptionId' => '42', 'source' => 'webcal://foo.bar/bla2']);
$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');
}
@@ -233,7 +233,7 @@ class RefreshWebcalServiceTest extends TestCase {
$client = $this->createMock(IClient::class);
$response = $this->createMock(IResponse::class);
$refreshWebcalService = $this->getMockBuilder(RefreshWebcalService::class)
- ->setMethods(['getRandomCalendarObjectUri', 'getSubscription', 'queryWebcalFeed'])
+ ->onlyMethods(['getRandomCalendarObjectUri', 'getSubscription', 'queryWebcalFeed'])
->setConstructorArgs([$this->caldavBackend, $this->clientService, $this->config, $this->logger])
->getMock();
@@ -294,7 +294,7 @@ class RefreshWebcalServiceTest extends TestCase {
$this->logger->expects($this->once())
->method('error')
- ->with($badRequestException->getMessage(), ['exception' => $badRequestException]);
+ ->with('Unable to create calendar object from subscription {subscriptionId}', ['exception' => $badRequestException, 'subscriptionId' => '42', 'source' => 'webcal://foo.bar/bla2']);
$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');
}
@@ -324,10 +324,8 @@ class RefreshWebcalServiceTest extends TestCase {
/**
* @dataProvider runLocalURLDataProvider
- *
- * @param string $source
*/
- public function testRunLocalURL($source) {
+ public function testRunLocalURL(string $source) {
$refreshWebcalService = new RefreshWebcalService(
$this->caldavBackend,
$this->clientService,
@@ -361,14 +359,15 @@ class RefreshWebcalServiceTest extends TestCase {
->with('dav', 'webcalAllowLocalAccess', 'no')
->willReturn('no');
- $exception = new LocalServerException();
+ $localServerException = new LocalServerException();
+
$client->expects($this->once())
->method('get')
- ->willThrowException($exception);
+ ->willThrowException($localServerException);
$this->logger->expects($this->once())
->method('warning')
- ->with($this->anything(), ['exception' => $exception]);
+ ->with("Subscription 42 was not refreshed because it violates local access rules", ['exception' => $localServerException]);
$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');
}