X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fuser%2FCentralIdLookupTest.php;h=feac641eb3056fa626c69af17c201cd1054804c4;hb=e638075936aaf83af7e5cc8f0d7538a0a8888aad;hp=386e7ab918931381ef020b2f142b594eb11fb2d1;hpb=174f34a86de3162bc673fd3bc6bed815cccf0edc;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/user/CentralIdLookupTest.php b/tests/phpunit/includes/user/CentralIdLookupTest.php index 386e7ab918..feac641eb3 100644 --- a/tests/phpunit/includes/user/CentralIdLookupTest.php +++ b/tests/phpunit/includes/user/CentralIdLookupTest.php @@ -9,17 +9,17 @@ class CentralIdLookupTest extends MediaWikiTestCase { public function testFactory() { $mock = $this->getMockForAbstractClass( 'CentralIdLookup' ); - $this->setMwGlobals( array( - 'wgCentralIdLookupProviders' => array( - 'local' => array( 'class' => 'LocalIdLookup' ), - 'local2' => array( 'class' => 'LocalIdLookup' ), - 'mock' => array( 'factory' => function () use ( $mock ) { + $this->setMwGlobals( [ + 'wgCentralIdLookupProviders' => [ + 'local' => [ 'class' => 'LocalIdLookup' ], + 'local2' => [ 'class' => 'LocalIdLookup' ], + 'mock' => [ 'factory' => function () use ( $mock ) { return $mock; - } ), - 'bad' => array( 'class' => 'stdClass' ), - ), + } ], + 'bad' => [ 'class' => 'stdClass' ], + ], 'wgCentralIdLookupProvider' => 'mock', - ) ); + ] ); $this->assertSame( $mock, CentralIdLookup::factory() ); $this->assertSame( $mock, CentralIdLookup::factory( 'mock' ) ); @@ -45,7 +45,7 @@ class CentralIdLookupTest extends MediaWikiTestCase { $this->getMockForAbstractClass( 'CentralIdLookup' ) ); - $user = User::newFromName( 'UTSysop' ); + $user = static::getTestSysop()->getUser(); $this->assertSame( $user, $mock->checkAudience( $user ) ); $user = $mock->checkAudience( CentralIdLookup::AUDIENCE_PUBLIC ); @@ -66,11 +66,11 @@ class CentralIdLookupTest extends MediaWikiTestCase { $mock = $this->getMockForAbstractClass( 'CentralIdLookup' ); $mock->expects( $this->once() )->method( 'lookupCentralIds' ) ->with( - $this->equalTo( array( 15 => null ) ), + $this->equalTo( [ 15 => null ] ), $this->equalTo( CentralIdLookup::AUDIENCE_RAW ), $this->equalTo( CentralIdLookup::READ_LATEST ) ) - ->will( $this->returnValue( array( 15 => 'FooBar' ) ) ); + ->will( $this->returnValue( [ 15 => 'FooBar' ] ) ); $this->assertSame( 'FooBar', @@ -89,11 +89,11 @@ class CentralIdLookupTest extends MediaWikiTestCase { ->will( $this->returnValue( true ) ); $mock->expects( $this->once() )->method( 'lookupCentralIds' ) ->with( - $this->equalTo( array( 42 => null ) ), + $this->equalTo( [ 42 => null ] ), $this->equalTo( CentralIdLookup::AUDIENCE_RAW ), $this->equalTo( CentralIdLookup::READ_LATEST ) ) - ->will( $this->returnValue( array( 42 => $name ) ) ); + ->will( $this->returnValue( [ 42 => $name ] ) ); $user = $mock->localUserFromCentralId( 42, CentralIdLookup::AUDIENCE_RAW, CentralIdLookup::READ_LATEST @@ -110,35 +110,35 @@ class CentralIdLookupTest extends MediaWikiTestCase { ->will( $this->returnValue( false ) ); $mock->expects( $this->once() )->method( 'lookupCentralIds' ) ->with( - $this->equalTo( array( 42 => null ) ), + $this->equalTo( [ 42 => null ] ), $this->equalTo( CentralIdLookup::AUDIENCE_RAW ), $this->equalTo( CentralIdLookup::READ_LATEST ) ) - ->will( $this->returnValue( array( 42 => $name ) ) ); + ->will( $this->returnValue( [ 42 => $name ] ) ); $this->assertNull( $mock->localUserFromCentralId( 42, CentralIdLookup::AUDIENCE_RAW, CentralIdLookup::READ_LATEST ) ); } public static function provideLocalUserFromCentralId() { - return array( - array( 'UTSysop', true ), - array( 'UTDoesNotExist', false ), - array( null, false ), - array( '', false ), - array( '', false ), - ); + return [ + [ 'UTSysop', true ], + [ 'UTDoesNotExist', false ], + [ null, false ], + [ '', false ], + [ '', false ], + ]; } public function testCentralIdFromName() { $mock = $this->getMockForAbstractClass( 'CentralIdLookup' ); $mock->expects( $this->once() )->method( 'lookupUserNames' ) ->with( - $this->equalTo( array( 'FooBar' => 0 ) ), + $this->equalTo( [ 'FooBar' => 0 ] ), $this->equalTo( CentralIdLookup::AUDIENCE_RAW ), $this->equalTo( CentralIdLookup::READ_LATEST ) ) - ->will( $this->returnValue( array( 'FooBar' => 23 ) ) ); + ->will( $this->returnValue( [ 'FooBar' => 23 ] ) ); $this->assertSame( 23, @@ -152,11 +152,11 @@ class CentralIdLookupTest extends MediaWikiTestCase { ->will( $this->returnValue( true ) ); $mock->expects( $this->once() )->method( 'lookupUserNames' ) ->with( - $this->equalTo( array( 'FooBar' => 0 ) ), + $this->equalTo( [ 'FooBar' => 0 ] ), $this->equalTo( CentralIdLookup::AUDIENCE_RAW ), $this->equalTo( CentralIdLookup::READ_LATEST ) ) - ->will( $this->returnValue( array( 'FooBar' => 23 ) ) ); + ->will( $this->returnValue( [ 'FooBar' => 23 ] ) ); $this->assertSame( 23,