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
test to bzflush function #1553
test to bzflush function #1553
Conversation
was create a test to bzflush function, where there dont exist anyone yet.
Not sure this test actually tests that the function works - it only tests that it returns true. |
Hi @smalyshev, i see it and i know that you are all right! a)in this file, don't have source code about this function, just calls and callback b)this function is not coverage, yet c) i don't found search code about d) here explain that this function just return false, if there are some problem or failure, but beleve me, i've try force a fail test case but, just return true, because it work so fine e) there, i don't see any more case of test to do, if has, please, give me some examples! f)thanks for everything g)hugs from brazil php community :-) |
I agree with @smalyshev, this isn't actually testing what the function should be doing. Due to what the function does, it is hard to test, but this is the way I would go about it: --FILE--
<?php
$file = __DIR__ . DIRECTORY_SEPARATOR . 'bzflush_test.txt.bz2';
$text = "This is a test string.";
$bz1 = bzopen($file, 'w');
bzwrite($bz1, $text);
var_dump(bzflush($bz1));
$bz2 = bzopen($file, 'r');
rewind($bz2);
var_dump(bzread($bz2));
bzclose($bz2);
bzclose($bz1);
?>
--CLEAN--
<?php
unlink(__DIR__ . DIRECTORY_SEPARATOR . 'bzflush_test.txt.bz2');
?>
--EXPECTF--
bool(true)
string(%d) "This is a test string." |
@jerrygrey |
@marcosptf I didn't test the code beforehand as it was meant as just an idea on how you could go about testing this function. I have edited the code above, but it looks like it found a bug in the function to me. Edit: Yep, it is a bug, see here. I added the Edit 2: I have filed a bug report for it, #70819. |
Hi @jerrygrey ! i did another debugs test without bzflush(); , the behavior is the same ==> |
@marcosptf I have edited my code to avoid that bug, the test I wrote should work now without any issues. The bug report I filed as nothing to do with the The two tests you did proves nothing, just because a function returns These are just my comments though, it is up to you what you do with this PR. |
"The two tests you did proves nothing....." nothing? thanks @jerrygrey 👍 |
As pointed out by reeze, this function doesn't actually do anything, see here. It doesn't need a test. |
Well, maybe check if return 0. If return another value in future the function was changed, point to make a complete test. |
@marcosptf sad but fun. Kkkkkk |
kkkkk |
@marcosptf This test is still wrong; it unconditionally attempt to flush what may have failed to open, and then prints that it couldn't open a file if it fails to flush. Please fix the test so that it adds value, and is correct, simply adding tests so that coverage is reported to be higher is not a useful thing to do, as I'm sure you understand by now :) |
okey @krakjoe thanks for explain !!! |
Sorry, but having read the source code of extension before merging: This function is an alias of Another user did already mention this before, it's a comment in the bug linked in this thread. Adding the test just so that test coverage is increased is simply not valuable, so I'm closing this. |
was create a test to bzflush function, where there dont exist anyone yet.