4 use Psr\Log\LoggerInterface;
13 'MediaWikiTestCaseTestGLOBAL-ExistingString' =>
'foo',
14 'MediaWikiTestCaseTestGLOBAL-ExistingStringEmpty' =>
'',
15 'MediaWikiTestCaseTestGLOBAL-ExistingArray' => [ 1,
'foo' =>
'bar' ],
16 'MediaWikiTestCaseTestGLOBAL-ExistingArrayEmpty' => [],
20 parent::setUpBeforeClass();
21 foreach ( self::$startGlobals
as $key =>
$value ) {
27 parent::tearDownAfterClass();
28 foreach ( self::$startGlobals
as $key =>
$value ) {
35 foreach ( array_keys( self::$startGlobals )
as $key ) {
36 $providedArray[] = [ $key,
'newValue' ];
37 $providedArray[] = [ $key, [
'newValue' ] ];
39 return $providedArray;
53 'Global failed to correctly set'
59 self::$startGlobals[$globalKey],
61 'Global failed to be restored on tearDown'
77 'Global failed to correctly set'
83 self::$startGlobals[$globalKey],
85 'Global failed to be restored on tearDown'
94 $globalKey =
'abcdefg1234567';
98 'Global failed to correctly set'
105 'Global failed to be correctly unset'
110 $initialServices = MediaWikiServices::getInstance();
113 $this->assertNotSame( $initialServices, MediaWikiServices::getInstance() );
116 $this->assertSame( $initialServices, MediaWikiServices::getInstance() );
120 $initialServices = MediaWikiServices::getInstance();
121 $initialService = $initialServices->getDBLoadBalancer();
123 ->disableOriginalConstructor()->getMock();
125 $this->
setService(
'DBLoadBalancer', $mockService );
126 $this->assertNotSame( $initialServices, MediaWikiServices::getInstance() );
127 $this->assertNotSame(
129 MediaWikiServices::getInstance()->getDBLoadBalancer()
131 $this->assertSame( $mockService, MediaWikiServices::getInstance()->getDBLoadBalancer() );
134 $this->assertSame( $initialServices, MediaWikiServices::getInstance() );
135 $this->assertNotSame( $mockService, MediaWikiServices::getInstance()->getDBLoadBalancer() );
136 $this->assertSame( $initialService, MediaWikiServices::getInstance()->getDBLoadBalancer() );
144 $logger1 = LoggerFactory::getInstance(
'foo' );
146 $logger2 = LoggerFactory::getInstance(
'foo' );
148 $logger3 = LoggerFactory::getInstance(
'foo' );
150 $this->assertSame( $logger1, $logger3 );
151 $this->assertNotSame( $logger1, $logger2 );
160 $logger1 = LoggerFactory::getInstance(
'foo' );
162 $logger2 = LoggerFactory::getInstance(
'foo' );
164 $this->assertNotSame( $logger1, $logger2 );
165 $this->assertInstanceOf(
'\Psr\Log\LoggerInterface', $logger2 );
173 $logger1 = LoggerFactory::getInstance(
'baz' );
177 $logger2 = LoggerFactory::getInstance(
'baz' );
179 $this->assertSame( $logger1, $logger2 );