diff options
Diffstat (limited to 'tests/Unit/Command/UpdateFeedTest.php')
-rw-r--r-- | tests/Unit/Command/UpdateFeedTest.php | 47 |
1 files changed, 46 insertions, 1 deletions
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)) |