diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2020-10-10 00:23:15 +0200 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2020-10-10 10:26:12 +0200 |
commit | b46c6df6322e09c05a34acca69403fd4ebd238ba (patch) | |
tree | 47182b11d97869304e97f729eacc490bc420d5df /tests/Unit/Controller/ItemApiControllerTest.php | |
parent | eb382ded61f608a4bb8d52a7a71478e461ca5be7 (diff) |
Fix usage of at() in unittests
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'tests/Unit/Controller/ItemApiControllerTest.php')
-rw-r--r-- | tests/Unit/Controller/ItemApiControllerTest.php | 101 |
1 files changed, 30 insertions, 71 deletions
diff --git a/tests/Unit/Controller/ItemApiControllerTest.php b/tests/Unit/Controller/ItemApiControllerTest.php index d2653b92a..75fd6bbef 100644 --- a/tests/Unit/Controller/ItemApiControllerTest.php +++ b/tests/Unit/Controller/ItemApiControllerTest.php @@ -308,19 +308,11 @@ class ItemApiControllerTest 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->getUID()) - ); - $this->itemService->expects($this->at(1)) - ->method('read') - ->with( - $this->equalTo(4), - $this->equalTo(true), - $this->equalTo($this->user->getUID()) + ->withConsecutive( + [2, true, $this->user->getUID()], + [4, true, $this->user->getUID()] ); $this->itemAPI->readMultiple([2, 4]); } @@ -328,35 +320,24 @@ class ItemApiControllerTest extends TestCase public function testReadMultipleDoesntCareAboutException() { - $this->itemService->expects($this->at(0)) - ->method('read') - ->will($this->throwException(new ServiceNotFoundException(''))); - $this->itemService->expects($this->at(1)) + $this->itemService->expects($this->exactly(2)) ->method('read') - ->with( - $this->equalTo(4), - $this->equalTo(true), - $this->equalTo($this->user->getUID()) - ); + ->withConsecutive( + [2, true, $this->user->getUID()], + [4, true, $this->user->getUID()] + ) + ->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('')), null); $this->itemAPI->readMultiple([2, 4]); } public function testUnreadMultiple() { - $this->itemService->expects($this->at(0)) - ->method('read') - ->with( - $this->equalTo(2), - $this->equalTo(false), - $this->equalTo($this->user->getUID()) - ); - $this->itemService->expects($this->at(1)) + $this->itemService->expects($this->exactly(2)) ->method('read') - ->with( - $this->equalTo(4), - $this->equalTo(false), - $this->equalTo($this->user->getUID()) + ->withConsecutive( + [2, false, $this->user->getUID()], + [4, false, $this->user->getUID()] ); $this->itemAPI->unreadMultiple([2, 4]); } @@ -375,21 +356,11 @@ class ItemApiControllerTest extends TestCase ] ]; - $this->itemService->expects($this->at(0)) - ->method('star') - ->with( - $this->equalTo(2), - $this->equalTo('a'), - $this->equalTo(true), - $this->equalTo($this->user->getUID()) - ); - $this->itemService->expects($this->at(1)) + $this->itemService->expects($this->exactly(2)) ->method('star') - ->with( - $this->equalTo(4), - $this->equalTo('b'), - $this->equalTo(true), - $this->equalTo($this->user->getUID()) + ->withConsecutive( + [2, 'a', true, $this->user->getUID()], + [4, 'b', true, $this->user->getUID()] ); $this->itemAPI->starMultiple($ids); } @@ -408,17 +379,14 @@ class ItemApiControllerTest extends TestCase ] ]; - $this->itemService->expects($this->at(0)) - ->method('star') - ->will($this->throwException(new ServiceNotFoundException(''))); - $this->itemService->expects($this->at(1)) + $this->itemService->expects($this->exactly(2)) ->method('star') - ->with( - $this->equalTo(4), - $this->equalTo('b'), - $this->equalTo(true), - $this->equalTo($this->user->getUID()) - ); + ->withConsecutive( + [2, 'a', true, $this->user->getUID()], + [4, 'b', true, $this->user->getUID()] + ) + ->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('')), null); + $this->itemAPI->starMultiple($ids); } @@ -436,22 +404,13 @@ class ItemApiControllerTest extends TestCase ] ]; - $this->itemService->expects($this->at(0)) - ->method('star') - ->with( - $this->equalTo(2), - $this->equalTo('a'), - $this->equalTo(false), - $this->equalTo($this->user->getUID()) - ); - $this->itemService->expects($this->at(1)) + $this->itemService->expects($this->exactly(2)) ->method('star') - ->with( - $this->equalTo(4), - $this->equalTo('b'), - $this->equalTo(false), - $this->equalTo($this->user->getUID()) + ->withConsecutive( + [2, 'a', false, $this->user->getUID()], + [4, 'b', false, $this->user->getUID()] ); + $this->itemAPI->unstarMultiple($ids); } |