Completed
Push — 4.0 ( 87d096...bcc1be )
by Kiyotaka
05:44 queued 11s
created

codeception/acceptance/EA02AuthenticationCest.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
class EA02AuthenticationCest
15
{
16
    public function _before(\AcceptanceTester $I)
17
    {
18
        $I->loginAsAdmin();
19
    }
20
21
    public function _after(\AcceptanceTester $I)
0 ignored issues
show
The parameter $I is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
    }
24
25
    public function authentication_パスワード認証(\AcceptanceTester $I)
26
    {
27
        $I->wantTo('EA0201-UC01-T01 パスワード認証');
28
29
        // _before()で正常系はテスト済み
30
        // 異常系のテスト
31
        $I->logoutAsAdmin();
32
33
        $I->submitForm('#form1', [
34
            'login_id' => 'invalid',
35
            'password' => 'invalidpassword',
36
        ]);
37
38
        $I->see('ログインできませんでした。', '#form1 > div:nth-child(5) > span');
39
    }
40
41
    public function authentication_最終ログイン日時確認(\AcceptanceTester $I)
42
    {
43
        $I->wantTo('EA0201-UC01-T01 最終ログイン日時確認');
44
45
        $I->click('header.c-headerBar div.c-headerBar__container a.c-headerBar__userMenu');
46
        $loginText = $I->grabTextFrom(['css' => '#page_admin_homepage div.popover .popover-body > p']);
47
48
        // Format Y/m/d only
49
        $lastLogin = preg_replace('/.*(\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}).*/s', '$1', $loginText);
50
        // 表示されるログイン日時では秒数がわからないため、タイミングによっては1分ちょっと変わる
51
        $now = new DateTime();
52
        $I->assertTrue((strtotime($now->format('Y/m/d')) - strtotime($lastLogin)) < 70, '最終ログイン日時が正しい');
53
    }
54
}
55