Clean up the rest of import tests (#19071)
* Clean up ImportMediawikiTest Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Clean up ImportOdsTest Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Convert $_REQUEST to setImportOptions Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Clean up ImportShpTest Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Clean up ImportSqlTest Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Clean up ImportXmlTest Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> --------- Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
6fde602c15
commit
c4167c0b8b
@ -16320,16 +16320,6 @@ parameters:
|
||||
count: 6
|
||||
path: tests/unit/Plugins/Import/ImportLdiTest.php
|
||||
|
||||
-
|
||||
message: "#^Class PhpMyAdmin\\\\Tests\\\\Plugins\\\\Import\\\\ImportOdsTest has an uninitialized property \\$dbi\\. Give it default value or assign it in the constructor\\.$#"
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Import/ImportOdsTest.php
|
||||
|
||||
-
|
||||
message: "#^Class PhpMyAdmin\\\\Tests\\\\Plugins\\\\Import\\\\ImportOdsTest has an uninitialized property \\$dummyDbi\\. Give it default value or assign it in the constructor\\.$#"
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Import/ImportOdsTest.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, mixed given\\.$#"
|
||||
count: 3
|
||||
|
||||
@ -8671,11 +8671,6 @@
|
||||
<PossiblyUnusedReturnValue>
|
||||
<code><![CDATA[string[]]]></code>
|
||||
</PossiblyUnusedReturnValue>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[$_REQUEST['ods_empty_rows'] ?? false]]></code>
|
||||
<code><![CDATA[$_REQUEST['ods_recognize_currency']]]></code>
|
||||
<code><![CDATA[$_REQUEST['ods_recognize_percentages']]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Plugins/Import/ImportShp.php">
|
||||
<DeprecatedMethod>
|
||||
@ -14246,11 +14241,6 @@
|
||||
<code><![CDATA[assertTrue]]></code>
|
||||
</TypeDoesNotContainType>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Import/ImportMediawikiTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Import/ImportOdsTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
@ -14260,24 +14250,11 @@
|
||||
</PossiblyUnusedMethod>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Import/ImportShpTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<RedundantCondition>
|
||||
<code><![CDATA[assertFalse]]></code>
|
||||
<code><![CDATA[assertSame]]></code>
|
||||
</RedundantCondition>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Import/ImportSqlTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Import/ImportXmlTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Schema/DiaRelationSchemaTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
|
||||
@ -40,6 +40,11 @@ use const LIBXML_COMPACT;
|
||||
*/
|
||||
class ImportOds extends ImportPlugin
|
||||
{
|
||||
private bool $recognizePercentages = false;
|
||||
private bool $recognizeCurrency = false;
|
||||
private bool $includeEmptyRows = false;
|
||||
private bool $hasColumnNames = false;
|
||||
|
||||
/** @psalm-return non-empty-lowercase-string */
|
||||
public function getName(): string
|
||||
{
|
||||
@ -99,6 +104,10 @@ class ImportOds extends ImportPlugin
|
||||
|
||||
public function setImportOptions(ServerRequest $request): void
|
||||
{
|
||||
$this->recognizePercentages = $request->getParsedBodyParam('ods_recognize_percentages') !== null;
|
||||
$this->recognizeCurrency = $request->getParsedBodyParam('ods_recognize_currency') !== null;
|
||||
$this->includeEmptyRows = $request->getParsedBodyParam('ods_empty_rows') !== null;
|
||||
$this->hasColumnNames = $request->getParsedBodyParam('ods_col_names') !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,7 +172,7 @@ class ImportOds extends ImportPlugin
|
||||
}
|
||||
}
|
||||
|
||||
$tables = $this->readSheets($sheets, isset($_REQUEST['ods_col_names']));
|
||||
$tables = $this->readSheets($sheets, $this->hasColumnNames);
|
||||
|
||||
/* Obtain the best-fit MySQL types for each column */
|
||||
$analyses = array_map($this->import->analyzeTable(...), $tables);
|
||||
@ -194,16 +203,14 @@ class ImportOds extends ImportPlugin
|
||||
protected function getValue(SimpleXMLElement $cellAttrs, SimpleXMLElement $text): float|string
|
||||
{
|
||||
if (
|
||||
isset($_REQUEST['ods_recognize_percentages'])
|
||||
&& $_REQUEST['ods_recognize_percentages']
|
||||
$this->recognizePercentages
|
||||
&& (string) $cellAttrs['value-type'] === 'percentage'
|
||||
) {
|
||||
return (float) $cellAttrs['value'];
|
||||
}
|
||||
|
||||
if (
|
||||
isset($_REQUEST['ods_recognize_currency'])
|
||||
&& $_REQUEST['ods_recognize_currency']
|
||||
$this->recognizeCurrency
|
||||
&& (string) $cellAttrs['value-type'] === 'currency'
|
||||
) {
|
||||
return (float) $cellAttrs['value'];
|
||||
@ -302,7 +309,7 @@ class ImportOds extends ImportPlugin
|
||||
$maxCols = max(count($tempRow), $maxCols);
|
||||
|
||||
/* Don't include a row that is full of NULL values */
|
||||
if ($_REQUEST['ods_empty_rows'] ?? false) {
|
||||
if ($this->includeEmptyRows) {
|
||||
foreach ($tempRow as $cell) {
|
||||
if ((string) $cell !== 'NULL') {
|
||||
$tempRows[] = $tempRow;
|
||||
|
||||
@ -30,7 +30,6 @@ class ImportLdiTest extends AbstractTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface();
|
||||
ImportSettings::$charsetConversion = false;
|
||||
ImportSettings::$maxSqlLength = 0;
|
||||
$GLOBALS['sql_query'] = '';
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Plugins\Import;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\File;
|
||||
@ -30,7 +29,6 @@ class ImportMediawikiTest extends AbstractTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface();
|
||||
$GLOBALS['error'] = null;
|
||||
ImportSettings::$timeoutPassed = false;
|
||||
ImportSettings::$maximumTime = 0;
|
||||
@ -44,17 +42,14 @@ class ImportMediawikiTest extends AbstractTestCase
|
||||
ImportSettings::$runQuery = false;
|
||||
ImportSettings::$goSql = false;
|
||||
ImportSettings::$importType = 'database';
|
||||
$this->object = new ImportMediawiki();
|
||||
|
||||
//setting
|
||||
ImportSettings::$finished = false;
|
||||
ImportSettings::$readLimit = 100000000;
|
||||
ImportSettings::$offset = 0;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
ImportSettings::$importFile = 'tests/test_data/phpmyadmin.mediawiki';
|
||||
$GLOBALS['import_text'] = 'ImportMediawiki_Test';
|
||||
ImportSettings::$readMultiply = 10;
|
||||
|
||||
$this->object = new ImportMediawiki();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,9 +93,6 @@ class ImportMediawikiTest extends AbstractTestCase
|
||||
*/
|
||||
public function testDoImport(): void
|
||||
{
|
||||
//$import_notice will show the import detail result
|
||||
|
||||
//Mock DBI
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
@ -139,7 +131,6 @@ class ImportMediawikiTest extends AbstractTestCase
|
||||
|
||||
public function testDoImportWithEmptyTable(): void
|
||||
{
|
||||
//Mock DBI
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
@ -8,10 +8,10 @@ use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\File;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Import\ImportSettings;
|
||||
use PhpMyAdmin\Plugins\Import\ImportOds;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Medium;
|
||||
@ -25,10 +25,6 @@ use function str_repeat;
|
||||
#[Medium]
|
||||
class ImportOdsTest extends AbstractTestCase
|
||||
{
|
||||
protected DatabaseInterface $dbi;
|
||||
|
||||
protected DbiDummy $dummyDbi;
|
||||
|
||||
protected ImportOds $object;
|
||||
|
||||
/**
|
||||
@ -39,7 +35,6 @@ class ImportOdsTest extends AbstractTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface();
|
||||
$GLOBALS['error'] = null;
|
||||
ImportSettings::$timeoutPassed = false;
|
||||
ImportSettings::$maximumTime = 0;
|
||||
@ -51,22 +46,21 @@ class ImportOdsTest extends AbstractTestCase
|
||||
ImportSettings::$runQuery = false;
|
||||
$GLOBALS['sql_query'] = '';
|
||||
ImportSettings::$goSql = false;
|
||||
$this->object = new ImportOds();
|
||||
|
||||
//setting
|
||||
ImportSettings::$finished = false;
|
||||
ImportSettings::$readLimit = 100000000;
|
||||
ImportSettings::$offset = 0;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
/**
|
||||
* Load interface for zip extension.
|
||||
*/
|
||||
ImportSettings::$readMultiply = 10;
|
||||
|
||||
$this->object = new ImportOds();
|
||||
|
||||
//variable for Ods
|
||||
$_REQUEST['ods_recognize_percentages'] = true;
|
||||
$_REQUEST['ods_recognize_currency'] = true;
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
|
||||
->withParsedBody([
|
||||
'ods_recognize_percentages' => 'yes',
|
||||
'ods_recognize_currency' => 'yes',
|
||||
]);
|
||||
$this->object->setImportOptions($request);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,23 +99,24 @@ class ImportOdsTest extends AbstractTestCase
|
||||
*/
|
||||
public function testDoImport(): void
|
||||
{
|
||||
//$sql_query_disabled will show the import SQL detail
|
||||
//$import_notice will show the import detail result
|
||||
|
||||
ImportSettings::$sqlQueryDisabled = false;
|
||||
ImportSettings::$sqlQueryDisabled = false; //will show the import SQL detail
|
||||
|
||||
ImportSettings::$importFile = 'tests/test_data/db_test.ods';
|
||||
$_REQUEST['ods_empty_rows'] = true;
|
||||
|
||||
$this->dummyDbi = $this->createDbiDummy();
|
||||
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
|
||||
DatabaseInterface::$instance = $this->dbi;
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
|
||||
->withParsedBody([
|
||||
'ods_recognize_percentages' => 'yes',
|
||||
'ods_recognize_currency' => 'yes',
|
||||
'ods_empty_rows' => 'yes',
|
||||
]);
|
||||
$this->object->setImportOptions($request);
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface();
|
||||
|
||||
$importHandle = new File(ImportSettings::$importFile);
|
||||
$importHandle->setDecompressContent(true);
|
||||
$importHandle->open();
|
||||
|
||||
//Test function called
|
||||
$this->object->doImport($importHandle);
|
||||
|
||||
self::assertStringContainsString(
|
||||
@ -134,7 +129,7 @@ class ImportOdsTest extends AbstractTestCase
|
||||
$GLOBALS['sql_query'],
|
||||
);
|
||||
|
||||
//asset that all databases and tables are imported
|
||||
//assert that all databases and tables are imported
|
||||
self::assertStringContainsString(
|
||||
'The following structures have either been created or altered.',
|
||||
ImportSettings::$importNotice,
|
||||
@ -144,14 +139,17 @@ class ImportOdsTest extends AbstractTestCase
|
||||
self::assertStringContainsString('Go to table: `pma_bookmark`', ImportSettings::$importNotice);
|
||||
self::assertStringContainsString('Edit settings for `pma_bookmark`', ImportSettings::$importNotice);
|
||||
|
||||
//asset that the import process is finished
|
||||
//assert that the import process is finished
|
||||
self::assertTrue(ImportSettings::$finished);
|
||||
}
|
||||
|
||||
/** @return mixed[] */
|
||||
/** @return array<string, array<string|null>> */
|
||||
public static function dataProviderOdsEmptyRows(): array
|
||||
{
|
||||
return ['remove empty columns' => [true], 'keep empty columns' => [false]];
|
||||
return [
|
||||
'remove empty columns' => ['yes'],
|
||||
'keep empty columns' => [null],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,20 +157,21 @@ class ImportOdsTest extends AbstractTestCase
|
||||
*/
|
||||
#[DataProvider('dataProviderOdsEmptyRows')]
|
||||
#[RequiresPhpExtension('simplexml')]
|
||||
public function testDoImportDataset2(bool $odsEmptyRowsMode): void
|
||||
public function testDoImportDataset2(string|null $odsEmptyRowsMode): void
|
||||
{
|
||||
//$sql_query_disabled will show the import SQL detail
|
||||
//$import_notice will show the import detail result
|
||||
|
||||
ImportSettings::$sqlQueryDisabled = false;
|
||||
ImportSettings::$sqlQueryDisabled = false; //will show the import SQL detail
|
||||
|
||||
ImportSettings::$importFile = 'tests/test_data/import-slim.ods.xml';
|
||||
$_REQUEST['ods_col_names'] = true;
|
||||
$_REQUEST['ods_empty_rows'] = $odsEmptyRowsMode;
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
|
||||
->withParsedBody([
|
||||
'ods_recognize_percentages' => 'yes',
|
||||
'ods_recognize_currency' => 'yes',
|
||||
'ods_col_names' => 'yes',
|
||||
'ods_empty_rows' => $odsEmptyRowsMode,
|
||||
]);
|
||||
$this->object->setImportOptions($request);
|
||||
|
||||
$this->dummyDbi = $this->createDbiDummy();
|
||||
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
|
||||
DatabaseInterface::$instance = $this->dbi;
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface();
|
||||
|
||||
$importHandle = new File(ImportSettings::$importFile);
|
||||
$importHandle->setDecompressContent(false);// Not compressed
|
||||
@ -183,12 +182,11 @@ class ImportOdsTest extends AbstractTestCase
|
||||
|
||||
$endOfSql = ');';
|
||||
|
||||
if (! $odsEmptyRowsMode) {
|
||||
if ($odsEmptyRowsMode === null) {
|
||||
$fullCols = 'NULL' . str_repeat(', NULL', 18);// 19 empty cells
|
||||
$endOfSql = '),' . "\n" . ' (' . $fullCols . '),' . "\n" . ' (' . $fullCols . ');';
|
||||
}
|
||||
|
||||
//Test function called
|
||||
$this->object->doImport($importHandle);
|
||||
|
||||
self::assertSame(
|
||||
@ -240,12 +238,12 @@ class ImportOdsTest extends AbstractTestCase
|
||||
. ' (\'0.05\'),' . "\n"
|
||||
. ' (\'true\'),' . "\n"
|
||||
. ' (\'12\')'
|
||||
. ($odsEmptyRowsMode ? '' : ',' . "\n" . ' (NULL)')
|
||||
. ($odsEmptyRowsMode ? ';' : ',' . "\n" . ' (NULL);'),
|
||||
. ($odsEmptyRowsMode !== null ? '' : ',' . "\n" . ' (NULL)')
|
||||
. ($odsEmptyRowsMode !== null ? ';' : ',' . "\n" . ' (NULL);'),
|
||||
$GLOBALS['sql_query'],
|
||||
);
|
||||
|
||||
//asset that all databases and tables are imported
|
||||
//assert that all databases and tables are imported
|
||||
self::assertStringContainsString(
|
||||
'The following structures have either been created or altered.',
|
||||
ImportSettings::$importNotice,
|
||||
@ -255,7 +253,7 @@ class ImportOdsTest extends AbstractTestCase
|
||||
self::assertStringContainsString('Go to table: `Shop`', ImportSettings::$importNotice);
|
||||
self::assertStringContainsString('Edit settings for `Shop`', ImportSettings::$importNotice);
|
||||
|
||||
//asset that the import process is finished
|
||||
//assert that the import process is finished
|
||||
self::assertTrue(ImportSettings::$finished);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Plugins\Import;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\File;
|
||||
@ -35,7 +34,6 @@ class ImportShpTest extends AbstractTestCase
|
||||
parent::setUp();
|
||||
|
||||
$GLOBALS['error'] = null;
|
||||
$GLOBALS['buffer'] = null;
|
||||
ImportSettings::$maximumTime = 0;
|
||||
ImportSettings::$charsetConversion = false;
|
||||
$GLOBALS['eof'] = null;
|
||||
@ -46,15 +44,11 @@ class ImportShpTest extends AbstractTestCase
|
||||
ImportSettings::$executedQueries = 0;
|
||||
ImportSettings::$runQuery = false;
|
||||
ImportSettings::$goSql = false;
|
||||
|
||||
//setting
|
||||
ImportSettings::$importType = 'table';
|
||||
ImportSettings::$finished = false;
|
||||
ImportSettings::$readLimit = 100000000;
|
||||
ImportSettings::$offset = 0;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
//Mock DBI
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
@ -62,7 +56,6 @@ class ImportShpTest extends AbstractTestCase
|
||||
|
||||
$this->object = new ImportShp();
|
||||
|
||||
$GLOBALS['compression'] = 'application/zip';
|
||||
ImportSettings::$readMultiply = 10;
|
||||
Current::$database = '';
|
||||
Current::$table = '';
|
||||
@ -126,13 +119,9 @@ class ImportShpTest extends AbstractTestCase
|
||||
#[Group('32bit-incompatible')]
|
||||
public function testImportOsm(): void
|
||||
{
|
||||
//$sql_query_disabled will show the import SQL detail
|
||||
//$import_notice will show the import detail result
|
||||
|
||||
ImportSettings::$sqlQueryDisabled = false;
|
||||
ImportSettings::$sqlQueryDisabled = false; //will show the import SQL detail
|
||||
Current::$database = '';
|
||||
|
||||
//Test function called
|
||||
$this->runImport('tests/test_data/dresden_osm.shp.zip');
|
||||
|
||||
$this->assertMessages(ImportSettings::$importNotice);
|
||||
@ -160,16 +149,11 @@ class ImportShpTest extends AbstractTestCase
|
||||
#[Group('32bit-incompatible')]
|
||||
public function testDoImport(): void
|
||||
{
|
||||
//$sql_query_disabled will show the import SQL detail
|
||||
//$import_notice will show the import detail result
|
||||
|
||||
ImportSettings::$sqlQueryDisabled = false;
|
||||
ImportSettings::$sqlQueryDisabled = false; //will show the import SQL detail
|
||||
Current::$database = '';
|
||||
|
||||
//Test function called
|
||||
$this->runImport('tests/test_data/timezone.shp.zip');
|
||||
|
||||
// asset that all sql are executed
|
||||
self::assertStringContainsString(
|
||||
'CREATE DATABASE IF NOT EXISTS `SHP_DB` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci',
|
||||
$GLOBALS['sql_query'],
|
||||
@ -201,7 +185,7 @@ class ImportShpTest extends AbstractTestCase
|
||||
|
||||
self::assertStringContainsString("GeomFromText('POINT(1294523.1759236", $GLOBALS['sql_query']);
|
||||
|
||||
//asset that all databases and tables are imported
|
||||
//assert that all databases and tables are imported
|
||||
$this->assertMessages(ImportSettings::$importNotice);
|
||||
}
|
||||
|
||||
@ -221,7 +205,7 @@ class ImportShpTest extends AbstractTestCase
|
||||
self::assertStringContainsString('Go to table: `TBL_NAME`', $importNotice);
|
||||
self::assertStringContainsString('Edit settings for `TBL_NAME`', $importNotice);
|
||||
|
||||
//asset that the import process is finished
|
||||
//assert that the import process is finished
|
||||
self::assertTrue(ImportSettings::$finished);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Plugins\Import;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\File;
|
||||
use PhpMyAdmin\Import\ImportSettings;
|
||||
@ -27,7 +26,6 @@ class ImportSqlTest extends AbstractTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface();
|
||||
$GLOBALS['error'] = null;
|
||||
ImportSettings::$timeoutPassed = false;
|
||||
ImportSettings::$maximumTime = 0;
|
||||
@ -38,19 +36,14 @@ class ImportSqlTest extends AbstractTestCase
|
||||
ImportSettings::$executedQueries = 0;
|
||||
ImportSettings::$runQuery = false;
|
||||
ImportSettings::$goSql = false;
|
||||
|
||||
$this->object = new ImportSql();
|
||||
|
||||
//setting
|
||||
ImportSettings::$finished = false;
|
||||
ImportSettings::$readLimit = 100000000;
|
||||
ImportSettings::$offset = 0;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
ImportSettings::$importFile = 'tests/test_data/pma_bookmark.sql';
|
||||
$GLOBALS['import_text'] = 'ImportSql_Test';
|
||||
$GLOBALS['compression'] = 'none';
|
||||
ImportSettings::$readMultiply = 10;
|
||||
|
||||
$this->object = new ImportSql();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,11 +62,8 @@ class ImportSqlTest extends AbstractTestCase
|
||||
*/
|
||||
public function testDoImport(): void
|
||||
{
|
||||
//$sql_query_disabled will show the import SQL detail
|
||||
ImportSettings::$sqlQueryDisabled = false; // will show the import SQL detail
|
||||
|
||||
ImportSettings::$sqlQueryDisabled = false;
|
||||
|
||||
//Mock DBI
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
@ -82,10 +72,8 @@ class ImportSqlTest extends AbstractTestCase
|
||||
$importHandle = new File(ImportSettings::$importFile);
|
||||
$importHandle->open();
|
||||
|
||||
//Test function called
|
||||
$this->object->doImport($importHandle);
|
||||
|
||||
//asset that all sql are executed
|
||||
self::assertStringContainsString('SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"', $GLOBALS['sql_query']);
|
||||
self::assertStringContainsString('CREATE TABLE IF NOT EXISTS `pma_bookmark`', $GLOBALS['sql_query']);
|
||||
self::assertStringContainsString(
|
||||
|
||||
@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Plugins\Import;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\File;
|
||||
@ -33,7 +32,6 @@ class ImportXmlTest extends AbstractTestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface();
|
||||
$GLOBALS['error'] = null;
|
||||
ImportSettings::$timeoutPassed = false;
|
||||
ImportSettings::$maximumTime = 0;
|
||||
@ -46,19 +44,14 @@ class ImportXmlTest extends AbstractTestCase
|
||||
ImportSettings::$executedQueries = 0;
|
||||
ImportSettings::$runQuery = false;
|
||||
ImportSettings::$goSql = false;
|
||||
|
||||
$this->object = new ImportXml();
|
||||
|
||||
//setting
|
||||
ImportSettings::$finished = false;
|
||||
ImportSettings::$readLimit = 100000000;
|
||||
ImportSettings::$offset = 0;
|
||||
Config::getInstance()->selectedServer['DisableIS'] = false;
|
||||
|
||||
ImportSettings::$importFile = 'tests/test_data/phpmyadmin_importXML_For_Testing.xml';
|
||||
$GLOBALS['import_text'] = 'ImportXml_Test';
|
||||
$GLOBALS['compression'] = 'none';
|
||||
ImportSettings::$readMultiply = 10;
|
||||
|
||||
$this->object = new ImportXml();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,9 +96,6 @@ class ImportXmlTest extends AbstractTestCase
|
||||
#[RequiresPhpExtension('simplexml')]
|
||||
public function testDoImport(): void
|
||||
{
|
||||
//$import_notice will show the import detail result
|
||||
|
||||
//Mock DBI
|
||||
$dbi = $this->getMockBuilder(DatabaseInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
@ -114,7 +104,6 @@ class ImportXmlTest extends AbstractTestCase
|
||||
$importHandle = new File(ImportSettings::$importFile);
|
||||
$importHandle->open();
|
||||
|
||||
//Test function called
|
||||
$this->object->doImport($importHandle);
|
||||
|
||||
// If import successfully, PMA will show all databases and tables
|
||||
@ -130,7 +119,6 @@ class ImportXmlTest extends AbstractTestCase
|
||||
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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user