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
I'm testing a method, which echoes some content (it's a widget for an Elementor WordPress plugin). Since this method does not return anything, and the only way to check if it works properly is to check what it prints to the output, I've designed a test which uses output buffering to capture what the method echoes and test its value. This worked well but suddenly this tests started to fail because there is some patchwork code added to my buffered output - in each test the output is suffixed with this string: \Patchwork\CodeManipulation\Stream::reinstateWrapper();.
Here is a simplified test code (using Pest):
it('renders the widget', function () {
ob_start();
$this->widget->render();
expect(ob_get_clean())->toEqual('assumed_render_result');
});
For example, if my widget's render() method had this code:
echo'assumed_render_result';
the test should pass. Instead it fails, because the actual output is: assumed_render_result;\Patchwork\CodeManipulation\Stream::reinstateWrapper();
Why is that? Is is some bug in Patchwork or am I missing something?
I'm testing a method, which echoes some content (it's a widget for an Elementor WordPress plugin). Since this method does not return anything, and the only way to check if it works properly is to check what it prints to the output, I've designed a test which uses output buffering to capture what the method echoes and test its value. This worked well but suddenly this tests started to fail because there is some patchwork code added to my buffered output - in each test the output is suffixed with this string:
\Patchwork\CodeManipulation\Stream::reinstateWrapper();
.Here is a simplified test code (using Pest):
For example, if my widget's
render()
method had this code:the test should pass. Instead it fails, because the actual output is:
assumed_render_result;\Patchwork\CodeManipulation\Stream::reinstateWrapper();
Why is that? Is is some bug in Patchwork or am I missing something?
Here I found this code in source:
patchwork/src/CodeManipulation/Actions/CodeManipulation.php
Line 16 in 16a1ab8
but I don't understand why it gets appended to my output buffering result and how to avoid id.
The text was updated successfully, but these errors were encountered: