-
Notifications
You must be signed in to change notification settings - Fork 2k
Testing: fix failure of testStreamFilter function.
#6499
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
Conversation
There was 1 failure:
1) CodeIgniter\Test\TestCaseTest::testStreamFilter
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'
-first.
+'first.
'
/home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Test/TestCaseTest.php:60
phpvfscomposer:///home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/phpunit:97https://github.com/codeigniter4/CodeIgniter4/runs/8185500592?check_suite_focus=true |
|
@kenjis I don't have this failure in my side.
Do I order the wrong command to run unit test or fix the wrong file? I comment out the other function in this testing file, and this is the result I get. |
|
The first CLI::write() call adds a newline before the line. CodeIgniter4/system/CLI/CLI.php Lines 359 to 364 in ddee0c6
It's a strange decision. |
|
@iRedds I also notice that design so that I make that change of testing. Probably the design can make the first line of command print look more comfortable?! And I don't think this is a good idea to change the |
No. But both of the following commands should result in OK. This shows static variables are very difficult to handle. Speaking of the test cases, these are depending on the global state and we do not reset the global state after one test,
Yes, it is difficult to change the behavior because it is a breaking change. |
|
How about |
|
|
|
Whether |
|
How about this? --- a/tests/system/Test/TestCaseTest.php
+++ b/tests/system/Test/TestCaseTest.php
@@ -27,6 +27,14 @@ final class TestCaseTest extends CIUnitTestCase
*/
private $stream_filter;
+ protected function setUp(): void
+ {
+ parent::setUp();
+
+ // Reset CLI::$lastWrite
+ CLI::print();
+ }
+
public function testGetPrivatePropertyWithObject()
{
$obj = new __TestForReflectionHelper(); |
Love it! Hacky but efficient 🤗 |
8c14e30 to
ac1c4a5
Compare
|
@kenjis I have been add your suggestion code and pushed, review pls. |
|
@ping-yee See GitHub Actions results. PHPUnit failed. |
|
Please run |

Description
Fixed #6203
Checklist: