Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

302
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda