77
88namespace Tester \Runner ;
99
10- use Tester \Environment ;
1110use Tester \Helpers ;
1211
1312
@@ -36,6 +35,9 @@ class Job
3635 /** @var string[] test arguments */
3736 private $ args ;
3837
38+ /** @var string[] environment variables for test */
39+ private $ envVars ;
40+
3941 /** @var string test output */
4042 private $ output ;
4143
@@ -65,11 +67,12 @@ class Job
6567 * @param string test file name
6668 * @return void
6769 */
68- public function __construct ($ testFile , PhpInterpreter $ interpreter , array $ args = NULL )
70+ public function __construct ($ testFile , PhpInterpreter $ interpreter , array $ args = NULL , array $ envVars = NULL )
6971 {
7072 $ this ->file = (string ) $ testFile ;
7173 $ this ->interpreter = $ interpreter ;
7274 $ this ->args = (array ) $ args ;
75+ $ this ->envVars = (array ) $ envVars ;
7376 }
7477
7578
@@ -80,8 +83,10 @@ public function __construct($testFile, PhpInterpreter $interpreter, array $args
8083 */
8184 public function run ($ flags = NULL )
8285 {
83- putenv (Environment::RUNNER . '=1 ' );
84- putenv (Environment::COLORS . '= ' . (int ) Environment::$ useColors );
86+ foreach ($ this ->envVars as $ name => $ value ) {
87+ putenv ("$ name= $ value " );
88+ }
89+
8590 $ this ->proc = proc_open (
8691 $ this ->interpreter ->getCommandLine ()
8792 . ' -d register_argc_argv=on ' . Helpers::escapeArg ($ this ->file ) . ' ' . implode (' ' , $ this ->args ),
@@ -96,6 +101,10 @@ public function run($flags = NULL)
96101 ['bypass_shell ' => TRUE ]
97102 );
98103
104+ foreach (array_keys ($ this ->envVars ) as $ name ) {
105+ putenv ($ name );
106+ }
107+
99108 list ($ stdin , $ this ->stdout , $ stderr ) = $ pipes ;
100109 fclose ($ stdin );
101110 if ($ flags & self ::RUN_COLLECT_ERRORS ) {
0 commit comments