-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathUserSteps.php
69 lines (58 loc) · 1.37 KB
/
UserSteps.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace User\Functional;
use FunctionalTester;
/**
* Class UserSteps
*
* @package User\Functional
*/
class UserSteps
{
/**
* @var FunctionalTester
*/
protected $tester;
protected $formFields = [
'email' => 'i_regular@phalcon-demo.local',
'password' => 'password',
'username' => 'Regular User',
'name' => 'i_regular',
'active' => 'Y',
];
public function __construct(FunctionalTester $I)
{
$this->tester = $I;
}
/**
* @return int
*/
public function createUser()
{
$I = $this->tester;
return $I->haveRecord('PhalconDemo\Models\Users', $this->formFields);
}
/**
* @return void
* @throws \Exception
*/
public function loginAsFirstUser()
{
$I = $this->tester;
$I->amOnPage('/#');
$this->fillFormFields([
'email' => 'demo@phalconphp.com',
'password' => 'phalcon'
]);
$I->click('Login');
$I->amOnPage('/session/start');
}
protected function fillFormFields(array $data)
{
foreach ($data as $field => $value) {
if (!isset($this->formFields[$field])) {
throw new \Exception("Form field $field does not exist");
}
$this->tester->fillField($field, $value);
}
}
}