Merge branch 'QA_5_2'

Fixes #18930

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2024-02-18 18:59:28 -03:00
commit 09cf21915e
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
3 changed files with 60 additions and 0 deletions

View File

@ -1011,6 +1011,10 @@ class Import
$numCols = count($table->columns);
$lastColumnKey = array_key_last($table->columns);
if ($table->rows === []) {
break;
}
$tempSQLStr = 'INSERT INTO ' . Util::backquote($dbName) . '.'
. Util::backquote($table->tableName) . ' (';

View File

@ -138,4 +138,48 @@ class ImportMediawikiTest extends AbstractTestCase
self::assertStringContainsString('Edit settings for `pma_bookmarktest`', ImportSettings::$importNotice);
self::assertTrue(ImportSettings::$finished);
}
/**
* Test for doImport
*
* @group medium
*/
public function testDoImportWithEmptyTable(): void
{
//Mock DBI
$dbi = $this->getMockBuilder(DatabaseInterface::class)
->disableOriginalConstructor()
->getMock();
DatabaseInterface::$instance = $dbi;
$importHandle = new File('tests/test_data/__slashes.mediawiki');
$importHandle->open();
//Test function called
$this->object->doImport($importHandle);
// If import successfully, PMA will show all databases and
// tables imported as following HTML Page
/*
The following structures have either been created or altered. Here you
can:
View a structure's contents by clicking on its name
Change any of its settings by clicking the corresponding "Options" link
Edit structure by following the "Structure" link
mediawiki_DB (Options)
pma_bookmarktest (Structure) (Options)
*/
//asset that all databases and tables are imported
self::assertStringContainsString(
'The following structures have either been created or altered.',
ImportSettings::$importNotice,
);
self::assertStringContainsString('Go to database: `mediawiki_DB`', ImportSettings::$importNotice);
self::assertStringContainsString('Edit settings for `mediawiki_DB`', ImportSettings::$importNotice);
self::assertStringContainsString('Go to table: `empty`', ImportSettings::$importNotice);
self::assertStringContainsString('Edit settings for `empty`', ImportSettings::$importNotice);
self::assertTrue(ImportSettings::$finished);
}
}

View File

@ -0,0 +1,12 @@
<!--
Table data for `empty`
-->
{| class="wikitable sortable" style="text-align:center;"
|+'''empty'''
|-
! \'table
! \\column
|}