You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
minor #61485 [HttpFoundation] use PHPUnit's native expectUserDeprecationMessage() method (xabbuh)
This PR was merged into the 7.4 branch.
Discussion
----------
[HttpFoundation] use PHPUnit's native expectUserDeprecationMessage() method
| Q | A
| ------------- | ---
| Branch? | 7.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Issues |
| License | MIT
In #58370 I rewrote the tests in `NativeSessionStorageTest` to work around a bug in PHPUnit that didn't allow to have assertions about deprecations triggered in tests that were run in separate processes. Thanks to sebastianbergmann/phpunit#6283 (available in e.g. PHPUnit 12.3.5+) we don't need this workaround anymore.
Commits
-------
c7b14f8 use PHPUnit's native expectUserDeprecationMessage() method
Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php
+9-24Lines changed: 9 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -227,12 +227,10 @@ public function testCacheExpireOption()
227
227
#[Group('legacy')]
228
228
publicfunctiontestTransSidTagsOption()
229
229
{
230
-
$unignoredErrors = [];
230
+
$this->expectUserDeprecationMessage('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "trans_sid_tags" option is deprecated and will be ignored in Symfony 8.0.');
231
231
232
-
$previousErrorHandler = set_error_handler(function ($errno, $errstr) use (&$previousErrorHandler, &$unignoredErrors) {
232
+
$previousErrorHandler = set_error_handler(function ($errno, $errstr) use (&$previousErrorHandler) {
233
233
if ('ini_set(): Usage of session.trans_sid_tags INI setting is deprecated' !== $errstr) {
@@ -245,8 +243,6 @@ public function testTransSidTagsOption()
245
243
restore_error_handler();
246
244
}
247
245
248
-
$this->assertCount(1, $unignoredErrors);
249
-
$this->assertSame('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "trans_sid_tags" option is deprecated and will be ignored in Symfony 8.0.', $unignoredErrors[0]);
$this->expectUserDeprecationMessage('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "sid_length" option is deprecated and will be ignored in Symfony 8.0.');
376
+
$this->expectUserDeprecationMessage('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "sid_bits_per_character" option is deprecated and will be ignored in Symfony 8.0.');
377
+
$this->expectUserDeprecationMessage('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "referer_check" option is deprecated and will be ignored in Symfony 8.0.');
378
+
$this->expectUserDeprecationMessage('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "use_only_cookies" option is deprecated and will be ignored in Symfony 8.0.');
379
+
$this->expectUserDeprecationMessage('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "use_trans_sid" option is deprecated and will be ignored in Symfony 8.0.');
380
+
$this->expectUserDeprecationMessage('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "trans_sid_hosts" option is deprecated and will be ignored in Symfony 8.0.');
381
+
$this->expectUserDeprecationMessage('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "trans_sid_tags" option is deprecated and will be ignored in Symfony 8.0.');
388
382
389
383
$this->getStorage([
390
384
'sid_length' => 42,
@@ -395,14 +389,5 @@ public function testPassingDeprecatedOptions()
395
389
'trans_sid_hosts' => 'foo',
396
390
'trans_sid_tags' => 'foo',
397
391
]);
398
-
399
-
$this->assertCount(7, $unignoredErrors);
400
-
$this->assertContains('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "sid_length" option is deprecated and will be ignored in Symfony 8.0.', $unignoredErrors);
401
-
$this->assertContains('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "sid_bits_per_character" option is deprecated and will be ignored in Symfony 8.0.', $unignoredErrors);
402
-
$this->assertContains('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "referer_check" option is deprecated and will be ignored in Symfony 8.0.', $unignoredErrors);
403
-
$this->assertContains('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "use_only_cookies" option is deprecated and will be ignored in Symfony 8.0.', $unignoredErrors);
404
-
$this->assertContains('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "use_trans_sid" option is deprecated and will be ignored in Symfony 8.0.', $unignoredErrors);
405
-
$this->assertContains('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "trans_sid_hosts" option is deprecated and will be ignored in Symfony 8.0.', $unignoredErrors);
406
-
$this->assertContains('Since symfony/http-foundation 7.2: NativeSessionStorage\'s "trans_sid_tags" option is deprecated and will be ignored in Symfony 8.0.', $unignoredErrors);
0 commit comments