using env variable BEHAT_PARAMS to set base_url for Mink

1,765 views
Skip to first unread message

mar...@brightonart.co.uk

unread,
Nov 29, 2013, 5:44:55 AM11/29/13
to be...@googlegroups.com
I want to execute a set of tests against multiple sites.
I could use profiles but the only thing that needs to change is the url and I'd prefer not to manage a long (42) set of profiles.
So I'm using

export BEHAT_PARAMS="context[parameters][base_url]=http://mysite.com"

To set the base_url in the context. However Mink doesn't pick this up and I couldn't work out how to structure the BEHAT_PARAMS string to get to work.
Instead I added a before step hook:

 /** @BeforeStep */
  public function beforeStep(Behat\Behat\Event\StepEvent  $event)
  {
    $this->setMinkParameter('base_url', $this->parameters['base_url']);
  }


Is there a better way of doing this?

thanks

Marcus

Konstantin Kudryashov

unread,
Dec 2, 2013, 5:30:21 AM12/2/13
to be...@googlegroups.com
MinkExtension has own env variable:
`MINK_EXTENSION_PARAMS`

Konstantin Kudryashov

--- PHP developer, BDD evangelist, Scrum master

a: http://about.me/everzet
b: http://everzet.com
c: https://github.com/everzet

--
You received this message because you are subscribed to the Google Groups "Behat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to behat+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Chuck Musser

unread,
Jan 8, 2015, 2:42:28 PM1/8/15
to be...@googlegroups.com
I had a working set of tests with this behat.yml:

default:
    extensions:
        Behat\MinkExtension:
            goutte:
                guzzle_parameters:
                    ssl.certificate_authority: false
            base_url: https://my.dev.site/

I tried commenting out the last line and hope that following environment variable definition would be equivalent:

export MINK_EXTENSION_PARAMS="base_url=my.dev.site/"

The tests failed. Is there more specific guidance in the documentation that describes how to make this work?

Christophe COEVOET

unread,
Jan 8, 2015, 2:50:56 PM1/8/15
to be...@googlegroups.com
Le 08/01/2015 20:42, Chuck Musser a écrit :
I had a working set of tests with this behat.yml:

default:
    extensions:
        Behat\MinkExtension:
            goutte:
                guzzle_parameters:
                    ssl.certificate_authority: false
            base_url: https://my.dev.site/

I tried commenting out the last line and hope that following environment variable definition would be equivalent:

export MINK_EXTENSION_PARAMS="base_url=my.dev.site/"

The tests failed. Is there more specific guidance in the documentation that describes how to make this work?

MINK_EXTENSION_PARAMS does not exist anymore in MinkExtension 2.0 (for Behat 3). It was handled in a hacky way which was not working reliably. You should use the BEHAT_PARAMS env var instead.
-- 
Christophe | Stof

Chuck Musser

unread,
Jan 8, 2015, 2:54:59 PM1/8/15
to be...@googlegroups.com
Slight correction: I tried it with this (correct) environment variable. No luck.

export MINK_EXTENSION_PARAMS="base_url=https://my.dev.site/"

Chuck Musser

unread,
Jan 8, 2015, 4:10:17 PM1/8/15
to be...@googlegroups.com
Christophe,

The following worked:

export BEHAT_PARAMS='{"extensions" : {"Behat\\MinkExtension" : {"base_url" : "https://my.dev.site/"}}}'


Things to note:

The value now needs to be a JSON string. Not sure if that's documented anywhere.

The backslash in the MinkExtension class needs to be escaped. Use single quotes in the shell command.

The top-level in the configuration file, named "default" in my case, is implicit. It does not have to be in the JSON hierarchy.

Other than that, the hierarchy here matches that in the behat.yml file.




For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages