Skip to content

Commit a801d52

Browse files
minor #49621 [Tests] Remove occurrences of withConsecutive() (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Tests] Remove occurrences of `withConsecutive()` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - `withConsecutive()` has been deprecated in PHPUnit 9.6 and removed in PHP 10 (sebastianbergmann/phpunit#4564). This PR aims at starting the work to remove these occurrences. There is unfortunately no given migration path, and this requires manual work. I'll create a meta issue referencing remaining occurrences if this one's merged, to keep track. Some seems pretty hard to remove. cc `@OskarStark` this might interest you, as we worked a lot on tests lately 😄 Commits ------- 2047763649 [Tests] Remove occurrences of `withConsecutive()`
2 parents 2363f8e + e41d909 commit a801d52

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,15 @@ public function toArray(): array
123123
$ldap = $this->createMock(LdapInterface::class);
124124
$ldap
125125
->method('bind')
126-
->withConsecutive(
127-
['elsa', 'test1234A$']
128-
);
126+
->willReturnCallback(function (...$args) {
127+
static $series = [
128+
['elsa', 'test1234A$'],
129+
['', 'bar'],
130+
];
131+
132+
$this->assertSame(array_shift($series), $args);
133+
})
134+
;
129135
$ldap
130136
->expects($this->once())
131137
->method('escape')
@@ -169,9 +175,15 @@ public function toArray(): array
169175
$ldap = $this->createMock(LdapInterface::class);
170176
$ldap
171177
->method('bind')
172-
->withConsecutive(
173-
['elsa', 'test1234A$']
174-
);
178+
->willReturnCallback(function (...$args) {
179+
static $series = [
180+
['elsa', 'test1234A$'],
181+
['', 'bar'],
182+
];
183+
184+
$this->assertSame(array_shift($series), $args);
185+
})
186+
;
175187
$ldap
176188
->expects($this->once())
177189
->method('escape')
@@ -213,9 +225,15 @@ public function testEmptyQueryResultShouldThrowAnException()
213225
$ldap = $this->createMock(LdapInterface::class);
214226
$ldap
215227
->method('bind')
216-
->withConsecutive(
217-
['elsa', 'test1234A$']
218-
);
228+
->willReturnCallback(function (...$args) {
229+
static $series = [
230+
['elsa', 'test1234A$'],
231+
['', 'bar'],
232+
];
233+
234+
$this->assertSame(array_shift($series), $args);
235+
})
236+
;
219237
$ldap
220238
->expects($this->once())
221239
->method('query')

Tests/Authorization/AccessDecisionManagerTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,17 @@ public function testCacheableVotersWithMultipleAttributes()
229229
$voter
230230
->expects($this->exactly(2))
231231
->method('supportsAttribute')
232-
->withConsecutive(['foo'], ['bar'])
233-
->willReturnOnConsecutiveCalls(false, true);
232+
->willReturnCallback(function (...$args) {
233+
static $series = [
234+
[['foo'], false],
235+
[['bar'], true],
236+
];
237+
238+
[$expectedArgs, $return] = array_shift($series);
239+
$this->assertSame($expectedArgs, $args);
240+
241+
return $return;
242+
});
234243
$voter
235244
->expects($this->once())
236245
->method('supportsType')

0 commit comments

Comments
 (0)