Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to force set an environment variable from phpunit.xml #1276

Closed
gena01 opened this issue May 29, 2014 · 7 comments
Closed

Provide a way to force set an environment variable from phpunit.xml #1276

gena01 opened this issue May 29, 2014 · 7 comments

Comments

@gena01
Copy link

gena01 commented May 29, 2014

I would love to be able to override an environment variable when running unit tests. This is currently failing if that variable is already set before I run PHPUnit.

See here:
https://github.com/sebastianbergmann/phpunit/blob/master/src/Util/Configuration.php#L550

@whatthejeff
Copy link
Contributor

It works this way to facilitate a pretty common workflow (see #1181).

@richardkmiller
Copy link

I am also interested in this. The idea for us is that developers use a dotenv file to specify a database -- development or production -- but when PHPUnit runs, it should override this env and always choose the testing database.

How about something like this?
<env name="database" value="testing" override="true" />

@gabeguz
Copy link

gabeguz commented Dec 11, 2014

#1181 seems backwards to me, but... if that's the way it is, that's the way it is. In my opinion, environment variables can be overridden by configuration variables which in turn can be overridden by command line flags.

@ramsey
Copy link

ramsey commented Apr 29, 2015

I was expecting the <env> value set in my phpunit.xml file to override the one set in my .bashrc file in my console, but it looks like #1181 changed the behavior so that I can no longer do this. I don't want to unset my console's environment variables each time I run tests. Is there some work-around for this?

@lucacri
Copy link

lucacri commented Aug 7, 2015

Same problem for me. It definitely needs to have some sort of override since most of the environment I create have ENV variables set for the user..

@terbooter
Copy link

+1
phpunit.xml should override ENV vars

@sebastianbergmann
Copy link
Owner

Dear contributor,

let me start by apologizing for not commenting and/or working on the issue you have reported or merging the pull request you have sent sooner.

PHPUnit 5.0 was released today. And today I am closing all open bug reports and pull requests for PHPUnit and its dependencies that I maintain. Please do not interpret the closing of this ticket as an insult or a lack of interest in your problem. I am sorry for any inconvenience this may cause.

If the topic of this ticket is still relevant then please open a new ticket or send a new pull request. If your ticket or pull request is about a defect then please check whether the issue still exists in PHPUnit 4.8 (which will received bug fixes until August 2016). If your ticket or pull request is about a new feature then please port your patch PHPUnit 5.0 before sending a new pull request.

I hope that today's extreme backlog grooming will allow me to respond to bug reports and pull requests in a more timely manner in the future.

Thank you for your understanding,
Sebastian

Repository owner locked and limited conversation to collaborators Oct 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants