From 11f5904dd58cbcb45e0e3e6c466f187e30323155 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Wed, 16 Dec 2020 22:30:19 +0100 Subject: Fix mapper->find and empty user sessions Signed-off-by: Sean Molenaar --- tests/Unit/Controller/AdminControllerTest.php | 2 +- tests/Unit/Controller/ExportControllerTest.php | 1 - tests/Unit/Controller/FeedApiControllerTest.php | 1 - tests/Unit/Controller/FeedControllerTest.php | 1 - tests/Unit/Controller/FolderApiControllerTest.php | 1 - tests/Unit/Controller/FolderControllerTest.php | 1 - tests/Unit/Controller/ItemApiControllerTest.php | 1 - tests/Unit/Controller/ItemControllerTest.php | 1 - tests/Unit/Controller/PageControllerTest.php | 1 - tests/Unit/Controller/UserApiControllerTest.php | 3 +- tests/Unit/Controller/UtilityApiControllerTest.php | 1 - tests/Unit/Service/FeedServiceTest.php | 38 +++++++++++----------- tests/Unit/Service/ServiceTest.php | 8 ++--- 13 files changed, 26 insertions(+), 34 deletions(-) (limited to 'tests') diff --git a/tests/Unit/Controller/AdminControllerTest.php b/tests/Unit/Controller/AdminControllerTest.php index 81490bb6f..a9d7bb127 100644 --- a/tests/Unit/Controller/AdminControllerTest.php +++ b/tests/Unit/Controller/AdminControllerTest.php @@ -62,7 +62,7 @@ class AdminControllerTest extends TestCase ->disableOriginalConstructor() ->getMock(); - $this->controller = new AdminController($this->appName, $this->request, $this->config, $this->itemService); + $this->controller = new AdminController($this->request, $this->config, $this->itemService); } /** diff --git a/tests/Unit/Controller/ExportControllerTest.php b/tests/Unit/Controller/ExportControllerTest.php index 276a36abf..1565daf81 100644 --- a/tests/Unit/Controller/ExportControllerTest.php +++ b/tests/Unit/Controller/ExportControllerTest.php @@ -86,7 +86,6 @@ class ExportControllerTest extends TestCase ->disableOriginalConstructor() ->getMock(); $this->controller = new ExportController( - $appName, $request, $this->folderService, $this->feedService, diff --git a/tests/Unit/Controller/FeedApiControllerTest.php b/tests/Unit/Controller/FeedApiControllerTest.php index 0ed65f5c5..9cfc47cec 100644 --- a/tests/Unit/Controller/FeedApiControllerTest.php +++ b/tests/Unit/Controller/FeedApiControllerTest.php @@ -91,7 +91,6 @@ class FeedApiControllerTest extends TestCase ->disableOriginalConstructor() ->getMock(); $this->class = new FeedApiController( - $appName, $request, $userSession, $this->oldFeedService, diff --git a/tests/Unit/Controller/FeedControllerTest.php b/tests/Unit/Controller/FeedControllerTest.php index 6285be9dc..aba8cdc1f 100644 --- a/tests/Unit/Controller/FeedControllerTest.php +++ b/tests/Unit/Controller/FeedControllerTest.php @@ -106,7 +106,6 @@ class FeedControllerTest extends TestCase ->disableOriginalConstructor() ->getMock(); $this->class = new FeedController( - $this->appName, $request, $this->folderService, $this->feedService, diff --git a/tests/Unit/Controller/FolderApiControllerTest.php b/tests/Unit/Controller/FolderApiControllerTest.php index cf66b4c03..858e7ff9e 100644 --- a/tests/Unit/Controller/FolderApiControllerTest.php +++ b/tests/Unit/Controller/FolderApiControllerTest.php @@ -66,7 +66,6 @@ class FolderApiControllerTest extends TestCase ->disableOriginalConstructor() ->getMock(); $this->folderAPI = new FolderApiController( - $appName, $request, $userSession, $this->folderService, diff --git a/tests/Unit/Controller/FolderControllerTest.php b/tests/Unit/Controller/FolderControllerTest.php index ef1b1e965..522b3a754 100644 --- a/tests/Unit/Controller/FolderControllerTest.php +++ b/tests/Unit/Controller/FolderControllerTest.php @@ -79,7 +79,6 @@ class FolderControllerTest extends TestCase ->method('getUser') ->will($this->returnValue($this->user)); $this->class = new FolderController( - $appName, $request, $this->folderService, $this->feedService, diff --git a/tests/Unit/Controller/ItemApiControllerTest.php b/tests/Unit/Controller/ItemApiControllerTest.php index 06b60f78c..8177bb0a2 100644 --- a/tests/Unit/Controller/ItemApiControllerTest.php +++ b/tests/Unit/Controller/ItemApiControllerTest.php @@ -66,7 +66,6 @@ class ItemApiControllerTest extends TestCase ->disableOriginalConstructor() ->getMock(); $this->class = new ItemApiController( - $this->appName, $this->request, $this->userSession, $this->oldItemService, diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php index 9929cde23..12f851ade 100644 --- a/tests/Unit/Controller/ItemControllerTest.php +++ b/tests/Unit/Controller/ItemControllerTest.php @@ -80,7 +80,6 @@ class ItemControllerTest extends TestCase ->method('getUser') ->will($this->returnValue($this->user)); $this->controller = new ItemController( - $this->appName, $this->request, $this->feedService, $this->itemService, diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php index 0c642fe29..2f259b316 100644 --- a/tests/Unit/Controller/PageControllerTest.php +++ b/tests/Unit/Controller/PageControllerTest.php @@ -113,7 +113,6 @@ class PageControllerTest extends TestCase ->method('getUser') ->will($this->returnValue($this->user)); $this->controller = new PageController( - 'news', $this->request, $this->settings, $this->urlGenerator, diff --git a/tests/Unit/Controller/UserApiControllerTest.php b/tests/Unit/Controller/UserApiControllerTest.php index 49010627b..45a59ce4b 100644 --- a/tests/Unit/Controller/UserApiControllerTest.php +++ b/tests/Unit/Controller/UserApiControllerTest.php @@ -52,7 +52,8 @@ class UserApiControllerTest extends TestCase ->disableOriginalConstructor() ->getMock(); $this->controller = new UserApiController( - $this->appName, $this->request, $this->userSession, + $this->request, + $this->userSession, $this->rootFolder ); diff --git a/tests/Unit/Controller/UtilityApiControllerTest.php b/tests/Unit/Controller/UtilityApiControllerTest.php index 127618288..16d583b71 100644 --- a/tests/Unit/Controller/UtilityApiControllerTest.php +++ b/tests/Unit/Controller/UtilityApiControllerTest.php @@ -93,7 +93,6 @@ class UtilityApiControllerTest extends TestCase ->disableOriginalConstructor() ->getMock(); $this->newsAPI = new UtilityApiController( - $this->appName, $this->request, $this->userSession, $this->updateService, diff --git a/tests/Unit/Service/FeedServiceTest.php b/tests/Unit/Service/FeedServiceTest.php index 769453459..961d5d5e7 100644 --- a/tests/Unit/Service/FeedServiceTest.php +++ b/tests/Unit/Service/FeedServiceTest.php @@ -349,7 +349,7 @@ class FeedServiceTest extends TestCase $fetchReturn = [$feed, $items]; $this->feedMapper->expects($this->exactly(2)) - ->method('find') + ->method('findFromUser') ->with($this->user, $feed->getId()) ->will($this->returnValue($feed)); $this->fetcher->expects($this->once()) @@ -408,7 +408,7 @@ class FeedServiceTest extends TestCase $fetchReturn = [$feed, $items]; $this->feedMapper->expects($this->exactly(2)) - ->method('find') + ->method('findFromUser') ->with($this->user, $feed->getId()) ->will($this->returnValue($feed)); $this->fetcher->expects($this->once()) @@ -498,7 +498,7 @@ class FeedServiceTest extends TestCase $fetchReturn = [$feed, $items]; $this->feedMapper->expects($this->exactly(2)) - ->method('find') + ->method('findFromUser') ->will($this->returnValue($feed)); $this->fetcher->expects($this->once()) ->method('fetch') @@ -536,7 +536,7 @@ class FeedServiceTest extends TestCase $fetchReturn = [$feed, $items]; $this->feedMapper->expects($this->exactly(2)) - ->method('find') + ->method('findFromUser') ->will($this->returnValue($feed)); $this->fetcher->expects($this->once()) ->method('fetch') @@ -577,7 +577,7 @@ class FeedServiceTest extends TestCase $items = [$item]; $this->feedMapper->expects($this->any()) - ->method('find') + ->method('findFromUser') ->will($this->returnValue($existingFeed)); $this->fetcher->expects($this->once()) @@ -612,7 +612,7 @@ class FeedServiceTest extends TestCase $ex = new ReadErrorException('hi'); $this->feedMapper->expects($this->exactly(2)) - ->method('find') + ->method('findFromUser') ->with($this->user, $feed->getId()) ->willReturnOnConsecutiveCalls($feed, $expectedFeed); $this->fetcher->expects($this->once()) @@ -640,7 +640,7 @@ class FeedServiceTest extends TestCase $ex = new DoesNotExistException(''); $this->feedMapper->expects($this->exactly(1)) - ->method('find') + ->method('findFromUser') ->with($this->user, $feed->getId()) ->will($this->throwException($ex)); @@ -660,7 +660,7 @@ class FeedServiceTest extends TestCase $ex = new DoesNotExistException(''); $this->feedMapper->expects($this->exactly(1)) - ->method('find') + ->method('findFromUser') ->with($this->user, $feed->getId()) ->will($this->returnValue($feed)); @@ -699,7 +699,7 @@ class FeedServiceTest extends TestCase $ex = new DoesNotExistException(''); $this->feedMapper->expects($this->exactly(2)) - ->method('find') + ->method('findFromUser') ->with($this->user, $feed->getId()) ->willReturnOnConsecutiveCalls($feed, $this->throwException($ex)); $this->feedMapper->expects($this->exactly(1)) @@ -731,7 +731,7 @@ class FeedServiceTest extends TestCase $feed->setPreventUpdate(true); $this->feedMapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->with($this->user, $feed->getId()) ->will($this->returnValue($feed)); $this->fetcher->expects($this->never()) @@ -750,7 +750,7 @@ class FeedServiceTest extends TestCase $feed->setUrl('http://example.com'); $this->feedMapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->with($this->user, $feed->getId()) ->will($this->returnValue($feed)); $this->fetcher->expects($this->once()) @@ -771,7 +771,7 @@ class FeedServiceTest extends TestCase $feed->setId($feedId); $this->feedMapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->with($this->user, $feedId) ->will($this->returnValue($feed)); @@ -796,7 +796,7 @@ class FeedServiceTest extends TestCase $feed->setId($feedId); $this->feedMapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->with($this->equalTo($this->user), $this->equalTo($feedId)) ->will($this->returnValue($feed)); @@ -968,7 +968,7 @@ class FeedServiceTest extends TestCase $feed2->setDeletedAt($this->time); $this->feedMapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->with($this->equalTo($this->user), $this->equalTo($id)) ->will($this->returnValue($feed)); $this->feedMapper->expects($this->once()) @@ -987,7 +987,7 @@ class FeedServiceTest extends TestCase $feed2->setDeletedAt(0); $this->feedMapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->with($this->equalTo($this->user), $this->equalTo($id)) ->will($this->returnValue($feed)); $this->feedMapper->expects($this->once()) @@ -1064,7 +1064,7 @@ class FeedServiceTest extends TestCase { $feed = Feed::fromRow(['id' => 3]); $this->feedMapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->with( $this->equalTo($this->user), $this->equalTo($feed->getId()) @@ -1092,7 +1092,7 @@ class FeedServiceTest extends TestCase ); $feed2 = Feed::fromRow(['id' => 3]); $this->feedMapper->expects($this->exactly(2)) - ->method('find') + ->method('findFromUser') ->with( $this->equalTo($this->user), $this->equalTo($feed->getId()) @@ -1116,7 +1116,7 @@ class FeedServiceTest extends TestCase $this->expectException('OCA\News\Service\Exceptions\ServiceNotFoundException'); $feed = Feed::fromRow(['id' => 3]); $this->feedMapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->will($this->throwException(new DoesNotExistException(''))); $this->feedService->patch(3, $this->user); @@ -1127,7 +1127,7 @@ class FeedServiceTest extends TestCase { $feed = Feed::fromRow(['id' => 3, 'pinned' => false]); $this->feedMapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->with($this->user, $feed->getId()) ->will($this->returnValue($feed)); diff --git a/tests/Unit/Service/ServiceTest.php b/tests/Unit/Service/ServiceTest.php index 4b6c6b03d..ce4e2e61f 100644 --- a/tests/Unit/Service/ServiceTest.php +++ b/tests/Unit/Service/ServiceTest.php @@ -73,7 +73,7 @@ class ServiceTest extends TestCase ->method('delete') ->with($this->equalTo($folder)); $this->mapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->with($this->equalTo($user), $this->equalTo($id)) ->will($this->returnValue($folder)); @@ -87,7 +87,7 @@ class ServiceTest extends TestCase $user = 'ken'; $this->mapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->with($this->equalTo($user), $this->equalTo($id)) ->will($this->returnValue(new Feed())); @@ -100,7 +100,7 @@ class ServiceTest extends TestCase $ex = new DoesNotExistException('hi'); $this->mapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->will($this->throwException($ex)); $this->expectException(ServiceNotFoundException::class); @@ -113,7 +113,7 @@ class ServiceTest extends TestCase $ex = new MultipleObjectsReturnedException('hi'); $this->mapper->expects($this->once()) - ->method('find') + ->method('findFromUser') ->will($this->throwException($ex)); $this->expectException(ServiceNotFoundException::class); -- cgit v1.2.3