- Issue created by @julienjoye
- Merge request !10329issue #3489668: fix wrong variable sent to EscaperRuntime::escape() method β (Open) created by Unnamed author
- πΊπΈUnited States smustgrave
Thank you for reporting, as a bug next step will be to add test coverage to show the issue.
- π«π·France julienjoye
Hey!
I don't have much time for this by now, therefore I use the MR diff in the meantime.
Still, I checked in the tests if a quick win could be done (Unfortunately, it can take some time).Nevertheless, some inputs:
By now, all this `escapeFilter()` method is covered by only one test method (`TwigExtensionTest::testEscaping()`) and seems to implement "Happy Path testing anti-pattern", because all the scenarios provided by the `providerTestEscaping` data provider, are based on `path()` twig function. And this twig function always returns a string.
Then, the escape method always pass by `$return = (string) $arg;` path, and then the call to `$env->getRuntime(EscaperRuntime::class)->escape();` with `$arg` or `$return` argument, is pretty identical.. That's why we missed this issue.
Unfortunately, I don't know if we can call a twig function that could return an object. I did not find any in that TwigExtension core class.
Is there a TwigExtension that could be loaded only during tests?
Maybe we can write an anonymous class and load it dynamically in that test method?Cheers.