rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / DeprecatedGlobalTest.php
blob237e3fb7b70db27efa22aaedf2fd8c395c634032
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
21 /**
22 * @covers DeprecatedGlobal
24 class DeprecatedGlobalTest extends MediaWikiTestCase {
26 public function setUp() {
27 parent::setUp();
28 $this->oldErrorLevel = error_reporting( -1 );
31 public function tearDown() {
32 error_reporting( $this->oldErrorLevel );
33 parent::tearDown();
36 public function testObjectDeStub() {
37 global $wgDummy;
39 $wgDummy = new DeprecatedGlobal( 'wgDummy', new HashBagOStuff(), '1.30' );
40 $this->assertInstanceOf( DeprecatedGlobal::class, $wgDummy );
42 $this->hideDeprecated( '$wgDummy' );
43 // Trigger de-stubification
44 $wgDummy->get( 'foo' );
46 $this->assertInstanceOf( HashBagOStuff::class, $wgDummy );
49 public function testLazyLoad() {
50 global $wgDummyLazy;
52 $called = false;
53 $factory = function () use ( &$called ) {
54 $called = true;
55 return new HashBagOStuff();
58 $wgDummyLazy = new DeprecatedGlobal( 'wgDummyLazy', $factory, '1.30' );
59 $this->assertInstanceOf( DeprecatedGlobal::class, $wgDummyLazy );
61 $this->hideDeprecated( '$wgDummyLazy' );
62 $this->assertFalse( $called );
63 // Trigger de-stubification
64 $wgDummyLazy->get( 'foo' );
65 $this->assertTrue( $called );
66 $this->assertInstanceOf( HashBagOStuff::class, $wgDummyLazy );
69 /**
70 * @expectedException PHPUnit_Framework_Error
71 * @expectedExceptionMessage Use of $wgDummy1 was deprecated in MediaWiki 1.30
73 public function testWarning() {
74 global $wgDummy1;
76 $wgDummy1 = new DeprecatedGlobal( 'wgDummy1', new HashBagOStuff(), '1.30' );
77 $wgDummy1->get( 'foo' );
78 $this->assertInstanceOf( HashBagOStuff::class, $wgDummy1 );