diff options
author | Anna Larch <anna@nextcloud.com> | 2024-10-01 21:54:04 +0200 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2024-10-01 22:41:54 +0200 |
commit | e862c886d08e47fb29d977d90d496e13dd027a2b (patch) | |
tree | 06748bd1464aeb631e4637b5c79db9efd4d20486 /apps/dav/tests/unit | |
parent | da8ef3c9ea72bb36ca1726680ce27f18e2ea801f (diff) | |
download | nextcloud-server-e862c886d08e47fb29d977d90d496e13dd027a2b.tar.gz nextcloud-server-e862c886d08e47fb29d977d90d496e13dd027a2b.zip |
fix(caldav): add missing handlersfix/stable29/webcal-subscription-jobs-middleware
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'apps/dav/tests/unit')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php index 5ae62ea8b74..c05593ec587 100644 --- a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php @@ -26,14 +26,13 @@ */ namespace OCA\DAV\Tests\unit\CalDAV\WebcalCaching; -use GuzzleHttp\HandlerStack; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\WebcalCaching\RefreshWebcalService; use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; use OCP\Http\Client\LocalServerException; -use OCP\IConfig; +use OCP\IAppConfig; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; use Sabre\DAV\Exception\BadRequest; @@ -50,7 +49,7 @@ class RefreshWebcalServiceTest extends TestCase { /** @var IClientService | MockObject */ private $clientService; - /** @var IConfig | MockObject */ + /** @var IAppConfig | MockObject */ private $config; /** @var LoggerInterface | MockObject */ @@ -61,7 +60,7 @@ class RefreshWebcalServiceTest extends TestCase { $this->caldavBackend = $this->createMock(CalDavBackend::class); $this->clientService = $this->createMock(IClientService::class); - $this->config = $this->createMock(IConfig::class); + $this->config = $this->createMock(IAppConfig::class); $this->logger = $this->createMock(LoggerInterface::class); } @@ -114,15 +113,13 @@ class RefreshWebcalServiceTest extends TestCase { ->willReturn($client); $this->config->expects($this->once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'webcalAllowLocalAccess', 'no') ->willReturn('no'); $client->expects($this->once()) ->method('get') - ->with('https://foo.bar/bla2', $this->callback(function ($obj) { - return $obj['allow_redirects']['redirects'] === 10 && $obj['handler'] instanceof HandlerStack; - })) + ->with('https://foo.bar/bla2') ->willReturn($response); $response->expects($this->once()) @@ -182,15 +179,13 @@ class RefreshWebcalServiceTest extends TestCase { ->willReturn($client); $this->config->expects($this->once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'webcalAllowLocalAccess', 'no') ->willReturn('no'); $client->expects($this->once()) ->method('get') - ->with('https://foo.bar/bla2', $this->callback(function ($obj) { - return $obj['allow_redirects']['redirects'] === 10 && $obj['handler'] instanceof HandlerStack; - })) + ->with('https://foo.bar/bla2') ->willReturn($response); $response->expects($this->once()) @@ -212,7 +207,7 @@ class RefreshWebcalServiceTest extends TestCase { $noInstanceException = new NoInstancesException("can't add calendar object"); $this->caldavBackend->expects($this->once()) - ->method("createCalendarObject") + ->method('createCalendarObject') ->willThrowException($noInstanceException); $this->logger->expects($this->once()) @@ -259,15 +254,13 @@ class RefreshWebcalServiceTest extends TestCase { ->willReturn($client); $this->config->expects($this->once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'webcalAllowLocalAccess', 'no') ->willReturn('no'); $client->expects($this->once()) ->method('get') - ->with('https://foo.bar/bla2', $this->callback(function ($obj) { - return $obj['allow_redirects']['redirects'] === 10 && $obj['handler'] instanceof HandlerStack; - })) + ->with('https://foo.bar/bla2') ->willReturn($response); $response->expects($this->once()) @@ -289,7 +282,7 @@ class RefreshWebcalServiceTest extends TestCase { $badRequestException = new BadRequest("can't add reach calendar url"); $this->caldavBackend->expects($this->once()) - ->method("createCalendarObject") + ->method('createCalendarObject') ->willThrowException($badRequestException); $this->logger->expects($this->once()) @@ -355,7 +348,7 @@ class RefreshWebcalServiceTest extends TestCase { ->willReturn($client); $this->config->expects($this->once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'webcalAllowLocalAccess', 'no') ->willReturn('no'); @@ -367,7 +360,7 @@ class RefreshWebcalServiceTest extends TestCase { $this->logger->expects($this->once()) ->method('warning') - ->with("Subscription 42 was not refreshed because it violates local access rules", ['exception' => $localServerException]); + ->with('Subscription 42 was not refreshed because it violates local access rules', ['exception' => $localServerException]); $refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123'); } @@ -411,15 +404,11 @@ class RefreshWebcalServiceTest extends TestCase { ]); $client = $this->createMock(IClient::class); - $this->clientService->expects($this->once()) - ->method('newClient') - ->with() - ->willReturn($client); + $this->clientService->expects($this->never()) + ->method('newClient'); - $this->config->expects($this->once()) - ->method('getAppValue') - ->with('dav', 'webcalAllowLocalAccess', 'no') - ->willReturn('no'); + $this->config->expects($this->never()) + ->method('getValueString'); $client->expects($this->never()) ->method('get'); |