10 $mock = $this->getMockForAbstractClass(
'CentralIdLookup' );
13 'wgCentralIdLookupProviders' => [
14 'local' => [
'class' =>
'LocalIdLookup' ],
15 'local2' => [
'class' =>
'LocalIdLookup' ],
16 'mock' => [
'factory' =>
function ()
use ( $mock ) {
19 'bad' => [
'class' =>
'stdClass' ],
21 'wgCentralIdLookupProvider' =>
'mock',
26 $this->assertSame(
'mock', $mock->getProviderId() );
29 $this->assertNotSame( $mock, $local );
30 $this->assertInstanceOf(
'LocalIdLookup', $local );
32 $this->assertSame(
'local', $local->getProviderId() );
35 $this->assertNotSame( $local, $local2 );
36 $this->assertInstanceOf(
'LocalIdLookup', $local2 );
37 $this->assertSame(
'local2', $local2->getProviderId() );
44 $mock = TestingAccessWrapper::newFromObject(
45 $this->getMockForAbstractClass(
'CentralIdLookup' )
48 $user = static::getTestSysop()->getUser();
49 $this->assertSame(
$user, $mock->checkAudience(
$user ) );
52 $this->assertInstanceOf(
'User',
$user );
53 $this->assertSame( 0,
$user->getId() );
58 $mock->checkAudience( 100 );
59 $this->fail(
'Expected exception not thrown' );
60 }
catch ( InvalidArgumentException $ex ) {
61 $this->assertSame(
'Invalid audience', $ex->getMessage() );
66 $mock = $this->getMockForAbstractClass(
'CentralIdLookup' );
67 $mock->expects( $this->once() )->method(
'lookupCentralIds' )
69 $this->equalTo( [ 15 =>
null ] ),
71 $this->equalTo( CentralIdLookup::READ_LATEST )
73 ->will( $this->returnValue( [ 15 =>
'FooBar' ] ) );
87 $mock = $this->getMockForAbstractClass(
'CentralIdLookup' );
88 $mock->expects( $this->any() )->method(
'isAttached' )
89 ->will( $this->returnValue(
true ) );
90 $mock->expects( $this->once() )->method(
'lookupCentralIds' )
92 $this->equalTo( [ 42 =>
null ] ),
94 $this->equalTo( CentralIdLookup::READ_LATEST )
96 ->will( $this->returnValue( [ 42 =>
$name ] ) );
98 $user = $mock->localUserFromCentralId(
102 $this->assertInstanceOf(
'User',
$user );
105 $this->assertNull(
$user );
108 $mock = $this->getMockForAbstractClass(
'CentralIdLookup' );
109 $mock->expects( $this->any() )->method(
'isAttached' )
110 ->will( $this->returnValue(
false ) );
111 $mock->expects( $this->once() )->method(
'lookupCentralIds' )
113 $this->equalTo( [ 42 =>
null ] ),
115 $this->equalTo( CentralIdLookup::READ_LATEST )
117 ->will( $this->returnValue( [ 42 =>
$name ] ) );
134 $mock = $this->getMockForAbstractClass(
'CentralIdLookup' );
135 $mock->expects( $this->once() )->method(
'lookupUserNames' )
137 $this->equalTo( [
'FooBar' => 0 ] ),
139 $this->equalTo( CentralIdLookup::READ_LATEST )
141 ->will( $this->returnValue( [
'FooBar' => 23 ] ) );
150 $mock = $this->getMockForAbstractClass(
'CentralIdLookup' );
151 $mock->expects( $this->any() )->method(
'isAttached' )
152 ->will( $this->returnValue(
true ) );
153 $mock->expects( $this->once() )->method(
'lookupUserNames' )
155 $this->equalTo( [
'FooBar' => 0 ] ),
157 $this->equalTo( CentralIdLookup::READ_LATEST )
159 ->will( $this->returnValue( [
'FooBar' => 23 ] ) );
163 $mock->centralIdFromLocalUser(
168 $mock = $this->getMockForAbstractClass(
'CentralIdLookup' );
169 $mock->expects( $this->any() )->method(
'isAttached' )
170 ->will( $this->returnValue(
false ) );
171 $mock->expects( $this->never() )->method(
'lookupUserNames' );
175 $mock->centralIdFromLocalUser(