Skip to content

Commit c085f58

Browse files
minor #49662 [Tests] Remove withConsecutive() calls from tests (alexandre-daubois)
This PR was merged into the 6.2 branch. Discussion ---------- [Tests] Remove `withConsecutive()` calls from tests | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | _NA_ | License | MIT | Doc PR | _NA_ Follows-up #49621 ℹ️ No more `setMethods()` deprecated calls have been found in 6.2. Commits ------- 6b27e78 [Tests] Remove `withConsecutive()` calls from tests
2 parents 76d14ac + 6b27e78 commit c085f58

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

src/Symfony/Bridge/Twig/Tests/EventListener/TemplateAttributeListenerTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@ public function testAttribute()
2929
$twig = $this->createMock(Environment::class);
3030
$twig->expects($this->exactly(3))
3131
->method('render')
32-
->withConsecutive(
33-
['templates/foo.html.twig', ['foo' => 'bar']],
34-
['templates/foo.html.twig', ['bar' => 'Bar', 'buz' => 'def']],
35-
['templates/foo.html.twig', []],
36-
)
37-
->willReturn('Bar');
32+
->willReturnCallback(function (...$args) {
33+
static $series = [
34+
['templates/foo.html.twig', ['foo' => 'bar']],
35+
['templates/foo.html.twig', ['bar' => 'Bar', 'buz' => 'def']],
36+
['templates/foo.html.twig', []],
37+
];
38+
39+
$this->assertSame(array_shift($series), $args);
40+
41+
return 'Bar';
42+
})
43+
;
3844

3945
$request = new Request();
4046
$kernel = $this->createMock(HttpKernelInterface::class);

src/Symfony/Component/Ldap/Tests/Security/CheckLdapCredentialsListenerTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,15 @@ public function toArray(): array
146146

147147
$this->ldap
148148
->method('bind')
149-
->withConsecutive(
150-
['elsa', 'test1234A$']
151-
);
149+
->willReturnCallback(function (...$args) {
150+
static $series = [
151+
['elsa', 'test1234A$'],
152+
['', 's3cr3t'],
153+
];
154+
155+
$this->assertSame(array_shift($series), $args);
156+
})
157+
;
152158
$this->ldap->expects($this->any())->method('escape')->with('Wouter', '', LdapInterface::ESCAPE_FILTER)->willReturn('wouter');
153159
$this->ldap->expects($this->once())->method('query')->with('{user_identifier}', 'wouter_test')->willReturn($query);
154160

src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,11 @@ public function testReadWithLastModified(array $locales, array $domains, array $
803803
$loader = $this->getLoader();
804804
$loader->expects($this->exactly(\count($consecutiveLoadArguments)))
805805
->method('load')
806-
->withConsecutive(...$consecutiveLoadArguments)
807-
->willReturnOnConsecutiveCalls(...$consecutiveLoadReturns);
806+
->willReturnCallback(function (...$args) use (&$consecutiveLoadArguments, &$consecutiveLoadReturns) {
807+
$this->assertSame(array_shift($consecutiveLoadArguments), $args);
808+
809+
return array_shift($consecutiveLoadReturns);
810+
});
808811

809812
$provider = self::createProvider(
810813
new MockHttpClient($responses, 'https://localise.biz/api/'),

src/Symfony/Component/Translation/Bridge/Loco/Tests/LocoProviderWithoutTranslatorBagTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,16 @@ public function testReadWithLastModified(array $locales, array $domains, array $
6161
}
6262

6363
$loader = $this->getLoader();
64-
$loader->expects($this->exactly(\count($consecutiveLoadArguments) * 2))
64+
$consecutiveLoadArguments = array_merge($consecutiveLoadArguments, $consecutiveLoadArguments);
65+
$consecutiveLoadReturns = array_merge($consecutiveLoadReturns, $consecutiveLoadReturns);
66+
67+
$loader->expects($this->exactly(\count($consecutiveLoadArguments)))
6568
->method('load')
66-
->withConsecutive(...$consecutiveLoadArguments, ...$consecutiveLoadArguments)
67-
->willReturnOnConsecutiveCalls(...$consecutiveLoadReturns, ...$consecutiveLoadReturns);
69+
->willReturnCallback(function (...$args) use (&$consecutiveLoadArguments, &$consecutiveLoadReturns) {
70+
$this->assertSame(array_shift($consecutiveLoadArguments), $args);
71+
72+
return array_shift($consecutiveLoadReturns);
73+
});
6874

6975
$provider = $this->createProvider(
7076
new MockHttpClient($responses, 'https://localise.biz/api/'),

0 commit comments

Comments
 (0)