Skip to content

Commit 010fbd0

Browse files
committed
fpm: add support for passing ini files to tester
1 parent 43c3afe commit 010fbd0

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

sapi/fpm/tests/tester.inc

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Tester
5656
/**
5757
* @var array
5858
*/
59-
static private array $filesToClean = ['.user.ini'];
59+
static private array $filesToClean = ['.user.ini', 'php.ini'];
6060

6161
/**
6262
* @var bool
@@ -496,12 +496,12 @@ class Tester
496496
/**
497497
* Start PHP-FPM master process
498498
*
499-
* @param array $extraArgs Command extra arguments.
500-
* @param bool $forceStderr Whether to output to stderr so error log is used.
501-
* @param bool $daemonize Whether to start FPM daemonized
502-
* @param array $extensions List of extension to add if shared build used.
503-
* @param array $iniEntries List of ini entries to use.
504-
* @param array|null $envVars List of env variable to execute FPM with or null to use the current ones.
499+
* @param array $extraArgs Command extra arguments.
500+
* @param bool $forceStderr Whether to output to stderr so error log is used.
501+
* @param bool $daemonize Whether to start FPM daemonized
502+
* @param array $extensions List of extension to add if shared build used.
503+
* @param array|string $iniEntries List of ini entries or content of php.ini to use.
504+
* @param array|null $envVars List of env variable to execute FPM with or null to use the current ones.
505505
*
506506
* @return bool
507507
* @throws \Exception
@@ -511,7 +511,7 @@ class Tester
511511
bool $forceStderr = true,
512512
bool $daemonize = false,
513513
array $extensions = [],
514-
array $iniEntries = [],
514+
array|string $iniEntries = [],
515515
?array $envVars = null,
516516
) {
517517
$configFile = $this->createConfig();
@@ -536,8 +536,15 @@ class Tester
536536
}
537537
}
538538

539-
foreach ($iniEntries as $iniEntryName => $iniEntryValue) {
540-
$cmd[] = '-d' . $iniEntryName . '=' . $iniEntryValue;
539+
if (is_string($iniEntries)) {
540+
$iniFile = __DIR__ . '/php.ini';
541+
$this->trace('Writing php.ini file', $iniEntries, isFile: true);
542+
file_put_contents($iniFile, $iniEntries);
543+
$cmd[] = '-c' . $iniFile;
544+
} else {
545+
foreach ($iniEntries as $iniEntryName => $iniEntryValue) {
546+
$cmd[] = '-d' . $iniEntryName . '=' . $iniEntryValue;
547+
}
541548
}
542549

543550
if ($envVars['TEST_FPM_RUN_AS_ROOT'] ?? getenv('TEST_FPM_RUN_AS_ROOT')) {

0 commit comments

Comments
 (0)