Backport XML tests for no database (#20153) and improve GIS test

From: 7985b04f2d

Pull-request: #20170

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2026-03-17 10:53:11 +01:00
parent 4c0760bf5d
commit a59be33d71
No known key found for this signature in database
GPG Key ID: 70684F4717D49A31
3 changed files with 49 additions and 3 deletions

View File

@ -115,12 +115,12 @@ class ImportXmlTest extends AbstractTestCase
}
/**
* Test for doImport using second dataset
* Test for doImport using the GIS dataset
*
* @group medium
* @requires extension simplexml
*/
public function testDoImportDataset2(): void
public function testDoImportDatasetGIS(): void
{
global $import_notice;
@ -129,7 +129,7 @@ class ImportXmlTest extends AbstractTestCase
->getMock();
$GLOBALS['dbi'] = $dbi;
$GLOBALS['import_file'] = 'test/test_data/test.xml';
$GLOBALS['import_file'] = 'test/test_data/phpmyadmin_importXML_GIS_For_Testing.xml';
$importHandle = new File($GLOBALS['import_file']);
$importHandle->open();
@ -146,4 +146,37 @@ class ImportXmlTest extends AbstractTestCase
self::assertStringContainsString('Edit settings for `test`', $import_notice);
self::assertTrue($GLOBALS['finished']);
}
/**
* Test for doImport using no database dataset
*
* @group medium
* @requires extension simplexml
*/
public function testDoImportDatasetNoDatabase(): void
{
global $import_notice;
$dbi = $this->getMockBuilder(DatabaseInterface::class)
->disableOriginalConstructor()
->getMock();
$GLOBALS['dbi'] = $dbi;
$GLOBALS['import_file'] = 'test/test_data/phpmyadmin_importXML_No_Database_For_Testing.xml';
$importHandle = new File($GLOBALS['import_file']);
$importHandle->open();
$this->object->doImport($importHandle);
self::assertStringContainsString(
'The following structures have either been created or altered.',
$import_notice
);
self::assertStringContainsString('Go to database: `test25`', $import_notice);
self::assertStringContainsString('Edit settings for `test`', $import_notice);
self::assertStringContainsString('Go to table: `test`', $import_notice);
self::assertStringContainsString('Edit settings for `test`', $import_notice);
self::assertTrue($GLOBALS['finished']);
}
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<pma_xml_export version="1.0" xmlns:pma="https://www.phpmyadmin.net/some_doc_url/">
<pma:structure_schemas>
<pma:database name="test25" collation="utf8mb4_general_ci" charset="utf8mb4">
<pma:table name="test">
CREATE TABLE `test` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
</pma:table>
</pma:database>
</pma:structure_schemas>
</pma_xml_export>