Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F585096
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/maintenance/rebuildall.php b/maintenance/rebuildall.php
index 7f734955a8c..9cae8a4eb84 100644
--- a/maintenance/rebuildall.php
+++ b/maintenance/rebuildall.php
@@ -49,19 +49,19 @@ class RebuildAll extends Maintenance {
if ( $this->getReplicaDB()->getType() != 'postgres' ) {
$this->output( "** Rebuilding fulltext search index (if you abort "
. "this will break searching; run this script again to fix):\n" );
- $rebuildText = $this->runChild( RebuildTextIndex::class, 'rebuildtextindex.php' );
+ $rebuildText = $this->createChild( RebuildTextIndex::class, 'rebuildtextindex.php' );
$rebuildText->execute();
}
// Rebuild RC
$this->output( "\n\n** Rebuilding recentchanges table:\n" );
- $rebuildRC = $this->runChild( RebuildRecentchanges::class, 'rebuildrecentchanges.php' );
+ $rebuildRC = $this->createChild( RebuildRecentchanges::class, 'rebuildrecentchanges.php' );
$rebuildRC->execute();
// Rebuild link tables
$this->output( "\n\n** Rebuilding links tables -- this can take a long time. "
. "It should be safe to abort via ctrl+C if you get bored.\n" );
- $rebuildLinks = $this->runChild( RefreshLinks::class, 'refreshLinks.php' );
+ $rebuildLinks = $this->createChild( RefreshLinks::class, 'refreshLinks.php' );
$rebuildLinks->execute();
$this->output( "Done.\n" );
diff --git a/tests/phpunit/maintenance/RebuildAllTest.php b/tests/phpunit/maintenance/RebuildAllTest.php
new file mode 100644
index 00000000000..5c21a2f3c76
--- /dev/null
+++ b/tests/phpunit/maintenance/RebuildAllTest.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace MediaWiki\Tests\Maintenance;
+
+use MediaWiki\Maintenance\Maintenance;
+use RebuildAll;
+use RebuildRecentchanges;
+use RebuildTextIndex;
+use RefreshLinks;
+
+/**
+ * @covers \RebuildAll
+ * @group Database
+ * @author Dreamy Jazz
+ */
+class RebuildAllTest extends MaintenanceBaseTestCase {
+
+ protected function getMaintenanceClass() {
+ return RebuildAll::class;
+ }
+
+ protected function createMaintenance() {
+ return $this->getMockBuilder( RebuildAll::class )
+ ->onlyMethods( [ 'createChild' ] )
+ ->getMock();
+ }
+
+ public function testExecute() {
+ $actualCreateChildCalls = [];
+ $maintenance = $this->createMaintenance();
+ $maintenance->method( 'createChild' )
+ ->willReturnCallback(
+ function (
+ string $maintClass, ?string $classFile
+ ) use ( &$actualCreateChildCalls ) {
+ $actualCreateChildCalls[] = [ $maintClass, $classFile ];
+
+ // Return a mocked Maintenance class to avoid testing the child scripts.
+ // These should be tested via separate tests.
+ $mockMaintenance = $this->createMock( Maintenance::class );
+ $mockMaintenance->expects( $this->once() )
+ ->method( 'execute' );
+ return $mockMaintenance;
+ }
+ );
+ $maintenance->execute();
+
+ // Verify that createChild was called for the maintenance scripts that are run by rebuildall.php
+ $expectedCreateChildCalls = [];
+ if ( $this->getDb()->getType() !== 'postgres' ) {
+ $expectedCreateChildCalls[] = [ RebuildTextIndex::class, 'rebuildtextindex.php' ];
+ }
+ $expectedCreateChildCalls[] = [ RebuildRecentchanges::class, 'rebuildrecentchanges.php' ];
+ $expectedCreateChildCalls[] = [ RefreshLinks::class, 'refreshLinks.php' ];
+
+ $this->assertSame( $expectedCreateChildCalls, $actualCreateChildCalls );
+
+ // Expect that the script outputs that it's running the above scripts
+ $actualOutput = $this->getActualOutputForAssertion();
+ if ( $this->getDb()->getType() === 'postgres' ) {
+ $this->assertStringNotContainsString( 'Rebuilding fulltext search index', $actualOutput );
+ } else {
+ $this->assertStringContainsString( 'Rebuilding fulltext search index', $actualOutput );
+ }
+ $this->assertStringContainsString( 'Rebuilding recentchanges table', $actualOutput );
+ $this->assertStringContainsString( 'Rebuilding links tables', $actualOutput );
+ }
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Jul 5, 5:32 AM (13 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
227524
Default Alt Text
(3 KB)
Attached To
Mode
rMW mediawiki
Attached
Detach File
Event Timeline
Log In to Comment