Comments (15)
I have exactly the same issue ; no matter how I try to set the env, it always use dev.
I tried to set it in :
- .env file
- phpunit xml file
- in the Dockerfile as env param
- in the docker command line when running the test
from panther.
Agreed, that would be nice to change the environment.
One of my usage case is to disable translations in test
env, so we can check translations keys instead of translated strings.
from panther.
i don't use panther now (I didn't like how it squeezes selenium / web driver into an unsuitable interface), but I think the solution would be to modify the code to not use the php server for its requests, but your actual server e.g. nginx / apache
from panther.
I noticed that during the tests the server runs with -t public option and when we launch it manually it has vendor/symfony/web-server-bundle/Resources/router.php (without -t) provided we have the web server bundle.
I could make it work by :
- forcing the argument to vendor/symfony/web-server-bundle/Resources/router.php in vendor/symfony/panther/src/ProcessManager/WebServerManager.php
- Adding a $_SERVER = array_merge($_SERVER, $_ENV); before the return is made in vendor/symfony/web-server-bundle/Resources/router.php
After that the APP_ENV environment var is correctly used
from panther.
I'm having struggles too because on my app, web test case is using the env vars from the phpunit.xml.dist
, but Panther test have a different configuration and I need an additional env.
For this, I just change APP_ENV
from test
to panther
in the test case by overriding setUpBeforeClass()
and tearDownAfterClass()
methods.
But, what I see is that the env, even if it's overriden, it is not correctly populated in the PHP web server.
When I dump($_SERVER, $_ENV);
in public/index.php
, I see that $_ENV['APP_ENV']
exists, but *not $_SERVER['APP_ENV']
, so it will still load the .env
file, which is not what I need at all.
I think we definitely need a proper way to retrieve env vars in our projects instead of relying on $_SERVER
all the time...
from panther.
Hello, have you since found a way to launch Panther with the Test environment? I have the same problem
from panther.
@bastien70 There's one specific thing about using the test
environment that is not the best option: session. Since Panther uses a web browser, you can't use Session, since it's mocked as an array in the memory, therefore the session is lost after every request.
The solution I had was to create a custom panther
environment, create a services_panther.yaml
in which I imported everything from the config/dev/
files and overrode the session parameters to use a native session handler instead of the mocked one.
Then, I made sure that every Panther test case use the panther
environment name, and that's it.
from panther.
@bastien70 There's one specific thing about using the
test
environment that is not the best option: session. Since Panther uses a web browser, you can't use Session, since it's mocked as an array in the memory, therefore the session is lost after every request.The solution I had was to create a custom
panther
environment, create aservices_panther.yaml
in which I imported everything from theconfig/dev/
files and overrode the session parameters to use a native session handler instead of the mocked one.Then, I made sure that every Panther test case use the
panther
environment name, and that's it.
Wow, I'm quite interested! Could you share an example of the code you use to do all of this? That interests me a lot
from panther.
Hmm, it's on a private project, I can't share it now, I would need to create a reproducer somewhere, I'll look into it when I have time to focus on this subject 😉
from panther.
Hmm, it's on a private project, I can't share it now, I would need to create a reproducer somewhere, I'll look into it when I have time to focus on this subject 😉
Okay good ! I can not wait to see it !
from panther.
Tiny bit of information though @bastien70 : are you using Panther inside a Docker container?
from panther.
Not at all @Pierstoval . To be honest, I am new to Symfony. I have never used Docker.
Right now all I can do with Panther is log a user by going to the login page and submitting the authentication information to be able to initiate the user's session. However, as said above, it relies on data in the dev environment which is problematic.
from panther.
Then, I made sure that every Panther test case use the panther environment name, and that's it.
Can you please explain how to to this?
from panther.
Can you please explain how to to this?
By creating a new environment, it can be pretty quick if you follow the official docs about creating new environments
from panther.
@Pierstoval Thanks
from panther.
Related Issues (20)
- Adjust Window for Firefox driver HOT 1
- Allow for a WebServer process to be started in a specific environment
- apt-get install firefox-geckodriver won't work on Ubuntu 22(.04?) HOT 1
- I cant get PANTHER_ERROR_SCREENSHOT_DIR to work HOT 1
- Documentation missing remote browser integration instructions
- clickLink not working with special characters. HOT 1
- Windows/Firefox driver does not always clean up after itself
- Download Image HOT 1
- Using Panther in Messenger HOT 1
- Do you plan to update panther product till Symfony 6.2? HOT 6
- is Symfony\Component\Panther\ServerExtension PHPUnit 10 compatible? HOT 3
- Taking a Full Page screenshot using Symfony Panther?
- Make Panther PHPUnit 10 compatible HOT 3
- Example using Panther with remote Chrome instance in Docker (with Behat)
- Provide a higher level API for asserting against browser console log
- Could not start chrome. Exit code: 126 (Invoked command cannot execute) HOT 1
- createAdditionalPantherClient() with firefox driver not working. HOT 1
- No screenshot taken HOT 1
- TransportException
- Problem with detect driver HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from panther.