Nimut / testing-framework

TYPO3 testing framework that provides base classes and configuration for PHPUnit tests
GNU General Public License v2.0
52 stars 25 forks source link

Support .env file to set environment variables #36

Closed robert197 closed 7 years ago

robert197 commented 7 years ago

This pull request enables a confortable way to set environment variables.

helhum commented 7 years ago

@robert197 can you elaborate on your use case? Would using https://github.com/helhum/dotenv-connector cover your use case?

helhum commented 7 years ago

And you can specify env vars to be set in a phpunit.xml …

helhum commented 7 years ago

@robert197 I still don't understand your use case. What exactly is not covered with helhum/dotenv-connector?

robert197 commented 7 years ago

@helhum We wanted to use a standard way, which is followed by other technologies in web development. The reason and use case of this PR is to make tests work not only in CI but also locally after clonning an extension. We think tests should be ran localy before they are pushed into build server. At least this is the recommended way in software engineering. helhum/dotenv-connector is nice :+1: . but isnt it easier to put only .env file into the root of a project and make it work without doing extra stuff? I think this is how other frameworks work. I hope we didn't misunderstood this framework but if so, that would be great, if you could inform me :).

helhum commented 7 years ago

@robert197 if you have the testing framework as dev dependency, you can just add dotenv connector as dev dependency as well. then you can just put a .env file next to the composer.json and everything there is exposed as env vars to the testing framework without touching a line of code

robert197 commented 7 years ago

ok, i tried to integrate helhum/dotenv-connector but because of php version its not possible. maybe that could be the reason to use the previous solution?

helhum commented 7 years ago

@robert197 helhum/dotenv-connector 1.x is compatible with PHP 5.3.7 or higher.

robert197 commented 7 years ago

hey, is it possible to merge this changes?

IchHabRecht commented 7 years ago

Sorry, but for me it is still unclear why this change is needed and you cannot use helhum/dotenv-connector in your project?

robert197 commented 7 years ago

@IchHabRecht i thought because of https://de.wikipedia.org/wiki/Don%E2%80%99t_repeat_yourself

We have a lot of extensions which are used to be maintained. It would be better for us to centralize some of dependencies. Also less code or configuration is made in a SUT, less can be broken.

helhum commented 7 years ago

Thanks for your efforts.

However I still fail to see how we can improve things for our users without forcing them to use one solution (.env)

There are other ways to achieve the same like exporting the env vars in the shell or creating your own phpunit xml config and define env vars there.

You also can use the dotenv connector as pointed out in your setups. No change is required here for any of these solutions.

It would be better for us to centralize some of dependencies.

That is also easily possible. Just create your own testing package that requires everything you need and only require this package within your extensions.

Centralizing dependencies would mean forcing users to fetch a package which they don't need because the are more comfortable with other solution. The beauty of composer is giving control to users composing packages that fit their own needs.

Long story short: I'm closing this PR now. Everything you need as described in your use case is there. Just use it :)

robert197 commented 7 years ago

but... this feature was optional...

helhum commented 7 years ago

a requirement is not optional ;)

robert197 commented 7 years ago

okay nevermind, have a great day 👍

helhum commented 7 years ago

Thanks :) sorry for the back and forth and the misunderstandings!