1717use CodeIgniter \Test \StreamFilterTrait ;
1818use PHPUnit \Framework \Attributes \Group ;
1919
20+ /**
21+ * @return array<string, array<string, mixed>>|false
22+ */
23+ function ini_get_all (?string $ extension = null , bool $ details = true ): array |false
24+ {
25+ return CheckPhpIniTest::$ iniGetAllReturn ?? \ini_get_all ($ extension , $ details );
26+ }
27+
2028/**
2129 * @internal
2230 */
@@ -25,6 +33,18 @@ final class CheckPhpIniTest extends CIUnitTestCase
2533{
2634 use StreamFilterTrait;
2735
36+ /**
37+ * @var array<string, array<string, mixed>>|null
38+ */
39+ public static ?array $ iniGetAllReturn = null ;
40+
41+ protected function tearDown (): void
42+ {
43+ parent ::tearDown ();
44+
45+ self ::$ iniGetAllReturn = null ;
46+ }
47+
2848 public function testCheckIni (): void
2949 {
3050 $ output = self ::getPrivateMethodInvoker (CheckPhpIni::class, 'checkIni ' )();
@@ -51,6 +71,26 @@ public function testCheckIniOpcache(): void
5171 $ this ->assertSame ($ expected , $ output ['opcache.save_comments ' ]);
5272 }
5373
74+ public function testCheckIniCastsNullIniValuesToString (): void
75+ {
76+ self ::$ iniGetAllReturn = [
77+ 'default_charset ' => [
78+ 'global_value ' => null ,
79+ 'local_value ' => null ,
80+ ],
81+ ];
82+
83+ $ output = self ::getPrivateMethodInvoker (CheckPhpIni::class, 'checkIni ' )();
84+
85+ $ expected = [
86+ 'global ' => '' ,
87+ 'current ' => '' ,
88+ 'recommended ' => 'UTF-8 ' ,
89+ 'remark ' => '' ,
90+ ];
91+ $ this ->assertSame ($ expected , $ output ['default_charset ' ]);
92+ }
93+
5494 public function testRunCli (): void
5595 {
5696 CheckPhpIni::run (true );
0 commit comments