3 namespace MediaWiki\Tests\Maintenance
;
12 class PatchSqlTest
extends MaintenanceBaseTestCase
{
14 protected function getMaintenanceClass() {
15 return PatchSql
::class;
18 public function testExecute() {
19 // Create a SQL file with an insert query
20 $testFilename = $this->getNewTempFile();
21 $testFile = fopen( $testFilename, 'w' );
22 fwrite( $testFile, "INSERT INTO /*_*/updatelog (ul_key, ul_value) VALUES ('testing1234', 'testing');\n" );
24 // Pass the file to the maintenance script and run it
25 $this->maintenance
->setArg( 'patch-name', $testFilename );
26 $this->maintenance
->execute();
27 // Check that the insert query worked
28 $this->newSelectQueryBuilder()
29 ->select( [ 'ul_key', 'ul_value' ] )
31 ->caller( __METHOD__
)
32 ->assertRowValue( [ 'testing1234', 'testing' ] );