Skip to content

Conversation

@symfonyaml
Copy link
Contributor

Goal:
Making some improvements to be able to use Panther as standalone (without Symfony and without PHPUnit).

Feature:
I would like to send custom environment variables to the created web server like:

static::createPantherClient([
    'environmentVariables' => ['CUSTOM_ENV' => 'foo'],
]);

dunglas and others added 30 commits April 4, 2018 17:32
Use Process's array syntax to remove hackish code
made a few changes to make thing clear.
there is no stable version now. Default composer errors with

[InvalidArgumentException]
  Could not find a version of package dunglas/panthere matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability.
[CS] Removed property used only in constructor
Run PHP CS Fixer in the CI. Add Travis badge.
* Allowing customization of host and port for ChromeManager

* Update ChromeManager.php

* Update ChromeManager.php

* Update ChromeManager.php

* Style fixes

* Removing ?
* Fix wrong statement in README

* fix README - can be used instead of could be used
Prevent installing Browser Kit 4.1.0
Fixed command-line that was not retrieving all arguments properly
* Selenium manager

* Selenium manager create method

* fix cs

* simple test

* fix selenium manager test

* fix travis ci test, fix cs

* fix cs

* fix cs, refactor constructor

* fix constructor

* fix test
Allow customization of host & port for the web server at creation
Explicitly add document root to PHP's web server command line
This PR was merged into the 1.0.x-dev branch.

Discussion
----------

Fix composer name

Commits
-------

327bee1 fixed composer name
dunglas and others added 22 commits February 18, 2020 16:22
* Add timeouts to SeleniumManager

* Create php.yml

* Update php.yml

* Update php.yml

* Remove accidentally committed file.
Upgrade ChromeDriver to version 80.0.3987.106
* allow pass custom env parameter to webserver

* add pass panther app env test

* update changelog

* fix coding styles

* fix inherit env vars for symfony 3.4

* fix deprecation warning for inherit env vars in symfony 4.4

* remove changelog

* Prevent env vars leaking

Co-authored-by: Kévin Dunglas <dunglas@gmail.com>
Add PHP 7.4 to the Travis matrix
Prevent access to fixture files even if the web server is misconfigured
* Native Firefox support (through geckodriver)

* Fix CS

* Remove VCS repo

* Cleanup

* Fix lint

* Use cast instead of the null coalescing operator
Replace mentions of Goutte by HttpBrowser in the readme
Fix an issue when one uses only the PantherTestCaseTrait
)

* Fix some inconsistencies between Chrome and Firefox

* Fix tests
Option environmentVariables
@ThomasTr
Copy link
Contributor

Helps me to execute different test_cases via custom kernel, would like to see this in next release @dunglas 👍

@dunglas
Copy link
Member

dunglas commented Oct 2, 2020

I don't understand where environmentVariables is used?

@ThomasTr
Copy link
Contributor

ThomasTr commented Oct 3, 2020

I for myself have different test cases, with which I map different test scenarios, e.g. to mock different external API's, load different configs.

$this->options['environmentVariables']['TEST_CASE'] = $testCase;

Then i can load the kernel with the specific environment:

$kernel = new Kernel($_SERVER['TEST_CASE'], 'config.yaml', $_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);

@nicolas-grekas nicolas-grekas changed the base branch from master to main November 19, 2020 12:43
@dunglas dunglas closed this Dec 28, 2020
@arderyp
Copy link
Contributor

arderyp commented Apr 11, 2022

I am not sure how this works. Here is my code:

// in my panther test
$this->client = static::createPantherClient([
    'environmentVariables' => [
        "CUSTOM_PATHER_VAR" => "this is a test",
    ],
]);
// in my index.php
echo $_SERVER["CUSTOM_PATHER_VAR"];
echo getenv("CUSTOM_PATHER_VAR");
// in my Kernel.php
echo $_SERVER["CUSTOM_PATHER_VAR"];
echo getenv("CUSTOM_PATHER_VAR");

I am not seeing my custom var ("this is a test") make it into index.php or Kernel.php when crawling to a page using the Panther client instantiation above. Am I missing something?

@ThomasTr suggests it should be available in $_SERVER, which makes sense, as that's how APP_ENV and other env vars are made available, but I'm not finding that to be the case.

Or was this never merged @dunglas?

EDIT: answers to my questions starting here: #202 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.