Failed Conditions
Push — modify-scrutinizeryml ( 361e25...08b4c1 )
by Kentaro
63:54 queued 57:30
created

codeception/acceptance/EA02AuthenticationCest.php (1 issue)

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
 * @group admin
5
 * @group admin01
6
 * @group authentication
7
 * @group ea2
8
 */
9
class EA02AuthenticationCest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

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