Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

297
Vistas
How to override exported variables in phpunit?

I know I can set an environment variable inside my phpunit.xml

<php>
    <env name="MY_VARIABLE" value="foo" />
</php>

So this works great

phpunit
// foo

However, that value is ignored if the variable has been exported in the parent shell.

export MY_VARIABLE=bar
phpunit
// bar

I need this value exported for other child processes, but I really don't want to open another shell just to run tests. How can I configure phpunit to use the values defined for the test environment only?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

By default environment variables defined in phpunit.xml are overridden by the shell environment. This behaviour is consistent with the way environment variables are usually used in command line tools. Setting an environment variable we usually expect it to be passed to the tool and to be used instead of the configured value.

The new force attribute was introduced in PHPUnit 6.3 to let us disable this behaviour for chosen variables:

<env name="FOO" value="bar" force="true" />

Related github issues:

  • https://github.com/sebastianbergmann/phpunit/pull/2723
  • https://github.com/sebastianbergmann/phpunit/issues/2353
  • https://github.com/sebastianbergmann/phpunit/issues/1181
  • https://github.com/sebastianbergmann/phpunit/issues/2353#issuecomment-290702962
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda