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