Skip to content

Instantly share code, notes, and snippets.

@aderuwe
Created February 13, 2013 08:08
Show Gist options
  • Save aderuwe/4943019 to your computer and use it in GitHub Desktop.
Save aderuwe/4943019 to your computer and use it in GitHub Desktop.
Behat metastep for logging in a user
<?php
// ... code snipped
class FeatureContext extends MinkContext implements KernelAwareInterface
{
// ... code snipped
/**
* @Given /^I am logged in as user "([^"]*)" with password "([^"]*)"$/
*/
public function iAmLoggedInAsUserWithPassword($username, $password)
{
return array(
new Step\Given('I am on "/login"'),
new Step\When(sprintf('I fill in "Username:" with "%s"', $username)),
new Step\When(sprintf('I fill in "Password" with "%s"', $password)),
new Step\When('I press "Login"'),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment