4c59f474816c597b4eae059456065db2bc4d66cc
[lhc/web/wiklou.git] / tests / phpunit / includes / db / LBFactoryTest.php
1 <?php
2 /**
3 * Holds tests for LBFactory abstract MediaWiki class.
4 *
5 * @section LICENSE
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @group Database
22 * @file
23 * @author Antoine Musso
24 * @copyright © 2013 Antoine Musso
25 * @copyright © 2013 Wikimedia Foundation Inc.
26 */
27 class LBFactoryTest extends MediaWikiTestCase {
28
29 /**
30 * @dataProvider getLBFactoryClassProvider
31 */
32 public function testGetLBFactoryClass( $expected, $deprecated ) {
33 $mockDB = $this->getMockBuilder( 'DatabaseMysql' )
34 ->disableOriginalConstructor()
35 ->getMock();
36
37 $config = array(
38 'class' => $deprecated,
39 'connection' => $mockDB,
40 # Various other parameters required:
41 'sectionsByDB' => array(),
42 'sectionLoads' => array(),
43 'serverTemplate' => array(),
44 );
45
46 $this->hideDeprecated( '$wgLBFactoryConf must be updated. See RELEASE-NOTES for details' );
47 $result = LBFactory::getLBFactoryClass( $config );
48
49 $this->assertEquals( $expected, $result );
50 }
51
52 public function getLBFactoryClassProvider() {
53 return array(
54 # Format: new class, old class
55 array( 'LBFactorySimple', 'LBFactory_Simple' ),
56 array( 'LBFactorySingle', 'LBFactory_Single' ),
57 array( 'LBFactoryMulti', 'LBFactory_Multi' ),
58 array( 'LBFactoryFake', 'LBFactory_Fake' ),
59 );
60 }
61 }