Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various output buffer issues #5851

Open
kkmuffme opened this issue Jun 2, 2024 · 4 comments · May be fixed by #5852
Open

Various output buffer issues #5851

kkmuffme opened this issue Jun 2, 2024 · 4 comments · May be fixed by #5852
Labels
type/bug Something is broken

Comments

@kkmuffme
Copy link

kkmuffme commented Jun 2, 2024

Q A
PHPUnit version 11.1.3
PHP version 8.2.x, 8.3.x
Installation Method Composer / PHAR

Summary

  1. when a test (or any function called from the test) flushes or cleans the output buffer, this incorrectly changes the output making tests pass that fail with expectOutputString and/or would cause a PHP notice when the code is actually executed
  2. if a test ends but starts a new output buffer, no error is reported, since only the ob level is compared instead of comparing the output
  3. when a test (or any function called from the test) register a non-removable ob callback, this leads to complete failure/unexpected behavior
  4. non-removable ob callbacks cannot currently be tested
  5. if stopping output buffering fails, it will try again creating the same notices twice

I will provide a PR.

@kkmuffme kkmuffme added the type/bug Something is broken label Jun 2, 2024
@kkmuffme kkmuffme linked a pull request Jun 2, 2024 that will close this issue
@sebastianbergmann
Copy link
Owner

What are non-removable output buffering handlers?

@kkmuffme
Copy link
Author

kkmuffme commented Jun 3, 2024

e.g.

  • ob_start('my_cb', 0, 0);
  • ob_start('my_cb', 0, PHP_OUTPUT_HANDLER_FLUSHABLE);
  • ob_start(null, 0, PHP_OUTPUT_HANDLER_CLEANABLE);

These cannot be removed/terminated with e.g. ob_end_flush();

@mvorisek
Copy link
Contributor

mvorisek commented Jun 7, 2024

Can you show a small repro on https://3v4l.org/?

@kkmuffme
Copy link
Author

kkmuffme commented Jun 7, 2024

https://3v4l.org/kPQXO

See the PR, there are unit tests for that case already
https://github.com/sebastianbergmann/phpunit/pull/5852/files#diff-198b09778388878e8068a870068387c10c3f9db2a6ed610c24daccda3b669fa3R115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants