blob: 34ce9efeac64dc8a187145dd5cf8e54c16b346ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
namespace EmailLogin\Test;
use EmailLogin\EmailPasswordAuthenticationProvider;
use MediaWiki\Auth\AuthenticationRequest;
use MediaWiki\Auth\AuthenticationResponse;
use MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider;
use MediaWiki\Auth\PasswordAuthenticationRequest;
use Mockery;
use phpmock\mockery\PHPMockery;
define('DB_REPLICA', 0);
class EmailPasswordAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
{
private $provider;
protected function setUp()
{
Mockery::mock('overload:'.AuthenticationResponse::class)
->shouldReceive('newAbstain')
->andReturn(new AuthenticationResponse());
Mockery::mock('overload:'.LocalPasswordPrimaryAuthenticationProvider::class)
->shouldReceive('beginPrimaryAuthentication')
->andReturn(new AuthenticationResponse());
Mockery::mock('overload:'.PasswordAuthenticationRequest::class);
$req = new PasswordAuthenticationRequest();
$req->username = 'foo';
Mockery::mock('overload:'.AuthenticationRequest::class)
->shouldReceive('getRequestByClass')
->andReturn($req);
$row = new \StdClass();
$row->user_name = 'foo';
Mockery::mock('overload:DatabaseMysqli')
->shouldReceive('selectRow')
->andReturn(false, $row);
PHPMockery::mock('EmailLogin', 'wfGetDB')->andReturn(new \DatabaseMysqli());
$this->provider = new EmailPasswordAuthenticationProvider();
}
protected function tearDown()
{
Mockery::close();
}
public function testBeginPrimaryAuthentication()
{
//With no row
$this->assertInstanceOf(AuthenticationResponse::class, $this->provider->beginPrimaryAuthentication([]));
//With a row
$this->assertInstanceOf(AuthenticationResponse::class, $this->provider->beginPrimaryAuthentication([]));
}
}
|