]> granicus.if.org Git - php/commitdiff
Test ini file reporting functions
authorjohnstevenson <john-stevenson@blueyonder.co.uk>
Sat, 17 Mar 2018 14:01:25 +0000 (14:01 +0000)
committerJoe Watkins <krakjoe@php.net>
Tue, 27 Mar 2018 20:07:12 +0000 (22:07 +0200)
ext/standard/tests/bug73124.phpt [deleted file]
ext/standard/tests/ini_info/loaded.ini [new file with mode: 0644]
ext/standard/tests/ini_info/php_ini_loaded_file.phpt [new file with mode: 0644]
ext/standard/tests/ini_info/php_ini_scanned_files.phpt [new file with mode: 0644]
ext/standard/tests/ini_info/scandir/0.ini [new file with mode: 0644]
ext/standard/tests/php_ini_loaded_file.phpt [deleted file]

diff --git a/ext/standard/tests/bug73124.phpt b/ext/standard/tests/bug73124.phpt
deleted file mode 100644 (file)
index 7064d65..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-Bug #73124 (php_ini_scanned_files relied on PHP_CONFIG_FILE_SCAN_DIR)
---SKIPIF--
-<?php
-if (!empty(PHP_CONFIG_FILE_SCAN_DIR)) die("Skip: PHP_CONFIG_FILE_SCAN_DIR must not be available");
-?>
---FILE--
-<?php
-    $tempDir = sys_get_temp_dir();
-    putenv('PHP_INI_SCAN_DIR='.$tempDir);
-
-    $inifile = $tempDir.DIRECTORY_SEPARATOR.'scan-dir.ini';
-    @unlink($inifile);
-    file_put_contents($inifile, "\n");
-
-    $php = getenv('TEST_PHP_EXECUTABLE');
-    passthru('"'.$php.'" -r "print_r(php_ini_scanned_files());"');
-
-    putenv('PHP_INI_SCAN_DIR=');
-    @unlink($inifile);
-?>
---EXPECTREGEX--
-.*[\/\\]scan-dir\.ini.*|.*[\/\\]scan-dir\.ini
-Done
diff --git a/ext/standard/tests/ini_info/loaded.ini b/ext/standard/tests/ini_info/loaded.ini
new file mode 100644 (file)
index 0000000..c3d7967
--- /dev/null
@@ -0,0 +1 @@
+date.timezone = UTC
diff --git a/ext/standard/tests/ini_info/php_ini_loaded_file.phpt b/ext/standard/tests/ini_info/php_ini_loaded_file.phpt
new file mode 100644 (file)
index 0000000..b4ad617
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+php_ini_loaded_file() function
+--FILE--
+<?php
+    $inifile = __DIR__.DIRECTORY_SEPARATOR.'loaded.ini';
+    $php = '"'.getenv('TEST_PHP_EXECUTABLE').'"';
+    $code = '"var_dump(php_ini_loaded_file());"';
+
+    // No ini file
+    passthru($php.' -n -r '.$code);
+
+    // Specified ini file
+    passthru($php.' -c "'.$inifile.'" -r '.$code);
+?>
+--EXPECTREGEX--
+bool\(false\)
+string\(\d+\) ".*[\/\\]loaded\.ini"
diff --git a/ext/standard/tests/ini_info/php_ini_scanned_files.phpt b/ext/standard/tests/ini_info/php_ini_scanned_files.phpt
new file mode 100644 (file)
index 0000000..27d2beb
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+php_ini_scanned_files() function
+--FILE--
+<?php
+    $inifile = __DIR__.DIRECTORY_SEPARATOR.'loaded.ini';
+    $php = sprintf('"%s" -c "%s"', getenv('TEST_PHP_EXECUTABLE'), $inifile);
+    $scandir = __DIR__.DIRECTORY_SEPARATOR.'scandir';
+
+    // Empty env value disables any config option
+    putenv('PHP_INI_SCAN_DIR=');
+    passthru($php.' -r "var_dump(php_ini_scanned_files());"');
+
+    // Env value without path separator overrides any config option
+    putenv('PHP_INI_SCAN_DIR='.$scandir);
+    passthru($php.' -r "var_dump(php_ini_scanned_files());"');
+
+    // Scanned ini values override previously loaded values
+    passthru($php.' -r "var_dump(ini_get(\'date.timezone\'));"');
+?>
+--EXPECTREGEX--
+bool\(false\)
+string\(\d+\) ".*[\/\\]0\.ini
+"
+string\(\d+\) "Antarctica\/McMurdo"
diff --git a/ext/standard/tests/ini_info/scandir/0.ini b/ext/standard/tests/ini_info/scandir/0.ini
new file mode 100644 (file)
index 0000000..fa09802
--- /dev/null
@@ -0,0 +1,4 @@
+; This file is named 0.ini so it should be the first line of 
+; any scanned ini output
+
+date.timezone = Antarctica/McMurdo
\ No newline at end of file
diff --git a/ext/standard/tests/php_ini_loaded_file.phpt b/ext/standard/tests/php_ini_loaded_file.phpt
deleted file mode 100644 (file)
index 7d44158..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-Check the php_ini_loaded_file() function
---CREDITS--
-Sebastian Schürmann
-sschuermann@chip.de
-Testfest 2009 Munich
---INI--
-precision=12
---FILE--
-<?php
-var_dump(php_ini_loaded_file());
-?>
---EXPECTREGEX--
-string\(\d+\) ".*php\.ini"|bool\(false\)