diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3cd385d80d..381781931e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,7 @@ You can also check [on GitHub](https://github.com/nextcloud/news/releases), the
# Unreleased
## [28.x.x]
### Changed
-
+- Replace deprecated PHPUnit `withConsecutive` method to prepare for PHPUnit 10 upgrade
### Fixed
diff --git a/composer.lock b/composer.lock
index b15efe9736..0fa91b77d1 100644
--- a/composer.lock
+++ b/composer.lock
@@ -304,33 +304,38 @@
},
{
"name": "league/uri",
- "version": "7.5.1",
+ "version": "7.6.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/uri.git",
- "reference": "81fb5145d2644324614cc532b28efd0215bda430"
+ "reference": "f625804987a0a9112d954f9209d91fec52182344"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/uri/zipball/81fb5145d2644324614cc532b28efd0215bda430",
- "reference": "81fb5145d2644324614cc532b28efd0215bda430",
+ "url": "https://api.github.com/repos/thephpleague/uri/zipball/f625804987a0a9112d954f9209d91fec52182344",
+ "reference": "f625804987a0a9112d954f9209d91fec52182344",
"shasum": ""
},
"require": {
- "league/uri-interfaces": "^7.5",
- "php": "^8.1"
+ "league/uri-interfaces": "^7.6",
+ "php": "^8.1",
+ "psr/http-factory": "^1"
},
"conflict": {
"league/uri-schemes": "^1.0"
},
"suggest": {
"ext-bcmath": "to improve IPV4 host parsing",
+ "ext-dom": "to convert the URI into an HTML anchor tag",
"ext-fileinfo": "to create Data URI from file contennts",
"ext-gmp": "to improve IPV4 host parsing",
"ext-intl": "to handle IDN host with the best performance",
+ "ext-uri": "to use the PHP native URI class",
"jeremykendall/php-domain-parser": "to resolve Public Suffix and Top Level Domain",
"league/uri-components": "Needed to easily manipulate URI objects components",
+ "league/uri-polyfill": "Needed to backport the PHP URI extension for older versions of PHP",
"php-64bit": "to improve IPV4 host parsing",
+ "rowbot/url": "to handle WHATWG URL",
"symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present"
},
"type": "library",
@@ -358,6 +363,7 @@
"description": "URI manipulation library",
"homepage": "https://uri.thephpleague.com",
"keywords": [
+ "URN",
"data-uri",
"file-uri",
"ftp",
@@ -370,9 +376,11 @@
"psr-7",
"query-string",
"querystring",
+ "rfc2141",
"rfc3986",
"rfc3987",
"rfc6570",
+ "rfc8141",
"uri",
"uri-template",
"url",
@@ -382,7 +390,7 @@
"docs": "https://uri.thephpleague.com",
"forum": "https://thephpleague.slack.com",
"issues": "https://github.com/thephpleague/uri-src/issues",
- "source": "https://github.com/thephpleague/uri/tree/7.5.1"
+ "source": "https://github.com/thephpleague/uri/tree/7.6.0"
},
"funding": [
{
@@ -390,26 +398,25 @@
"type": "github"
}
],
- "time": "2024-12-08T08:40:02+00:00"
+ "time": "2025-11-18T12:17:23+00:00"
},
{
"name": "league/uri-interfaces",
- "version": "7.5.0",
+ "version": "7.6.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/uri-interfaces.git",
- "reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742"
+ "reference": "ccbfb51c0445298e7e0b7f4481b942f589665368"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/08cfc6c4f3d811584fb09c37e2849e6a7f9b0742",
- "reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742",
+ "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/ccbfb51c0445298e7e0b7f4481b942f589665368",
+ "reference": "ccbfb51c0445298e7e0b7f4481b942f589665368",
"shasum": ""
},
"require": {
"ext-filter": "*",
"php": "^8.1",
- "psr/http-factory": "^1",
"psr/http-message": "^1.1 || ^2.0"
},
"suggest": {
@@ -417,6 +424,7 @@
"ext-gmp": "to improve IPV4 host parsing",
"ext-intl": "to handle IDN host with the best performance",
"php-64bit": "to improve IPV4 host parsing",
+ "rowbot/url": "to handle WHATWG URL",
"symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present"
},
"type": "library",
@@ -441,7 +449,7 @@
"homepage": "https://nyamsprod.com"
}
],
- "description": "Common interfaces and classes for URI representation and interaction",
+ "description": "Common tools for parsing and resolving RFC3987/RFC3986 URI",
"homepage": "https://uri.thephpleague.com",
"keywords": [
"data-uri",
@@ -466,7 +474,7 @@
"docs": "https://uri.thephpleague.com",
"forum": "https://thephpleague.slack.com",
"issues": "https://github.com/thephpleague/uri-src/issues",
- "source": "https://github.com/thephpleague/uri-interfaces/tree/7.5.0"
+ "source": "https://github.com/thephpleague/uri-interfaces/tree/7.6.0"
},
"funding": [
{
@@ -474,7 +482,7 @@
"type": "github"
}
],
- "time": "2024-12-08T08:18:47+00:00"
+ "time": "2025-11-18T12:17:23+00:00"
},
{
"name": "masterminds/html5",
@@ -3682,16 +3690,16 @@
},
{
"name": "theseer/tokenizer",
- "version": "1.2.3",
+ "version": "1.3.1",
"source": {
"type": "git",
"url": "https://github.com/theseer/tokenizer.git",
- "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2"
+ "reference": "b7489ce515e168639d17feec34b8847c326b0b3c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
- "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2",
+ "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c",
+ "reference": "b7489ce515e168639d17feec34b8847c326b0b3c",
"shasum": ""
},
"require": {
@@ -3720,7 +3728,7 @@
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"support": {
"issues": "https://github.com/theseer/tokenizer/issues",
- "source": "https://github.com/theseer/tokenizer/tree/1.2.3"
+ "source": "https://github.com/theseer/tokenizer/tree/1.3.1"
},
"funding": [
{
@@ -3728,7 +3736,7 @@
"type": "github"
}
],
- "time": "2024-03-03T12:36:25+00:00"
+ "time": "2025-11-17T20:03:58+00:00"
}
],
"aliases": [],
diff --git a/tests/Unit/Command/ExploreGeneratorTest.php b/tests/Unit/Command/ExploreGeneratorTest.php
index 2c4a337467..0067f90f9c 100644
--- a/tests/Unit/Command/ExploreGeneratorTest.php
+++ b/tests/Unit/Command/ExploreGeneratorTest.php
@@ -140,9 +140,18 @@ public function testFailingFeed()
->with('votes')
->willReturn(100);
+ $expectedCalls = [
+ ['Failed to fetch feed info:', 0],
+ ['Failure', 0]
+ ];
+ $callIndex = 0;
+
$this->consoleOutput->expects($this->exactly(2))
->method('writeln')
- ->withConsecutive(['Failed to fetch feed info:'], ['Failure']);
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ });
$result = $this->command->run($this->consoleInput, $this->consoleOutput);
$this->assertSame(1, $result);
diff --git a/tests/Unit/Command/ShowFeedTest.php b/tests/Unit/Command/ShowFeedTest.php
index ace16e0af2..1f80dca66a 100644
--- a/tests/Unit/Command/ShowFeedTest.php
+++ b/tests/Unit/Command/ShowFeedTest.php
@@ -75,12 +75,18 @@ public function testValid()
->with('feed', true, 'user', 'user')
->willReturn([['feed'], [['items']]]);
+ $expectedCalls = [
+ ["Feed: [\n \"feed\"\n]", 0], // writeln includes verbosity level
+ ["Items: [\n [\n \"items\"\n ]\n]", 0]
+ ];
+ $callIndex = 0;
+
$this->consoleOutput->expects($this->exactly(2))
->method('writeln')
- ->withConsecutive(
- ["Feed: [\n \"feed\"\n]"],
- ["Items: [\n [\n \"items\"\n ]\n]"]
- );
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ });
$result = $this->command->run($this->consoleInput, $this->consoleOutput);
$this->assertSame(0, $result);
@@ -109,12 +115,18 @@ public function testInValid()
->with('feed', true, 'user', 'user')
->will($this->throwException(new ServiceNotFoundException('test')));
+ $expectedCalls = [
+ ['Failed to fetch feed info:', 0], // writeln includes verbosity level
+ ['test', 0]
+ ];
+ $callIndex = 0;
+
$this->consoleOutput->expects($this->exactly(2))
->method('writeln')
- ->withConsecutive(
- ['Failed to fetch feed info:'],
- ['test']
- );
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ });
$result = $this->command->run($this->consoleInput, $this->consoleOutput);
$this->assertSame(1, $result);
diff --git a/tests/Unit/Controller/ExportControllerTest.php b/tests/Unit/Controller/ExportControllerTest.php
index 46bf39757f..f6e610a413 100644
--- a/tests/Unit/Controller/ExportControllerTest.php
+++ b/tests/Unit/Controller/ExportControllerTest.php
@@ -141,10 +141,20 @@ public function testGetAllArticles()
->method('findAllForUser')
->with('user')
->will($this->returnValue($feeds));
+
+ $expectedCalls = [
+ ['user', ['unread' => false, 'starred' => true]],
+ ['user', ['unread' => true]]
+ ];
+ $returns = [$articles, []];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('findAllForUser')
- ->withConsecutive(['user', ['unread' => false, 'starred' => true]], ['user', ['unread' => true]])
- ->willReturnOnConsecutiveCalls($articles, []);
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$returns, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ return $returns[$callIndex++];
+ });
$return = $this->controller->articles();
diff --git a/tests/Unit/Controller/FeedControllerTest.php b/tests/Unit/Controller/FeedControllerTest.php
index 3bfd925024..87a55c0832 100644
--- a/tests/Unit/Controller/FeedControllerTest.php
+++ b/tests/Unit/Controller/FeedControllerTest.php
@@ -199,13 +199,19 @@ public function testIndexHighestItemIdExists()
*/
private function activeInitMocks($id, $type): void
{
+ $expectedCalls = [
+ [$this->uid, $this->appName, 'lastViewedFeedId', ''],
+ [$this->uid, $this->appName, 'lastViewedFeedType', '']
+ ];
+ $returns = [$id, $type];
+ $callIndex = 0;
+
$this->settings->expects($this->exactly(2))
->method('getUserValue')
- ->withConsecutive(
- [$this->uid, $this->appName, 'lastViewedFeedId'],
- [$this->uid, $this->appName, 'lastViewedFeedType']
- )
- ->willReturnOnConsecutiveCalls($id, $type);
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$returns, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ return $returns[$callIndex++];
+ });
}
diff --git a/tests/Unit/Controller/ItemApiControllerTest.php b/tests/Unit/Controller/ItemApiControllerTest.php
index 81837e3f87..58d1801da9 100644
--- a/tests/Unit/Controller/ItemApiControllerTest.php
+++ b/tests/Unit/Controller/ItemApiControllerTest.php
@@ -392,37 +392,60 @@ public function testReadAll()
public function testReadMultiple()
{
+ $expectedCalls = [
+ [$this->user->getUID(), 2, true],
+ [$this->user->getUID(), 4, true]
+ ];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('read')
- ->withConsecutive(
- [$this->user->getUID(), 2, true],
- [$this->user->getUID(), 4, true]
- );
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ return new Item();
+ });
$this->class->readMultipleByIds([2, 4]);
}
public function testReadMultipleDoesntCareAboutException()
{
+ $expectedCalls = [
+ [$this->user->getUID(), 2, true],
+ [$this->user->getUID(), 4, true]
+ ];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('read')
- ->withConsecutive(
- [$this->user->getUID(), 2, true],
- [$this->user->getUID(), 4, true]
- )
- ->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('')), new Item());
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ if ($callIndex === 1) {
+ throw new ServiceNotFoundException('');
+ }
+ return new Item();
+ });
$this->class->readMultipleByIds([2, 4]);
}
public function testUnreadMultiple()
{
+ $expectedCalls = [
+ [$this->user->getUID(), 2, false],
+ [$this->user->getUID(), 4, false]
+ ];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('read')
- ->withConsecutive(
- [$this->user->getUID(), 2, false],
- [$this->user->getUID(), 4, false]
- );
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ return new Item();
+ });
$this->class->unreadMultipleByIds([2, 4]);
}
@@ -440,12 +463,19 @@ public function testStarMultiple()
]
];
+ $expectedCalls = [
+ [$this->user->getUID(), 2, 'a', true],
+ [$this->user->getUID(), 4, 'b', true]
+ ];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('starByGuid')
- ->withConsecutive(
- [$this->user->getUID(), 2, 'a', true],
- [$this->user->getUID(), 4, 'b', true]
- );
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ return new Item();
+ });
$this->class->starMultiple($ids);
}
@@ -463,13 +493,22 @@ public function testStarMultipleDoesntCareAboutException()
]
];
+ $expectedCalls = [
+ [$this->user->getUID(), 2, 'a', true],
+ [$this->user->getUID(), 4, 'b', true]
+ ];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('starByGuid')
- ->withConsecutive(
- [$this->user->getUID(), 2, 'a', true],
- [$this->user->getUID(), 4, 'b', true]
- )
- ->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('')), new Item());
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ if ($callIndex === 1) {
+ throw new ServiceNotFoundException('');
+ }
+ return new Item();
+ });
$this->class->starMultiple($ids);
}
@@ -488,12 +527,19 @@ public function testUnstarMultiple()
]
];
+ $expectedCalls = [
+ [$this->user->getUID(), 2, 'a', false],
+ [$this->user->getUID(), 4, 'b', false]
+ ];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('starByGuid')
- ->withConsecutive(
- [$this->user->getUID(), 2, 'a', false],
- [$this->user->getUID(), 4, 'b', false]
- );
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ return new Item();
+ });
$this->class->unstarMultiple($ids);
}
@@ -523,12 +569,19 @@ public function testStarMultipleByItemIds()
{
$ids = [ 345, 678 ];
+ $expectedCalls = [
+ [$this->user->getUID(), 345, true],
+ [$this->user->getUID(), 678, true]
+ ];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('star')
- ->withConsecutive(
- [$this->user->getUID(), 345, true],
- [$this->user->getUID(), 678, true]
- );
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ return new Item();
+ });
$this->class->starMultipleByItemIds($ids);
}
@@ -537,12 +590,19 @@ public function testUnstarMultipleByItemIds()
{
$ids = [ 345, 678 ];
+ $expectedCalls = [
+ [$this->user->getUID(), 345, false],
+ [$this->user->getUID(), 678, false]
+ ];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('star')
- ->withConsecutive(
- [$this->user->getUID(), 345, false],
- [$this->user->getUID(), 678, false]
- );
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ return new Item();
+ });
$this->class->unstarMultipleByItemIds($ids);
}
diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php
index 43aceb7e21..7f143bf0e6 100644
--- a/tests/Unit/Controller/ItemControllerTest.php
+++ b/tests/Unit/Controller/ItemControllerTest.php
@@ -166,12 +166,19 @@ public function testShareDoesNotExist()
public function testReadMultiple()
{
+ $expectedCalls = [
+ ['user', 2, true],
+ ['user', 4, true]
+ ];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('read')
- ->withConsecutive(
- ['user', 2, true],
- ['user', 4, true]
- );
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ return new Item();
+ });
$this->controller->readMultiple([2, 4]);
}
@@ -180,13 +187,22 @@ public function testReadMultiple()
public function testReadMultipleDontStopOnException()
{
+ $expectedCalls = [
+ ['user', 2, true],
+ ['user', 4, true]
+ ];
+ $callIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('read')
- ->withConsecutive(
- ['user', 2, true],
- ['user', 4, true]
- )
- ->willReturnOnConsecutiveCalls($this->throwException(new ServiceNotFoundException('yo')), new Item());
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ $callIndex++;
+ if ($callIndex === 1) {
+ throw new ServiceNotFoundException('yo');
+ }
+ return new Item();
+ });
$this->controller->readMultiple([2, 4]);
}
@@ -244,19 +260,32 @@ public function testReadAll()
*/
private function itemsApiExpects($id, $type, $oldestFirst = '1'): void
{
+ $getUserValueCalls = [
+ ['user', $this->appName, 'showAll', ''],
+ ['user', $this->appName, 'oldestFirst', '']
+ ];
+ $getUserValueReturns = ['1', $oldestFirst];
+ $getUserValueIndex = 0;
+
$this->settings->expects($this->exactly(2))
->method('getUserValue')
- ->withConsecutive(
- ['user', $this->appName, 'showAll'],
- ['user', $this->appName, 'oldestFirst']
- )
- ->willReturnOnConsecutiveCalls('1', $oldestFirst);
+ ->willReturnCallback(function (...$args) use (&$getUserValueCalls, &$getUserValueReturns, &$getUserValueIndex) {
+ $this->assertEquals($getUserValueCalls[$getUserValueIndex], $args);
+ return $getUserValueReturns[$getUserValueIndex++];
+ });
+
+ $setUserValueCalls = [
+ ['user', $this->appName, 'lastViewedFeedId', $id, null],
+ ['user', $this->appName, 'lastViewedFeedType', $type, null]
+ ];
+ $setUserValueIndex = 0;
+
$this->settings->expects($this->exactly(2))
->method('setUserValue')
- ->withConsecutive(
- ['user', $this->appName, 'lastViewedFeedId', $id],
- ['user', $this->appName, 'lastViewedFeedType', $type]
- );
+ ->willReturnCallback(function (...$args) use (&$setUserValueCalls, &$setUserValueIndex) {
+ $this->assertEquals($setUserValueCalls[$setUserValueIndex], $args);
+ $setUserValueIndex++;
+ });
}
diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php
index 5d5e3cffd2..fa75e555ff 100644
--- a/tests/Unit/Controller/PageControllerTest.php
+++ b/tests/Unit/Controller/PageControllerTest.php
@@ -204,14 +204,20 @@ public function testSettings()
->method('getLanguageCode')
->will($this->returnValue('de'));
+ $getUserValueCalls = [
+ ['becka', 'news', 'showAll', ''],
+ ['becka', 'news', 'preventReadOnScroll', ''],
+ ['becka', 'news', 'oldestFirst', '']
+ ];
+ $getUserValueIndex = 0;
+
$this->config->expects($this->exactly(3))
->method('getUserValue')
- ->withConsecutive(
- ['becka', 'news', 'showAll'],
- ['becka', 'news', 'preventReadOnScroll'],
- ['becka', 'news', 'oldestFirst']
- )
- ->will($this->returnValue('1'));
+ ->willReturnCallback(function (...$args) use (&$getUserValueCalls, &$getUserValueIndex) {
+ $this->assertEquals($getUserValueCalls[$getUserValueIndex], $args);
+ $getUserValueIndex++;
+ return '1';
+ });
$this->settings->expects($this->once())
->method('getValueString')
->with('news', 'exploreUrl')
@@ -243,14 +249,20 @@ public function testSettingsExploreUrlSet()
->method('getLanguageCode')
->will($this->returnValue('de'));
+ $getUserValueCalls = [
+ ['becka', 'news', 'showAll', ''],
+ ['becka', 'news', 'preventReadOnScroll', ''],
+ ['becka', 'news', 'oldestFirst', '']
+ ];
+ $getUserValueIndex = 0;
+
$this->config->expects($this->exactly(3))
->method('getUserValue')
- ->withConsecutive(
- ['becka', 'news', 'showAll'],
- ['becka', 'news', 'preventReadOnScroll'],
- ['becka', 'news', 'oldestFirst']
- )
- ->will($this->returnValue('1'));
+ ->willReturnCallback(function (...$args) use (&$getUserValueCalls, &$getUserValueIndex) {
+ $this->assertEquals($getUserValueCalls[$getUserValueIndex], $args);
+ $getUserValueIndex++;
+ return '1';
+ });
$this->settings->expects($this->once())
->method('getValueString')
->with('news', 'exploreUrl')
@@ -268,14 +280,20 @@ public function testSettingsExploreUrlSet()
*/
public function testUpdateSettings()
{
+ $setUserValueCalls = [
+ ['becka', 'news', 'showAll', '1', null],
+ ['becka', 'news', 'preventReadOnScroll', '0', null],
+ ['becka', 'news', 'oldestFirst', '1', null],
+ ['becka', 'news', 'disableRefresh', '0', null]
+ ];
+ $setUserValueIndex = 0;
+
$this->config->expects($this->exactly(4))
->method('setUserValue')
- ->withConsecutive(
- ['becka', 'news', 'showAll', '1'],
- ['becka', 'news', 'preventReadOnScroll', '0'],
- ['becka', 'news', 'oldestFirst', '1'],
- ['becka', 'news', 'disableRefresh', '0']
- );
+ ->willReturnCallback(function (...$args) use (&$setUserValueCalls, &$setUserValueIndex) {
+ $this->assertEquals($setUserValueCalls[$setUserValueIndex], $args);
+ $setUserValueIndex++;
+ });
$this->controller->updateSettings(true, false, true, false);
}
@@ -283,12 +301,18 @@ public function testUpdateSettings()
public function testExplore()
{
$in = ['test'];
+ $setUserValueCalls = [
+ ['becka', 'news', 'lastViewedFeedId', 0, null],
+ ['becka', 'news', 'lastViewedFeedType', ListType::EXPLORE, null]
+ ];
+ $setUserValueIndex = 0;
+
$this->config->expects($this->exactly(2))
->method('setUserValue')
- ->withConsecutive(
- ['becka', 'news', 'lastViewedFeedId', 0],
- ['becka', 'news', 'lastViewedFeedType', ListType::EXPLORE]
- );
+ ->willReturnCallback(function (...$args) use (&$setUserValueCalls, &$setUserValueIndex) {
+ $this->assertEquals($setUserValueCalls[$setUserValueIndex], $args);
+ $setUserValueIndex++;
+ });
$this->recommended->expects($this->once())
->method('forLanguage')
@@ -302,12 +326,18 @@ public function testExplore()
public function testExploreError()
{
+ $setUserValueCalls = [
+ ['becka', 'news', 'lastViewedFeedId', 0, null],
+ ['becka', 'news', 'lastViewedFeedType', ListType::EXPLORE, null]
+ ];
+ $setUserValueIndex = 0;
+
$this->config->expects($this->exactly(2))
->method('setUserValue')
- ->withConsecutive(
- ['becka', 'news', 'lastViewedFeedId', 0],
- ['becka', 'news', 'lastViewedFeedType', ListType::EXPLORE]
- );
+ ->willReturnCallback(function (...$args) use (&$setUserValueCalls, &$setUserValueIndex) {
+ $this->assertEquals($setUserValueCalls[$setUserValueIndex], $args);
+ $setUserValueIndex++;
+ });
$this->recommended->expects($this->once())
->method('forLanguage')
diff --git a/tests/Unit/Db/FeedMapperTest.php b/tests/Unit/Db/FeedMapperTest.php
index 2b53fcbd40..7996c6611a 100644
--- a/tests/Unit/Db/FeedMapperTest.php
+++ b/tests/Unit/Db/FeedMapperTest.php
@@ -113,10 +113,15 @@ public function testFindAllFromUser()
->with('feeds.id')
->will($this->returnSelf());
+ $setParameterCalls = [['unread', true, 'boolean'], ['user_id', 'jack', null]];
+ $setParameterIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['unread', true], ['user_id', 'jack'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -160,13 +165,18 @@ public function testFindFromUser()
$this->builder->expects($this->exactly(1))
->method('andWhere')
- ->withConsecutive(['id = :id'])
+ ->with('id = :id')
->will($this->returnSelf());
+ $setParameterCalls = [['user_id', 'jack', null], ['id', 1, null]];
+ $setParameterIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'], ['id', 1])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -209,13 +219,18 @@ public function testFindFromUserEmpty()
$this->builder->expects($this->exactly(1))
->method('andWhere')
- ->withConsecutive(['id = :id'])
+ ->with('id = :id')
->will($this->returnSelf());
+ $setParameterCalls = [['user_id', 'jack', null], ['id', 1, null]];
+ $setParameterIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'], ['id', 1])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -257,13 +272,21 @@ public function testFindByUrl()
$this->builder->expects($this->exactly(1))
->method('andWhere')
- ->withConsecutive(['url = :url'])
+ ->with('url = :url')
->will($this->returnSelf());
+ $setParameterCalls = [
+ ['user_id', 'jack', null],
+ ['url', 'https://url.com', null]
+ ];
+ $setParameterIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'], ['url', 'https://url.com'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -307,13 +330,21 @@ public function testFindFromUserDuplicate()
$this->builder->expects($this->exactly(1))
->method('andWhere')
- ->withConsecutive(['id = :id'])
+ ->with('id = :id')
->will($this->returnSelf());
+ $setParameterCalls = [
+ ['user_id', 'jack', null],
+ ['id', 1, null]
+ ];
+ $setParameterIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'], ['id', 1])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -394,10 +425,17 @@ public function testFindAllFromFolder()
->with('folder_id = :folder_id')
->will($this->returnSelf());
+ $setParameterCalls = [
+ ['folder_id', 1, null]
+ ];
+ $setParameterIndex = 0;
+
$this->builder->expects($this->exactly(1))
->method('setParameter')
- ->withConsecutive(['folder_id', 1])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -483,15 +521,25 @@ public function testRead()
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.id = :feedId']];
+ $andWhereIndex = 0;
+
$selectbuilder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['feeds.user_id = :userId'], ['feeds.id = :feedId'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex, $selectbuilder) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $selectbuilder;
+ });
+
+ $setParameterCalls = [['userId', 'admin', null], ['feedId', 1, null]];
+ $setParameterIndex = 0;
$selectbuilder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['userId', 'admin'], ['feedId', 1])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex, $selectbuilder) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $selectbuilder;
+ });
$selectbuilder->expects($this->exactly(1))
->method('getSQL')
@@ -523,20 +571,41 @@ public function testRead()
->method('createParameter')
->will($this->returnArgument(0));
+ $setCalls = [['unread', 'unread'], ['last_modified', 'last_modified']];
+ $setIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('set')
- ->withConsecutive(['unread', 'unread'], ['last_modified', 'last_modified'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setCalls, &$setIndex) {
+ $this->assertEquals($setCalls[$setIndex++], $args);
+ return $this->builder;
+ });
+
+ $andWhereCalls2 = [['id IN (:idList)'], ['unread != :unread']];
+ $andWhereIndex2 = 0;
$this->builder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['id IN (:idList)'], ['unread != :unread'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls2, &$andWhereIndex2) {
+ $this->assertEquals($andWhereCalls2[$andWhereIndex2++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls2 = [['unread', false, 'boolean'], ['idList', [1, 2], 101]];
+ $setParameterIndex2 = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['unread', false], ['idList', [1, 2]], ['last_modified'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls2, &$setParameterIndex2) {
+ if ($setParameterIndex2 < count($setParameterCalls2)) {
+ $this->assertEquals($setParameterCalls2[$setParameterIndex2++], $args);
+ } else {
+ // last_modified with dynamic timestamp - just check it's called
+ $this->assertEquals('last_modified', $args[0]);
+ $setParameterIndex2++;
+ }
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('getSQL')
@@ -585,15 +654,25 @@ public function testReadWithMaxID()
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.id = :feedId'], ['items.id <= :maxItemId']];
+ $andWhereIndex = 0;
+
$selectbuilder->expects($this->exactly(3))
->method('andWhere')
- ->withConsecutive(['feeds.user_id = :userId'], ['feeds.id = :feedId'], ['items.id <= :maxItemId'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex, $selectbuilder) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $selectbuilder;
+ });
+
+ $setParameterCalls = [['userId', 'admin', null], ['feedId', 1, null], ['maxItemId', 4, null]];
+ $setParameterIndex = 0;
$selectbuilder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'admin'], ['feedId', 1], ['maxItemId', 4])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex, $selectbuilder) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $selectbuilder;
+ });
$selectbuilder->expects($this->exactly(1))
->method('getSQL')
@@ -625,20 +704,41 @@ public function testReadWithMaxID()
->with('news_items')
->will($this->returnSelf());
+ $setCalls = [['unread', 'unread'], ['last_modified', 'last_modified']];
+ $setIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('set')
- ->withConsecutive(['unread', 'unread'], ['last_modified', 'last_modified'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setCalls, &$setIndex) {
+ $this->assertEquals($setCalls[$setIndex++], $args);
+ return $this->builder;
+ });
+
+ $andWhereCalls2 = [['id IN (:idList)'], ['unread != :unread']];
+ $andWhereIndex2 = 0;
$this->builder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['id IN (:idList)'], ['unread != :unread'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls2, &$andWhereIndex2) {
+ $this->assertEquals($andWhereCalls2[$andWhereIndex2++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls2 = [['unread', false, 'boolean'], ['idList', [1, 2], 101]];
+ $setParameterIndex2 = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['unread', false], ['idList', [1, 2]], ['last_modified'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls2, &$setParameterIndex2) {
+ if ($setParameterIndex2 < count($setParameterCalls2)) {
+ $this->assertEquals($setParameterCalls2[$setParameterIndex2++], $args);
+ } else {
+ // last_modified with dynamic timestamp - just check it's called
+ $this->assertEquals('last_modified', $args[0]);
+ $setParameterIndex2++;
+ }
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('getSQL')
@@ -654,7 +754,7 @@ public function testReadWithMaxID()
$this->db->expects($this->exactly(1))
->method('executeStatement')
- ->with('QUERY');
+ ->with('QUERY', [], []);
$this->class->read('admin', 1, 4);
}
diff --git a/tests/Unit/Db/FolderMapperTest.php b/tests/Unit/Db/FolderMapperTest.php
index db43f64e1c..19e3f63d4e 100644
--- a/tests/Unit/Db/FolderMapperTest.php
+++ b/tests/Unit/Db/FolderMapperTest.php
@@ -120,15 +120,25 @@ public function testFindFromUser()
->with('user_id = :user_id')
->will($this->returnSelf());
+ $andWhereCalls = [['id = :id'], ['deleted_at = 0']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['id = :id'], ['deleted_at = 0'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [['user_id', 'jack', null], ['id', 1, null]];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'], ['id', 1])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -169,15 +179,25 @@ public function testFindFromUserEmpty()
->with('user_id = :user_id')
->will($this->returnSelf());
+ $andWhereCalls = [['id = :id'], ['deleted_at = 0']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['id = :id'], ['deleted_at = 0'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [['user_id', 'jack', null], ['id', 1, null]];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'], ['id', 1])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -218,15 +238,25 @@ public function testFindFromUserDuplicate()
->with('user_id = :user_id')
->will($this->returnSelf());
+ $andWhereCalls = [['id = :id'], ['deleted_at = 0']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['id = :id'], ['deleted_at = 0'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [['user_id', 'jack', null], ['id', 1, null]];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'], ['id', 1])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -311,15 +341,25 @@ public function testRead()
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.folder_id = :folderId']];
+ $andWhereIndex = 0;
+
$selectbuilder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['feeds.user_id = :userId'], ['feeds.folder_id = :folderId'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex, $selectbuilder) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $selectbuilder;
+ });
+
+ $setParameterCalls = [['userId', 'admin', null], ['folderId', 1, null]];
+ $setParameterIndex = 0;
$selectbuilder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['userId', 'admin'], ['folderId', 1])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex, $selectbuilder) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $selectbuilder;
+ });
$selectbuilder->expects($this->exactly(1))
->method('getSQL')
@@ -351,20 +391,41 @@ public function testRead()
->with('news_items')
->will($this->returnSelf());
+ $setCalls = [['unread', 'unread'], ['last_modified', 'last_modified']];
+ $setIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('set')
- ->withConsecutive(['unread', 'unread'], ['last_modified', 'last_modified'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setCalls, &$setIndex) {
+ $this->assertEquals($setCalls[$setIndex++], $args);
+ return $this->builder;
+ });
+
+ $andWhereCalls2 = [['id IN (:idList)'], ['unread != :unread']];
+ $andWhereIndex2 = 0;
$this->builder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['id IN (:idList)'], ['unread != :unread'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls2, &$andWhereIndex2) {
+ $this->assertEquals($andWhereCalls2[$andWhereIndex2++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls2 = [['unread', false, 'boolean'], ['idList', [1, 2], 101]];
+ $setParameterIndex2 = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['unread', false], ['idList', [1, 2]], ['last_modified'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls2, &$setParameterIndex2) {
+ if ($setParameterIndex2 < count($setParameterCalls2)) {
+ $this->assertEquals($setParameterCalls2[$setParameterIndex2++], $args);
+ } else {
+ // last_modified with dynamic timestamp - just check it's called
+ $this->assertEquals('last_modified', $args[0]);
+ $setParameterIndex2++;
+ }
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('getSQL')
@@ -414,15 +475,25 @@ public function testReadWithMaxId()
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.folder_id = :folderId'], ['items.id <= :maxItemId']];
+ $andWhereIndex = 0;
+
$selectbuilder->expects($this->exactly(3))
->method('andWhere')
- ->withConsecutive(['feeds.user_id = :userId'], ['feeds.folder_id = :folderId'], ['items.id <= :maxItemId'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex, $selectbuilder) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $selectbuilder;
+ });
+
+ $setParameterCalls = [['userId', 'admin', null], ['folderId', 1, null], ['maxItemId', 4, null]];
+ $setParameterIndex = 0;
$selectbuilder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'admin'], ['folderId', 1], ['maxItemId', 4])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex, $selectbuilder) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $selectbuilder;
+ });
$selectbuilder->expects($this->exactly(1))
->method('getSQL')
@@ -454,20 +525,41 @@ public function testReadWithMaxId()
->with('news_items')
->will($this->returnSelf());
+ $setCalls = [['unread', 'unread'], ['last_modified', 'last_modified']];
+ $setIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('set')
- ->withConsecutive(['unread', 'unread'], ['last_modified', 'last_modified'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setCalls, &$setIndex) {
+ $this->assertEquals($setCalls[$setIndex++], $args);
+ return $this->builder;
+ });
+
+ $andWhereCalls2 = [['id IN (:idList)'], ['unread != :unread']];
+ $andWhereIndex2 = 0;
$this->builder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['id IN (:idList)'], ['unread != :unread'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls2, &$andWhereIndex2) {
+ $this->assertEquals($andWhereCalls2[$andWhereIndex2++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls2 = [['unread', false, 'boolean'], ['idList', [1, 2], 101]];
+ $setParameterIndex2 = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['unread', false], ['idList', [1, 2]], ['last_modified'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls2, &$setParameterIndex2) {
+ if ($setParameterIndex2 < count($setParameterCalls2)) {
+ $this->assertEquals($setParameterCalls2[$setParameterIndex2++], $args);
+ } else {
+ // last_modified with dynamic timestamp - just check it's called
+ $this->assertEquals('last_modified', $args[0]);
+ $setParameterIndex2++;
+ }
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('getSQL')
diff --git a/tests/Unit/Db/ItemMapperAfterTest.php b/tests/Unit/Db/ItemMapperAfterTest.php
index 4b17518c1d..c2752de152 100644
--- a/tests/Unit/Db/ItemMapperAfterTest.php
+++ b/tests/Unit/Db/ItemMapperAfterTest.php
@@ -62,15 +62,20 @@ public function testFindAllInFeedAfter()
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [
+ ['items.last_modified >= :updatedSince'],
+ ['feeds.user_id = :userId'],
+ ['feeds.id = :feedId'],
+ ['feeds.deleted_at = 0']
+ ];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['items.last_modified >= :updatedSince'],
- ['feeds.user_id = :userId'],
- ['feeds.id = :feedId'],
- ['feeds.deleted_at = 0']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setParameters')
@@ -127,16 +132,21 @@ public function testFindAllInFeedAfterHideRead()
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [
+ ['items.last_modified >= :updatedSince'],
+ ['feeds.user_id = :userId'],
+ ['feeds.id = :feedId'],
+ ['feeds.deleted_at = 0'],
+ ['items.unread = :unread']
+ ];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(5))
->method('andWhere')
- ->withConsecutive(
- ['items.last_modified >= :updatedSince'],
- ['feeds.user_id = :userId'],
- ['feeds.id = :feedId'],
- ['feeds.deleted_at = 0'],
- ['items.unread = :unread']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setParameters')
@@ -193,23 +203,33 @@ public function testFindAllInFolderAfter()
->with('news_items', 'items')
->will($this->returnSelf());
+ $innerJoinCalls = [
+ ['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'],
+ ['feeds', 'news_folders', 'folders', 'feeds.folder_id = folders.id']
+ ];
+ $innerJoinIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('innerJoin')
- ->withConsecutive(
- ['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'],
- ['feeds', 'news_folders', 'folders', 'feeds.folder_id = folders.id']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$innerJoinCalls, &$innerJoinIndex) {
+ $this->assertEquals($innerJoinCalls[$innerJoinIndex++], $args);
+ return $this->builder;
+ });
+
+ $andWhereCalls = [
+ ['items.last_modified >= :updatedSince'],
+ ['feeds.user_id = :userId'],
+ ['feeds.deleted_at = 0'],
+ ['folders.id = :folderId']
+ ];
+ $andWhereIndex = 0;
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['items.last_modified >= :updatedSince'],
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['folders.id = :folderId']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setParameters')
@@ -261,24 +281,34 @@ public function testFindAllInFolderAfterHideRead()
->with('news_items', 'items')
->will($this->returnSelf());
+ $innerJoinCalls = [
+ ['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'],
+ ['feeds', 'news_folders', 'folders', 'feeds.folder_id = folders.id']
+ ];
+ $innerJoinIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('innerJoin')
- ->withConsecutive(
- ['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'],
- ['feeds', 'news_folders', 'folders', 'feeds.folder_id = folders.id']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$innerJoinCalls, &$innerJoinIndex) {
+ $this->assertEquals($innerJoinCalls[$innerJoinIndex++], $args);
+ return $this->builder;
+ });
+
+ $andWhereCalls = [
+ ['items.last_modified >= :updatedSince'],
+ ['feeds.user_id = :userId'],
+ ['feeds.deleted_at = 0'],
+ ['folders.id = :folderId'],
+ ['items.unread = :unread']
+ ];
+ $andWhereIndex = 0;
$this->builder->expects($this->exactly(5))
->method('andWhere')
- ->withConsecutive(
- ['items.last_modified >= :updatedSince'],
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['folders.id = :folderId'],
- ['items.unread = :unread']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setParameters')
@@ -337,18 +367,23 @@ public function testFindAllAfterUnread()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [
+ ['items.last_modified >= :updatedSince'],
+ ['feeds.deleted_at = 0'],
+ ['feeds.user_id = :userId'],
+ ['items.unread = :unread']
+ ];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['items.last_modified >= :updatedSince'],
- ['feeds.deleted_at = 0'],
- ['feeds.user_id = :userId'],
- ['items.unread = :unread']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setParameters')
@@ -406,18 +441,23 @@ public function testFindAllAfterStarred()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [
+ ['items.last_modified >= :updatedSince'],
+ ['feeds.deleted_at = 0'],
+ ['feeds.user_id = :userId'],
+ ['items.starred = :starred']
+ ];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['items.last_modified >= :updatedSince'],
- ['feeds.deleted_at = 0'],
- ['feeds.user_id = :userId'],
- ['items.starred = :starred']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setParameters')
@@ -475,17 +515,22 @@ public function testFindAllAfterAll()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [
+ ['items.last_modified >= :updatedSince'],
+ ['feeds.deleted_at = 0'],
+ ['feeds.user_id = :userId']
+ ];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(3))
->method('andWhere')
- ->withConsecutive(
- ['items.last_modified >= :updatedSince'],
- ['feeds.deleted_at = 0'],
- ['feeds.user_id = :userId']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setParameters')
@@ -541,17 +586,22 @@ public function testFindAllAfterInvalid()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [
+ ['items.last_modified >= :updatedSince'],
+ ['feeds.deleted_at = 0'],
+ ['feeds.user_id = :userId']
+ ];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(3))
->method('andWhere')
- ->withConsecutive(
- ['items.last_modified >= :updatedSince'],
- ['feeds.deleted_at = 0'],
- ['feeds.user_id = :userId']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setParameters')
diff --git a/tests/Unit/Db/ItemMapperPaginatedTest.php b/tests/Unit/Db/ItemMapperPaginatedTest.php
index 5e331fbfdc..ca783a5d3d 100644
--- a/tests/Unit/Db/ItemMapperPaginatedTest.php
+++ b/tests/Unit/Db/ItemMapperPaginatedTest.php
@@ -64,21 +64,34 @@ public function testFindAllItemsInvalid()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], []]; // 3rd call - any args (before exception)
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(3))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ if ($andWhereIndex < count($andWhereCalls) - 1) { // Check only first 2 calls
+ $this->assertEquals($andWhereCalls[$andWhereIndex], $args);
+ }
+ $andWhereIndex++;
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['offset', 10, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['offset', 10])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
@@ -129,22 +142,31 @@ public function testFindAllItemsFullInverted()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['items.id > :offset']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(3))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['items.id > :offset']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['offset', 10, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['offset', 10])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
@@ -196,23 +218,32 @@ public function testFindAllItemsUnread()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['items.id < :offset'], ['items.unread = :unread']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['items.id < :offset'],
- ['items.unread = :unread']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['offset', 10, null],
+ ['unread', true, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['offset', 10], ['unread', true])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setMaxResults')
@@ -267,23 +298,32 @@ public function testFindAllItemsUnreadNoLimit()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['items.id < :offset'], ['items.unread = :unread']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['items.id < :offset'],
- ['items.unread = :unread']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['offset', 10, null],
+ ['unread', true, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['offset', 10], ['unread', true])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->never())
->method('setMaxResults');
@@ -336,23 +376,32 @@ public function testFindAllItemsStarred()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['items.id < :offset'], ['items.starred = :starred']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['items.id < :offset'],
- ['items.starred = :starred']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['offset', 10, null],
+ ['starred', true, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['offset', 10], ['starred', true])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
@@ -411,31 +460,28 @@ public function testFindAllItemsStarredSearch()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['items.id < :offset'], ['items.search_index LIKE :term0'], ['items.search_index LIKE :term1'], ['items.starred = :starred']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(6))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['items.id < :offset'],
- ['items.search_index LIKE :term0'],
- ['items.search_index LIKE :term1'],
- ['items.starred = :starred']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [['userId', 'jack', null], ['offset', 10, null], ['term0', '%key%', null], ['term1', '%word%', null], ['starred', true, null]];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(5))
->method('setParameter')
- ->withConsecutive(
- ['userId', 'jack'],
- ['offset', 10],
- ['term0', '%key%'],
- ['term1', '%word%'],
- ['starred', true]
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
@@ -492,23 +538,32 @@ public function testFindAllFeed()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.deleted_at = 0'], ['feeds.user_id = :userId'], ['items.feed_id = :feedId'], ['items.id < :offset']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['feeds.deleted_at = 0'],
- ['feeds.user_id = :userId'],
- ['items.feed_id = :feedId'],
- ['items.id < :offset']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['feedId', 2, null],
+ ['offset', 10, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['feedId', 2], ['offset', 10])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
@@ -565,23 +620,32 @@ public function testFindAllFeedNoLimit()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.deleted_at = 0'], ['feeds.user_id = :userId'], ['items.feed_id = :feedId'], ['items.id < :offset']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['feeds.deleted_at = 0'],
- ['feeds.user_id = :userId'],
- ['items.feed_id = :feedId'],
- ['items.id < :offset']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['feedId', 2, null],
+ ['offset', 10, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['feedId', 2], ['offset', 10])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->never())
@@ -636,23 +700,32 @@ public function testFindAllFeedInverted()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.deleted_at = 0'], ['feeds.user_id = :userId'], ['items.feed_id = :feedId'], ['items.id > :offset']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['feeds.deleted_at = 0'],
- ['feeds.user_id = :userId'],
- ['items.feed_id = :feedId'],
- ['items.id > :offset']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['feedId', 2, null],
+ ['offset', 10, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['feedId', 2], ['offset', 10])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setMaxResults')
@@ -707,24 +780,33 @@ public function testFindAllFeedHideRead()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.deleted_at = 0'], ['feeds.user_id = :userId'], ['items.feed_id = :feedId'], ['items.id < :offset'], ['items.unread = :unread']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(5))
->method('andWhere')
- ->withConsecutive(
- ['feeds.deleted_at = 0'],
- ['feeds.user_id = :userId'],
- ['items.feed_id = :feedId'],
- ['items.id < :offset'],
- ['items.unread = :unread']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['feedId', 2, null],
+ ['offset', 10, null],
+ ['unread', true, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(4))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['feedId', 2], ['offset', 10], ['unread', true])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
@@ -784,31 +866,28 @@ public function testFindAllFeedSearch()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.deleted_at = 0'], ['feeds.user_id = :userId'], ['items.feed_id = :feedId'], ['items.search_index LIKE :term0'], ['items.search_index LIKE :term1'], ['items.id < :offset']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(6))
->method('andWhere')
- ->withConsecutive(
- ['feeds.deleted_at = 0'],
- ['feeds.user_id = :userId'],
- ['items.feed_id = :feedId'],
- ['items.search_index LIKE :term0'],
- ['items.search_index LIKE :term1'],
- ['items.id < :offset']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [['userId', 'jack', null], ['feedId', 2, null], ['term0', '%key%', null], ['term1', '%word%', null], ['offset', 10, null]];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(5))
->method('setParameter')
- ->withConsecutive(
- ['userId', 'jack'],
- ['feedId', 2],
- ['term0', '%key%'],
- ['term1', '%word%'],
- ['offset', 10]
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
@@ -877,23 +956,31 @@ public function testFindAllFolderIdNull()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['x IS NULL'], ['items.id < :offset']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['x IS NULL'],
- ['items.id < :offset']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['offset', 10, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['offset', 10])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
@@ -962,23 +1049,31 @@ public function testFindAllFolderIdNullNoLimit()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['x IS NULL'], ['items.id < :offset']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(4))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['x IS NULL'],
- ['items.id < :offset']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['offset', 10, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['offset', 10])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->never())
@@ -1045,24 +1140,32 @@ public function testFindAllFolderHideRead()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['x IS NULL'], ['items.id < :offset'], ['items.unread = :unread']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(5))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['x IS NULL'],
- ['items.id < :offset'],
- ['items.unread = :unread']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['offset', 10, null],
+ ['unread', true, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['offset', 10], ['unread', true])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
@@ -1131,24 +1234,32 @@ public function testFindAllFolderHideReadInvertOrder()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['x IS NULL'], ['items.id > :offset'], ['items.unread = :unread']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(5))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['x IS NULL'],
- ['items.id > :offset'],
- ['items.unread = :unread']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['offset', 10, null],
+ ['unread', true, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['offset', 10], ['unread', true])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
@@ -1220,25 +1331,33 @@ public function testFindAllFolderSearchId()
$this->builder->expects($this->exactly(1))
->method('innerJoin')
- ->withConsecutive(['items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id'])
+ ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['feeds.deleted_at = 0'], ['x = y'], ['items.search_index LIKE :term0'], ['items.search_index LIKE :term1'], ['items.id < :offset']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(6))
->method('andWhere')
- ->withConsecutive(
- ['feeds.user_id = :userId'],
- ['feeds.deleted_at = 0'],
- ['x = y'],
- ['items.search_index LIKE :term0'],
- ['items.search_index LIKE :term1'],
- ['items.id < :offset']
- )
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['userId', 'jack', null],
+ ['term0', '%key%', null],
+ ['term1', '%word%', null],
+ ['offset', 10, null]
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(4))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'], ['term0', '%key%'], ['term1', '%word%'], ['offset', 10])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
diff --git a/tests/Unit/Db/ItemMapperTest.php b/tests/Unit/Db/ItemMapperTest.php
index fc599a4588..29e43ba105 100644
--- a/tests/Unit/Db/ItemMapperTest.php
+++ b/tests/Unit/Db/ItemMapperTest.php
@@ -103,7 +103,7 @@ public function testFindAllFromUser()
$this->builder->expects($this->exactly(1))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'])
+ ->with('user_id', 'jack')
->will($this->returnSelf());
$this->builder->expects($this->once())
@@ -157,14 +157,19 @@ public function testFindAllFromUserWithParams()
->with('feeds.user_id = :user_id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.deleted_at = 0'], ['key = :val']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['feeds.deleted_at = 0'], ['key = :val'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'])
+ ->with('user_id', 'jack')
->will($this->returnSelf());
$this->builder->expects($this->once())
@@ -299,15 +304,28 @@ public function testFindFromUser()
->with('feeds.user_id = :user_id')
->will($this->returnSelf());
+ $andWhereCalls = [['items.id = :item_id'], ['feeds.deleted_at = 0']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['items.id = :item_id'], ['feeds.deleted_at = 0'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['user_id', 'jack', 2], // PDO::PARAM_STR
+ ['item_id', 4, 1] // PDO::PARAM_INT
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'], ['item_id', 4])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -340,15 +358,28 @@ public function testFindByGUIDHash()
->with('news_items')
->will($this->returnSelf());
+ $andWhereCalls = [['feed_id = :feed_id'], ['guid_hash = :guid_hash']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['feed_id = :feed_id'], ['guid_hash = :guid_hash'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['feed_id', 4, 1], // PDO::PARAM_INT
+ ['guid_hash', 'hash', 2] // PDO::PARAM_STR
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['feed_id', 4], ['guid_hash', 'hash'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -386,15 +417,29 @@ public function testFindForUserByGUIDHash()
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :user_id'], ['feeds.id = :feed_id'], ['items.guid_hash = :guid_hash']];
+ $andWhereIndex = 0;
+
$this->builder->expects($this->exactly(3))
->method('andWhere')
- ->withConsecutive(['feeds.user_id = :user_id'], ['feeds.id = :feed_id'], ['items.guid_hash = :guid_hash'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $this->builder;
+ });
+
+ $setParameterCalls = [
+ ['user_id', 'jack', 2], // PDO::PARAM_STR
+ ['feed_id', 4, 1], // PDO::PARAM_INT
+ ['guid_hash', 'hash', 2] // PDO::PARAM_STR
+ ];
+ $setParameterIndex = 0;
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'], ['feed_id', 4], ['guid_hash', 'hash'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->once())
->method('executeQuery')
@@ -444,12 +489,12 @@ public function testNewest()
$this->builder->expects($this->exactly(1))
->method('where')
- ->withConsecutive(['feeds.user_id = :userId'])
+ ->with('feeds.user_id = :userId')
->will($this->returnSelf());
$this->builder->expects($this->exactly(1))
->method('setParameter')
- ->withConsecutive(['userId', 'jack'])
+ ->with('userId', 'jack')
->will($this->returnSelf());
$this->builder->expects($this->exactly(1))
@@ -497,15 +542,25 @@ public function testReadAll()
->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id')
->will($this->returnSelf());
+ $andWhereCalls = [['feeds.user_id = :userId'], ['items.id <= :maxItemId'], ['items.unread = :unread']];
+ $andWhereIndex = 0;
+
$selectbuilder->expects($this->exactly(3))
->method('andWhere')
- ->withConsecutive(['feeds.user_id = :userId'], ['items.id <= :maxItemId'], ['items.unread = :unread'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex, $selectbuilder) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $selectbuilder;
+ });
+
+ $setParameterCalls = [['userId', 'admin', null], ['maxItemId', 4, null], ['unread', true, 'boolean']];
+ $setParameterIndex = 0;
$selectbuilder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['userId', 'admin'], ['maxItemId', 4], ['unread', true])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex, $selectbuilder) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex++], $args);
+ return $selectbuilder;
+ });
$selectbuilder->expects($this->exactly(1))
->method('getSQL')
@@ -537,20 +592,36 @@ public function testReadAll()
->with('news_items')
->will($this->returnSelf());
+ $setCalls = [['unread', 'unread'], ['last_modified', 'last_modified']];
+ $setIndex = 0;
+
$this->builder->expects($this->exactly(2))
->method('set')
- ->withConsecutive(['unread', 'unread'], ['last_modified', 'last_modified'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setCalls, &$setIndex) {
+ $this->assertEquals($setCalls[$setIndex++], $args);
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('andWhere')
- ->withConsecutive(['id IN (:idList)'])
+ ->with('id IN (:idList)')
->will($this->returnSelf());
+ $setParameterCalls2 = [['idList', [1, 2], 101], ['unread', false, 'boolean']];
+ $setParameterIndex2 = 0;
+
$this->builder->expects($this->exactly(3))
->method('setParameter')
- ->withConsecutive(['idList', [1, 2]], ['unread', false], ['last_modified'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls2, &$setParameterIndex2) {
+ if ($setParameterIndex2 < count($setParameterCalls2)) {
+ $this->assertEquals($setParameterCalls2[$setParameterIndex2++], $args);
+ } else {
+ // last_modified with dynamic timestamp - just check it's called
+ $this->assertEquals('last_modified', $args[0]);
+ $setParameterIndex2++;
+ }
+ return $this->builder;
+ });
$this->builder->expects($this->exactly(1))
->method('getSQL')
@@ -715,14 +786,20 @@ public function testDeleteOverThresholdSuccess()
->method('getSQL')
->willReturn('FEED_SQL');
+ $executeQueryCalls = [
+ ['FEED_SQL', [], []], // executeQuery gets default empty arrays for params and types
+ ['RANGE_SQL', ['feedId' => 5], []],
+ ['RANGE_SQL', ['feedId' => 1], []]
+ ];
+ $executeQueryReturns = [$result1, $result2, $result3];
+ $executeQueryIndex = 0;
+
$this->db->expects($this->exactly(3))
->method('executeQuery')
- ->withConsecutive(
- ['FEED_SQL'],
- ['RANGE_SQL', ['feedId' => 5], []],
- ['RANGE_SQL', ['feedId' => 1], []]
- )
- ->willReturnOnConsecutiveCalls($result1, $result2, $result3);
+ ->willReturnCallback(function (...$args) use (&$executeQueryCalls, &$executeQueryReturns, &$executeQueryIndex) {
+ $this->assertEquals($executeQueryCalls[$executeQueryIndex], $args);
+ return $executeQueryReturns[$executeQueryIndex++];
+ });
$result1->expects($this->once())
->method('fetchAll')
@@ -873,14 +950,20 @@ public function testDeleteOverThresholdSuccessUnread()
->method('getSQL')
->willReturn('FEED_SQL');
+ $executeQueryCalls = [
+ ['FEED_SQL', [], []], // executeQuery gets default empty arrays for params and types
+ ['RANGE_SQL', ['feedId' => 5], []],
+ ['RANGE_SQL', ['feedId' => 1], []]
+ ];
+ $executeQueryReturns = [$result1, $result2, $result3];
+ $executeQueryIndex = 0;
+
$this->db->expects($this->exactly(3))
->method('executeQuery')
- ->withConsecutive(
- ['FEED_SQL'],
- ['RANGE_SQL', ['feedId' => 5], []],
- ['RANGE_SQL', ['feedId' => 1], []]
- )
- ->willReturnOnConsecutiveCalls($result1, $result2, $result3);
+ ->willReturnCallback(function (...$args) use (&$executeQueryCalls, &$executeQueryReturns, &$executeQueryIndex) {
+ $this->assertEquals($executeQueryCalls[$executeQueryIndex], $args);
+ return $executeQueryReturns[$executeQueryIndex++];
+ });
$result1->expects($this->once())
->method('fetchAll')
@@ -905,10 +988,18 @@ public function testDeleteOverThresholdSuccessUnread()
->with('feed_id = :feedId')
->willReturnSelf();
+ $andWhereCalls = [['starred = false'], ['unread = false']];
+ $andWhereCalls = [['starred = false'], ['unread = false']];
+ $andWhereIndex = 0;
+
$builder2->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['starred = false'], ['unread = false'])
- ->willReturnSelf();
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex, $builder2) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $builder2;
+ });
+ $andWhereCalls = [['starred = false'], ['unread = false']];
+ $andWhereCalls = [['starred = false'], ['unread = false']];
$builder2->expects($this->never())
->method('orderBy')
@@ -1031,13 +1122,19 @@ public function testDeleteOverThresholdSuccessUnreadSkipsIfUnderThreshold()
->method('getSQL')
->willReturn('FEED_SQL');
+ $executeQueryCalls = [
+ ['FEED_SQL', [], []], // executeQuery gets default empty arrays for params and types
+ ['RANGE_SQL', ['feedId' => 5], []]
+ ];
+ $executeQueryReturns = [$result1, $result2, $result3];
+ $executeQueryIndex = 0;
+
$this->db->expects($this->exactly(2))
->method('executeQuery')
- ->withConsecutive(
- ['FEED_SQL'],
- ['RANGE_SQL', ['feedId' => 5], []]
- )
- ->willReturnOnConsecutiveCalls($result1, $result2, $result3);
+ ->willReturnCallback(function (...$args) use (&$executeQueryCalls, &$executeQueryReturns, &$executeQueryIndex) {
+ $this->assertEquals($executeQueryCalls[$executeQueryIndex], $args);
+ return $executeQueryReturns[$executeQueryIndex++];
+ });
$result1->expects($this->once())
->method('fetchAll')
@@ -1062,10 +1159,15 @@ public function testDeleteOverThresholdSuccessUnreadSkipsIfUnderThreshold()
->with('feed_id = :feedId')
->willReturnSelf();
+ $andWhereCalls = [['starred = false'], ['unread = false']];
+ $andWhereIndex = 0;
+
$builder2->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['starred = false'], ['unread = false'])
- ->willReturnSelf();
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex, $builder2) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex++], $args);
+ return $builder2;
+ });
$builder2->expects($this->never())
->method('orderBy')
diff --git a/tests/Unit/Db/NewsMapperTest.php b/tests/Unit/Db/NewsMapperTest.php
index 66e27b99f7..03a64d2765 100644
--- a/tests/Unit/Db/NewsMapperTest.php
+++ b/tests/Unit/Db/NewsMapperTest.php
@@ -192,10 +192,16 @@ public function testPurgeUser()
->with('NAME')
->will($this->returnSelf());
+ $andWhereCalls = [['deleted_at != 0'], ['user_id = :user_id']];
+ $andWhereIndex = 0;
+
$qb->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['deleted_at != 0'], ['user_id = :user_id'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex, $qb) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex], $args);
+ $andWhereIndex++;
+ return $qb;
+ });
$qb->expects($this->once())
->method('setParameter')
@@ -225,10 +231,16 @@ public function testPurgeTime()
->with('NAME')
->will($this->returnSelf());
+ $andWhereCalls = [['deleted_at != 0'], ['deleted_at < :deleted_at']];
+ $andWhereIndex = 0;
+
$qb->expects($this->exactly(2))
->method('andWhere')
- ->withConsecutive(['deleted_at != 0'], ['deleted_at < :deleted_at'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex, $qb) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex], $args);
+ $andWhereIndex++;
+ return $qb;
+ });
$qb->expects($this->once())
->method('setParameter')
@@ -258,15 +270,27 @@ public function testPurgeBoth()
->with('NAME')
->will($this->returnSelf());
+ $andWhereCalls = [['deleted_at != 0'], ['user_id = :user_id'], ['deleted_at < :deleted_at']];
+ $andWhereIndex = 0;
+
$qb->expects($this->exactly(3))
->method('andWhere')
- ->withConsecutive(['deleted_at != 0'], ['user_id = :user_id'], ['deleted_at < :deleted_at'])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$andWhereCalls, &$andWhereIndex, $qb) {
+ $this->assertEquals($andWhereCalls[$andWhereIndex], $args);
+ $andWhereIndex++;
+ return $qb;
+ });
+
+ $setParameterCalls = [['user_id', 'jack', null], ['deleted_at', 1, null]];
+ $setParameterIndex = 0;
$qb->expects($this->exactly(2))
->method('setParameter')
- ->withConsecutive(['user_id', 'jack'], ['deleted_at', 1])
- ->will($this->returnSelf());
+ ->willReturnCallback(function (...$args) use (&$setParameterCalls, &$setParameterIndex, $qb) {
+ $this->assertEquals($setParameterCalls[$setParameterIndex], $args);
+ $setParameterIndex++;
+ return $qb;
+ });
$qb->expects($this->once())
->method('executeStatement');
diff --git a/tests/Unit/Service/FeedServiceTest.php b/tests/Unit/Service/FeedServiceTest.php
index 786dad4d4b..14f35dbb86 100644
--- a/tests/Unit/Service/FeedServiceTest.php
+++ b/tests/Unit/Service/FeedServiceTest.php
@@ -336,13 +336,24 @@ public function testCreateDiscovers()
->method('discover')
->with($url)
->will($this->returnValue(['http://discover.test']));
+
+ $expectedCalls = [
+ ['http://test', false, 'user', 'pass', null],
+ ['http://discover.test', false, 'user', 'pass', null]
+ ];
+ $callIndex = 0;
+
$this->fetcher->expects($this->exactly(2))
->method('fetch')
- ->withConsecutive(
- ['http://test'],
- ['http://discover.test']
- )
- ->willReturnOnConsecutiveCalls($this->throwException(new ReadErrorException('There is no feed')), $this->returnValue($return));
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$callIndex, $return) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ if ($callIndex === 0) {
+ $callIndex++;
+ throw new ReadErrorException('There is no feed');
+ }
+ $callIndex++;
+ return $return;
+ });
$this->mapper->expects($this->once())
->method('insert')
@@ -611,15 +622,27 @@ public function testFetchSucceedsFullItems()
->with($feed)
->will($this->returnValue($feed));
+ $purifyCalls = [['2'], ['1']];
+ $purifyIndex = 0;
+
$this->purifier->expects($this->exactly(2))
->method('purify')
- ->withConsecutive(['2'], ['1'])
- ->will($this->returnArgument(0));
+ ->willReturnCallback(function (...$args) use (&$purifyCalls, &$purifyIndex) {
+ $this->assertEquals($purifyCalls[$purifyIndex], $args);
+ $purifyIndex++;
+ return $args[0]; // returnArgument(0)
+ });
+
+ $insertOrUpdateCalls = [[$item2], [$item1]];
+ $insertOrUpdateIndex = 0;
$this->itemService->expects($this->exactly(2))
->method('insertOrUpdate')
- ->withConsecutive([$item2], [$item1])
- ->will($this->returnValue($feed));
+ ->willReturnCallback(function (...$args) use (&$insertOrUpdateCalls, &$insertOrUpdateIndex, $feed) {
+ $this->assertEquals($insertOrUpdateCalls[$insertOrUpdateIndex], $args);
+ $insertOrUpdateIndex++;
+ return $feed;
+ });
$this->assertSame($feed, $this->class->fetch($feed));
$this->assertEquals(2, $feed->getUnreadCount());
@@ -825,10 +848,16 @@ public function testFindAllFromUserRecursive()
->with($this->uid)
->will($this->returnValue([$feed1, $feed2]));
+ $findAllInFeedCalls = [['jack', 1], ['jack', 2]];
+ $findAllInFeedIndex = 0;
+
$this->itemService->expects($this->exactly(2))
->method('findAllInFeed')
- ->withConsecutive(['jack', 1], ['jack', 2])
- ->willReturn(['a']);
+ ->willReturnCallback(function (...$args) use (&$findAllInFeedCalls, &$findAllInFeedIndex) {
+ $this->assertEquals($findAllInFeedCalls[$findAllInFeedIndex], $args);
+ $findAllInFeedIndex++;
+ return ['a'];
+ });
$feeds = $this->class->findAllForUserRecursive($this->uid);
$this->assertEquals(['a'], $feeds[0]->items);
@@ -847,7 +876,7 @@ public function testRead()
$this->mapper->expects($this->exactly(1))
->method('read')
- ->withConsecutive(['jack', 1, null]);
+ ->with('jack', 1, null);
$this->class->read($this->uid, 1);
}
diff --git a/tests/Unit/Service/FolderServiceTest.php b/tests/Unit/Service/FolderServiceTest.php
index 6701d0be93..09f75f3bf9 100644
--- a/tests/Unit/Service/FolderServiceTest.php
+++ b/tests/Unit/Service/FolderServiceTest.php
@@ -282,7 +282,7 @@ public function testRead()
$this->mapper->expects($this->exactly(1))
->method('read')
- ->withConsecutive(['jack', 1, null]);
+ ->with('jack', 1, null);
$this->class->read('jack', 1);
}
diff --git a/tests/Unit/Service/ImportServiceTest.php b/tests/Unit/Service/ImportServiceTest.php
index 9015be2f5f..fb14118d17 100644
--- a/tests/Unit/Service/ImportServiceTest.php
+++ b/tests/Unit/Service/ImportServiceTest.php
@@ -204,7 +204,7 @@ function () use ($insertFeed) {
$this->itemService->expects($this->exactly(2))
->method('insertOrUpdate')
- ->withConsecutive([$item]);
+ ->with($item);
$this->purifier->expects($this->exactly(2))
->method('purify')
->with($this->equalTo($item->getBody()))
diff --git a/tests/Unit/Service/ServiceTest.php b/tests/Unit/Service/ServiceTest.php
index b9eda74506..e34bb68594 100644
--- a/tests/Unit/Service/ServiceTest.php
+++ b/tests/Unit/Service/ServiceTest.php
@@ -127,9 +127,19 @@ public function testDeleteUser()
->with('')
->willReturn([$feed1, $feed2]);
+ $expectedCalls = [
+ [$feed1],
+ [$feed2]
+ ];
+ $returns = [$feed1, $feed2]; // delete() returns the deleted entity
+ $callIndex = 0;
+
$this->mapper->expects($this->exactly(2))
->method('delete')
- ->withConsecutive([$feed1], [$feed2]);
+ ->willReturnCallback(function (...$args) use (&$expectedCalls, &$returns, &$callIndex) {
+ $this->assertEquals($expectedCalls[$callIndex], $args);
+ return $returns[$callIndex++];
+ });
$this->class->deleteUser('');
}
diff --git a/tests/Unit/Service/StatusServiceTest.php b/tests/Unit/Service/StatusServiceTest.php
index 1101f041f0..718d10851f 100644
--- a/tests/Unit/Service/StatusServiceTest.php
+++ b/tests/Unit/Service/StatusServiceTest.php
@@ -89,26 +89,24 @@ public function testGetStatus()
public function testGetStatusNoCorrectCronAjax()
{
+ $getValueStringCalls = [
+ ['news', 'installed_version', '', false],
+ ['core', 'backgroundjobs_mode', '', false],
+ ];
+ $getValueStringReturns = ['1.0', 'ajax'];
+ $getValueStringIndex = 0;
+
$this->settings->expects($this->exactly(2))
->method('getValueString')
- ->withConsecutive(
- ['news', 'installed_version'],
- ['core', 'backgroundjobs_mode'],
- )
- ->will($this->returnValueMap([
- ['news', 'installed_version', '', false, '1.0'],
- ['core', 'backgroundjobs_mode', '', false, 'ajax'],
- ]));
-
+ ->willReturnCallback(function (...$args) use (&$getValueStringCalls, &$getValueStringReturns, &$getValueStringIndex) {
+ $this->assertEquals($getValueStringCalls[$getValueStringIndex], $args);
+ return $getValueStringReturns[$getValueStringIndex++];
+ });
$this->settings->expects($this->exactly(1))
->method('getValueBool')
- ->withConsecutive(
- ['news', 'useCronUpdates']
- )
- ->will($this->returnValueMap([
- ['news', 'useCronUpdates', true, false, true],
- ]));
+ ->with('news', 'useCronUpdates')
+ ->willReturn(true);
$this->connection->expects($this->exactly(1))
->method('supports4ByteText')
@@ -156,26 +154,24 @@ public function testGetStatusNoCorrectCronTurnedOff()
public function testGetStatusReportsNon4ByteText()
{
+ $getValueStringCalls = [
+ ['news', 'installed_version', '', false],
+ ['core', 'backgroundjobs_mode', '', false],
+ ];
+ $getValueStringReturns = ['1.0', 'cron'];
+ $getValueStringIndex = 0;
+
$this->settings->expects($this->exactly(2))
->method('getValueString')
- ->withConsecutive(
- ['news', 'installed_version'],
- ['core', 'backgroundjobs_mode'],
- )
- ->will($this->returnValueMap([
- ['news', 'installed_version', '', false, '1.0'],
- ['core', 'backgroundjobs_mode', '', false, 'cron'],
- ]));
-
+ ->willReturnCallback(function (...$args) use (&$getValueStringCalls, &$getValueStringReturns, &$getValueStringIndex) {
+ $this->assertEquals($getValueStringCalls[$getValueStringIndex], $args);
+ return $getValueStringReturns[$getValueStringIndex++];
+ });
$this->settings->expects($this->exactly(1))
->method('getValueBool')
- ->withConsecutive(
- ['news', 'useCronUpdates']
- )
- ->will($this->returnValueMap([
- ['news', 'useCronUpdates', true, false, true],
- ]));
+ ->with('news', 'useCronUpdates')
+ ->willReturn(true);
$this->connection->expects($this->exactly(1))
->method('supports4ByteText')
@@ -196,22 +192,13 @@ public function testIsProperlyConfiguredNone()
{
$this->settings->expects($this->exactly(1))
->method('getValueString')
- ->withConsecutive(
- ['core', 'backgroundjobs_mode'],
- )
- ->will($this->returnValueMap([
- ['core', 'backgroundjobs_mode', '', false, 'ajax'],
- ]));
-
+ ->with('core', 'backgroundjobs_mode')
+ ->willReturn('ajax');
$this->settings->expects($this->exactly(1))
->method('getValueBool')
- ->withConsecutive(
- ['news', 'useCronUpdates']
- )
- ->will($this->returnValueMap([
- ['news', 'useCronUpdates', true, false, true],
- ]));
+ ->with('news', 'useCronUpdates')
+ ->willReturn(true);
$response = $this->service->isCronProperlyConfigured();
$this->assertFalse($response);
@@ -221,22 +208,13 @@ public function testIsProperlyConfiguredModeCronNoSystem()
{
$this->settings->expects($this->exactly(1))
->method('getValueString')
- ->withConsecutive(
- ['core', 'backgroundjobs_mode'],
- )
- ->will($this->returnValueMap([
- ['core', 'backgroundjobs_mode', '', false, 'cron'],
- ]));
-
+ ->with('core', 'backgroundjobs_mode')
+ ->willReturn('cron');
$this->settings->expects($this->exactly(1))
->method('getValueBool')
- ->withConsecutive(
- ['news', 'useCronUpdates']
- )
- ->will($this->returnValueMap([
- ['news', 'useCronUpdates', true, false, true],
- ]));
+ ->with('news', 'useCronUpdates')
+ ->willReturn(true);
$response = $this->service->isCronProperlyConfigured();
$this->assertTrue($response);
@@ -246,22 +224,13 @@ public function testIsProperlyConfiguredModeCron()
{
$this->settings->expects($this->exactly(1))
->method('getValueString')
- ->withConsecutive(
- ['core', 'backgroundjobs_mode'],
- )
- ->will($this->returnValueMap([
- ['core', 'backgroundjobs_mode', '', false, 'cron'],
- ]));
-
+ ->with('core', 'backgroundjobs_mode')
+ ->willReturn('cron');
$this->settings->expects($this->exactly(1))
->method('getValueBool')
- ->withConsecutive(
- ['news', 'useCronUpdates']
- )
- ->will($this->returnValueMap([
- ['news', 'useCronUpdates', true, false, true],
- ]));
+ ->with('news', 'useCronUpdates')
+ ->willReturn(true);
$response = $this->service->isCronProperlyConfigured();
$this->assertTrue($response);