Skip to content

Commit

Permalink
minor #49621 [Tests] Remove occurrences of withConsecutive() (alexa…
Browse files Browse the repository at this point in the history
…ndre-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()`
  • Loading branch information
nicolas-grekas committed Mar 10, 2023
2 parents 2363f8e + e41d909 commit a801d52
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,15 @@ public function toArray(): array
$ldap = $this->createMock(LdapInterface::class);
$ldap
->method('bind')
->withConsecutive(
['elsa', 'test1234A$']
);
->willReturnCallback(function (...$args) {
static $series = [
['elsa', 'test1234A$'],
['', 'bar'],
];

$this->assertSame(array_shift($series), $args);
})
;
$ldap
->expects($this->once())
->method('escape')
Expand Down Expand Up @@ -169,9 +175,15 @@ public function toArray(): array
$ldap = $this->createMock(LdapInterface::class);
$ldap
->method('bind')
->withConsecutive(
['elsa', 'test1234A$']
);
->willReturnCallback(function (...$args) {
static $series = [
['elsa', 'test1234A$'],
['', 'bar'],
];

$this->assertSame(array_shift($series), $args);
})
;
$ldap
->expects($this->once())
->method('escape')
Expand Down Expand Up @@ -213,9 +225,15 @@ public function testEmptyQueryResultShouldThrowAnException()
$ldap = $this->createMock(LdapInterface::class);
$ldap
->method('bind')
->withConsecutive(
['elsa', 'test1234A$']
);
->willReturnCallback(function (...$args) {
static $series = [
['elsa', 'test1234A$'],
['', 'bar'],
];

$this->assertSame(array_shift($series), $args);
})
;
$ldap
->expects($this->once())
->method('query')
Expand Down
13 changes: 11 additions & 2 deletions Tests/Authorization/AccessDecisionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,17 @@ public function testCacheableVotersWithMultipleAttributes()
$voter
->expects($this->exactly(2))
->method('supportsAttribute')
->withConsecutive(['foo'], ['bar'])
->willReturnOnConsecutiveCalls(false, true);
->willReturnCallback(function (...$args) {
static $series = [
[['foo'], false],
[['bar'], true],
];

[$expectedArgs, $return] = array_shift($series);
$this->assertSame($expectedArgs, $args);

return $return;
});
$voter
->expects($this->once())
->method('supportsType')
Expand Down

0 comments on commit a801d52

Please sign in to comment.