Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

296
Views
¿Cómo anular las variables exportadas en phpunit?

Sé que puedo configurar una variable de entorno dentro de mi phpunit.xml

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

Así que esto funciona muy bien

 phpunit // foo

Sin embargo, ese valor se ignora si la variable se ha exportado en el shell principal.

 export MY_VARIABLE=bar phpunit // bar

Necesito exportar este valor para otros procesos secundarios, pero realmente no quiero abrir otro shell solo para ejecutar pruebas. ¿Cómo puedo configurar phpunit para usar los valores definidos solo para el entorno de prueba?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Por defecto, las variables de entorno definidas en phpunit.xml son anuladas por el entorno de shell. Este comportamiento es coherente con la forma en que se suelen utilizar las variables de entorno en las herramientas de línea de comandos. Al configurar una variable de entorno, generalmente esperamos que se pase a la herramienta y se use en lugar del valor configurado.

El nuevo atributo de force se introdujo en PHPUnit 6.3 para permitirnos deshabilitar este comportamiento para las variables elegidas:

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

Problemas relacionados con github:

  • 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!