diff options
Diffstat (limited to 'tests/Unit/Service/FeedServiceTest.php')
-rw-r--r-- | tests/Unit/Service/FeedServiceTest.php | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/tests/Unit/Service/FeedServiceTest.php b/tests/Unit/Service/FeedServiceTest.php index 9f4743777..f0c367b7a 100644 --- a/tests/Unit/Service/FeedServiceTest.php +++ b/tests/Unit/Service/FeedServiceTest.php @@ -165,21 +165,14 @@ class FeedServiceTest extends TestCase public function testCreateDoesNotFindFeed() { - $ex = new ReadErrorException('hi'); $url = 'test'; - $this->mapper->expects($this->once()) - ->method('findByURL') - ->with($this->uid, $url) - ->willReturn(new Feed()); - - $this->fetcher->expects($this->never()) + $this->fetcher->expects($this->exactly(2)) ->method('fetch') ->with($url) - ->will($this->throwException($ex)); + ->will($this->throwException(new ReadErrorException('There is no feed'))); - $this->expectException(ServiceConflictException::class); - $this->expectExceptionMessage('Feed with this URL exists'); + $this->expectException(ServiceNotFoundException::class); $this->class->create($this->uid, $url, 1); } @@ -209,15 +202,16 @@ class FeedServiceTest extends TestCase ->method('findByURL') ->with($this->uid, $url) ->will($this->throwException(new DoesNotExistException('no'))); - $this->explorer->expects($this->once()) - ->method('discover') - ->with($url) - ->will($this->returnValue([])); + $this->explorer->expects($this->never()) + ->method('discover') + ->with($url) + ->will($this->returnValue([])); $this->fetcher->expects($this->once()) ->method('fetch') ->with($url) ->will($this->returnValue($return)); + $this->mapper->expects($this->once()) ->method('insert') ->with($createdFeed) @@ -268,7 +262,7 @@ class FeedServiceTest extends TestCase ->method('findByURL') ->with($this->uid, $url) ->will($this->throwException(new DoesNotExistException('no'))); - $this->explorer->expects($this->once()) + $this->explorer->expects($this->never()) ->method('discover') ->with($url) ->will($this->returnValue([])); @@ -326,16 +320,19 @@ class FeedServiceTest extends TestCase $this->mapper->expects($this->once()) ->method('findByURL') - ->with($this->uid, $url) + ->with($this->uid, 'http://discover.test') ->will($this->throwException(new DoesNotExistException('no'))); $this->explorer->expects($this->once()) ->method('discover') ->with($url) ->will($this->returnValue(['http://discover.test'])); - $this->fetcher->expects($this->once()) + $this->fetcher->expects($this->exactly(2)) ->method('fetch') - ->with('http://discover.test') - ->will($this->returnValue($return)); + ->withConsecutive( + ['http://test'], + ['http://discover.test'] + ) + ->willReturnOnConsecutiveCalls($this->throwException(new ReadErrorException('There is no feed')), $this->returnValue($return)); $this->mapper->expects($this->once()) ->method('insert') @@ -434,12 +431,12 @@ class FeedServiceTest extends TestCase $url = 'http://test'; $folderId = 10; - $this->fetcher->expects($this->once()) + $this->fetcher->expects($this->exactly(2)) ->method('fetch') ->with($url) ->will($this->throwException(new ReadErrorException('ERROR'))); - $this->mapper->expects($this->once()) + $this->mapper->expects($this->never()) ->method('findByURL') ->with($this->uid, $url) ->will($this->throwException(new DoesNotExistException('no'))); |