Use DB domain in JobQueueGroup and make WikiMap domain ID methods stricter
[lhc/web/wiklou.git] / tests / phpunit / includes / jobqueue / JobQueueTest.php
index 7b34b59..0421fe7 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * @group JobQueue
  * @group medium
@@ -26,7 +28,7 @@ class JobQueueTest extends MediaWikiTestCase {
                        }
                        $baseConfig = $wgJobTypeConf[$name];
                } else {
-                       $baseConfig = [ 'class' => 'JobQueueDB' ];
+                       $baseConfig = [ 'class' => JobQueueDBSingle::class ];
                }
                $baseConfig['type'] = 'null';
                $baseConfig['wiki'] = wfWikiID();
@@ -73,6 +75,7 @@ class JobQueueTest extends MediaWikiTestCase {
                        $this->markTestSkipped( $desc );
                }
                $this->assertEquals( wfWikiID(), $queue->getWiki(), "Proper wiki ID ($desc)" );
+               $this->assertEquals( wfWikiID(), $queue->getDomain(), "Proper wiki ID ($desc)" );
        }
 
        /**
@@ -232,7 +235,7 @@ class JobQueueTest extends MediaWikiTestCase {
 
                $j = $queue->pop();
                // Make sure ack() of the twin did not delete the sibling data
-               $this->assertType( 'NullJob', $j );
+               $this->assertType( NullJob::class, $j );
        }
 
        /**
@@ -381,3 +384,11 @@ class JobQueueTest extends MediaWikiTestCase {
                        [ 'lives' => 0, 'usleep' => 0, 'removeDuplicates' => 1, 'i' => $i ] + $rootJob );
        }
 }
+
+class JobQueueDBSingle extends JobQueueDB {
+       protected function getDB( $index ) {
+               $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
+               // Override to not use CONN_TRX_AUTOCOMMIT so that we see the same temporary `job` table
+               return $lb->getConnection( $index, [], $this->domain );
+       }
+}