diff options
author | Marco Nassabain <marco.nassabain@hotmail.com> | 2021-03-06 22:22:20 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-04-08 22:31:21 +0200 |
commit | 7f3c63a2a4acea929e70a4136fea5c51e832ec16 (patch) | |
tree | 2e9b5b3313428e56e26d53444854ae5f290a3eeb /tests | |
parent | 920ae54a2c6d4fa1e1e2612ed7f945a3bf770a18 (diff) |
🎨 ShareService: update dummy feed URL
- add IURLGenerator DI
- update url to "http://serverurl/news/sharedwithme"
- updated tests: added DI + adapted expected url
Signed-off-by: Marco Nassabain <marco.nassabain@hotmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Unit/Service/ShareServiceTest.php | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/Unit/Service/ShareServiceTest.php b/tests/Unit/Service/ShareServiceTest.php index e6fb34716..7c6e068f5 100644 --- a/tests/Unit/Service/ShareServiceTest.php +++ b/tests/Unit/Service/ShareServiceTest.php @@ -25,6 +25,8 @@ use OCA\News\Utility\Time; use OCA\News\Db\Feed; use OCA\News\Db\Item; + +use OCP\IURLGenerator; use OCP\IConfig; use OCP\IL10N; @@ -46,6 +48,11 @@ class ShareServiceTest extends TestCase private $feedService; /** + * @var MockObject|IURLGenerator + */ + private $url; + + /** * @var MockObject|IL10N */ private $l; @@ -81,6 +88,10 @@ class ShareServiceTest extends TestCase ->getMockBuilder(FeedServiceV2::class) ->disableOriginalConstructor() ->getMock(); + $this->url = $this + ->getMockBuilder(IURLGenerator::class) + ->disableOriginalConstructor() + ->getMock(); $this->l = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor() ->getMock(); @@ -90,6 +101,7 @@ class ShareServiceTest extends TestCase $this->class = new ShareService( $this->feedService, $this->itemService, + $this->url, $this->l, $this->logger ); @@ -100,7 +112,7 @@ class ShareServiceTest extends TestCase public function testShareItemWithUser() { - $feedUrl = 'http://nextcloud/sharedwithme'; + $feedUrl = 'http://serverurl/news/sharedwithme'; $itemId = 3; // Item to be shared @@ -138,6 +150,10 @@ class ShareServiceTest extends TestCase ->with($this->uid, $itemId) ->will($this->returnValue($item)); + $this->url->expects($this->once()) + ->method('getBaseUrl') + ->will($this->returnValue('http://serverurl')); + $this->feedService->expects($this->once()) ->method('findByUrl') ->with($this->recipient, $feedUrl) @@ -155,7 +171,7 @@ class ShareServiceTest extends TestCase public function testShareItemWithUserCreatesOwnFeedWhenNotFound() { - $feedUrl = 'http://nextcloud/sharedwithme'; + $feedUrl = 'http://serverurl/news/sharedwithme'; $itemId = 3; // Item to be shared @@ -193,6 +209,10 @@ class ShareServiceTest extends TestCase ->with($this->uid, $itemId) ->will($this->returnValue($item)); + $this->url->expects($this->once()) + ->method('getBaseUrl') + ->will($this->returnValue('http://serverurl')); + $this->feedService->expects($this->once()) ->method('findByUrl') ->with($this->recipient, $feedUrl) |