summaryrefslogtreecommitdiffstats
path: root/tests/Unit/Controller/ItemControllerTest.php
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-10-10 00:23:15 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-10-10 10:26:12 +0200
commitb46c6df6322e09c05a34acca69403fd4ebd238ba (patch)
tree47182b11d97869304e97f729eacc490bc420d5df /tests/Unit/Controller/ItemControllerTest.php
parenteb382ded61f608a4bb8d52a7a71478e461ca5be7 (diff)
Fix usage of at() in unittests
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'tests/Unit/Controller/ItemControllerTest.php')
-rw-r--r--tests/Unit/Controller/ItemControllerTest.php87
1 files changed, 23 insertions, 64 deletions
diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php
index c69191423..c015c33a1 100644
--- a/tests/Unit/Controller/ItemControllerTest.php
+++ b/tests/Unit/Controller/ItemControllerTest.php
@@ -36,6 +36,7 @@ class ItemControllerTest extends TestCase
private $itemService;
private $feedService;
private $request;
+ private $user;
private $controller;
private $newestItemId;
@@ -98,41 +99,27 @@ class ItemControllerTest extends TestCase
public function testReadMultiple()
{
- $this->itemService->expects($this->at(0))
+ $this->itemService->expects($this->exactly(2))
->method('read')
- ->with(
- $this->equalTo(2),
- $this->equalTo(true),
- $this->equalTo($this->user)
- );
- $this->itemService->expects($this->at(1))
- ->method('read')
- ->with(
- $this->equalTo(4),
- $this->equalTo(true),
- $this->equalTo($this->user)
+ ->withConsecutive(
+ [2, true, $this->user],
+ [4, true, $this->user]
);
+
$this->controller->readMultiple([2, 4]);
}
public function testReadMultipleDontStopOnException()
{
- $this->itemService->expects($this->at(0))
+
+ $this->itemService->expects($this->exactly(2))
->method('read')
- ->with(
- $this->equalTo(2),
- $this->equalTo(true),
- $this->equalTo($this->user)
+ ->withConsecutive(
+ [2, true, $this->user],
+ [4, true, $this->user]
)
- ->will($this->throwException(new ServiceNotFoundException('yo')));
- $this->itemService->expects($this->at(1))
- ->method('read')
- ->with(
- $this->equalTo(4),
- $this->equalTo(true),
- $this->equalTo($this->user)
- );
+ ->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('yo')), null);
$this->controller->readMultiple([2, 4]);
}
@@ -190,39 +177,20 @@ class ItemControllerTest extends TestCase
}
- private function itemsApiExpects($id, $type, $oldestFirst='1')
+ private function itemsApiExpects($id, $type, $oldestFirst = '1')
{
- $this->settings->expects($this->at(0))
+ $this->settings->expects($this->exactly(2))
->method('getUserValue')
- ->with(
- $this->equalTo($this->user),
- $this->equalTo($this->appName),
- $this->equalTo('showAll')
- )
- ->will($this->returnValue('1'));
- $this->settings->expects($this->at(1))
- ->method('getUserValue')
- ->with(
- $this->equalTo($this->user),
- $this->equalTo($this->appName),
- $this->equalTo('oldestFirst')
+ ->withConsecutive(
+ [$this->user, $this->appName, 'showAll'],
+ [$this->user, $this->appName, 'oldestFirst']
)
- ->will($this->returnValue($oldestFirst));
- $this->settings->expects($this->at(2))
- ->method('setUserValue')
- ->with(
- $this->equalTo($this->user),
- $this->equalTo($this->appName),
- $this->equalTo('lastViewedFeedId'),
- $this->equalTo($id)
- );
- $this->settings->expects($this->at(3))
+ ->willReturnOnConsecutiveCalls('1', $oldestFirst);
+ $this->settings->expects($this->exactly(2))
->method('setUserValue')
- ->with(
- $this->equalTo($this->user),
- $this->equalTo($this->appName),
- $this->equalTo('lastViewedFeedType'),
- $this->equalTo($type)
+ ->withConsecutive(
+ [$this->user, $this->appName, 'lastViewedFeedId', $id],
+ [$this->user, $this->appName, 'lastViewedFeedType', $type]
);
}
@@ -256,16 +224,7 @@ class ItemControllerTest extends TestCase
$this->itemService->expects($this->once())
->method('findAllItems')
- ->with(
- $this->equalTo(2),
- $this->equalTo(FeedType::FEED),
- $this->equalTo(3),
- $this->equalTo(0),
- $this->equalTo(true),
- $this->equalTo(false),
- $this->equalTo($this->user),
- $this->equalTo([])
- )
+ ->with(2, FeedType::FEED, 3, 0, true, false, $this->user, [])
->will($this->returnValue($result['items']));
$response = $this->controller->index(FeedType::FEED, 2, 3);