From fc989b1829845584603edb46103496f310236feb Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Oct 2023 08:55:05 +0900 Subject: [PATCH 01/17] chore: update PHPUnit to 10 --- admin/framework/composer.json | 2 +- admin/starter/composer.json | 2 +- composer.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/framework/composer.json b/admin/framework/composer.json index fc06e8fa57b1..a851d6b53390 100644 --- a/admin/framework/composer.json +++ b/admin/framework/composer.json @@ -23,7 +23,7 @@ "kint-php/kint": "^5.0.4", "mikey179/vfsstream": "^1.6", "nexusphp/cs-config": "^3.6", - "phpunit/phpunit": "^9.1", + "phpunit/phpunit": "^10.5.11", "predis/predis": "^1.1 || ^2.0" }, "suggest": { diff --git a/admin/starter/composer.json b/admin/starter/composer.json index 27b4efc5903b..f19b65e61bdc 100644 --- a/admin/starter/composer.json +++ b/admin/starter/composer.json @@ -16,7 +16,7 @@ "require-dev": { "fakerphp/faker": "^1.9", "mikey179/vfsstream": "^1.6", - "phpunit/phpunit": "^9.1" + "phpunit/phpunit": "^10.5.11" }, "autoload": { "psr-4": { diff --git a/composer.json b/composer.json index cc7de0f54f8f..89b97276b64a 100644 --- a/composer.json +++ b/composer.json @@ -29,8 +29,8 @@ "phpstan/extension-installer": "^1.3", "phpstan/phpstan": "^1.10.2", "phpstan/phpstan-strict-rules": "^1.5", - "phpunit/phpcov": "^8.2", - "phpunit/phpunit": "^9.1", + "phpunit/phpcov": "^9.0.2", + "phpunit/phpunit": "^10.5.11", "predis/predis": "^1.1 || ^2.0", "rector/rector": "1.0.4", "vimeo/psalm": "^5.0" From 041cd7a660694290896e06b1e30db044d42f45dd Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Oct 2023 09:46:58 +0900 Subject: [PATCH 02/17] test: rename abtract classname for PHPUnit10 --- .../{AbstractHandlerTest.php => AbstractHandlerTestCase.php} | 2 +- tests/system/Cache/Handlers/FileHandlerTest.php | 2 +- tests/system/Cache/Handlers/MemcachedHandlerTest.php | 2 +- tests/system/Cache/Handlers/PredisHandlerTest.php | 2 +- tests/system/Cache/Handlers/RedisHandlerTest.php | 2 +- ...tGetFieldDataTest.php => AbstractGetFieldDataTestCase.php} | 2 +- .../MySQLi/{GetFieldDataTest.php => GetFieldDataTestCase.php} | 4 ++-- .../OCI8/{GetFieldDataTest.php => GetFieldDataTestCase.php} | 4 ++-- .../{GetFieldDataTest.php => GetFieldDataTestCase.php} | 4 ++-- .../SQLSRV/{GetFieldDataTest.php => GetFieldDataTestCase.php} | 4 ++-- .../{GetFieldDataTest.php => GetFieldDataTestCase.php} | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) rename tests/system/Cache/Handlers/{AbstractHandlerTest.php => AbstractHandlerTestCase.php} (95%) rename tests/system/Database/Live/{AbstractGetFieldDataTest.php => AbstractGetFieldDataTestCase.php} (98%) rename tests/system/Database/Live/MySQLi/{GetFieldDataTest.php => GetFieldDataTestCase.php} (98%) rename tests/system/Database/Live/OCI8/{GetFieldDataTest.php => GetFieldDataTestCase.php} (98%) rename tests/system/Database/Live/Postgre/{GetFieldDataTest.php => GetFieldDataTestCase.php} (98%) rename tests/system/Database/Live/SQLSRV/{GetFieldDataTest.php => GetFieldDataTestCase.php} (98%) rename tests/system/Database/Live/SQLite3/{GetFieldDataTest.php => GetFieldDataTestCase.php} (98%) diff --git a/tests/system/Cache/Handlers/AbstractHandlerTest.php b/tests/system/Cache/Handlers/AbstractHandlerTestCase.php similarity index 95% rename from tests/system/Cache/Handlers/AbstractHandlerTest.php rename to tests/system/Cache/Handlers/AbstractHandlerTestCase.php index 80c551a394a8..ff0be27f88f2 100644 --- a/tests/system/Cache/Handlers/AbstractHandlerTest.php +++ b/tests/system/Cache/Handlers/AbstractHandlerTestCase.php @@ -19,7 +19,7 @@ /** * @internal */ -abstract class AbstractHandlerTest extends CIUnitTestCase +abstract class AbstractHandlerTestCase extends CIUnitTestCase { protected BaseHandler $handler; protected static $key1 = 'key1'; diff --git a/tests/system/Cache/Handlers/FileHandlerTest.php b/tests/system/Cache/Handlers/FileHandlerTest.php index bc96a8a9cf4b..67aa170c75f5 100644 --- a/tests/system/Cache/Handlers/FileHandlerTest.php +++ b/tests/system/Cache/Handlers/FileHandlerTest.php @@ -23,7 +23,7 @@ * * @group Others */ -final class FileHandlerTest extends AbstractHandlerTest +final class FileHandlerTest extends AbstractHandlerTestCase { private static string $directory = 'FileHandler'; private Cache $config; diff --git a/tests/system/Cache/Handlers/MemcachedHandlerTest.php b/tests/system/Cache/Handlers/MemcachedHandlerTest.php index bbb91bf6a8de..06ee0c567239 100644 --- a/tests/system/Cache/Handlers/MemcachedHandlerTest.php +++ b/tests/system/Cache/Handlers/MemcachedHandlerTest.php @@ -23,7 +23,7 @@ * * @internal */ -final class MemcachedHandlerTest extends AbstractHandlerTest +final class MemcachedHandlerTest extends AbstractHandlerTestCase { private Cache $config; diff --git a/tests/system/Cache/Handlers/PredisHandlerTest.php b/tests/system/Cache/Handlers/PredisHandlerTest.php index 83aab83419b0..59e68346517b 100644 --- a/tests/system/Cache/Handlers/PredisHandlerTest.php +++ b/tests/system/Cache/Handlers/PredisHandlerTest.php @@ -22,7 +22,7 @@ * * @internal */ -final class PredisHandlerTest extends AbstractHandlerTest +final class PredisHandlerTest extends AbstractHandlerTestCase { private Cache $config; diff --git a/tests/system/Cache/Handlers/RedisHandlerTest.php b/tests/system/Cache/Handlers/RedisHandlerTest.php index 887175eee14d..c8182111971a 100644 --- a/tests/system/Cache/Handlers/RedisHandlerTest.php +++ b/tests/system/Cache/Handlers/RedisHandlerTest.php @@ -22,7 +22,7 @@ * * @internal */ -final class RedisHandlerTest extends AbstractHandlerTest +final class RedisHandlerTest extends AbstractHandlerTestCase { private Cache $config; diff --git a/tests/system/Database/Live/AbstractGetFieldDataTest.php b/tests/system/Database/Live/AbstractGetFieldDataTestCase.php similarity index 98% rename from tests/system/Database/Live/AbstractGetFieldDataTest.php rename to tests/system/Database/Live/AbstractGetFieldDataTestCase.php index 42ced8a69d52..3e9148266d38 100644 --- a/tests/system/Database/Live/AbstractGetFieldDataTest.php +++ b/tests/system/Database/Live/AbstractGetFieldDataTestCase.php @@ -18,7 +18,7 @@ use CodeIgniter\Test\CIUnitTestCase; use Config\Database; -abstract class AbstractGetFieldDataTest extends CIUnitTestCase +abstract class AbstractGetFieldDataTestCase extends CIUnitTestCase { /** * @var BaseConnection diff --git a/tests/system/Database/Live/MySQLi/GetFieldDataTest.php b/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php similarity index 98% rename from tests/system/Database/Live/MySQLi/GetFieldDataTest.php rename to tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php index 4eae602316ba..5b9bc3b16701 100644 --- a/tests/system/Database/Live/MySQLi/GetFieldDataTest.php +++ b/tests/system/Database/Live/MySQLi/GetFieldDataTestCase.php @@ -13,7 +13,7 @@ namespace CodeIgniter\Database\Live\MySQLi; -use CodeIgniter\Database\Live\AbstractGetFieldDataTest; +use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; /** @@ -21,7 +21,7 @@ * * @internal */ -final class GetFieldDataTest extends AbstractGetFieldDataTest +final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { protected function createForge(): void { diff --git a/tests/system/Database/Live/OCI8/GetFieldDataTest.php b/tests/system/Database/Live/OCI8/GetFieldDataTestCase.php similarity index 98% rename from tests/system/Database/Live/OCI8/GetFieldDataTest.php rename to tests/system/Database/Live/OCI8/GetFieldDataTestCase.php index ec985252214f..809a58e30264 100644 --- a/tests/system/Database/Live/OCI8/GetFieldDataTest.php +++ b/tests/system/Database/Live/OCI8/GetFieldDataTestCase.php @@ -13,7 +13,7 @@ namespace CodeIgniter\Database\Live\OCI8; -use CodeIgniter\Database\Live\AbstractGetFieldDataTest; +use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; use LogicException; use stdClass; @@ -23,7 +23,7 @@ * * @internal */ -final class GetFieldDataTest extends AbstractGetFieldDataTest +final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { protected function createForge(): void { diff --git a/tests/system/Database/Live/Postgre/GetFieldDataTest.php b/tests/system/Database/Live/Postgre/GetFieldDataTestCase.php similarity index 98% rename from tests/system/Database/Live/Postgre/GetFieldDataTest.php rename to tests/system/Database/Live/Postgre/GetFieldDataTestCase.php index 7ff4d57b5bce..04adeb0bda53 100644 --- a/tests/system/Database/Live/Postgre/GetFieldDataTest.php +++ b/tests/system/Database/Live/Postgre/GetFieldDataTestCase.php @@ -13,7 +13,7 @@ namespace CodeIgniter\Database\Live\Postgre; -use CodeIgniter\Database\Live\AbstractGetFieldDataTest; +use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; /** @@ -21,7 +21,7 @@ * * @internal */ -final class GetFieldDataTest extends AbstractGetFieldDataTest +final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { protected function createForge(): void { diff --git a/tests/system/Database/Live/SQLSRV/GetFieldDataTest.php b/tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php similarity index 98% rename from tests/system/Database/Live/SQLSRV/GetFieldDataTest.php rename to tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php index b6fda8161f60..05f77981cff0 100644 --- a/tests/system/Database/Live/SQLSRV/GetFieldDataTest.php +++ b/tests/system/Database/Live/SQLSRV/GetFieldDataTestCase.php @@ -13,7 +13,7 @@ namespace CodeIgniter\Database\Live\SQLSRV; -use CodeIgniter\Database\Live\AbstractGetFieldDataTest; +use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; /** @@ -21,7 +21,7 @@ * * @internal */ -final class GetFieldDataTest extends AbstractGetFieldDataTest +final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { protected function createForge(): void { diff --git a/tests/system/Database/Live/SQLite3/GetFieldDataTest.php b/tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php similarity index 98% rename from tests/system/Database/Live/SQLite3/GetFieldDataTest.php rename to tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php index c9c4a5e33efa..e1a0e22aa6b2 100644 --- a/tests/system/Database/Live/SQLite3/GetFieldDataTest.php +++ b/tests/system/Database/Live/SQLite3/GetFieldDataTestCase.php @@ -13,7 +13,7 @@ namespace CodeIgniter\Database\Live\SQLite3; -use CodeIgniter\Database\Live\AbstractGetFieldDataTest; +use CodeIgniter\Database\Live\AbstractGetFieldDataTestCase; use Config\Database; /** @@ -21,7 +21,7 @@ * * @internal */ -final class GetFieldDataTest extends AbstractGetFieldDataTest +final class GetFieldDataTestCase extends AbstractGetFieldDataTestCase { protected function createForge(): void { From e360bed937c48f9967cd7436fd4313791b667644 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Oct 2023 11:04:26 +0900 Subject: [PATCH 03/17] chore: update phpunit.xml.dist for PHPUnit10 vendor/bin/phpunit --migrate-configuration -c phpunit.xml.dist --- admin/framework/phpunit.xml.dist | 87 ++++++++++++++------------------ admin/starter/phpunit.xml.dist | 87 ++++++++++++++------------------ phpunit.xml.dist | 60 +++++++++------------- 3 files changed, 102 insertions(+), 132 deletions(-) diff --git a/admin/framework/phpunit.xml.dist b/admin/framework/phpunit.xml.dist index 51c5fddc530b..0235b8a739c1 100644 --- a/admin/framework/phpunit.xml.dist +++ b/admin/framework/phpunit.xml.dist @@ -1,51 +1,33 @@ - - - - ./app - - - ./app/Views - ./app/Config/Routes.php - - - - - - - - - - - ./tests - - - - - - - - - - - - - - - - - + + + + + + + - + + + + ./app + + + ./app/Views + ./app/Config/Routes.php + + diff --git a/admin/starter/phpunit.xml.dist b/admin/starter/phpunit.xml.dist index 62a473a733c4..7cd6d3af600a 100644 --- a/admin/starter/phpunit.xml.dist +++ b/admin/starter/phpunit.xml.dist @@ -1,51 +1,33 @@ - - - - ./app - - - ./app/Views - ./app/Config/Routes.php - - - - - - - - - - - ./tests - - - - - - - - - - - - - - - - - + + + + + + + - + + + + ./app + + + ./app/Views + ./app/Config/Routes.php + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e23d8ad9d6a5..b23efcde71b6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,51 +1,22 @@ - - - - system - - - - system/Commands/Generators/Views - system/Debug/Toolbar/Views - system/Pager/Views - system/ThirdParty - system/Validation/Views - system/bootstrap.php - system/ComposerScripts.php - system/Config/Routes.php - system/Test/bootstrap.php - system/Test/ControllerTester.php - system/Test/FeatureTestCase.php - - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" + bootstrap="system/Test/bootstrap.php" backupGlobals="false" + beStrictAboutOutputDuringTests="true" colors="true" columns="max" + failOnRisky="true" failOnWarning="true" + cacheDirectory=".phpunit.cache"> + - tests/system - @@ -66,7 +37,6 @@ - @@ -77,4 +47,22 @@ + + + system + + + system/Commands/Generators/Views + system/Debug/Toolbar/Views + system/Pager/Views + system/ThirdParty + system/Validation/Views + system/bootstrap.php + system/ComposerScripts.php + system/Config/Routes.php + system/Test/bootstrap.php + system/Test/ControllerTester.php + system/Test/FeatureTestCase.php + + From 34342624f04779c221b81ee1fae11d5d03279917 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Oct 2023 11:27:49 +0900 Subject: [PATCH 04/17] chore: update gitignore for PHPUnit10 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 74c6d0ce6c4f..71cf213fbfaf 100644 --- a/.gitignore +++ b/.gitignore @@ -126,5 +126,6 @@ nb-configuration.xml /results/ /phpunit*.xml /.phpunit.*.cache +/.phpunit.cache /.php-cs-fixer.php From 9568dc9ab4049e4f9b92af8c7bb9abc4b8504dcb Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Oct 2023 11:41:12 +0900 Subject: [PATCH 05/17] test: update PHPUnit error message for PHPUnit10 --- tests/system/Validation/ValidationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/Validation/ValidationTest.php b/tests/system/Validation/ValidationTest.php index 81119249cc0d..6b6f1a8129c5 100644 --- a/tests/system/Validation/ValidationTest.php +++ b/tests/system/Validation/ValidationTest.php @@ -1593,7 +1593,7 @@ public function testPlaceholderReplacementTestFails(): void { // to test if placeholderReplacementResultDetermination() works we provoke and expect an exception $this->expectException(ExpectationFailedException::class); - $this->expectExceptionMessage('Failed asserting that \'filter[{id}]\' does not contain "{id}".'); + $this->expectExceptionMessage('Failed asserting that \'filter[{id}]\' [ASCII](length: 12) does not contain "{id}" [ASCII](length: 4).'); $this->validation->setRule('foo', 'foo-label', 'required|filter[{id}]'); From 18d6a84d2931958fe615dd7b670a67bbcc29c1f9 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Oct 2023 11:41:49 +0900 Subject: [PATCH 06/17] style: break long line --- tests/system/Validation/ValidationTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/system/Validation/ValidationTest.php b/tests/system/Validation/ValidationTest.php index 6b6f1a8129c5..f47e62b0f319 100644 --- a/tests/system/Validation/ValidationTest.php +++ b/tests/system/Validation/ValidationTest.php @@ -1593,7 +1593,9 @@ public function testPlaceholderReplacementTestFails(): void { // to test if placeholderReplacementResultDetermination() works we provoke and expect an exception $this->expectException(ExpectationFailedException::class); - $this->expectExceptionMessage('Failed asserting that \'filter[{id}]\' [ASCII](length: 12) does not contain "{id}" [ASCII](length: 4).'); + $this->expectExceptionMessage( + 'Failed asserting that \'filter[{id}]\' [ASCII](length: 12) does not contain "{id}" [ASCII](length: 4).' + ); $this->validation->setRule('foo', 'foo-label', 'required|filter[{id}]'); From 8b137fb667460166d0b91b637e47fbd6f41d37cd Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 21 Oct 2023 08:55:35 +0900 Subject: [PATCH 07/17] chore: update nexusphp/tachycardia --- composer.json | 2 +- phpunit.xml.dist | 22 ++++------------------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index 89b97276b64a..4e8ae89a109a 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "kint-php/kint": "^5.0.4", "mikey179/vfsstream": "^1.6", "nexusphp/cs-config": "^3.6", - "nexusphp/tachycardia": "^1.0", + "nexusphp/tachycardia": "^2.0", "phpstan/extension-installer": "^1.3", "phpstan/phpstan": "^1.10.2", "phpstan/phpstan-strict-rules": "^1.5", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b23efcde71b6..266435dbcec4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -18,24 +18,10 @@ - - - - - 0.50 - - - 30 - - - 2 - - - false - - - - + + + + From bec9e6db9305c9ddd8831ed259f1f8d7dcf35827 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 27 Oct 2023 13:46:56 +0900 Subject: [PATCH 08/17] chore: change config section order --- phpunit.xml.dist | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 266435dbcec4..e1ffb70393e7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,27 +12,17 @@ - - - tests/system - - - - - - - - - - - - + + + tests/system + + system @@ -51,4 +41,14 @@ system/Test/FeatureTestCase.php + + + + + + + + + + From 38d4aa7a87fecad2926805a536ae0c00827424ba Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 26 Feb 2024 12:00:56 +0900 Subject: [PATCH 09/17] test: workaround for errors on PHPUnit 10 and PHP 8.3 --- tests/system/Autoloader/AutoloaderTest.php | 4 ++++ tests/system/CodeIgniterTest.php | 4 ++++ tests/system/Helpers/URLHelper/MiscUrlTest.php | 8 ++++++++ tests/system/View/ParserPluginTest.php | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/tests/system/Autoloader/AutoloaderTest.php b/tests/system/Autoloader/AutoloaderTest.php index fbefbe20b0ef..b0e7852c2910 100644 --- a/tests/system/Autoloader/AutoloaderTest.php +++ b/tests/system/Autoloader/AutoloaderTest.php @@ -396,6 +396,10 @@ public function testAutoloaderLoadsNonClassFiles(): void */ public function testLoadHelpers(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $config = new Autoload(); $config->helpers[] = 'form'; diff --git a/tests/system/CodeIgniterTest.php b/tests/system/CodeIgniterTest.php index 4dc50d328004..d6e93ab7a6d0 100644 --- a/tests/system/CodeIgniterTest.php +++ b/tests/system/CodeIgniterTest.php @@ -52,6 +52,10 @@ protected function setUp(): void parent::setUp(); $this->resetServices(); + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; $this->codeigniter = new MockCodeIgniter(new App()); diff --git a/tests/system/Helpers/URLHelper/MiscUrlTest.php b/tests/system/Helpers/URLHelper/MiscUrlTest.php index 777d8637b352..6670b9fec4d2 100644 --- a/tests/system/Helpers/URLHelper/MiscUrlTest.php +++ b/tests/system/Helpers/URLHelper/MiscUrlTest.php @@ -63,6 +63,10 @@ protected function tearDown(): void */ public function testPreviousURLUsesSessionFirst(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $uri1 = 'http://example.com/one?two'; $uri2 = 'http://example.com/two?foo'; @@ -97,6 +101,10 @@ private function createRequest(string $uri): void */ public function testPreviousURLUsesRefererIfNeeded(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $uri1 = 'http://example.com/one?two'; $_SERVER['HTTP_REFERER'] = $uri1; diff --git a/tests/system/View/ParserPluginTest.php b/tests/system/View/ParserPluginTest.php index 3e675ae620c9..d0295ef387b5 100644 --- a/tests/system/View/ParserPluginTest.php +++ b/tests/system/View/ParserPluginTest.php @@ -52,6 +52,10 @@ public function testCurrentURL(): void */ public function testPreviousURL(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $template = '{+ previous_url +}'; // Ensure a previous URL exists to work with. From 100ea8a6abc1371e5303df0885b5cbda2dcf1ca9 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 5 Mar 2024 16:37:20 +0900 Subject: [PATCH 10/17] chore: change output dir for coverage.txt 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. --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e1ffb70393e7..45b6b07231c4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,7 +9,7 @@ - + From 5bf6de94164b1eefef7543c1cbe04d8a5f707066 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 5 Mar 2024 17:03:56 +0900 Subject: [PATCH 11/17] fix: update toString() params 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 --- system/Test/Constraints/SeeInDatabase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Test/Constraints/SeeInDatabase.php b/system/Test/Constraints/SeeInDatabase.php index 31297f53a0d7..faf874be9ce8 100644 --- a/system/Test/Constraints/SeeInDatabase.php +++ b/system/Test/Constraints/SeeInDatabase.php @@ -67,7 +67,7 @@ protected function failureDescription($table): string return sprintf( "a row in the table [%s] matches the attributes \n%s\n\n%s", $table, - $this->toString(JSON_PRETTY_PRINT), + $this->toString(false, JSON_PRETTY_PRINT), $this->getAdditionalInfo($table) ); } @@ -113,7 +113,7 @@ protected function getAdditionalInfo(string $table): string * * @param int $options */ - public function toString($options = 0): string + public function toString(bool $exportObjects = false, $options = 0): string { return json_encode($this->data, $options); } From 21e99b5c000c707d70e2739850ac01e3528daea3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 5 Mar 2024 17:31:31 +0900 Subject: [PATCH 12/17] test: workaround for errors on PHPUnit 10 and PHP 8.3 --- tests/system/Commands/GenerateKeyTest.php | 4 +++ tests/system/CommonFunctionsSendTest.php | 4 +++ tests/system/CommonFunctionsTest.php | 36 +++++++++++++++++++ tests/system/Config/BaseConfigTest.php | 4 +++ tests/system/Config/DotEnvTest.php | 4 +++ tests/system/Config/ServicesTest.php | 4 +++ tests/system/Events/EventsTest.php | 4 +++ tests/system/Filters/HoneypotTest.php | 4 +++ .../system/HTTP/ContentSecurityPolicyTest.php | 9 +++++ tests/system/HTTP/DownloadResponseTest.php | 9 +++++ tests/system/HTTP/IncomingRequestTest.php | 4 +++ tests/system/HTTP/RedirectResponseTest.php | 4 +++ tests/system/HTTP/ResponseSendTest.php | 12 +++++++ tests/system/Helpers/FormHelperTest.php | 4 +++ .../system/RESTful/ResourceControllerTest.php | 4 +++ .../system/RESTful/ResourcePresenterTest.php | 4 +++ .../SecurityCSRFSessionRandomizeTokenTest.php | 4 +++ .../Security/SecurityCSRFSessionTest.php | 4 +++ tests/system/Session/SessionTest.php | 4 +++ tests/system/Test/ControllerTestTraitTest.php | 9 +++++ tests/system/Test/TestCaseEmissionsTest.php | 8 +++++ 21 files changed, 143 insertions(+) diff --git a/tests/system/Commands/GenerateKeyTest.php b/tests/system/Commands/GenerateKeyTest.php index 151400745ef4..80d0879bc958 100644 --- a/tests/system/Commands/GenerateKeyTest.php +++ b/tests/system/Commands/GenerateKeyTest.php @@ -41,6 +41,10 @@ protected function setUp(): void } $this->resetEnvironment(); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } protected function tearDown(): void diff --git a/tests/system/CommonFunctionsSendTest.php b/tests/system/CommonFunctionsSendTest.php index f26e40cadf14..ee4090264da2 100644 --- a/tests/system/CommonFunctionsSendTest.php +++ b/tests/system/CommonFunctionsSendTest.php @@ -27,6 +27,10 @@ protected function setUp(): void parent::setUp(); unset($_ENV['foo'], $_SERVER['foo']); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } /** diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index bfe54e291529..536098bb0227 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -275,6 +275,10 @@ public function testEscapeRecursiveArrayRaw(): void */ public function testSessionInstance(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $this->injectSessionMock(); $this->assertInstanceOf(Session::class, session()); @@ -286,6 +290,10 @@ public function testSessionInstance(): void */ public function testSessionVariable(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $this->injectSessionMock(); $_SESSION['notbogus'] = 'Hi there'; @@ -299,6 +307,10 @@ public function testSessionVariable(): void */ public function testSessionVariableNotThere(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $this->injectSessionMock(); $_SESSION['bogus'] = 'Hi there'; @@ -423,6 +435,10 @@ public function testModelExistsAbsoluteClassname(): void */ public function testOldInput(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $this->injectSessionMock(); // setup from RedirectResponseTest... $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -458,6 +474,10 @@ public function testOldInput(): void */ public function testOldInputSerializeData(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $this->injectSessionMock(); // setup from RedirectResponseTest... $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -493,6 +513,10 @@ public function testOldInputSerializeData(): void */ public function testOldInputArray(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $this->injectSessionMock(); // setup from RedirectResponseTest... $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -610,6 +634,10 @@ public function testRedirectResponseCookies1(): void */ public function testTrace(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + ob_start(); trace(); $content = ob_get_clean(); @@ -633,6 +661,10 @@ public function testViewNotSaveData(): void */ public function testForceHttpsNullRequestAndResponse(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $this->assertNull(Services::response()->header('Location')); Services::response()->setCookie('force', 'cookie'); @@ -748,6 +780,10 @@ public function testDWithCSP(): void */ public function testTraceWithCSP(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $this->resetServices(); /** @var App $config */ diff --git a/tests/system/Config/BaseConfigTest.php b/tests/system/Config/BaseConfigTest.php index a0f681f0c7f0..1b59fc623e52 100644 --- a/tests/system/Config/BaseConfigTest.php +++ b/tests/system/Config/BaseConfigTest.php @@ -52,6 +52,10 @@ protected function setUp(): void } BaseConfig::reset(); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } protected function tearDown(): void diff --git a/tests/system/Config/DotEnvTest.php b/tests/system/Config/DotEnvTest.php index 6348b1567a59..d5ad1448a036 100644 --- a/tests/system/Config/DotEnvTest.php +++ b/tests/system/Config/DotEnvTest.php @@ -43,6 +43,10 @@ protected function setUp(): void $file = 'unreadable.env'; $path = rtrim($this->fixturesFolder, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file; chmod($path, 0644); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } protected function tearDown(): void diff --git a/tests/system/Config/ServicesTest.php b/tests/system/Config/ServicesTest.php index f2fa03fa7a17..24d2afb7302e 100644 --- a/tests/system/Config/ServicesTest.php +++ b/tests/system/Config/ServicesTest.php @@ -63,6 +63,10 @@ protected function setUp(): void parent::setUp(); $this->original = $_SERVER; + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } protected function tearDown(): void diff --git a/tests/system/Events/EventsTest.php b/tests/system/Events/EventsTest.php index d22954c83b0b..dc8af0977455 100644 --- a/tests/system/Events/EventsTest.php +++ b/tests/system/Events/EventsTest.php @@ -36,6 +36,10 @@ protected function setUp(): void $this->manager = new MockEvents(); Events::removeAllListeners(); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } protected function tearDown(): void diff --git a/tests/system/Filters/HoneypotTest.php b/tests/system/Filters/HoneypotTest.php index 22d2bc0649cd..cb2d804d4cbc 100644 --- a/tests/system/Filters/HoneypotTest.php +++ b/tests/system/Filters/HoneypotTest.php @@ -49,6 +49,10 @@ protected function setUp(): void unset($_POST[$this->honey->name]); $_SERVER['REQUEST_METHOD'] = 'POST'; $_POST[$this->honey->name] = 'hey'; + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } public function testBeforeTriggered(): void diff --git a/tests/system/HTTP/ContentSecurityPolicyTest.php b/tests/system/HTTP/ContentSecurityPolicyTest.php index f6e347dad17f..6502579eadf4 100644 --- a/tests/system/HTTP/ContentSecurityPolicyTest.php +++ b/tests/system/HTTP/ContentSecurityPolicyTest.php @@ -33,6 +33,15 @@ final class ContentSecurityPolicyTest extends CIUnitTestCase private ?Response $response = null; private ?ContentSecurityPolicy $csp = null; + protected function setUp(): void + { + parent::setUp(); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + } + // Having this method as setUp() doesn't work - can't find Config\App !? protected function prepare(bool $CSPEnabled = true): void { diff --git a/tests/system/HTTP/DownloadResponseTest.php b/tests/system/HTTP/DownloadResponseTest.php index 65cddf0a5a3c..b1071e39dc01 100644 --- a/tests/system/HTTP/DownloadResponseTest.php +++ b/tests/system/HTTP/DownloadResponseTest.php @@ -26,6 +26,15 @@ */ final class DownloadResponseTest extends CIUnitTestCase { + protected function setUp(): void + { + parent::setUp(); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + } + protected function tearDown(): void { if (isset($_SERVER['HTTP_USER_AGENT'])) { diff --git a/tests/system/HTTP/IncomingRequestTest.php b/tests/system/HTTP/IncomingRequestTest.php index a8cc2d628404..7060af62f31f 100644 --- a/tests/system/HTTP/IncomingRequestTest.php +++ b/tests/system/HTTP/IncomingRequestTest.php @@ -42,6 +42,10 @@ protected function setUp(): void $this->request = $this->createRequest($config); $_POST = $_GET = $_SERVER = $_REQUEST = $_ENV = $_COOKIE = $_SESSION = []; + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } private function createRequest(?App $config = null, $body = null, ?string $path = null): IncomingRequest diff --git a/tests/system/HTTP/RedirectResponseTest.php b/tests/system/HTTP/RedirectResponseTest.php index 37c151ff9ace..4abc965d59da 100644 --- a/tests/system/HTTP/RedirectResponseTest.php +++ b/tests/system/HTTP/RedirectResponseTest.php @@ -60,6 +60,10 @@ protected function setUp(): void new UserAgent() ); Services::injectMock('request', $this->request); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } public function testRedirectToFullURI(): void diff --git a/tests/system/HTTP/ResponseSendTest.php b/tests/system/HTTP/ResponseSendTest.php index 5e46b341a288..a4cc67765d3d 100644 --- a/tests/system/HTTP/ResponseSendTest.php +++ b/tests/system/HTTP/ResponseSendTest.php @@ -50,6 +50,10 @@ final class ResponseSendTest extends CIUnitTestCase */ public function testHeadersMissingDate(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $response = new Response(new App()); $response->pretend(false); @@ -83,6 +87,10 @@ public function testHeadersMissingDate(): void */ public function testHeadersWithCSP(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $this->resetFactories(); $this->resetServices(); @@ -119,6 +127,10 @@ public function testHeadersWithCSP(): void */ public function testRedirectResponseCookies(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $loginTime = time(); $response = new Response(new App()); diff --git a/tests/system/Helpers/FormHelperTest.php b/tests/system/Helpers/FormHelperTest.php index adae7bbb1094..2ee32da768fc 100644 --- a/tests/system/Helpers/FormHelperTest.php +++ b/tests/system/Helpers/FormHelperTest.php @@ -34,6 +34,10 @@ protected function setUp(): void parent::setUp(); helper('form'); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } private function setRequest(): void diff --git a/tests/system/RESTful/ResourceControllerTest.php b/tests/system/RESTful/ResourceControllerTest.php index 0eb040030adb..471ae58157c5 100644 --- a/tests/system/RESTful/ResourceControllerTest.php +++ b/tests/system/RESTful/ResourceControllerTest.php @@ -60,6 +60,10 @@ protected function setUp(): void $this->resetServices(true); $this->resetFactories(); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } private function createCodeigniter(): void diff --git a/tests/system/RESTful/ResourcePresenterTest.php b/tests/system/RESTful/ResourcePresenterTest.php index 69e9b33d9a3f..975f0d2b9e0c 100644 --- a/tests/system/RESTful/ResourcePresenterTest.php +++ b/tests/system/RESTful/ResourcePresenterTest.php @@ -54,6 +54,10 @@ protected function setUp(): void $this->resetServices(true); $this->resetFactories(); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } private function createCodeigniter(): void diff --git a/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php b/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php index 9b7e88933f2f..47dea517f687 100644 --- a/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php +++ b/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php @@ -69,6 +69,10 @@ protected function setUp(): void Factories::injectMock('config', 'Security', $this->config); $this->injectSession($this->hash); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } private function createSession($options = []): Session diff --git a/tests/system/Security/SecurityCSRFSessionTest.php b/tests/system/Security/SecurityCSRFSessionTest.php index 79750d0a90eb..397932889182 100644 --- a/tests/system/Security/SecurityCSRFSessionTest.php +++ b/tests/system/Security/SecurityCSRFSessionTest.php @@ -62,6 +62,10 @@ protected function setUp(): void Factories::injectMock('config', 'Security', $this->config); $this->injectSession($this->hash); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } private function createSession($options = []): Session diff --git a/tests/system/Session/SessionTest.php b/tests/system/Session/SessionTest.php index ae40fe9c09ab..63009e5230a0 100644 --- a/tests/system/Session/SessionTest.php +++ b/tests/system/Session/SessionTest.php @@ -40,6 +40,10 @@ protected function setUp(): void $_COOKIE = []; $_SESSION = []; + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); } protected function getInstance($options = []) diff --git a/tests/system/Test/ControllerTestTraitTest.php b/tests/system/Test/ControllerTestTraitTest.php index d8316e74425c..26c356116db5 100644 --- a/tests/system/Test/ControllerTestTraitTest.php +++ b/tests/system/Test/ControllerTestTraitTest.php @@ -39,6 +39,15 @@ final class ControllerTestTraitTest extends CIUnitTestCase { use ControllerTestTrait; + protected function setUp(): void + { + parent::setUp(); + + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + } + public function testBadController(): void { $this->expectException('InvalidArgumentException'); diff --git a/tests/system/Test/TestCaseEmissionsTest.php b/tests/system/Test/TestCaseEmissionsTest.php index 7a43aefdc44b..26d7ee7898d3 100644 --- a/tests/system/Test/TestCaseEmissionsTest.php +++ b/tests/system/Test/TestCaseEmissionsTest.php @@ -48,6 +48,10 @@ final class TestCaseEmissionsTest extends CIUnitTestCase */ public function testHeadersEmitted(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $response = new Response(new App()); $response->pretend(false); @@ -76,6 +80,10 @@ public function testHeadersEmitted(): void */ public function testHeadersNotEmitted(): void { + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + restore_error_handler(); + $response = new Response(new App()); $response->pretend(false); From a0849d5a6d88baba9d6a592890d38f608aba824c Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 5 Mar 2024 18:00:20 +0900 Subject: [PATCH 13/17] test: fix test for error handling 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 --- .../system/Security/SecurityCSRFSessionRandomizeTokenTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php b/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php index 47dea517f687..c2d11db26a05 100644 --- a/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php +++ b/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php @@ -32,6 +32,7 @@ use Config\Logger as LoggerConfig; use Config\Security as SecurityConfig; use Config\Session as SessionConfig; +use PHPUnit\Framework\Attributes\WithoutErrorHandler; /** * @runTestsInSeparateProcesses @@ -170,8 +171,11 @@ public function testCSRFVerifyPostThrowsExceptionOnNoMatch(): void $security->verify($request); } + #[WithoutErrorHandler] public function testCSRFVerifyPostInvalidToken(): void { + Services::exceptions()->initialize(); + $this->expectException(SecurityException::class); $this->expectExceptionMessage('The action you requested is not allowed.'); From bf733f3f5d779ae6d5a7e756c20e45d3896e7536 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 5 Mar 2024 19:10:26 +0900 Subject: [PATCH 14/17] test: fix CommonFunctionsTest::testTraceWithCSP() There was 1 error: 1) CodeIgniter\CommonFunctionsTest::testTraceWithCSP Test was run in child process and ended unexpectedly --- tests/system/CommonFunctionsTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/system/CommonFunctionsTest.php b/tests/system/CommonFunctionsTest.php index 536098bb0227..35866f640ee9 100644 --- a/tests/system/CommonFunctionsTest.php +++ b/tests/system/CommonFunctionsTest.php @@ -795,6 +795,11 @@ public function testTraceWithCSP(): void Kint::$cli_detection = false; + // Workaround for errors on PHPUnit 10 and PHP 8.3. + // See https://github.com/sebastianbergmann/phpunit/issues/5403#issuecomment-1906810619 + // `$app->initialize()` sets error handler. + restore_error_handler(); + $this->expectOutputRegex('/