Skip to content

Commit ddabada

Browse files
minor #19067 [3.1] update tests to use the new error assertion helper (xabbuh)
This PR was merged into the 3.1 branch. Discussion ---------- [3.1] update tests to use the new error assertion helper | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 9c7512b update tests to use the new error assertion helper
2 parents 7b04f78 + 2cd852f commit ddabada

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

Tests/InlineTest.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Yaml\Tests;
1313

14+
use Symfony\Bridge\PhpUnit\ErrorAssert;
1415
use Symfony\Component\Yaml\Inline;
1516
use Symfony\Component\Yaml\Yaml;
1617

@@ -258,23 +259,9 @@ public function getScalarIndicators()
258259
*/
259260
public function testParseUnquotedScalarStartingWithPercentCharacter()
260261
{
261-
$deprecations = array();
262-
set_error_handler(function ($type, $msg) use (&$deprecations) {
263-
if (E_USER_DEPRECATED !== $type) {
264-
restore_error_handler();
265-
266-
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
267-
}
268-
269-
$deprecations[] = $msg;
262+
ErrorAssert::assertDeprecationsAreTriggered('Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', function () {
263+
Inline::parse('{ foo: %foo }');
270264
});
271-
272-
Inline::parse('{ foo: %foo }');
273-
274-
restore_error_handler();
275-
276-
$this->assertCount(1, $deprecations);
277-
$this->assertContains('Not quoting a scalar starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $deprecations[0]);
278265
}
279266

280267
/**

0 commit comments

Comments
 (0)