Closed pawelkg closed 2 months ago
Hi, thanks for reporting. I made that test in Windows so I'm not sure why it's failing. I suspect this has something to do with your git config. Please run the following and tell me the output:
git config --get core.autocrlf
git config --get core.eol
git config --get core.autocrlf
Result: false
git config --get core.eol
Result empty
Please set your core.eol to lf.
git config --global core.eol lf
Run composer cs-fix
and try again the test.
Nothing changes after changing this config. To be sure I checkout to new branch from codeigniter4 develop branch...
Thank you for reporting!
But your test code works in 3v4l.org. https://3v4l.org/WeqvU
Also works on my mac.
$ cat test.php
<?php
// Copied from tests/_support/Commands/Foobar.php
$template = "<?php
use Config\App;
use CodeIgniter\CLI\CLI;
return [
'foo' => 'The command will use this as foo.',
'bar' => 'The command will use this as bar.',
'baz' => 'The baz is here.',
'bas' => CLI::color('bas', 'green') . (new App())->baseURL,
];
";
preg_match(
'/(?P<imports>(?:^use [^;]+;$\n?)+)/m',
$template,
$match
);
var_dump($match); // empty 'imports'
$ php test.php
/Users/kenji/work/codeigniter/official/CodeIgniter4/test.php:22:
array(3) {
[0] =>
string(41) "use Config\App;
use CodeIgniter\CLI\CLI;
"
'imports' =>
string(41) "use Config\App;
use CodeIgniter\CLI\CLI;
"
[1] =>
string(41) "use Config\App;
use CodeIgniter\CLI\CLI;
"
}
Well it's not working on my PC and not on server from my link I provided... Meaby it's depend on some configuration or extension version?
Try deleting your local copy again, then clone again.
I updated GIT to newest version, Set up again autocrlf and eol, than clone repository again, and tests pass with no problems...
PHP Version
8.1, 8.2, 8.3
CodeIgniter4 Version
latest version
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Windows, Linux
Which server did you use?
apache
Database
No response
What happened?
While runing test on Windows 10 with PHP 8.1.29: 1) CodeIgniter\Commands\ConfigurableSortImportsTest::testPublishLanguageWithoutOptions Failed asserting that two strings are not identical. \tests\system\Commands\ConfigurableSortImportsTest.php:33
2) CodeIgniter\Commands\ConfigurableSortImportsTest::testEnabledSortImportsWillDisruptLanguageFilePublish Failed asserting that two strings are not identical.
\tests\system\Commands\ConfigurableSortImportsTest.php:46
During debuging I found out that \CodeIgniter\CLI\GeneratorTrait::buildContent in if statement has preg_match that do not work.
Steps to Reproduce
Test try to publish tests/_support/Commands/Foobar.php with sort imports. Here test code with results of empty array: https://onlinephp.io/c/1946f
Expected Output
Should find imports to sort.
Anything else?
I run
composer cs-fix
before test