Reputation: 1854
I've just read that I can use tokens in the format of :argument in my context method Given annotations, however when I do this it's telling me the step is undefined...
/**
* @Given I am logged in as :username
*/
public function iAmLoggedInAs( $username )
{
// ...
}
This returns Undefined step "I am logged in as 'disco-superuser'"
, however ...
/**
* @Given /^I am logged in as "([^"]*)"$/
*/
public function iAmLoggedInAs( $username )
{
// ...
}
... works fine.
What am I missing here.
Behat version: 2.5.3
Upvotes: 0
Views: 143
Reputation: 9085
For those who are "unsure": the feature is called turnip pattern, this is new in Behat 3. You can read a little about it in the official docs or dig the TurnipPatternPolicy
class for more details.
It throws undefined step definition exception because you are using single quotes, given you provided the correct details. Check again with double quotes, must fix it. The TOKEN_REGEX
in the TurnipPatternPolicy
class allows for single and double quotes, as well as no quotes at all, the documentation also gives an example of all three cases, which I completely ignored.
Also, in case some one tries, you cannot combine different types of pattern in one definition (turnip and regex that is), like I did. Read Konstantin's answer on why and other useful information.
Upvotes: 1