Merge "Prevent login-only local password provider from removing passwords"
[lhc/web/wiklou.git] / tests / phpunit / includes / auth / RememberMeAuthenticationRequestTest.php
1 <?php
2
3 namespace MediaWiki\Auth;
4
5 /**
6 * @group AuthManager
7 * @covers MediaWiki\Auth\RememberMeAuthenticationRequest
8 */
9 class RememberMeAuthenticationRequestTest extends AuthenticationRequestTestCase {
10
11 public static function provideGetFieldInfo() {
12 return [
13 [ [ 1 ] ],
14 [ [ null ] ],
15 ];
16 }
17
18 public function testGetFieldInfo_2() {
19 $req = new RememberMeAuthenticationRequest();
20 $reqWrapper = \TestingAccessWrapper::newFromObject( $req );
21
22 $reqWrapper->expiration = 30 * 24 * 3600;
23 $this->assertNotEmpty( $req->getFieldInfo() );
24
25 $reqWrapper->expiration = null;
26 $this->assertEmpty( $req->getFieldInfo() );
27 }
28
29 protected function getInstance( array $args = [] ) {
30 $req = new RememberMeAuthenticationRequest();
31 $reqWrapper = \TestingAccessWrapper::newFromObject( $req );
32 $reqWrapper->expiration = $args[0];
33 return $req;
34 }
35
36 public function provideLoadFromSubmission() {
37 return [
38 'Empty request' => [
39 [ 30 * 24 * 3600 ],
40 [],
41 [ 'expiration' => 30 * 24 * 3600, 'rememberMe' => false ]
42 ],
43 'RememberMe present' => [
44 [ 30 * 24 * 3600 ],
45 [ 'rememberMe' => '' ],
46 [ 'expiration' => 30 * 24 * 3600, 'rememberMe' => true ]
47 ],
48 'RememberMe present but session provider cannot remember' => [
49 [ null ],
50 [ 'rememberMe' => '' ],
51 false
52 ],
53 ];
54 }
55 }