Merge "assertValidHtml for checking html in test cases."
[lhc/web/wiklou.git] / tests / phpunit / includes / db / LBFactoryTest.php
index f64a784..4c59f47 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  *
+ * @group Database
  * @file
  * @author Antoine Musso
  * @copyright © 2013 Antoine Musso
  * @copyright © 2013 Wikimedia Foundation Inc.
  */
-
-class FakeLBFactory extends LBFactory {
-       function __construct( $conf ) {}
-       function newMainLB( $wiki = false ) {}
-       function getMainLB( $wiki = false ) {}
-       function newExternalLB( $cluster, $wiki = false ) {}
-       function &getExternalLB( $cluster, $wiki = false ) {}
-       function forEachLB( $callback, $params = array() ) {}
-}
-
 class LBFactoryTest extends MediaWikiTestCase {
 
-       function setup() {
-               parent::setup();
-               FakeLBFactory::destroyInstance();
-       }
-
        /**
-        * @dataProvider provideDeprecatedLbfactoryClasses
+        * @dataProvider getLBFactoryClassProvider
         */
-       function testLbfactoryClassBackcompatibility( $expected, $deprecated ) {
+       public function testGetLBFactoryClass( $expected, $deprecated ) {
                $mockDB = $this->getMockBuilder( 'DatabaseMysql' )
-                       -> disableOriginalConstructor()
+                       ->disableOriginalConstructor()
                        ->getMock();
-               $this->setMwGlobals( 'wgLBFactoryConf',
-                       array(
-                               'class'          => $deprecated,
-                               'connection'     => $mockDB,
-                               # Various other parameters required:
-                               'sectionsByDB'   => array(),
-                               'sectionLoads'   => array(),
-                               'serverTemplate' => array(),
-                       )
-               );
 
-               global $wgLBFactoryConf;
-               $this->assertArrayHasKey( 'class', $wgLBFactoryConf );
-               $this->assertEquals( $wgLBFactoryConf['class'], $deprecated );
+               $config = array(
+                       'class'          => $deprecated,
+                       'connection'     => $mockDB,
+                       # Various other parameters required:
+                       'sectionsByDB'   => array(),
+                       'sectionLoads'   => array(),
+                       'serverTemplate' => array(),
+               );
 
-               # The point of this test is to call a deprecated interface and make
-               # sure it keeps back compatibility, so skip the deprecation warning.
                $this->hideDeprecated( '$wgLBFactoryConf must be updated. See RELEASE-NOTES for details' );
-               $lbfactory = FakeLBFactory::singleton();
-               $this->assertInstanceOf( $expected, $lbfactory,
-                       "LBFactory passed $deprecated should yield the new class $expected" );
+               $result = LBFactory::getLBFactoryClass( $config );
+
+               $this->assertEquals( $expected, $result );
        }
 
-       function provideDeprecatedLbfactoryClasses() {
+       public function getLBFactoryClassProvider() {
                return array(
                        # Format: new class, old class
                        array( 'LBFactorySimple', 'LBFactory_Simple' ),