codeigniter4 / codeigniter4/CodeIgniter4
Bug: [4.4] Failed tests on Windows.
- 主要言語
- PHP
- スター
- 6k
- フォーク
- 2k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 73
説明
### PHP Version
7.4
### CodeIgniter4 Version
4.4
### CodeIgniter4 Installation Method
Git
### Which operating systems have you tested for this bug?
Windows
### Which server did you use?
apache
### Database
_No response_
### What happened?
After PR https://github.com/codeigniter4/CodeIgniter4/pull/7380 in Windows CodeIgniter\CodeIgniterTest::testRun404Override() and similar tests fail.
Instead of the expected response from the 404 error handler, a welcome_page is returned (from App\Controller\Home::index)
```
$ d:\1\CodeIgniter4\vendor\bin\phpunit.bat tests\system\CodeIgniterTest.php
PHPUnit 9.6.7 by Sebastian Bergmann and contributors.
Runtime: PHP 8.1.1
Configuration: D:\1\CodeIgniter4\phpunit.xml.dist
Warning: No code coverage driver available
...FFFF............................ 35 / 35 (100%)
Time: 00:04.175, Memory: 28.00 MB
There were 4 failures:
1) CodeIgniter\CodeIgniterTest::testRun404Override
Failed asserting that '\r\n
[cut]
D:\1\CodeIgniter4\tests\system\CodeIgniterTest.php:124
2) CodeIgniter\CodeIgniterTest::testRun404OverrideControllerReturnsResponse
Failed asserting that '\r\n
[cut]
...etc
```
This is happening in this code snippet due to the difference in paths (directory separators) between Windows and UNIX.
https://github.com/codeigniter4/CodeIgniter4/blob/d9fd9d5e9dc34bcaa249c0df42c5d371ca45e582/system/Router/RouteCollection.php#L323-L332
```
$files
array(2) {
[0]=>
string(59) "D:\1\CodeIgniter4\app\Config\Routes.php"
[1]=>
string(70) "D:\1\CodeIgniter4\tests\_support\Config\Routes.php"
}
$this->routeFiles
array(1) {
[0]=>
string(59) "D:\1\CodeIgniter4\app\Config/Routes.php" <--- DS
}
```
Due to the difference in paths, the comparison fails and the file with routes from the application is loaded, thereby adding the route that is accessed in the tests.
### Expected Output
Since the framework can be used not only on UNIX, the tests must also pass on Windows. This issue is just a special case and fixing by changing the requested resource in the tests will not solve the problem. That is, the behavior should be like in UNIX, that is, the route from the application should not be loaded.
### Anything else?
In other tests related to file/directory paths, there are also errors on Windows due to the directory separator.
コントリビューションガイド
調査の方向性
リンクされている行の周辺にある system/Router/RouteCollection.php と tests/system/CodeIgniterTest.php から始め、その後 Windows で vendor/bin/phpunit.bat tests/system/CodeIgniterTest.php を実行します。ルートファイルのパス比較を追跡し、これらのテストでアプリケーションのルートが読み込まれないことを確認します。影響を受ける Windows テストと関連するパステストはパスするはずです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- backend, testing
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100