@@ -36,6 +36,9 @@ class Job
3636 /** @var string[] test arguments */
3737 private $ args ;
3838
39+ /** @var string[] environment variables for test */
40+ private $ envVars ;
41+
3942 /** @var string test output */
4043 private $ output ;
4144
@@ -65,11 +68,12 @@ class Job
6568 * @param string test file name
6669 * @return void
6770 */
68- public function __construct ($ testFile , PhpInterpreter $ interpreter , array $ args = NULL )
71+ public function __construct ($ testFile , PhpInterpreter $ interpreter , array $ args = NULL , array $ envVars = NULL )
6972 {
7073 $ this ->file = (string ) $ testFile ;
7174 $ this ->interpreter = $ interpreter ;
7275 $ this ->args = (array ) $ args ;
76+ $ this ->envVars = (array ) $ envVars ;
7377 }
7478
7579
@@ -80,8 +84,10 @@ public function __construct($testFile, PhpInterpreter $interpreter, array $args
8084 */
8185 public function run ($ flags = NULL )
8286 {
83- putenv (Environment::RUNNER . '=1 ' );
84- putenv (Environment::COLORS . '= ' . (int ) Environment::$ useColors );
87+ foreach ($ this ->envVars as $ name => $ value ) {
88+ putenv ("$ name= $ value " );
89+ }
90+
8591 $ this ->proc = proc_open (
8692 $ this ->interpreter ->getCommandLine ()
8793 . ' -d register_argc_argv=on ' . Helpers::escapeArg ($ this ->file ) . ' ' . implode (' ' , $ this ->args ),
@@ -96,6 +102,10 @@ public function run($flags = NULL)
96102 ['bypass_shell ' => TRUE ]
97103 );
98104
105+ foreach (array_keys ($ this ->envVars ) as $ name ) {
106+ putenv ("$ name " );
107+ }
108+
99109 list ($ stdin , $ this ->stdout , $ stderr ) = $ pipes ;
100110 fclose ($ stdin );
101111 if ($ flags & self ::RUN_COLLECT_ERRORS ) {
0 commit comments