Failed Conditions
Pull Request — experimental/sf (#3236)
by Kentaro
132:46 queued 125:39
created

EA02AuthenticationCest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1
1
<?php
2
3
use Codeception\Util\Fixtures;
4
5
/**
6
 * @group admin
7
 * @group admin01
8
 * @group authentication
9
 * @group ea2
10
 */
11
class EA02AuthenticationCest
12
{
13
    public function _before(\AcceptanceTester $I)
14
    {
15
        $I->loginAsAdmin();
16
    }
17
18
    public function _after(\AcceptanceTester $I)
19
    {
20
    }
21
22
    public function authentication_パスワード認証(\AcceptanceTester $I)
23
    {
24
        $I->wantTo('EA0201-UC01-T01 パスワード認証');
25
26
        // _before()で正常系はテスト済み
27
        // 異常系のテスト
28
        $I->logoutAsAdmin();
29
30
        $I->submitForm('#form1', [
31
            'login_id' => "invalid",
32
            'password' => "invalidpassword"
33
        ]);
34
35
        $I->see('ログインできませんでした。', '.login-box #form1 .text-danger');
36
    }
37
38
    public function authentication_最終ログイン日時確認(\AcceptanceTester $I)
39
    {
40
        $I->wantTo('EA0201-UC01-T01 最終ログイン日時確認');
41
42
        $I->click('header.c-headerBar div.c-headerBar__container a.c-headerBar__userMenu');
43
        $loginText = $I->grabTextFrom(['css' => '#page_admin_homepage div.popover .popover-body > p']);
44
45
        // Format Y/m/d only
46
        $lastLogin = preg_replace('/.*(\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}).*/s', '$1', $loginText);
47
        // 表示されるログイン日時では秒数がわからないため、タイミングによっては1分ちょっと変わる
48
        $now = new DateTime();
49
        $I->assertTrue((strtotime($now->format('Y/m/d')) - strtotime($lastLogin)) < 70, '最終ログイン日時が正しい');
50
    }
51
}
52