ENH Add lightweight test override for Environment::isCli()
This commit is contained in:
parent
054c2389c9
commit
a75ac1d98b
|
@ -35,6 +35,13 @@ class Environment
|
||||||
*/
|
*/
|
||||||
protected static $env = [];
|
protected static $env = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by unit tests to override `isCli()`
|
||||||
|
* This is not config. Use reflection to change the value
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
private static ?bool $isCliOverride = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract env vars prior to modification
|
* Extract env vars prior to modification
|
||||||
*
|
*
|
||||||
|
@ -251,6 +258,9 @@ class Environment
|
||||||
*/
|
*/
|
||||||
public static function isCli()
|
public static function isCli()
|
||||||
{
|
{
|
||||||
|
if (self::$isCliOverride !== null) {
|
||||||
|
return self::$isCliOverride;
|
||||||
|
}
|
||||||
return in_array(strtolower(php_sapi_name() ?? ''), ['cli', 'phpdbg']);
|
return in_array(strtolower(php_sapi_name() ?? ''), ['cli', 'phpdbg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue