-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
refactor: update PHPUnit to 10 #8069
Conversation
@paulbalandan Any plan to release |
Is it ready but lacking integration tests. I'll try to finish this weekend. Thanks for reminding me. |
https://github.com/codeigniter4/CodeIgniter4/actions/runs/6593809502/job/17916840733?pr=8069 |
https://github.com/codeigniter4/CodeIgniter4/actions/runs/6593809497/job/17916881103?pr=8069 |
The first warning is easy. Just change the name to AbstractHandlerTestCase. Abstract tests need to be suffixed with TestCase. For the static issues, just run the rule |
Unfortunately php-cs-fixer was not able to refactor the dataProviders because of |
Ah yes. The rule is risky because of uses of |
9a41574
to
54e6c4d
Compare
Why does this test fail? $ vendor/bin/phpunit tests/system/Validation/StrictRules/ValidationTest.php
PHPUnit 10.4.1 by Sebastian Bergmann and contributors.
Runtime: PHP 8.1.24
Configuration: /Users/kenji/work/codeigniter/official/CodeIgniter4/phpunit.xml
.................................................................................................... 100 / 121 ( 82%)
...........F......... 121 / 121 (100%)
Time: 00:00.930, Memory: 16.00 MB
...
--
There was 1 failure:
1) CodeIgniter\Validation\StrictRules\ValidationTest::testPlaceholderReplacementTestFails
Failed asserting that exception message 'Failed asserting that 'filter[{id}]' [ASCII](length: 12) does not contain "{id}" [ASCII](length: 4).' contains 'Failed asserting that 'filter[{id}]' does not contain "{id}".'.
FAILURES!
Tests: 121, Assertions: 173, Failures: 1, Warnings: 1. |
I got the reason. The error message of PHPUnit has been changed. |
9a6d208
to
7b1d446
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will want to update DevKit as well - not sure when the appropriate time to do that is though, maybe when we actually drop 8.0? I know @paulbalandan is working on Tachycardia comparability - that would be great to include.
Edit: oops! I missed the existing conversation. All good.
|
2052f1a
to
a524abc
Compare
I don't know why, but only in PHP 8.3, the $ vendor/bin/phpunit tests/system/Autoloader/AutoloaderTest.php
PHPUnit 10.4.2 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.0-dev
Configuration: /Users/kenji/work/codeigniter/official/CodeIgniter4/phpunit.xml
..........................E 27 / 27 (100%)
Time: 00:00.486, Memory: 16.00 MB
There was 1 error:
1) CodeIgniter\Autoloader\AutoloaderTest::testLoadHelpers
PHPUnit\Framework\Exception: PHP Fatal error: Uncaught CodeIgniter\Format\Exceptions\FormatException: Failed to parse JSON string. Error: Type is not supported in /Users/kenji/work/codeigniter/official/CodeIgniter4/system/Format/JSONFormatter.php:44
Stack trace:
#0 /Users/kenji/work/codeigniter/official/CodeIgniter4/system/Format/JSONFormatter.php(44): CodeIgniter\Format\Exceptions\FormatException::forInvalidJSON('Type is not sup...')
#1 /Users/kenji/work/codeigniter/official/CodeIgniter4/system/API/ResponseTrait.php(345): CodeIgniter\Format\JSONFormatter->format(Array)
#2 /Users/kenji/work/codeigniter/official/CodeIgniter4/system/API/ResponseTrait.php(98): CodeIgniter\Debug\ExceptionHandler->format(Array)
#3 /Users/kenji/work/codeigniter/official/CodeIgniter4/system/Debug/ExceptionHandler.php(81): CodeIgniter\Debug\ExceptionHandler->respond(Array, 500)
#4 /Users/kenji/work/codeigniter/official/CodeIgniter4/system/Debug/Exceptions.php(148): CodeIgniter\Debug\ExceptionHandler->handle(Object(PHPUnit\Event\Code\NoTestCaseObjectOnCallStackException), Object(CodeIgniter\HTTP\IncomingRequest), Object(CodeIgniter\HTTP\Response), 500, 1)
#5 [internal function]: CodeIgniter\Debug\Exceptions->exceptionHandler(Object(PHPUnit\Event\Code\NoTestCaseObjectOnCallStackException))
#6 {main}
thrown in /Users/kenji/work/codeigniter/official/CodeIgniter4/system/Format/JSONFormatter.php on line 44
ERRORS!
Tests: 27, Assertions: 45, Errors: 1. |
--- a/system/Format/JSONFormatter.php
+++ b/system/Format/JSONFormatter.php
@@ -37,6 +37,7 @@ class JSONFormatter implements FormatterInterface
$options = ENVIRONMENT === 'production' ? $options : $options | JSON_PRETTY_PRINT;
+ log_message('debug', var_export($data, true));
$result = json_encode($data, $options, 512);
if (! in_array(json_last_error(), [JSON_ERROR_NONE, JSON_ERROR_RECURSION], true)) {
|
This comment was marked as outdated.
This comment was marked as outdated.
a524abc
to
2f23a6f
Compare
2f23a6f
to
69bcbbb
Compare
This comment was marked as outdated.
This comment was marked as outdated.
69bcbbb
to
1829df8
Compare
No good. Tests on PHP 8.3 fails.
https://github.com/codeigniter4/CodeIgniter4/actions/runs/7043858533/job/19170759175?pr=8069 |
5b2f18f
to
47bf62e
Compare
47bf62e
to
fe41852
Compare
vendor/bin/phpunit --migrate-configuration -c phpunit.xml.dist
Message: file_put_contents(/home/runner/work/CodeIgniter4/CodeIgniter4/build/coverage/text/coverage.txt): Failed to open stream: No such file or directory Location: /home/runner/work/CodeIgniter4/CodeIgniter4/vendor/phpunit/phpunit/src/Runner/CodeCoverage.php:317 Script done. Error: Process completed with exit code 255.
1) CodeIgniter\Database\DatabaseTestCase\DatabaseTestCaseMigrationOnce1Test::testMigrationDone TypeError: json_encode(): Argument #2 ($flags) must be of type int, bool given /home/runner/work/CodeIgniter4/CodeIgniter4/system/Test/Constraints/SeeInDatabase.php:118 /home/runner/work/CodeIgniter4/CodeIgniter4/system/Test/DatabaseTestTrait.php:282 /home/runner/work/CodeIgniter4/CodeIgniter4/tests/system/Database/DatabaseTestCase/DatabaseTestCaseMigrationOnce1Test.php:86
There was 1 error: 1) CodeIgniter\Security\SecurityCSRFSessionRandomizeTokenTest::testCSRFVerifyPostInvalidToken PHPUnit\Framework\Exception: PHP Warning: hex2bin(): Hexadecimal input string must have an even length in /home/runner/work/CodeIgniter4/CodeIgniter4/system/Security/Security.php on line 378 PHP Warning: hex2bin(): Hexadecimal input string must have an even length in /home/runner/work/CodeIgniter4/CodeIgniter4/system/Security/Security.php on line 378
There was 1 error: 1) CodeIgniter\CommonFunctionsTest::testTraceWithCSP Test was run in child process and ended unexpectedly
fe41852
to
9e009e9
Compare
Rebased to resolve the conflict. |
Happy to see this one launched! |
But we still need |
Important
This PR will be merged just prior to the release of v4.5.0.
Description
PHPUnit requires PHP 8.1 or later.
https://packagist.org/packages/phpunit/phpunit#10.4.1
https://phpunit.de/announcements/phpunit-10.html
TODO
nexusphp/tachycardia
Checklist: