Skip to content

Commit 76d14ac

Browse files
Merge branch '5.4' into 6.2
* 5.4: [Tests] Remove occurrences of `withConsecutive()` Fix support binary values in parameters. [Dotenv] Improve Dotenv::usePutenv phpdoc
2 parents 9fd2a04 + 431b6ef commit 76d14ac

File tree

36 files changed

+710
-338
lines changed

36 files changed

+710
-338
lines changed

src/Symfony/Bridge/Twig/Tests/Extension/StopwatchExtensionTest.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bridge\Twig\Extension\StopwatchExtension;
1616
use Symfony\Component\Stopwatch\Stopwatch;
17+
use Symfony\Component\Stopwatch\StopwatchEvent;
1718
use Twig\Environment;
1819
use Twig\Error\RuntimeError;
1920
use Twig\Loader\ArrayLoader;
@@ -67,12 +68,29 @@ protected function getStopwatch($events = [])
6768
$expectedStopCalls[] = [$this->equalTo($eventName)];
6869
}
6970

70-
$startInvocationMocker = $stopwatch->expects($this->exactly($expectedCalls))
71-
->method('start');
72-
\call_user_func_array([$startInvocationMocker, 'withConsecutive'], $expectedStartCalls);
73-
$stopInvocationMocker = $stopwatch->expects($this->exactly($expectedCalls))
74-
->method('stop');
75-
\call_user_func_array([$stopInvocationMocker, 'withConsecutive'], $expectedStopCalls);
71+
$stopwatch
72+
->expects($this->exactly($expectedCalls))
73+
->method('start')
74+
->willReturnCallback(function (string $name, string $category) use (&$expectedStartCalls) {
75+
[$expectedName, $expectedCategory] = array_shift($expectedStartCalls);
76+
77+
$expectedName->evaluate($name);
78+
$this->assertSame($expectedCategory, $category);
79+
80+
return $this->createMock(StopwatchEvent::class);
81+
})
82+
;
83+
84+
$stopwatch
85+
->expects($this->exactly($expectedCalls))
86+
->method('stop')
87+
->willReturnCallback(function (string $name) use (&$expectedStopCalls) {
88+
[$expectedName] = array_shift($expectedStopCalls);
89+
$expectedName->evaluate($name);
90+
91+
return $this->createMock(StopwatchEvent::class);
92+
})
93+
;
7694

7795
return $stopwatch;
7896
}

src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,31 @@ private function getKernel(array $bundles, $useDispatcher = false)
258258
$container
259259
->expects($this->exactly(2))
260260
->method('hasParameter')
261-
->withConsecutive(['console.command.ids'], ['console.lazy_command.ids'])
262-
->willReturnOnConsecutiveCalls(true, true)
261+
->willReturnCallback(function (...$args) {
262+
static $series = [
263+
['console.command.ids'],
264+
['console.lazy_command.ids'],
265+
];
266+
267+
$this->assertSame(array_shift($series), $args);
268+
269+
return true;
270+
})
263271
;
272+
264273
$container
265274
->expects($this->exactly(2))
266275
->method('getParameter')
267-
->withConsecutive(['console.lazy_command.ids'], ['console.command.ids'])
268-
->willReturnOnConsecutiveCalls([], [])
276+
->willReturnCallback(function (...$args) {
277+
static $series = [
278+
['console.lazy_command.ids'],
279+
['console.command.ids'],
280+
];
281+
282+
$this->assertSame(array_shift($series), $args);
283+
284+
return [];
285+
})
269286
;
270287

271288
$kernel = $this->createMock(KernelInterface::class);

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,21 @@ public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $e
149149

150150
$loader = $this->createMock(LoaderInterface::class);
151151

152+
$series = [
153+
/* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */
154+
[['messages.some_locale.loader', 'some_locale', 'messages'], $someCatalogue],
155+
/* This resource is added by an addResource() call and shall be loaded after the resource_files */
156+
[['second_resource.some_locale.loader', 'some_locale', 'messages'], $someCatalogue],
157+
];
158+
152159
$loader->expects($this->exactly(2))
153160
->method('load')
154-
->withConsecutive(
155-
/* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */
156-
['messages.some_locale.loader', 'some_locale', 'messages'],
157-
/* This resource is added by an addResource() call and shall be loaded after the resource_files */
158-
['second_resource.some_locale.loader', 'some_locale', 'messages']
159-
)
160-
->willReturnOnConsecutiveCalls(
161-
$someCatalogue,
162-
$someCatalogue
163-
);
161+
->willReturnCallback(function (...$args) use (&$series) {
162+
[$expectedArgs, $return] = array_shift($series);
163+
$this->assertSame($expectedArgs, $args);
164+
165+
return $return;
166+
});
164167

165168
$options = [
166169
'resource_files' => ['some_locale' => ['messages.some_locale.loader']],

src/Symfony/Bundle/SecurityBundle/Tests/CacheWarmer/ExpressionCacheWarmerTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bundle\SecurityBundle\CacheWarmer\ExpressionCacheWarmer;
1616
use Symfony\Component\ExpressionLanguage\Expression;
17+
use Symfony\Component\ExpressionLanguage\ParsedExpression;
1718
use Symfony\Component\Security\Core\Authorization\ExpressionLanguage;
1819

1920
class ExpressionCacheWarmerTest extends TestCase
@@ -22,13 +23,21 @@ public function testWarmUp()
2223
{
2324
$expressions = [new Expression('A'), new Expression('B')];
2425

26+
$series = [
27+
[$expressions[0], ['token', 'user', 'object', 'subject', 'role_names', 'request', 'trust_resolver']],
28+
[$expressions[1], ['token', 'user', 'object', 'subject', 'role_names', 'request', 'trust_resolver']],
29+
];
30+
2531
$expressionLang = $this->createMock(ExpressionLanguage::class);
2632
$expressionLang->expects($this->exactly(2))
2733
->method('parse')
28-
->withConsecutive(
29-
[$expressions[0], ['token', 'user', 'object', 'subject', 'role_names', 'request', 'trust_resolver']],
30-
[$expressions[1], ['token', 'user', 'object', 'subject', 'role_names', 'request', 'trust_resolver']]
31-
);
34+
->willReturnCallback(function (...$args) use (&$series) {
35+
$expectedArgs = array_shift($series);
36+
$this->assertSame($expectedArgs, $args);
37+
38+
return $this->createMock(ParsedExpression::class);
39+
})
40+
;
3241

3342
(new ExpressionCacheWarmer($expressions, $expressionLang))->warmUp('');
3443
}

src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@ public function testLongKey()
2626

2727
$cache->expects($this->exactly(2))
2828
->method('doHave')
29-
->withConsecutive(
30-
[$this->equalTo('----------:nWfzGiCgLczv3SSUzXL3kg:')],
31-
[$this->equalTo('----------:---------------------------------------')]
32-
)->willReturn(false);
29+
->willReturnCallback(function (...$args) {
30+
static $series = [
31+
['----------:nWfzGiCgLczv3SSUzXL3kg:'],
32+
['----------:---------------------------------------'],
33+
];
34+
35+
$expectedArgs = array_shift($series);
36+
$this->assertSame($expectedArgs, $args);
37+
38+
return false;
39+
})
40+
;
3341

3442
$cache->hasItem(str_repeat('-', 40));
3543
$cache->hasItem(str_repeat('-', 39));

src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ private function convertParameters(array $parameters, string $type, \DOMElement
349349
$element->setAttribute('type', 'expression');
350350
$text = $this->document->createTextNode(self::phpToXml((string) $value));
351351
$element->appendChild($text);
352-
} elseif (\is_string($value) && !preg_match('/^[^\x00-\x08\x0B\x0E-\x1A\x1C-\x1F\x7F]*+$/u', $value)) {
352+
} elseif (\is_string($value) && !preg_match('/^[^\x00-\x08\x0B\x0C\x0E-\x1F\x7F]*+$/u', $value)) {
353353
$element->setAttribute('type', 'binary');
354354
$text = $this->document->createTextNode(self::phpToXml(base64_encode($value)));
355355
$element->appendChild($text);

src/Symfony/Component/DependencyInjection/Tests/Config/ContainerParametersResourceCheckerTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,17 @@ public static function isFreshProvider()
6464
yield 'fresh on every identical parameters' => [function (MockObject $container) {
6565
$container->expects(self::exactly(2))->method('hasParameter')->willReturn(true);
6666
$container->expects(self::exactly(2))->method('getParameter')
67-
->withConsecutive(
68-
[self::equalTo('locales')],
69-
[self::equalTo('default_locale')]
70-
)
71-
->willReturnMap([
72-
['locales', ['fr', 'en']],
73-
['default_locale', 'fr'],
74-
])
67+
->willReturnCallback(function (...$args) {
68+
static $series = [
69+
[['locales'], ['fr', 'en']],
70+
[['default_locale'], 'fr'],
71+
];
72+
73+
[$expectedArgs, $return] = array_shift($series);
74+
self::assertSame($expectedArgs, $args);
75+
76+
return $return;
77+
})
7578
;
7679
}, true];
7780
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container8.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
'bar' => 'foo is %%foo bar',
1010
'escape' => '@escapeme',
1111
'values' => [true, false, null, 0, 1000.3, 'true', 'false', 'null'],
12+
'utf-8 valid string' => "\u{021b}\u{1b56}\ttest",
1213
'binary' => "\xf0\xf0\xf0\xf0",
1314
'binary-control-char' => "This is a Bell char \x07",
15+
'console banner' => "\e[37;44m#StandWith\e[30;43mUkraine\e[0m",
1416
'null string' => 'null',
1517
'string of digits' => '123',
1618
'string of digits prefixed with minus character' => '-123',

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ protected function getDefaultParameters(): array
9595
6 => 'false',
9696
7 => 'null',
9797
],
98+
'utf-8 valid string' => 'ț᭖ test',
9899
'binary' => 'ðððð',
99100
'binary-control-char' => 'This is a Bell char ',
101+
'console banner' => '#StandWithUkraine',
100102
'null string' => 'null',
101103
'string of digits' => '123',
102104
'string of digits prefixed with minus character' => '-123',

src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
<parameter type="string">false</parameter>
1919
<parameter type="string">null</parameter>
2020
</parameter>
21+
<parameter key="utf-8 valid string">&#x21B;&#x1B56; test</parameter>
2122
<parameter key="binary" type="binary">8PDw8A==</parameter>
2223
<parameter key="binary-control-char" type="binary">VGhpcyBpcyBhIEJlbGwgY2hhciAH</parameter>
24+
<parameter key="console banner" type="binary">G1szNzs0NG0jU3RhbmRXaXRoG1szMDs0M21Va3JhaW5lG1swbQ==</parameter>
2325
<parameter key="null string" type="string">null</parameter>
2426
<parameter key="string of digits" type="string">123</parameter>
2527
<parameter key="string of digits prefixed with minus character" type="string">-123</parameter>

0 commit comments

Comments
 (0)