-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAuthenticationContext.php
More file actions
50 lines (42 loc) · 1.29 KB
/
AuthenticationContext.php
File metadata and controls
50 lines (42 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace App\ModuleUser\Bundle\ModuleUserBundle\Behat\Context;
use Behat\Gherkin\Node\TableNode;
use AppBundle\Behat\Context\DefaultContext;
/**
*
* @author Athlan
*
*/
class AuthenticationContext extends DefaultContext
{
private $users = array();
/**
* @Given /^there are following users:$/
*/
public function thereAreFollowingUsers(TableNode $table) {
foreach ($table->getHash() as $row) {
$this->users[$row['username']] = $row;
}
}
/**
* @Given /^I am authenticated as "([^"]+)"$/
*/
public function iAmAuthenticatedAs($username) {
if (!isset($this->users[$username]['password'])) {
throw new \OutOfBoundsException('Invalid user ' . $username);
}
$this->visitPath('/login');
$this->fillField('_username', $username);
$this->fillField('_password', $this->users[$username]['password']);
$this->checkField('remember_me');
$this->pressButton('_submit');
}
/**
* @Given /^I am not logged in$/
* @Given /^I am (an )?anonymous user?$/
*/
public function iAmNotLoggedIn()
{
$this->getSession()->visit($this->generateUrl('fos_user_security_logout'));
}
}