diff options
-rw-r--r-- | AUTHORS.md | 7 | ||||
-rw-r--r-- | tests/Unit/Command/ExploreGeneratorTest.php | 8 | ||||
-rw-r--r-- | tests/Unit/Controller/FeedControllerTest.php | 19 | ||||
-rw-r--r-- | tests/Unit/Controller/ItemApiControllerTest.php | 101 | ||||
-rw-r--r-- | tests/Unit/Controller/ItemControllerTest.php | 87 | ||||
-rw-r--r-- | tests/Unit/Controller/PageControllerTest.php | 33 | ||||
-rw-r--r-- | tests/Unit/Db/FolderMapperTest.php | 228 | ||||
-rw-r--r-- | tests/Unit/Db/MapperTestUtility.php | 202 | ||||
-rw-r--r-- | tests/Unit/Service/FeedServiceTest.php | 195 | ||||
-rw-r--r-- | tests/Unit/Service/FolderServiceTest.php | 14 |
10 files changed, 370 insertions, 524 deletions
diff --git a/AUTHORS.md b/AUTHORS.md index e9064ce67..fab6e9c07 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -6,8 +6,8 @@ * [Gregor Tätzner](mailto:gregor@freenet.de) * [Morris Jobke](mailto:hey@morrisjobke.de) * [Sean Molenaar](mailto:SMillerDev@users.noreply.github.com) -* [Jan-Christoph Borchardt](mailto:hey@jancborchardt.net) * [Sean Molenaar](mailto:sean@seanmolenaar.eu) +* [Jan-Christoph Borchardt](mailto:hey@jancborchardt.net) * [Daniel Schaal](mailto:daniel@schaal.email) * [Davide Saurino](mailto:davide.saurino@alcacoop.it) * [raghunayyar](mailto:me@iraghu.com) @@ -15,9 +15,9 @@ * [Bernhard Posselt](mailto:bep@foryouandyourcustomers.com) * [Thomas Müller](mailto:thomas.mueller@tmit.eu) * [Hoàng Đức Hiếu](mailto:hdhoang@zahe.me) +* [anoy](mailto:anoymouserver+github@mailbox.org) * [Daniel Opitz](mailto:git@copynpaste.de) * [Sean Molenaar](mailto:sean@m2mobi.com) -* [anoy](mailto:anoymouserver+github@mailbox.org) * [rakekniven](mailto:mark.ziegler@rakekniven.de) * [David-Development](mailto:david-dev@live.de) * [IBBoard](mailto:dev@ibboard.co.uk) @@ -43,6 +43,7 @@ * [Andreas Fischer](mailto:bantu@owncloud.com) * [David Guillot](mailto:david@guillot.me) * [Gioele Falcetti](mailto:thegio.f@gmail.com) +* [Jan C. Borchardt](mailto:hey@jancborchardt.net) * [John Kristensen](mailto:john@jerrykan.com) * [Konrad Graefe](mailto:konradgraefe@aol.com) * [Loki3000](mailto:github@labcms.ru) @@ -112,11 +113,13 @@ * [Roeland Jago Douma](mailto:roeland@famdouma.nl) * [Simon](mailto:sschubert89@gmail.com) * [Simon Gilliot](mailto:simon@gilliot.fr) +* [Sturtz Network](mailto:sturtz110751@indianola.k12.ia.us) * [SuliacLEGUILLOU](mailto:suliac.leguillou@pm.me) * [Talon24](mailto:talontalon24@gmail.com) * [TexasGamer](mailto:tpgaubert@gmail.com) * [The Gitter Badger](mailto:badger@gitter.im) * [Thomas Wouters](mailto:twouters@users.noreply.github.com) +* [Tilo Spannagel](mailto:development@tilosp.de) * [Timo Schmidt](mailto:timo@xinterchange.net) * [Welling Guzmán](mailto:WellingGuzman@users.noreply.github.com) * [Xaver Maierhofer](mailto:xaver.maierhofer@xwissen.info) diff --git a/tests/Unit/Command/ExploreGeneratorTest.php b/tests/Unit/Command/ExploreGeneratorTest.php index 213633549..4512e206c 100644 --- a/tests/Unit/Command/ExploreGeneratorTest.php +++ b/tests/Unit/Command/ExploreGeneratorTest.php @@ -136,13 +136,9 @@ class ExploreGeneratorTest extends TestCase { ->with('votes') ->willReturn(100); - $this->consoleOutput->expects($this->at(0)) + $this->consoleOutput->expects($this->exactly(2)) ->method('writeln') - ->with($this->stringContains('<error>')); - - $this->consoleOutput->expects($this->at(1)) - ->method('writeln') - ->with($this->stringContains('Failure')); + ->withConsecutive(['<error>Failed to fetch feed info:</error>'], ['Failure']); self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); } diff --git a/tests/Unit/Controller/FeedControllerTest.php b/tests/Unit/Controller/FeedControllerTest.php index 7498d0ccb..f5c51b93e 100644 --- a/tests/Unit/Controller/FeedControllerTest.php +++ b/tests/Unit/Controller/FeedControllerTest.php @@ -142,22 +142,13 @@ class FeedControllerTest extends TestCase private function activeInitMocks($id, $type) { - $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('lastViewedFeedId') - ) - ->will($this->returnValue($id)); - $this->settings->expects($this->at(1)) - ->method('getUserValue') - ->with( - $this->equalTo($this->user), - $this->equalTo($this->appName), - $this->equalTo('lastViewedFeedType') + ->withConsecutive( + [$this->user, $this->appName, 'lastViewedFeedId'], + [$this->user, $this->appName, 'lastViewedFeedType'] ) - ->will($this->returnValue($type)); + ->willReturnOnConsecutiveCalls($id, $type); } 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); } 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); diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php index fe263f242..2afe2d590 100644 --- a/tests/Unit/Controller/PageControllerTest.php +++ b/tests/Unit/Controller/PageControllerTest.php @@ -234,21 +234,15 @@ class PageControllerTest extends TestCase */ public function testUpdateSettings() { - $this->settings->expects($this->at(0)) - ->method('setUserValue') - ->with('becka', 'news', 'showAll', '1'); - $this->settings->expects($this->at(1)) - ->method('setUserValue') - ->with('becka', 'news', 'compact', '1'); - $this->settings->expects($this->at(2)) - ->method('setUserValue') - ->with('becka', 'news', 'preventReadOnScroll', '0'); - $this->settings->expects($this->at(3)) - ->method('setUserValue') - ->with('becka', 'news', 'oldestFirst', '1'); - $this->settings->expects($this->at(4)) + $this->settings->expects($this->exactly(5)) ->method('setUserValue') - ->with('becka', 'news', 'compactExpand', '1'); + ->withConsecutive( + ['becka', 'news', 'showAll', '1'], + ['becka', 'news', 'compact', '1'], + ['becka', 'news', 'preventReadOnScroll', '0'], + ['becka', 'news', 'oldestFirst', '1'], + ['becka', 'news', 'compactExpand', '1'] + ); $this->controller->updateSettings(true, true, false, true, true); } @@ -256,13 +250,12 @@ class PageControllerTest extends TestCase public function testExplore() { $in = ['test']; - $this->settings->expects($this->at(0)) - ->method('setUserValue') - ->with('becka', 'news', 'lastViewedFeedId', 0); - - $this->settings->expects($this->at(1)) + $this->settings->expects($this->exactly(2)) ->method('setUserValue') - ->with('becka', 'news', 'lastViewedFeedType', FeedType::EXPLORE); + ->withConsecutive( + ['becka', 'news', 'lastViewedFeedId', 0], + ['becka', 'news', 'lastViewedFeedType', FeedType::EXPLORE] + ); $this->recommended->expects($this->once()) ->method('forLanguage') diff --git a/tests/Unit/Db/FolderMapperTest.php b/tests/Unit/Db/FolderMapperTest.php index deb235ff7..803c84ebe 100644 --- a/tests/Unit/Db/FolderMapperTest.php +++ b/tests/Unit/Db/FolderMapperTest.php @@ -50,21 +50,40 @@ class FolderMapperTest extends MapperTestUtility ]; } - + /** + * @covers \OCA\News\Db\FolderMapper::find + */ public function testFind() { $userId = 'john'; $id = 3; - $rows = [['id' => $this->folders[0]->getId()]]; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `id` = ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, [$id, $userId], $rows); + $this->db->expects($this->exactly(1)) + ->method('prepare') + ->with($sql, null, null) + ->will(($this->returnValue($this->query))); + + $this->query->expects($this->exactly(2)) + ->method('fetch') + ->willReturnOnConsecutiveCalls(['id' => 4], false); + + $this->query->expects($this->exactly(2)) + ->method('bindValue') + ->withConsecutive([1, 3, 1], [2, $userId, 2]); + + $this->query->expects($this->exactly(1)) + ->method('closeCursor'); + + $this->query->expects($this->once()) + ->method('execute') + ->with('') + ->will($this->returnValue([])); $result = $this->folderMapper->find($userId, $id); $this->assertEquals($this->folders[0], $result); - } @@ -76,7 +95,26 @@ class FolderMapperTest extends MapperTestUtility 'WHERE `id` = ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, [$id, $userId]); + $this->db->expects($this->exactly(1)) + ->method('prepare') + ->with($sql, null, null) + ->will(($this->returnValue($this->query))); + + $this->query->expects($this->exactly(1)) + ->method('fetch') + ->willReturnOnConsecutiveCalls(false); + + $this->query->expects($this->exactly(2)) + ->method('bindValue') + ->withConsecutive([1, $id, 1], [2, $userId, 2]); + + $this->query->expects($this->exactly(1)) + ->method('closeCursor'); + + $this->query->expects($this->once()) + ->method('execute') + ->with('') + ->will($this->returnValue([])); $this->expectException(DoesNotExistException::class); $this->folderMapper->find($userId, $id); @@ -87,12 +125,30 @@ class FolderMapperTest extends MapperTestUtility { $userId = 'john'; $id = 3; - $rows = $this->twoRows; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `id` = ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, [$id, $userId], $rows); + $this->db->expects($this->exactly(1)) + ->method('prepare') + ->with($sql, null, null) + ->will(($this->returnValue($this->query))); + + $this->query->expects($this->exactly(2)) + ->method('fetch') + ->willReturnOnConsecutiveCalls(['id' => 4], ['id' => 5]); + + $this->query->expects($this->exactly(2)) + ->method('bindValue') + ->withConsecutive([1, 3, 1], [2, $userId, 2]); + + $this->query->expects($this->exactly(1)) + ->method('closeCursor'); + + $this->query->expects($this->once()) + ->method('execute') + ->with('') + ->will($this->returnValue([])); $this->expectException(MultipleObjectsReturnedException::class); $this->folderMapper->find($userId, $id); @@ -103,12 +159,29 @@ class FolderMapperTest extends MapperTestUtility public function testFindAllFromUser() { $userId = 'john'; - $rows = $this->twoRows; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `user_id` = ? ' . 'AND `deleted_at` = 0'; - $this->setMapperResult($sql, [$userId], $rows); + $this->db->expects($this->exactly(1)) + ->method('prepare') + ->with($sql, null, null) + ->will(($this->returnValue($this->query))); + + $this->query->expects($this->exactly(3)) + ->method('fetch') + ->willReturnOnConsecutiveCalls(['id' => 4], ['id' => 5]); + + $this->query->expects($this->exactly(1)) + ->method('bindValue') + ->withConsecutive([1, $userId, 2]); + + $this->query->expects($this->exactly(1)) + ->method('closeCursor'); + + $this->query->expects($this->once()) + ->method('execute') + ->will($this->returnValue([])); $result = $this->folderMapper->findAllFromUser($userId); $this->assertEquals($this->folders, $result); @@ -119,12 +192,29 @@ class FolderMapperTest extends MapperTestUtility { $folderName = 'heheh'; $userId = 'john'; - $rows = $this->twoRows; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `name` = ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, [$folderName, $userId], $rows); + $this->db->expects($this->exactly(1)) + ->method('prepare') + ->with($sql, null, null) + ->will(($this->returnValue($this->query))); + + $this->query->expects($this->exactly(3)) + ->method('fetch') + ->willReturnOnConsecutiveCalls(['id' => 4], ['id' => 5]); + + $this->query->expects($this->exactly(2)) + ->method('bindValue') + ->withConsecutive([1, $folderName, 2], [2, $userId, 2]); + + $this->query->expects($this->exactly(1)) + ->method('closeCursor'); + + $this->query->expects($this->once()) + ->method('execute') + ->will($this->returnValue([])); $result = $this->folderMapper->findByName($folderName, $userId); $this->assertEquals($this->folders, $result); @@ -145,9 +235,25 @@ class FolderMapperTest extends MapperTestUtility $sql3 = 'DELETE FROM `*PREFIX*news_items` WHERE `feed_id` NOT IN '. '(SELECT `feeds`.`id` FROM `*PREFIX*news_feeds` `feeds`)'; - $this->setMapperResult($sql, $arguments, [], null, null, true); - $this->setMapperResult($sql2, $arguments2, [], null, null, true); - $this->setMapperResult($sql3, [], [], null, null, true); + $this->db->expects($this->exactly(3)) + ->method('prepare') + ->withConsecutive( + [$sql, null, null], + [$sql2, null, null], + [$sql3, null, null] + ) + ->will(($this->returnValue($this->query))); + + $this->query->expects($this->exactly(2)) + ->method('bindValue') + ->withConsecutive([1, 3, 1]); + + $this->query->expects($this->exactly(3)) + ->method('closeCursor'); + + $this->query->expects($this->exactly(3)) + ->method('execute') + ->will($this->returnValue([])); $this->folderMapper->delete($folder); } @@ -155,13 +261,32 @@ class FolderMapperTest extends MapperTestUtility public function testGetPurgeDeleted() { - $rows = $this->twoRows; - $deleteOlderThan = 110; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `deleted_at` > 0 ' . 'AND `deleted_at` < ? '; - $this->setMapperResult($sql, [$deleteOlderThan], $rows); - $result = $this->folderMapper->getToDelete($deleteOlderThan); + + + $this->db->expects($this->exactly(1)) + ->method('prepare') + ->with($sql, null, null) + ->will(($this->returnValue($this->query))); + + $this->query->expects($this->exactly(3)) + ->method('fetch') + ->willReturnOnConsecutiveCalls(['id' => 4], ['id' => 5]); + + $this->query->expects($this->exactly(1)) + ->method('bindValue') + ->withConsecutive([1, 110, 1]); + + $this->query->expects($this->exactly(1)) + ->method('closeCursor'); + + $this->query->expects($this->once()) + ->method('execute') + ->will($this->returnValue([])); + + $result = $this->folderMapper->getToDelete(110); $this->assertEquals($this->folders, $result); } @@ -170,13 +295,33 @@ class FolderMapperTest extends MapperTestUtility public function testGetPurgeDeletedUser() { - $rows = $this->twoRows; $deleteOlderThan = 110; $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `deleted_at` > 0 ' . 'AND `deleted_at` < ? ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, [$deleteOlderThan, $this->user], $rows); + + + $this->db->expects($this->exactly(1)) + ->method('prepare') + ->with($sql, null, null) + ->will(($this->returnValue($this->query))); + + $this->query->expects($this->exactly(3)) + ->method('fetch') + ->willReturnOnConsecutiveCalls(['id' => 4], ['id' => 5]); + + $this->query->expects($this->exactly(2)) + ->method('bindValue') + ->withConsecutive([1, 110, 1], [2, 'hh', 2]); + + $this->query->expects($this->exactly(1)) + ->method('closeCursor'); + + $this->query->expects($this->once()) + ->method('execute') + ->will($this->returnValue([])); + $result = $this->folderMapper->getToDelete( $deleteOlderThan, $this->user ); @@ -187,12 +332,30 @@ class FolderMapperTest extends MapperTestUtility public function testGetAllPurgeDeletedUser() { - $rows = $this->twoRows; - $sql = 'SELECT * FROM `*PREFIX*news_folders` ' . 'WHERE `deleted_at` > 0 ' . 'AND `user_id` = ?'; - $this->setMapperResult($sql, [$this->user], $rows); + + $this->db->expects($this->exactly(1)) + ->method('prepare') + ->with($sql, null, null) + ->will(($this->returnValue($this->query))); + + $this->query->expects($this->exactly(3)) + ->method('fetch') + ->willReturnOnConsecutiveCalls(['id' => 4], ['id' => 5]); + + $this->query->expects($this->exactly(1)) + ->method('bindValue') + ->withConsecutive([1, 'hh', 2]); + + $this->query->expects($this->exactly(1)) + ->method('closeCursor'); + + $this->query->expects($this->once()) + ->method('execute') + ->will($this->returnValue([])); + $result = $this->folderMapper->getToDelete(null, $this->user); $this->assertEquals($this->folders, $result); @@ -204,7 +367,24 @@ class FolderMapperTest extends MapperTestUtility $userId = 'john'; $sql = 'DEL |