[DependencyInjection] Replaced try/catch block with an @expectedException annotation in a test.
merged branch jakzal/bugfix/di-tests-segfault (PR #8298)

This PR was merged into the 2.3 branch.

Discussion
----------

[DependencyInjection] Replaced try/catch block with an @expectedException annotation

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This fix doesn't seem like changing anything but thanks to it, PHP 5.3.3 stops segfaulting.

Tests started failing after merging #8285. However, it's not the change which made them failing (the change is totally unrelated to the segfaulting test case). I suspect it has something to do with memory management in the early PHP 5.3 versions. We've had this kind of failures in the past.

Commits
-------

494e803 [DependencyInjection] Replaced try/catch block with an @expectedException annotation in a test.