minor #19067 [3.1] update tests to use the new error assertion helper (xabbuh)
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

symfony/yaml,symfony/Yaml,gencer/Yaml