diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2020-11-09 23:29:25 +0100 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2020-11-10 16:47:42 +0100 |
commit | 5bdc2df7f484f6618919a63247045027d43b78f7 (patch) | |
tree | 25a5f6a834d736e7c985bfa30c50099185a8f3b1 /tests | |
parent | 3a1b406b193a395cb459b9e513168726d82e7c93 (diff) |
Fix unread count and related issues
Issue GH-924
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Integration/Db/FeedMapperTest.php | 7 | ||||
-rw-r--r-- | tests/Unit/Command/UpdateFeedTest.php | 47 |
2 files changed, 46 insertions, 8 deletions
diff --git a/tests/Integration/Db/FeedMapperTest.php b/tests/Integration/Db/FeedMapperTest.php index f07103d10..803e9260b 100644 --- a/tests/Integration/Db/FeedMapperTest.php +++ b/tests/Integration/Db/FeedMapperTest.php @@ -119,9 +119,6 @@ class FeedMapperTest extends IntegrationTest $this->assertEquals($feed->getTitle(), $fetched->getTitle()); } - /** - * @expectedException OCP\AppFramework\Db\MultipleObjectsReturnedException - */ public function testFindByUrlHashMoreThanOneResult() { $this->expectException('OCP\AppFramework\Db\MultipleObjectsReturnedException'); @@ -143,10 +140,6 @@ class FeedMapperTest extends IntegrationTest $this->feedMapper->findByUrlHash($feed1->getUrlHash(), $this->user); } - - /** - * @expectedException OCP\AppFramework\Db\DoesNotExistException - */ public function testFindByUrlHashNotExisting() { $this->expectException('OCP\AppFramework\Db\DoesNotExistException'); diff --git a/tests/Unit/Command/UpdateFeedTest.php b/tests/Unit/Command/UpdateFeedTest.php index 05d12fa66..bd0cd34e4 100644 --- a/tests/Unit/Command/UpdateFeedTest.php +++ b/tests/Unit/Command/UpdateFeedTest.php @@ -67,6 +67,12 @@ class UpdateFeedTest extends TestCase $feed = $this->createMock(Feed::class); + $feed->expects($this->exactly(1)) + ->method('getUpdateErrorCount') + ->willReturn(0); + $feed->expects($this->exactly(0)) + ->method('getLastUpdateError'); + $this->service->expects($this->exactly(1)) ->method('findForUser') ->with('admin', '1') @@ -74,7 +80,8 @@ class UpdateFeedTest extends TestCase $this->service->expects($this->exactly(1)) ->method('fetch') - ->with($feed); + ->with($feed) + ->willReturn($feed); $result = $this->command->run($this->consoleInput, $this->consoleOutput); $this->assertSame(0, $result); @@ -83,6 +90,44 @@ class UpdateFeedTest extends TestCase /** * Test a valid call will work */ + public function testValidFeedError() + { + $this->consoleInput->expects($this->exactly(2)) + ->method('getArgument') + ->will($this->returnValueMap([ + ['feed-id', '1'], + ['user-id', 'admin'], + ])); + + $feed = $this->createMock(Feed::class); + $feed->expects($this->exactly(1)) + ->method('getUpdateErrorCount') + ->willReturn(10); + $feed->expects($this->exactly(1)) + ->method('getLastUpdateError') + ->willReturn('Problem'); + + $this->service->expects($this->exactly(1)) + ->method('findForUser') + ->with('admin', '1') + ->willReturn($feed); + + $this->service->expects($this->exactly(1)) + ->method('fetch') + ->with($feed) + ->willReturn($feed); + + $this->consoleOutput->expects($this->exactly(1)) + ->method('writeln') + ->with('Problem'); + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(255, $result); + } + + /** + * Test a valid call will work + */ public function testInValid() { $this->consoleInput->expects($this->exactly(2)) |