diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 16df40dd1c..94590621b4 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -8407,13 +8407,13 @@ parameters:
path: src/Export/Template.php
-
- message: '#^Parameter \#2 \$username of class PhpMyAdmin\\Export\\Template constructor expects string, mixed given\.$#'
+ message: '#^Parameter \#1 \$value of static method PhpMyAdmin\\Plugins\\ExportType\:\:from\(\) expects int\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Export/Template.php
-
- message: '#^Parameter \#3 \$exportType of class PhpMyAdmin\\Export\\Template constructor expects string, mixed given\.$#'
+ message: '#^Parameter \#2 \$username of class PhpMyAdmin\\Export\\Template constructor expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Export/Template.php
diff --git a/src/Controllers/Database/ExportController.php b/src/Controllers/Database/ExportController.php
index 48bd8d1671..9a107466d3 100644
--- a/src/Controllers/Database/ExportController.php
+++ b/src/Controllers/Database/ExportController.php
@@ -15,6 +15,7 @@ use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Url;
use PhpMyAdmin\UrlParams;
@@ -123,9 +124,9 @@ final class ExportController implements InvocableController
$isReturnBackFromRawExport = $request->getParsedBodyParam('export_type') === 'raw';
if ($request->hasBodyParam('raw_query') || $isReturnBackFromRawExport) {
- $exportType = 'raw';
+ $exportType = ExportType::Raw;
} else {
- $exportType = 'database';
+ $exportType = ExportType::Database;
}
$GLOBALS['single_table'] = $request->getParam('single_table') ?? $GLOBALS['single_table'] ?? null;
diff --git a/src/Controllers/Export/ExportController.php b/src/Controllers/Export/ExportController.php
index 9b2fd863cd..89eb0c3539 100644
--- a/src/Controllers/Export/ExportController.php
+++ b/src/Controllers/Export/ExportController.php
@@ -22,6 +22,7 @@ use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\Export\ExportSql;
use PhpMyAdmin\Plugins\Export\ExportXml;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Sanitize;
use PhpMyAdmin\SqlParser\Parser;
@@ -94,10 +95,7 @@ final class ExportController implements InvocableController
return $this->response->missingParameterError('what');
}
- $exportType = $request->getParsedBodyParamAsString('export_type');
- if ($exportType === '') {
- return $this->response->missingParameterError('export_type');
- }
+ $exportType = ExportType::from($request->getParsedBodyParamAsString('export_type'));
// export class instance, not array of properties, as before
$exportPlugin = Plugins::getPlugin('export', $GLOBALS['what'], $exportType, isset($GLOBALS['single_table']));
@@ -162,7 +160,7 @@ final class ExportController implements InvocableController
$tableNames = [];
// Generate error url and check for needed variables
- if ($exportType === 'database') {
+ if ($exportType === ExportType::Database) {
if (Current::$database === '') {
return $this->response->missingParameterError('db');
}
@@ -171,7 +169,7 @@ final class ExportController implements InvocableController
$tableNames = $GLOBALS['table_select'] ?? [];
Assert::isArray($tableNames);
Assert::allString($tableNames);
- } elseif ($exportType === 'table') {
+ } elseif ($exportType === ExportType::Table) {
if (Current::$database === '') {
return $this->response->missingParameterError('db');
}
@@ -179,11 +177,6 @@ final class ExportController implements InvocableController
if (Current::$table === '') {
return $this->response->missingParameterError('table');
}
- } elseif ($exportType !== 'raw' && $exportType !== 'server') {
- $this->response->setRequestStatus(false);
- $this->response->addHTML(Message::error(__('Bad parameters!'))->getDisplay());
-
- return $this->response->response();
}
// Merge SQL Query aliases with Export aliases from
@@ -252,7 +245,7 @@ final class ExportController implements InvocableController
}
// For raw query export, filename will be export.extension
- if ($exportType === 'raw') {
+ if ($exportType === ExportType::Raw) {
$filename = $this->export->getFinalFilename($exportPlugin, $GLOBALS['compression'], 'export');
}
@@ -283,7 +276,7 @@ final class ExportController implements InvocableController
Core::downloadHeader($filename, $mimeType);
} else {
// HTML
- if ($exportType === 'database') {
+ if ($exportType === ExportType::Database) {
$GLOBALS['num_tables'] = count($tableNames);
if ($GLOBALS['num_tables'] === 0) {
$GLOBALS['message'] = Message::error(
@@ -337,14 +330,14 @@ final class ExportController implements InvocableController
$GLOBALS[$GLOBALS['what'] . '_structure_or_data'] = $whatStrucOrData;
}
- if ($exportType === 'raw') {
+ if ($exportType === ExportType::Raw) {
$whatStrucOrData = 'raw';
}
/**
* Builds the dump
*/
- if ($exportType === 'server') {
+ if ($exportType === ExportType::Server) {
if ($dbSelect === null) {
$dbSelect = '';
}
@@ -361,7 +354,7 @@ final class ExportController implements InvocableController
$aliases,
$separateFiles,
);
- } elseif ($exportType === 'database') {
+ } elseif ($exportType === ExportType::Database) {
if (! is_array($tableStructure)) {
$tableStructure = [];
}
@@ -413,7 +406,7 @@ final class ExportController implements InvocableController
$separateFiles,
);
}
- } elseif ($exportType === 'raw') {
+ } elseif ($exportType === ExportType::Raw) {
Export::exportRaw($whatStrucOrData, $exportPlugin, Current::$database, Current::$sqlQuery);
} else {
// We export just one table
diff --git a/src/Controllers/Operations/DatabaseController.php b/src/Controllers/Operations/DatabaseController.php
index c7b72ae72d..86465195d1 100644
--- a/src/Controllers/Operations/DatabaseController.php
+++ b/src/Controllers/Operations/DatabaseController.php
@@ -21,6 +21,7 @@ use PhpMyAdmin\Message;
use PhpMyAdmin\MessageType;
use PhpMyAdmin\Operations;
use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Query\Utilities;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Url;
@@ -100,7 +101,7 @@ final class DatabaseController implements InvocableController
$tableNames = $this->dbi->getTables(Current::$database);
// remove all foreign key constraints, otherwise we can get errors
- $exportSqlPlugin = Plugins::getPlugin('export', 'sql', 'database', isset($GLOBALS['single_table']));
+ $exportSqlPlugin = Plugins::getPlugin('export', 'sql', ExportType::Database, isset($GLOBALS['single_table']));
// create stand-in tables for views
$views = $this->operations->getViewsAndCreateSqlViewStandIn(
diff --git a/src/Controllers/Server/ExportController.php b/src/Controllers/Server/ExportController.php
index e3f9b320a9..3ec911beda 100644
--- a/src/Controllers/Server/ExportController.php
+++ b/src/Controllers/Server/ExportController.php
@@ -13,6 +13,7 @@ use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\ResponseRenderer;
use function __;
@@ -57,7 +58,7 @@ final class ExportController implements InvocableController
$GLOBALS['single_table'] = $request->getParam('single_table') ?? $GLOBALS['single_table'] ?? null;
- $exportList = Plugins::getExport('server', isset($GLOBALS['single_table']));
+ $exportList = Plugins::getExport(ExportType::Server, isset($GLOBALS['single_table']));
if ($exportList === []) {
$this->response->addHTML(Message::error(
@@ -68,7 +69,7 @@ final class ExportController implements InvocableController
}
$options = $this->export->getOptions(
- 'server',
+ ExportType::Server,
Current::$database,
Current::$table,
Current::$sqlQuery,
diff --git a/src/Controllers/Table/ExportController.php b/src/Controllers/Table/ExportController.php
index d352261478..b12e203e36 100644
--- a/src/Controllers/Table/ExportController.php
+++ b/src/Controllers/Table/ExportController.php
@@ -12,6 +12,7 @@ use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Statements\SelectStatement;
@@ -88,7 +89,7 @@ class ExportController implements InvocableController
$GLOBALS['single_table'] = $request->getParam('single_table') ?? $GLOBALS['single_table'] ?? null;
- $exportList = Plugins::getExport('table', isset($GLOBALS['single_table']));
+ $exportList = Plugins::getExport(ExportType::Table, isset($GLOBALS['single_table']));
if ($exportList === []) {
$this->response->addHTML(Message::error(
@@ -98,10 +99,10 @@ class ExportController implements InvocableController
return $this->response->response();
}
- $exportType = 'table';
+ $exportType = ExportType::Table;
$isReturnBackFromRawExport = $request->getParsedBodyParam('export_type') === 'raw';
if ($request->hasBodyParam('raw_query') || $isReturnBackFromRawExport) {
- $exportType = 'raw';
+ $exportType = ExportType::Raw;
}
$options = $this->export->getOptions(
@@ -115,7 +116,7 @@ class ExportController implements InvocableController
);
$this->response->render('table/export/index', array_merge($options, [
- 'export_type' => $exportType,
+ 'export_type' => $exportType->value,
'page_settings_error_html' => $pageSettingsErrorHtml,
'page_settings_html' => $pageSettingsHtml,
]));
diff --git a/src/Export/Export.php b/src/Export/Export.php
index 6990ae4de7..bd947dff36 100644
--- a/src/Export/Export.php
+++ b/src/Export/Export.php
@@ -18,6 +18,7 @@ use PhpMyAdmin\Message;
use PhpMyAdmin\MessageType;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Plugins\SchemaPlugin;
use PhpMyAdmin\Table\Table;
use PhpMyAdmin\Url;
@@ -223,14 +224,14 @@ class Export
/**
* Returns HTML containing the footer for a displayed export
*
- * @param string $exportType the export type
- * @param string $db the database name
- * @param string $table the table name
+ * @param ExportType $exportType the export type
+ * @param string $db the database name
+ * @param string $table the table name
*
* @return string the HTML output
*/
public function getHtmlForDisplayedExportFooter(
- string $exportType,
+ ExportType $exportType,
string $db,
string $table,
): string {
@@ -314,14 +315,14 @@ class Export
public function rememberFilename(
Config $config,
- string $exportType,
+ ExportType $exportType,
string $filenameTemplate,
): void {
- if ($exportType === 'server') {
+ if ($exportType === ExportType::Server) {
$config->setUserValue('pma_server_filename_template', 'Export/file_template_server', $filenameTemplate);
- } elseif ($exportType === 'database') {
+ } elseif ($exportType === ExportType::Database) {
$config->setUserValue('pma_db_filename_template', 'Export/file_template_database', $filenameTemplate);
- } elseif ($exportType === 'raw') {
+ } elseif ($exportType === ExportType::Raw) {
$config->setUserValue('pma_raw_filename_template', 'Export/file_template_raw', $filenameTemplate);
} else {
$config->setUserValue('pma_table_filename_template', 'Export/file_template_table', $filenameTemplate);
@@ -463,14 +464,14 @@ class Export
/**
* Returns HTML containing the header for a displayed export
*
- * @param string $exportType the export type
- * @param string $db the database name
- * @param string $table the table name
+ * @param ExportType $exportType the export type
+ * @param string $db the database name
+ * @param string $table the table name
*
* @return string the generated HTML and back button
*/
public function getHtmlForDisplayedExportHeader(
- string $exportType,
+ ExportType $exportType,
string $db,
string $table,
): string {
@@ -495,7 +496,7 @@ class Export
* @param string|mixed[] $dbSelect the selected databases to export
* @param string $whatStrucOrData structure or data or both
* @param ExportPlugin $exportPlugin the selected export plugin
- * @param string $exportType the export type
+ * @param ExportType $exportType the export type
* @param bool $doRelation whether to export relation info
* @param bool $doComments whether to add comments
* @param bool $doMime whether to add MIME info
@@ -507,7 +508,7 @@ class Export
string|array $dbSelect,
string $whatStrucOrData,
ExportPlugin $exportPlugin,
- string $exportType,
+ ExportType $exportType,
bool $doRelation,
bool $doComments,
bool $doMime,
@@ -559,7 +560,7 @@ class Export
* @param string[] $tableStructure whether to export structure for each table
* @param string[] $tableData whether to export data for each table
* @param ExportPlugin $exportPlugin the selected export plugin
- * @param string $exportType the export type
+ * @param ExportType $exportType the export type
* @param bool $doRelation whether to export relation info
* @param bool $doComments whether to add comments
* @param bool $doMime whether to add MIME info
@@ -574,7 +575,7 @@ class Export
array $tableStructure,
array $tableData,
ExportPlugin $exportPlugin,
- string $exportType,
+ ExportType $exportType,
bool $doRelation,
bool $doComments,
bool $doMime,
@@ -850,7 +851,7 @@ class Export
* @param string $table the table to export
* @param string $whatStrucOrData structure or data or both
* @param ExportPlugin $exportPlugin the selected export plugin
- * @param string $exportType the export type
+ * @param ExportType $exportType the export type
* @param bool $doRelation whether to export relation info
* @param bool $doComments whether to add comments
* @param bool $doMime whether to add MIME info
@@ -866,7 +867,7 @@ class Export
string $table,
string $whatStrucOrData,
ExportPlugin $exportPlugin,
- string $exportType,
+ ExportType $exportType,
bool $doRelation,
bool $doComments,
bool $doMime,
@@ -1001,15 +1002,15 @@ class Export
*
* @psalm-return non-empty-string
*/
- public function getPageLocationAndSaveMessage(string $exportType, Message $message): string
+ public function getPageLocationAndSaveMessage(ExportType $exportType, Message $message): string
{
(new FlashMessenger())->addMessage($message->isError() ? 'danger' : 'success', $message->getMessage());
- if ($exportType === 'server') {
+ if ($exportType === ExportType::Server) {
return 'index.php?route=/server/export' . Url::getCommonRaw([], '&');
}
- if ($exportType === 'database') {
+ if ($exportType === ExportType::Database) {
$params = ['db' => Current::$database];
return 'index.php?route=/database/export' . Url::getCommonRaw($params, '&');
@@ -1148,24 +1149,22 @@ class Export
* get all the export options and verify
* call and include the appropriate Schema Class depending on $export_type
*
- * @param non-empty-string $exportType
- *
* @return array{fileName: non-empty-string, mediaType: non-empty-string, fileData: string}
*
* @throws ExportException
*/
- public function getExportSchemaInfo(DatabaseName $db, string $exportType): array
+ public function getExportSchemaInfo(DatabaseName $db, string $format): array
{
/**
* default is PDF, otherwise validate it's only letters a-z
*/
- if (preg_match('/^[a-zA-Z]+$/', $exportType) !== 1) {
- $exportType = 'pdf';
+ if (preg_match('/^[a-zA-Z]+$/', $format) !== 1) {
+ $format = 'pdf';
}
// get the specific plugin
/** @var SchemaPlugin|null $exportPlugin */
- $exportPlugin = Plugins::getPlugin('schema', $exportType);
+ $exportPlugin = Plugins::getPlugin('schema', $format);
// Check schema export type
if ($exportPlugin === null) {
@@ -1183,7 +1182,7 @@ class Export
return $this->dbi->getTables($database);
}
- private function getHTMLForRefreshButton(string $exportType): string
+ private function getHTMLForRefreshButton(ExportType $exportType): string
{
$postParams = $this->getPostParams($exportType);
@@ -1211,12 +1210,12 @@ class Export
. __('Copy to clipboard') . ' ]
';
}
- private function getHTMLForBackButton(string $exportType, string $db, string $table): string
+ private function getHTMLForBackButton(ExportType $exportType, string $db, string $table): string
{
$backButton = '[ exportComment();
// delete the stand-in table previously created (if any)
- if ($exportType !== 'table') {
+ if ($exportType !== ExportType::Table) {
$dump .= 'DROP TABLE IF EXISTS '
. Util::backquote($tableAlias) . ';' . "\n";
}
diff --git a/src/Plugins/Export/ExportTexytext.php b/src/Plugins/Export/ExportTexytext.php
index 741d53f20c..088f021517 100644
--- a/src/Plugins/Export/ExportTexytext.php
+++ b/src/Plugins/Export/ExportTexytext.php
@@ -11,6 +11,7 @@ use PhpMyAdmin\Column;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@@ -136,11 +137,11 @@ class ExportTexytext extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
- * @param string $db Database name
- * @param string $exportType 'server', 'database', 'table'
- * @param string $dbAlias Aliases of db
+ * @param string $db Database name
+ * @param ExportType $exportType 'server', 'database', 'table'
+ * @param string $dbAlias Aliases of db
*/
- public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
+ public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}
@@ -450,26 +451,26 @@ class ExportTexytext extends ExportPlugin
/**
* Outputs table's structure
*
- * @param string $db database name
- * @param string $table table name
- * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
- * @param string $exportType 'server', 'database', 'table'
- * @param bool $doRelation whether to include relation comments
- * @param bool $doComments whether to include the pmadb-style column
- * comments as comments in the structure;
- * this is deprecated but the parameter is
- * left here because /export calls
- * $this->exportStructure() also for other
- * export types which use this parameter
- * @param bool $doMime whether to include mime comments
- * @param bool $dates whether to include creation/update/check dates
- * @param mixed[] $aliases Aliases of db/table/columns
+ * @param string $db database name
+ * @param string $table table name
+ * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
+ * @param ExportType $exportType 'server', 'database', 'table'
+ * @param bool $doRelation whether to include relation comments
+ * @param bool $doComments whether to include the pmadb-style column
+ * comments as comments in the structure;
+ * this is deprecated but the parameter is
+ * left here because /export calls
+ * $this->exportStructure() also for other
+ * export types which use this parameter
+ * @param bool $doMime whether to include mime comments
+ * @param bool $dates whether to include creation/update/check dates
+ * @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(
string $db,
string $table,
string $exportMode,
- string $exportType,
+ ExportType $exportType,
bool $doRelation = false,
bool $doComments = false,
bool $doMime = false,
diff --git a/src/Plugins/Export/ExportXml.php b/src/Plugins/Export/ExportXml.php
index 032023bf51..cb4c4e5d6e 100644
--- a/src/Plugins/Export/ExportXml.php
+++ b/src/Plugins/Export/ExportXml.php
@@ -12,6 +12,7 @@ use PhpMyAdmin\Database\Routines;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@@ -383,11 +384,11 @@ class ExportXml extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
- * @param string $db Database name
- * @param string $exportType 'server', 'database', 'table'
- * @param string $dbAlias Aliases of db
+ * @param string $db Database name
+ * @param ExportType $exportType 'server', 'database', 'table'
+ * @param string $dbAlias Aliases of db
*/
- public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
+ public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}
diff --git a/src/Plugins/Export/ExportYaml.php b/src/Plugins/Export/ExportYaml.php
index 95c7dc395b..2a0e5754a8 100644
--- a/src/Plugins/Export/ExportYaml.php
+++ b/src/Plugins/Export/ExportYaml.php
@@ -11,6 +11,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\FieldMetadata;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@@ -104,11 +105,11 @@ class ExportYaml extends ExportPlugin
/**
* Outputs CREATE DATABASE statement
*
- * @param string $db Database name
- * @param string $exportType 'server', 'database', 'table'
- * @param string $dbAlias Aliases of db
+ * @param string $db Database name
+ * @param ExportType $exportType 'server', 'database', 'table'
+ * @param string $dbAlias Aliases of db
*/
- public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool
+ public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool
{
return true;
}
diff --git a/src/Plugins/ExportPlugin.php b/src/Plugins/ExportPlugin.php
index 094eea28a3..fce79b235e 100644
--- a/src/Plugins/ExportPlugin.php
+++ b/src/Plugins/ExportPlugin.php
@@ -28,7 +28,7 @@ abstract class ExportPlugin implements Plugin
*/
protected ExportPluginProperties $properties;
- public static string $exportType = '';
+ public static ExportType $exportType = ExportType::Raw;
public static bool $singleTable = false;
final public function __construct(
@@ -68,11 +68,11 @@ abstract class ExportPlugin implements Plugin
/**
* Outputs CREATE DATABASE statement
*
- * @param string $db Database name
- * @param string $exportType 'server', 'database', 'table'
- * @param string $dbAlias Aliases of db
+ * @param string $db Database name
+ * @param ExportType $exportType 'server', 'database', 'table'
+ * @param string $dbAlias Aliases of db
*/
- abstract public function exportDBCreate(string $db, string $exportType, string $dbAlias = ''): bool;
+ abstract public function exportDBCreate(string $db, ExportType $exportType, string $dbAlias = ''): bool;
/**
* Outputs the content of a table
@@ -129,25 +129,25 @@ abstract class ExportPlugin implements Plugin
/**
* Outputs table's structure
*
- * @param string $db database name
- * @param string $table table name
- * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
- * @param string $exportType 'server', 'database', 'table'
- * @param bool $doRelation whether to include relation comments
- * @param bool $doComments whether to include the pmadb-style column comments
- * as comments in the structure; this is deprecated
- * but the parameter is left here because /export
- * calls exportStructure() also for other export
- * types which use this parameter
- * @param bool $doMime whether to include mime comments
- * @param bool $dates whether to include creation/update/check dates
- * @param mixed[] $aliases Aliases of db/table/columns
+ * @param string $db database name
+ * @param string $table table name
+ * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in'
+ * @param ExportType $exportType 'server', 'database', 'table'
+ * @param bool $doRelation whether to include relation comments
+ * @param bool $doComments whether to include the pmadb-style column comments
+ * as comments in the structure; this is deprecated
+ * but the parameter is left here because /export
+ * calls exportStructure() also for other export
+ * types which use this parameter
+ * @param bool $doMime whether to include mime comments
+ * @param bool $dates whether to include creation/update/check dates
+ * @param mixed[] $aliases Aliases of db/table/columns
*/
public function exportStructure(
string $db,
string $table,
string $exportMode,
- string $exportType,
+ ExportType $exportType,
bool $doRelation = false,
bool $doComments = false,
bool $doMime = false,
diff --git a/src/Plugins/ExportType.php b/src/Plugins/ExportType.php
new file mode 100644
index 0000000000..9a735e5a61
--- /dev/null
+++ b/src/Plugins/ExportType.php
@@ -0,0 +1,13 @@
+useSqlBackquotes(true);
diff --git a/tests/unit/Controllers/Export/Template/CreateControllerTest.php b/tests/unit/Controllers/Export/Template/CreateControllerTest.php
index ba777eba57..5c9f087cc8 100644
--- a/tests/unit/Controllers/Export/Template/CreateControllerTest.php
+++ b/tests/unit/Controllers/Export/Template/CreateControllerTest.php
@@ -50,7 +50,7 @@ class CreateControllerTest extends AbstractTestCase
$template = new Template();
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody([
- 'exportType' => 'type',
+ 'exportType' => 'raw',
'templateName' => 'name',
'templateData' => 'data',
'template_id' => null,
@@ -67,14 +67,14 @@ class CreateControllerTest extends AbstractTestCase
ExportTemplate::fromArray([
'id' => 1,
'username' => 'user1',
- 'exportType' => 'type1',
+ 'exportType' => 'raw',
'name' => 'name1',
'data' => 'data1',
]),
ExportTemplate::fromArray([
'id' => 2,
'username' => 'user2',
- 'exportType' => 'type2',
+ 'exportType' => 'raw',
'name' => 'name2',
'data' => 'data2',
]),
diff --git a/tests/unit/Controllers/Table/ExportControllerTest.php b/tests/unit/Controllers/Table/ExportControllerTest.php
index e69ce41ea4..68e8ee4509 100644
--- a/tests/unit/Controllers/Table/ExportControllerTest.php
+++ b/tests/unit/Controllers/Table/ExportControllerTest.php
@@ -15,6 +15,7 @@ use PhpMyAdmin\Export\Options;
use PhpMyAdmin\Export\TemplateModel;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
@@ -58,7 +59,7 @@ class ExportControllerTest extends AbstractTestCase
);
$pageSettings->init('Export');
$template = new Template();
- $exportList = Plugins::getExport('table', true);
+ $exportList = Plugins::getExport(ExportType::Table, true);
$expected = $template->render('table/export/index', [
'export_type' => 'table',
diff --git a/tests/unit/Export/ExportTest.php b/tests/unit/Export/ExportTest.php
index d9c54ce7fb..75e000a2ca 100644
--- a/tests/unit/Export/ExportTest.php
+++ b/tests/unit/Export/ExportTest.php
@@ -14,6 +14,7 @@ use PhpMyAdmin\Identifiers\DatabaseName;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins\Export\ExportPhparray;
use PhpMyAdmin\Plugins\Export\ExportSql;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Transformations;
use PHPUnit\Framework\Attributes\CoversClass;
@@ -139,7 +140,7 @@ class ExportTest extends AbstractTestCase
['test_table'],
['test_table'],
new ExportSql(new Relation($dbi), $export, new Transformations()),
- 'database',
+ ExportType::Database,
false,
true,
false,
@@ -218,7 +219,7 @@ SQL;
['test_db'],
'structure_and_data',
new ExportSql(new Relation($dbi), $export, new Transformations()),
- 'server',
+ ExportType::Server,
false,
true,
false,
@@ -248,7 +249,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
- $location = $export->getPageLocationAndSaveMessage('server', Message::error('Error message!'));
+ $location = $export->getPageLocationAndSaveMessage(ExportType::Server, Message::error('Error message!'));
self::assertSame('index.php?route=/server/export&server=2&lang=en', $location);
self::assertSame(
[['context' => 'danger', 'message' => 'Error message!', 'statement' => '']],
@@ -263,7 +264,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
- $location = $export->getPageLocationAndSaveMessage('server', Message::success('Success message!'));
+ $location = $export->getPageLocationAndSaveMessage(ExportType::Server, Message::success('Success message!'));
self::assertSame('index.php?route=/server/export&server=2&lang=en', $location);
self::assertSame(
[['context' => 'success', 'message' => 'Success message!', 'statement' => '']],
@@ -279,7 +280,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
- $location = $export->getPageLocationAndSaveMessage('database', Message::error('Error message!'));
+ $location = $export->getPageLocationAndSaveMessage(ExportType::Database, Message::error('Error message!'));
self::assertSame('index.php?route=/database/export&db=test_db&server=2&lang=en', $location);
self::assertSame(
[['context' => 'danger', 'message' => 'Error message!', 'statement' => '']],
@@ -295,7 +296,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
- $location = $export->getPageLocationAndSaveMessage('database', Message::success('Success message!'));
+ $location = $export->getPageLocationAndSaveMessage(ExportType::Database, Message::success('Success message!'));
self::assertSame('index.php?route=/database/export&db=test_db&server=2&lang=en', $location);
self::assertSame(
[['context' => 'success', 'message' => 'Success message!', 'statement' => '']],
@@ -312,7 +313,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
- $location = $export->getPageLocationAndSaveMessage('table', Message::error('Error message!'));
+ $location = $export->getPageLocationAndSaveMessage(ExportType::Table, Message::error('Error message!'));
self::assertSame(
'index.php?route=/table/export&db=test_db&table=test_table&single_table=true&server=2&lang=en',
$location,
@@ -332,7 +333,7 @@ SQL;
$_SESSION = [];
$dbi = $this->createDatabaseInterface();
$export = new Export($dbi);
- $location = $export->getPageLocationAndSaveMessage('table', Message::success('Success message!'));
+ $location = $export->getPageLocationAndSaveMessage(ExportType::Table, Message::success('Success message!'));
self::assertSame(
'index.php?route=/table/export&db=test_db&table=test_table&single_table=true&server=2&lang=en',
$location,
diff --git a/tests/unit/Export/OptionsTest.php b/tests/unit/Export/OptionsTest.php
index 47ca58f71c..de2ed27dc7 100644
--- a/tests/unit/Export/OptionsTest.php
+++ b/tests/unit/Export/OptionsTest.php
@@ -12,6 +12,7 @@ use PhpMyAdmin\Encoding;
use PhpMyAdmin\Export\Options;
use PhpMyAdmin\Export\TemplateModel;
use PhpMyAdmin\Plugins;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Util;
use PHPUnit\Framework\Attributes\CoversClass;
@@ -56,7 +57,7 @@ class OptionsTest extends AbstractTestCase
$config->settings['ZipDump'] = false;
$config->settings['GZipDump'] = false;
- $exportType = 'server';
+ $exportType = ExportType::Server;
$db = 'PMA';
$table = 'PMA_test';
$numTablesStr = '10';
@@ -87,7 +88,7 @@ class OptionsTest extends AbstractTestCase
$actual = $this->export->getOptions($exportType, $db, $table, '', $numTablesStr, $unlimNumRowsStr, $exportList);
$expected = [
- 'export_type' => $exportType,
+ 'export_type' => $exportType->value,
'db' => $db,
'table' => $table,
'templates' => ['is_enabled' => '', 'templates' => [], 'selected' => null],
@@ -95,7 +96,7 @@ class OptionsTest extends AbstractTestCase
'hidden_inputs' => [
'db' => $db,
'table' => $table,
- 'export_type' => $exportType,
+ 'export_type' => $exportType->value,
'export_method' => $config->settings['Export']['method'],
'template_id' => '',
],
diff --git a/tests/unit/Plugins/Export/ExportCsvTest.php b/tests/unit/Plugins/Export/ExportCsvTest.php
index b0de9ff66b..b7ed86557f 100644
--- a/tests/unit/Plugins/Export/ExportCsvTest.php
+++ b/tests/unit/Plugins/Export/ExportCsvTest.php
@@ -9,6 +9,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportCsv;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@@ -362,7 +363,7 @@ class ExportCsvTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
diff --git a/tests/unit/Plugins/Export/ExportHtmlwordTest.php b/tests/unit/Plugins/Export/ExportHtmlwordTest.php
index d887222d94..d2764bc916 100644
--- a/tests/unit/Plugins/Export/ExportHtmlwordTest.php
+++ b/tests/unit/Plugins/Export/ExportHtmlwordTest.php
@@ -14,6 +14,7 @@ use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Identifiers\TriggerName;
use PhpMyAdmin\Plugins\Export\ExportHtmlword;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@@ -284,7 +285,7 @@ class ExportHtmlwordTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
@@ -583,7 +584,7 @@ class ExportHtmlwordTest extends AbstractTestCase
'test_db',
'test_table',
'create_table',
- 'test',
+ ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@@ -609,7 +610,7 @@ class ExportHtmlwordTest extends AbstractTestCase
'test_db',
'test_table',
'triggers',
- 'test',
+ ExportType::Raw,
),
);
$result = ob_get_clean();
@@ -631,7 +632,7 @@ class ExportHtmlwordTest extends AbstractTestCase
'test_db',
'test_table',
'create_view',
- 'test',
+ ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@@ -657,7 +658,7 @@ class ExportHtmlwordTest extends AbstractTestCase
'test_db',
'test_table',
'stand_in',
- 'test',
+ ExportType::Raw,
),
);
$result = ob_get_clean();
diff --git a/tests/unit/Plugins/Export/ExportJsonTest.php b/tests/unit/Plugins/Export/ExportJsonTest.php
index 6f1de0ab23..9a2da3f50c 100644
--- a/tests/unit/Plugins/Export/ExportJsonTest.php
+++ b/tests/unit/Plugins/Export/ExportJsonTest.php
@@ -8,6 +8,7 @@ use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportJson;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@@ -160,7 +161,7 @@ class ExportJsonTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
diff --git a/tests/unit/Plugins/Export/ExportLatexTest.php b/tests/unit/Plugins/Export/ExportLatexTest.php
index 42b8589de3..ee5622e01e 100644
--- a/tests/unit/Plugins/Export/ExportLatexTest.php
+++ b/tests/unit/Plugins/Export/ExportLatexTest.php
@@ -13,6 +13,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportLatex;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@@ -51,7 +52,7 @@ class ExportLatexTest extends AbstractTestCase
$GLOBALS['buffer_needed'] = false;
$GLOBALS['asfile'] = true;
$GLOBALS['save_on_server'] = false;
- ExportPlugin::$exportType = 'table';
+ ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
Current::$database = 'db';
Current::$table = 'table';
@@ -75,7 +76,7 @@ class ExportLatexTest extends AbstractTestCase
public function testSetProperties(): void
{
- ExportPlugin::$exportType = '';
+ ExportPlugin::$exportType = ExportType::Raw;
ExportPlugin::$singleTable = false;
$relationParameters = RelationParameters::fromArray([
@@ -419,7 +420,7 @@ class ExportLatexTest extends AbstractTestCase
);
// case 2
- ExportPlugin::$exportType = 'table';
+ ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
$method->invoke($this->object, null);
@@ -472,7 +473,7 @@ class ExportLatexTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
@@ -609,7 +610,7 @@ class ExportLatexTest extends AbstractTestCase
'database',
'',
'test',
- 'test',
+ ExportType::Raw,
true,
true,
true,
@@ -697,7 +698,7 @@ class ExportLatexTest extends AbstractTestCase
'database',
'',
'test',
- 'test',
+ ExportType::Raw,
true,
true,
true,
@@ -755,7 +756,7 @@ class ExportLatexTest extends AbstractTestCase
'database',
'',
'test',
- 'test',
+ ExportType::Raw,
),
);
$result = ob_get_clean();
@@ -772,7 +773,7 @@ class ExportLatexTest extends AbstractTestCase
'database',
'',
'triggers',
- 'test',
+ ExportType::Raw,
),
);
}
diff --git a/tests/unit/Plugins/Export/ExportMediawikiTest.php b/tests/unit/Plugins/Export/ExportMediawikiTest.php
index 8492ac8d0f..9504c8b993 100644
--- a/tests/unit/Plugins/Export/ExportMediawikiTest.php
+++ b/tests/unit/Plugins/Export/ExportMediawikiTest.php
@@ -10,6 +10,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportMediawiki;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertySubgroup;
@@ -214,7 +215,7 @@ class ExportMediawikiTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
@@ -247,7 +248,7 @@ class ExportMediawikiTest extends AbstractTestCase
'db',
'table',
'create_table',
- 'test',
+ ExportType::Raw,
),
);
$result = ob_get_clean();
diff --git a/tests/unit/Plugins/Export/ExportOdsTest.php b/tests/unit/Plugins/Export/ExportOdsTest.php
index 8205ccf1e9..549ba255ee 100644
--- a/tests/unit/Plugins/Export/ExportOdsTest.php
+++ b/tests/unit/Plugins/Export/ExportOdsTest.php
@@ -9,6 +9,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportOds;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@@ -207,7 +208,7 @@ class ExportOdsTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
diff --git a/tests/unit/Plugins/Export/ExportOdtTest.php b/tests/unit/Plugins/Export/ExportOdtTest.php
index b148421b30..13a8cfc20e 100644
--- a/tests/unit/Plugins/Export/ExportOdtTest.php
+++ b/tests/unit/Plugins/Export/ExportOdtTest.php
@@ -15,6 +15,7 @@ use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Identifiers\TriggerName;
use PhpMyAdmin\Plugins\Export\ExportOdt;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@@ -70,7 +71,7 @@ class ExportOdtTest extends AbstractTestCase
$GLOBALS['buffer_needed'] = false;
$GLOBALS['asfile'] = true;
$GLOBALS['save_on_server'] = false;
- ExportPlugin::$exportType = 'table';
+ ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
Config::getInstance()->selectedServer['DisableIS'] = true;
$this->object = new ExportOdt(
@@ -93,7 +94,7 @@ class ExportOdtTest extends AbstractTestCase
public function testSetProperties(): void
{
- ExportPlugin::$exportType = '';
+ ExportPlugin::$exportType = ExportType::Raw;
ExportPlugin::$singleTable = false;
$relationParameters = RelationParameters::fromArray([
@@ -294,7 +295,7 @@ class ExportOdtTest extends AbstractTestCase
);
// case 2
- ExportPlugin::$exportType = 'table';
+ ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
$method->invoke($this->object, null);
@@ -350,7 +351,7 @@ class ExportOdtTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
@@ -758,7 +759,7 @@ class ExportOdtTest extends AbstractTestCase
'test_db',
'test_table',
'create_table',
- 'test',
+ ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@@ -798,7 +799,7 @@ class ExportOdtTest extends AbstractTestCase
'test_db',
'test_table',
'triggers',
- 'test',
+ ExportType::Raw,
),
);
@@ -828,7 +829,7 @@ class ExportOdtTest extends AbstractTestCase
'test_db',
'test_table',
'create_view',
- 'test',
+ ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@@ -868,7 +869,7 @@ class ExportOdtTest extends AbstractTestCase
'test_db',
'test_table',
'stand_in',
- 'test',
+ ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
diff --git a/tests/unit/Plugins/Export/ExportPdfTest.php b/tests/unit/Plugins/Export/ExportPdfTest.php
index 0f327af1b6..2e65da2240 100644
--- a/tests/unit/Plugins/Export/ExportPdfTest.php
+++ b/tests/unit/Plugins/Export/ExportPdfTest.php
@@ -9,6 +9,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportPdf;
use PhpMyAdmin\Plugins\Export\Helpers\Pdf;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\RadioPropertyItem;
@@ -212,7 +213,7 @@ class ExportPdfTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
diff --git a/tests/unit/Plugins/Export/ExportPhparrayTest.php b/tests/unit/Plugins/Export/ExportPhparrayTest.php
index f12327d258..b6c2bdce6f 100644
--- a/tests/unit/Plugins/Export/ExportPhparrayTest.php
+++ b/tests/unit/Plugins/Export/ExportPhparrayTest.php
@@ -9,6 +9,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportPhparray;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@@ -162,7 +163,7 @@ class ExportPhparrayTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
diff --git a/tests/unit/Plugins/Export/ExportSqlTest.php b/tests/unit/Plugins/Export/ExportSqlTest.php
index 55e148bc5b..d3b0398716 100644
--- a/tests/unit/Plugins/Export/ExportSqlTest.php
+++ b/tests/unit/Plugins/Export/ExportSqlTest.php
@@ -14,6 +14,7 @@ use PhpMyAdmin\Dbal\ConnectionType;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportSql;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertySubgroup;
@@ -68,7 +69,7 @@ class ExportSqlTest extends AbstractTestCase
$GLOBALS['buffer_needed'] = false;
$GLOBALS['asfile'] = false;
$GLOBALS['save_on_server'] = false;
- ExportPlugin::$exportType = 'table';
+ ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
$this->object = new ExportSql(
@@ -93,7 +94,7 @@ class ExportSqlTest extends AbstractTestCase
public function testSetPropertiesWithHideSql(): void
{
// test with hide structure and hide sql as true
- ExportPlugin::$exportType = 'table';
+ ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
$method = new ReflectionMethod(ExportSql::class, 'setProperties');
@@ -116,7 +117,7 @@ class ExportSqlTest extends AbstractTestCase
->willReturn(['v1', 'v2']);
DatabaseInterface::$instance = $dbi;
- ExportPlugin::$exportType = 'server';
+ ExportPlugin::$exportType = ExportType::Server;
ExportPlugin::$singleTable = false;
$relationParameters = RelationParameters::fromArray([
@@ -485,7 +486,7 @@ class ExportSqlTest extends AbstractTestCase
ob_start();
self::assertTrue(
- $this->object->exportDBCreate('db', 'database'),
+ $this->object->exportDBCreate('db', ExportType::Database),
);
$result = ob_get_clean();
@@ -519,7 +520,7 @@ class ExportSqlTest extends AbstractTestCase
ob_start();
self::assertTrue(
- $this->object->exportDBCreate('db', 'database'),
+ $this->object->exportDBCreate('db', ExportType::Database),
);
$result = ob_get_clean();
@@ -907,7 +908,7 @@ SQL;
'test_db',
'test_table',
'create_table',
- 'test',
+ ExportType::Raw,
),
);
$result = ob_get_clean();
@@ -930,7 +931,7 @@ SQL;
'test_db',
'test_table',
'triggers',
- 'test',
+ ExportType::Raw,
),
);
$result = ob_get_clean();
@@ -956,7 +957,7 @@ SQL;
'test_db',
'test_table',
'create_view',
- 'test',
+ ExportType::Raw,
),
);
$result = ob_get_clean();
@@ -979,7 +980,7 @@ SQL;
'test_db',
'test_table',
'create_view',
- 'test',
+ ExportType::Raw,
),
);
$result = ob_get_clean();
@@ -996,7 +997,7 @@ SQL;
'test_db',
'test_table',
'stand_in',
- 'test',
+ ExportType::Raw,
),
);
$result = ob_get_clean();
diff --git a/tests/unit/Plugins/Export/ExportTexytextTest.php b/tests/unit/Plugins/Export/ExportTexytextTest.php
index 7869858238..45ddd36012 100644
--- a/tests/unit/Plugins/Export/ExportTexytextTest.php
+++ b/tests/unit/Plugins/Export/ExportTexytextTest.php
@@ -17,6 +17,7 @@ use PhpMyAdmin\Identifiers\TableName;
use PhpMyAdmin\Identifiers\TriggerName;
use PhpMyAdmin\Plugins\Export\ExportTexytext;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@@ -61,7 +62,7 @@ class ExportTexytextTest extends AbstractTestCase
$GLOBALS['buffer_needed'] = false;
$GLOBALS['asfile'] = false;
$GLOBALS['save_on_server'] = false;
- ExportPlugin::$exportType = 'table';
+ ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
Current::$database = '';
Current::$table = '';
@@ -205,7 +206,7 @@ class ExportTexytextTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
@@ -349,7 +350,7 @@ class ExportTexytextTest extends AbstractTestCase
'test_db',
'test_table',
'create_table',
- 'test',
+ ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@@ -374,7 +375,7 @@ class ExportTexytextTest extends AbstractTestCase
'test_db',
'test_table',
'triggers',
- 'test',
+ ExportType::Raw,
),
);
$result = ob_get_clean();
@@ -396,7 +397,7 @@ class ExportTexytextTest extends AbstractTestCase
'test_db',
'test_table',
'create_view',
- 'test',
+ ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
@@ -421,7 +422,7 @@ class ExportTexytextTest extends AbstractTestCase
'test_db',
'test_table',
'stand_in',
- 'test',
+ ExportType::Raw,
),
);
$this->dummyDbi->assertAllSelectsConsumed();
diff --git a/tests/unit/Plugins/Export/ExportXmlTest.php b/tests/unit/Plugins/Export/ExportXmlTest.php
index b233dd3218..63e2af19b0 100644
--- a/tests/unit/Plugins/Export/ExportXmlTest.php
+++ b/tests/unit/Plugins/Export/ExportXmlTest.php
@@ -11,6 +11,7 @@ use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportXml;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem;
@@ -46,7 +47,7 @@ class ExportXmlTest extends AbstractTestCase
$GLOBALS['buffer_needed'] = false;
$GLOBALS['asfile'] = false;
$GLOBALS['save_on_server'] = false;
- ExportPlugin::$exportType = 'table';
+ ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
Current::$database = 'db';
Config::getInstance()->selectedServer['DisableIS'] = true;
@@ -365,7 +366,7 @@ class ExportXmlTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
diff --git a/tests/unit/Plugins/Export/ExportYamlTest.php b/tests/unit/Plugins/Export/ExportYamlTest.php
index a9097f1ed5..2102d036cf 100644
--- a/tests/unit/Plugins/Export/ExportYamlTest.php
+++ b/tests/unit/Plugins/Export/ExportYamlTest.php
@@ -9,6 +9,7 @@ use PhpMyAdmin\Current;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Plugins\Export\ExportYaml;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@@ -152,7 +153,7 @@ class ExportYamlTest extends AbstractTestCase
public function testExportDBCreate(): void
{
self::assertTrue(
- $this->object->exportDBCreate('testDB', 'database'),
+ $this->object->exportDBCreate('testDB', ExportType::Database),
);
}
diff --git a/tests/unit/PluginsTest.php b/tests/unit/PluginsTest.php
index 0fbd5b11e4..8d5a84155b 100644
--- a/tests/unit/PluginsTest.php
+++ b/tests/unit/PluginsTest.php
@@ -11,6 +11,7 @@ use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Import\ImportSettings;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportPlugin;
+use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\Transformations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -27,8 +28,8 @@ class PluginsTest extends AbstractTestCase
public function testGetExport(): void
{
- $plugins = Plugins::getExport('database', false);
- self::assertSame('database', ExportPlugin::$exportType);
+ $plugins = Plugins::getExport(ExportType::Database, false);
+ self::assertSame(ExportType::Database, ExportPlugin::$exportType);
self::assertFalse(ExportPlugin::$singleTable);
self::assertCount(14, $plugins);
self::assertContainsOnlyInstancesOf(Plugins\ExportPlugin::class, $plugins);
diff --git a/tests/unit/Stubs/DbiDummy.php b/tests/unit/Stubs/DbiDummy.php
index 2a9e52e0b3..25c1d1f97d 100644
--- a/tests/unit/Stubs/DbiDummy.php
+++ b/tests/unit/Stubs/DbiDummy.php
@@ -1424,20 +1424,20 @@ class DbiDummy implements DbiExtension
],
[
'query' => 'INSERT INTO `db`.`table` (`username`, `export_type`, `template_name`, `template_data`)'
- . ' VALUES (\'user\', \'type\', \'name\', \'data\');',
+ . ' VALUES (\'user\', \'raw\', \'name\', \'data\');',
'result' => true,
],
[
'query' => 'SELECT * FROM `db`.`table` WHERE `username` = \'user\''
- . ' AND `export_type` = \'type\' ORDER BY `template_name`;',
+ . ' AND `export_type` = \'raw\' ORDER BY `template_name`;',
'columns' => ['id', 'username', 'export_type', 'template_name', 'template_data'],
- 'result' => [['1', 'user1', 'type1', 'name1', 'data1'], ['2', 'user2', 'type2', 'name2', 'data2']],
+ 'result' => [['1', 'user1', 'raw', 'name1', 'data1'], ['2', 'user2', 'raw', 'name2', 'data2']],
],
['query' => 'DELETE FROM `db`.`table` WHERE `id` = 1 AND `username` = \'user\';', 'result' => true],
[
'query' => 'SELECT * FROM `db`.`table` WHERE `id` = 1 AND `username` = \'user\';',
'columns' => ['id', 'username', 'export_type', 'template_name', 'template_data'],
- 'result' => [['1', 'user1', 'type1', 'name1', 'data1']],
+ 'result' => [['1', 'user1', 'raw', 'name1', 'data1']],
],
[
'query' => 'UPDATE `db`.`table` SET `template_data` = \'data\''