Passed
Push — master ( 711cdb...bacb9d )
by Torben
04:41
created

FrontendUserServiceTest::setup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
namespace Derhansen\FeChangePwd\Tests\Unit\Service;
3
4
/*
5
 * This file is part of the Extension "fe_change_pwd" for TYPO3 CMS.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.txt file that was distributed with this source code.
9
 */
10
11
use Derhansen\FeChangePwd\Service\FrontendUserService;
12
use Nimut\TestingFramework\TestCase\UnitTestCase;
13
14
/**
15
 * Class FrontendUserServiceTest
16
 */
17
class FrontendUserServiceTest extends UnitTestCase
18
{
19
    /**
20
     * @return array
21
     */
22
    public function mustChangePasswordReturnsExpectedResultDataProvider()
23
    {
24
        return [
25
            'no frontend user' => [
26
                [],
27
                false
28
            ],
29
            'must change password' => [
30
                [
31
                    'must_change_password' => 1,
32
                    'password_expiry_date' => 0
33
                ],
34
                true
35
            ],
36
            'password expired' => [
37
                [
38
                    'must_change_password' => 0,
39
                    'password_expiry_date' => 1538194307
40
                ],
41
                true
42
            ],
43
            'password not expired and no password change required' => [
44
                [
45
                    'must_change_password' => 0,
46
                    'password_expiry_date' => 0
47
                ],
48
                false
49
            ],
50
        ];
51
    }
52
53
    /**
54
     * @test
55
     * @dataProvider mustChangePasswordReturnsExpectedResultDataProvider
56
     */
57
    public function mustChangePasswordReturnsExpectedResult($feUserRecord, $expected)
58
    {
59
        $service = new FrontendUserService();
60
        $GLOBALS['TSFE'] = new \stdClass();
61
        $GLOBALS['TSFE']->fe_user = new \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication();
62
        $this->assertEquals($expected, $service->mustChangePassword($feUserRecord));
63
    }
64
}
65