phpunit-mink icon indicating copy to clipboard operation
phpunit-mink copied to clipboard

Why do I have to set PHPUNIT_MINK_TUNNEL_ID as environment variable?

Open robertfausk opened this issue 8 years ago • 3 comments

It seems I have to do a

putenv('PHPUNIT_MINK_TUNNEL_ID=' . $tunnel_id);

before creating my browser configuration which feels a little bit weird for me.

robertfausk avatar Jul 21 '17 08:07 robertfausk

You don't. Creating a tunnel is an optional feature of both SauceLabs and BrowserStack.

aik099 avatar Jul 21 '17 09:07 aik099

Yeah. Sorry, that it's an optional feature is clear to me. I meant: Why can't I set tunnel id not via desired capabilities or something else?

It feels a little bit hacky to do a putenv()

robertfausk avatar Jul 21 '17 09:07 robertfausk

The env-way is created mostly for build servers, where:

  • several tunnels can exist in parallel (usual stuff, when running tests on multiple PHP versions/browsers from build server like Travis CI)
  • tunnel is linked to IP starting it and attempt to use same tunnel from multiple IPs might fail

If you'll look at actual places where this env variable is used, then you'll see that in fact it's used exactly to populate desired capabilities in current browser configuration.

Sauce Labs

https://github.com/minkphp/phpunit-mink/blob/master/library/aik099/PHPUnit/BrowserConfiguration/SauceLabsBrowserConfiguration.php#L57-L59

$desired_capabilities['tunnel-identifier'] = getenv('PHPUNIT_MINK_TUNNEL_ID');

BrowserStack

https://github.com/minkphp/phpunit-mink/blob/master/library/aik099/PHPUnit/BrowserConfiguration/BrowserStackBrowserConfiguration.php#L59-L62

$desired_capabilities['browserstack.local'] = 'true';
$desired_capabilities['browserstack.localIdentifier'] = getenv('PHPUNIT_MINK_TUNNEL_ID');

So you can that as well.

aik099 avatar Jul 21 '17 09:07 aik099