diff --git a/libraries/classes/Plugins.php b/libraries/classes/Plugins.php index 8620f5d257..dd36bc5a04 100644 --- a/libraries/classes/Plugins.php +++ b/libraries/classes/Plugins.php @@ -66,6 +66,17 @@ class Plugins return null; } + if ($type === 'export') { + /** + * @psalm-suppress InvalidArrayOffset, MixedAssignment, MixedMethodCall + */ + return new $class( + $GLOBALS['containerBuilder']->get('relation'), + $GLOBALS['containerBuilder']->get('export'), + $GLOBALS['containerBuilder']->get('transformations') + ); + } + return new $class(); } @@ -133,7 +144,19 @@ class Plugins continue; } - $plugin = new $class(); + if ($type === 'Export') { + /** + * @psalm-suppress InvalidArrayOffset, MixedAssignment, MixedMethodCall + */ + $plugin = new $class( + $GLOBALS['containerBuilder']->get('relation'), + $GLOBALS['containerBuilder']->get('export'), + $GLOBALS['containerBuilder']->get('transformations') + ); + } else { + $plugin = new $class(); + } + if (! ($plugin instanceof Plugin) || ! $plugin->isAvailable()) { continue; } @@ -178,7 +201,7 @@ class Plugins isset($_GET[$opt]) || ! isset($_GET['repopulate']) && ((! empty($GLOBALS['timeout_passed']) && isset($_REQUEST[$opt])) - || ! empty($GLOBALS['cfg'][$section][$opt])) + || ! empty($GLOBALS['cfg'][$section][$opt])) ) { return ' checked="checked"'; } @@ -372,7 +395,7 @@ class Plugins * Get HTML for properties items * * @param string $section name of config section in - * $GLOBALS['cfg'][$section] for plugin + * $GLOBALS['cfg'][$section] for plugin * @param string $plugin_name unique plugin name * @param OptionsPropertyItem $propertyItem Property item * @psalm-param 'Export'|'Import'|'Schema' $section @@ -391,14 +414,14 @@ class Plugins $ret .= '
  • ' . "\n"; $ret .= '
    ' . "\n"; $ret .= 'getName() - ); + . $propertyItem->getName() . '"' + . ' value="something" id="checkbox_' . $plugin_name . '_' + . $propertyItem->getName() . '"' + . ' ' + . self::checkboxCheck( + $section, + $plugin_name . '_' . $propertyItem->getName() + ); if ($propertyItem->getForce() != null) { // Same code is also few lines lower, update both if needed @@ -413,19 +436,19 @@ class Plugins $ret .= '>'; $ret .= '
    '; + . $propertyItem->getName() . '">' + . self::getString($propertyItem->getText()) . ''; break; case DocPropertyItem::class: echo DocPropertyItem::class; break; case HiddenPropertyItem::class: $ret .= '
  • '; break; case MessageOnlyPropertyItem::class: @@ -455,8 +478,8 @@ class Plugins } $ret .= '>'; + . $pitem->getName() . '_' . $key . '">' + . self::getString($val) . ''; } $ret .= ''; @@ -469,12 +492,12 @@ class Plugins $pitem = $propertyItem; $ret .= '
  • ' . "\n"; $ret .= ''; + . $pitem->getName() . '" class="form-label">' + . self::getString($pitem->getText()) . ''; $ret .= 'getName() . '"' + . ' value="' . self::getDefault( + $section, + $plugin_name . '_' . $pitem->getName() + ) . '"' . ' id="text_' . $plugin_name . '_' . $pitem->getName() . '"' . ($pitem->getSize() != null - ? ' size="' . $pitem->getSize() . '"' - : '') + ? ' size="' . $pitem->getSize() . '"' + : '') . ($pitem->getLen() != null - ? ' maxlength="' . $pitem->getLen() . '"' - : '') + ? ' maxlength="' . $pitem->getLen() . '"' + : '') . '>'; break; case NumberPropertyItem::class: @@ -601,7 +624,7 @@ class Plugins if (! class_exists($class)) { Core::fatalError( __('Invalid authentication method set in configuration:') - . ' ' . $GLOBALS['cfg']['Server']['auth_type'] + . ' ' . $GLOBALS['cfg']['Server']['auth_type'] ); } diff --git a/libraries/classes/Plugins/ExportPlugin.php b/libraries/classes/Plugins/ExportPlugin.php index 234b0c5fd1..2e0d7b3fd3 100644 --- a/libraries/classes/Plugins/ExportPlugin.php +++ b/libraries/classes/Plugins/ExportPlugin.php @@ -42,11 +42,11 @@ abstract class ExportPlugin implements Plugin /** * @psalm-suppress InvalidArrayOffset, MixedAssignment, MixedMethodCall */ - final public function __construct() + final public function __construct(Relation $relation, Export $export, Transformations $transformations) { - $this->relation = $GLOBALS['containerBuilder']->get('relation'); - $this->export = $GLOBALS['containerBuilder']->get('export'); - $this->transformations = $GLOBALS['containerBuilder']->get('transformations'); + $this->relation = $relation; + $this->export = $export; + $this->transformations = $transformations; $this->init(); $this->properties = $this->setProperties(); } diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index c0506b2fd7..fb22602256 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -22,6 +22,7 @@ use function array_merge; use function array_shift; use function array_unique; use function bin2hex; +use function call_user_func; use function chr; use function count; use function ctype_digit; @@ -1599,14 +1600,9 @@ class Util /* Optional escaping */ if ($escape !== null) { - if (is_array($escape)) { - $escapeClass = new $escape[1](); - $escapeMethod = $escape[0]; - } - foreach ($replace as $key => $val) { - if (isset($escapeClass, $escapeMethod)) { - $replace[$key] = $escapeClass->$escapeMethod($val); + if (is_array($escape)) { + $replace[$key] = (string) call_user_func([$escape[1], $escape[0]], $val); } elseif ($escape === 'backquote') { $replace[$key] = self::backquote($val); } elseif (is_callable($escape)) { diff --git a/test/classes/ExportTest.php b/test/classes/ExportTest.php index c86716a73a..91c11dfa32 100644 --- a/test/classes/ExportTest.php +++ b/test/classes/ExportTest.php @@ -4,8 +4,10 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests; +use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportPhparray; +use PhpMyAdmin\Transformations; /** * @covers \PhpMyAdmin\Export @@ -97,7 +99,11 @@ class ExportTest extends AbstractTestCase */ public function testGetFinalFilenameAndMimetypeForFilename(): void { - $exportPlugin = new ExportPhparray(); + $exportPlugin = new ExportPhparray( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); $finalFileName = $this->export->getFinalFilenameAndMimetypeForFilename($exportPlugin, 'zip', 'myfilename'); $this->assertSame([ 'myfilename.php.zip', diff --git a/test/classes/Plugins/Export/ExportCodegenTest.php b/test/classes/Plugins/Export/ExportCodegenTest.php index 6534f491b9..89b7da12ca 100644 --- a/test/classes/Plugins/Export/ExportCodegenTest.php +++ b/test/classes/Plugins/Export/ExportCodegenTest.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Plugins\Export; +use PhpMyAdmin\ConfigStorage\Relation; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportCodegen; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; @@ -11,6 +13,7 @@ use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem; use PhpMyAdmin\Properties\Options\Items\SelectPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Transformations; use ReflectionClass; use ReflectionMethod; use ReflectionProperty; @@ -34,7 +37,11 @@ class ExportCodegenTest extends AbstractTestCase { parent::setUp(); $GLOBALS['server'] = 0; - $this->object = new ExportCodegen(); + $this->object = new ExportCodegen( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportCsvTest.php b/test/classes/Plugins/Export/ExportCsvTest.php index 793081b7bb..09982c6235 100644 --- a/test/classes/Plugins/Export/ExportCsvTest.php +++ b/test/classes/Plugins/Export/ExportCsvTest.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Plugins\Export; +use PhpMyAdmin\ConfigStorage\Relation; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportCsv; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; @@ -12,6 +14,7 @@ use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem; use PhpMyAdmin\Properties\Options\Items\TextPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Transformations; use ReflectionMethod; use ReflectionProperty; @@ -44,7 +47,11 @@ class ExportCsvTest extends AbstractTestCase $GLOBALS['csv_separator'] = null; $GLOBALS['save_filename'] = null; - $this->object = new ExportCsv(); + $this->object = new ExportCsv( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportExcelTest.php b/test/classes/Plugins/Export/ExportExcelTest.php index 14daf5f35f..fb54862894 100644 --- a/test/classes/Plugins/Export/ExportExcelTest.php +++ b/test/classes/Plugins/Export/ExportExcelTest.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Plugins\Export; +use PhpMyAdmin\ConfigStorage\Relation; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportExcel; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; @@ -13,6 +15,7 @@ use PhpMyAdmin\Properties\Options\Items\SelectPropertyItem; use PhpMyAdmin\Properties\Options\Items\TextPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Transformations; use ReflectionMethod; use ReflectionProperty; @@ -34,7 +37,11 @@ class ExportExcelTest extends AbstractTestCase { parent::setUp(); $GLOBALS['server'] = 0; - $this->object = new ExportExcel(); + $this->object = new ExportExcel( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportHtmlwordTest.php b/test/classes/Plugins/Export/ExportHtmlwordTest.php index 19c0263d21..575f1a3c98 100644 --- a/test/classes/Plugins/Export/ExportHtmlwordTest.php +++ b/test/classes/Plugins/Export/ExportHtmlwordTest.php @@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\ConfigStorage\RelationParameters; use PhpMyAdmin\DatabaseInterface; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportHtmlword; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; @@ -16,6 +17,7 @@ use PhpMyAdmin\Properties\Options\Items\TextPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; use PhpMyAdmin\Tests\Stubs\DummyResult; +use PhpMyAdmin\Transformations; use ReflectionMethod; use ReflectionProperty; @@ -40,7 +42,11 @@ class ExportHtmlwordTest extends AbstractTestCase { parent::setUp(); $GLOBALS['server'] = 0; - $this->object = new ExportHtmlword(); + $this->object = new ExportHtmlword( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); $GLOBALS['output_kanji_conversion'] = false; $GLOBALS['output_charset_conversion'] = false; $GLOBALS['buffer_needed'] = false; @@ -316,6 +322,7 @@ class ExportHtmlwordTest extends AbstractTestCase { $this->object = $this->getMockBuilder(ExportHtmlword::class) ->onlyMethods(['formatOneColumnDefinition']) + ->disableOriginalConstructor() ->getMock(); // case 1 @@ -367,6 +374,7 @@ class ExportHtmlwordTest extends AbstractTestCase { $this->object = $this->getMockBuilder(ExportHtmlword::class) ->onlyMethods(['formatOneColumnDefinition']) + ->setConstructorArgs([new Relation($GLOBALS['dbi']), new Export($GLOBALS['dbi']), new Transformations()]) ->getMock(); $keys = [ diff --git a/test/classes/Plugins/Export/ExportJsonTest.php b/test/classes/Plugins/Export/ExportJsonTest.php index 882d206218..a77afbbe77 100644 --- a/test/classes/Plugins/Export/ExportJsonTest.php +++ b/test/classes/Plugins/Export/ExportJsonTest.php @@ -4,12 +4,15 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Plugins\Export; +use PhpMyAdmin\ConfigStorage\Relation; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportJson; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Transformations; use PhpMyAdmin\Version; use ReflectionMethod; use ReflectionProperty; @@ -37,7 +40,11 @@ class ExportJsonTest extends AbstractTestCase $GLOBALS['buffer_needed'] = false; $GLOBALS['asfile'] = true; $GLOBALS['save_on_server'] = false; - $this->object = new ExportJson(); + $this->object = new ExportJson( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportLatexTest.php b/test/classes/Plugins/Export/ExportLatexTest.php index c0e78f1d66..2dbb011ad2 100644 --- a/test/classes/Plugins/Export/ExportLatexTest.php +++ b/test/classes/Plugins/Export/ExportLatexTest.php @@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\ConfigStorage\RelationParameters; use PhpMyAdmin\DatabaseInterface; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportLatex; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; @@ -16,6 +17,7 @@ use PhpMyAdmin\Properties\Options\Items\TextPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; use PhpMyAdmin\Tests\Stubs\DummyResult; +use PhpMyAdmin\Transformations; use ReflectionMethod; use function __; @@ -49,7 +51,11 @@ class ExportLatexTest extends AbstractTestCase $GLOBALS['plugin_param']['single_table'] = false; $GLOBALS['db'] = 'db'; $GLOBALS['table'] = 'table'; - $this->object = new ExportLatex(); + $this->object = new ExportLatex( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportMediawikiTest.php b/test/classes/Plugins/Export/ExportMediawikiTest.php index 0d50d8305a..1e5dfae784 100644 --- a/test/classes/Plugins/Export/ExportMediawikiTest.php +++ b/test/classes/Plugins/Export/ExportMediawikiTest.php @@ -4,7 +4,9 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Plugins\Export; +use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\DatabaseInterface; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportMediawiki; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; @@ -13,6 +15,7 @@ use PhpMyAdmin\Properties\Options\Items\BoolPropertyItem; use PhpMyAdmin\Properties\Options\Items\RadioPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Transformations; use ReflectionMethod; use ReflectionProperty; @@ -47,7 +50,11 @@ class ExportMediawikiTest extends AbstractTestCase $GLOBALS['lang'] = 'en'; $GLOBALS['text_dir'] = 'ltr'; $GLOBALS['PMA_PHP_SELF'] = ''; - $this->object = new ExportMediawiki(); + $this->object = new ExportMediawiki( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportOdsTest.php b/test/classes/Plugins/Export/ExportOdsTest.php index ec6083f49b..37b851494f 100644 --- a/test/classes/Plugins/Export/ExportOdsTest.php +++ b/test/classes/Plugins/Export/ExportOdsTest.php @@ -4,7 +4,9 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Plugins\Export; +use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\DatabaseInterface; +use PhpMyAdmin\Export; use PhpMyAdmin\FieldMetadata; use PhpMyAdmin\Plugins\Export\ExportOds; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; @@ -15,6 +17,7 @@ use PhpMyAdmin\Properties\Options\Items\TextPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; use PhpMyAdmin\Tests\Stubs\DummyResult; +use PhpMyAdmin\Transformations; use ReflectionMethod; use ReflectionProperty; use stdClass; @@ -51,7 +54,11 @@ class ExportOdsTest extends AbstractTestCase $GLOBALS['buffer_needed'] = false; $GLOBALS['asfile'] = true; $GLOBALS['save_on_server'] = false; - $this->object = new ExportOds(); + $this->object = new ExportOds( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportOdtTest.php b/test/classes/Plugins/Export/ExportOdtTest.php index 28bf5fa14c..b133cbb32c 100644 --- a/test/classes/Plugins/Export/ExportOdtTest.php +++ b/test/classes/Plugins/Export/ExportOdtTest.php @@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\ConfigStorage\RelationParameters; use PhpMyAdmin\DatabaseInterface; +use PhpMyAdmin\Export; use PhpMyAdmin\FieldMetadata; use PhpMyAdmin\Plugins\Export\ExportOdt; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; @@ -17,6 +18,7 @@ use PhpMyAdmin\Properties\Options\Items\TextPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; use PhpMyAdmin\Tests\Stubs\DummyResult; +use PhpMyAdmin\Transformations; use ReflectionMethod; use stdClass; @@ -55,7 +57,11 @@ class ExportOdtTest extends AbstractTestCase $GLOBALS['plugin_param']['export_type'] = 'table'; $GLOBALS['plugin_param']['single_table'] = false; $GLOBALS['cfg']['Server']['DisableIS'] = true; - $this->object = new ExportOdt(); + $this->object = new ExportOdt( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** @@ -569,6 +575,7 @@ class ExportOdtTest extends AbstractTestCase { $this->object = $this->getMockBuilder(ExportOdt::class) ->onlyMethods(['formatOneColumnDefinition']) + ->setConstructorArgs([new Relation($GLOBALS['dbi']), new Export($GLOBALS['dbi']), new Transformations()]) ->getMock(); // case 1 diff --git a/test/classes/Plugins/Export/ExportPdfTest.php b/test/classes/Plugins/Export/ExportPdfTest.php index e7165c1680..b60f194604 100644 --- a/test/classes/Plugins/Export/ExportPdfTest.php +++ b/test/classes/Plugins/Export/ExportPdfTest.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Plugins\Export; +use PhpMyAdmin\ConfigStorage\Relation; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportPdf; use PhpMyAdmin\Plugins\Export\Helpers\Pdf; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; @@ -12,6 +14,7 @@ use PhpMyAdmin\Properties\Options\Items\RadioPropertyItem; use PhpMyAdmin\Properties\Options\Items\TextPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Transformations; use ReflectionMethod; use ReflectionProperty; @@ -39,7 +42,11 @@ class ExportPdfTest extends AbstractTestCase $GLOBALS['buffer_needed'] = false; $GLOBALS['asfile'] = true; $GLOBALS['save_on_server'] = false; - $this->object = new ExportPdf(); + $this->object = new ExportPdf( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportPhparrayTest.php b/test/classes/Plugins/Export/ExportPhparrayTest.php index 75e805a521..4ca6a7e4f7 100644 --- a/test/classes/Plugins/Export/ExportPhparrayTest.php +++ b/test/classes/Plugins/Export/ExportPhparrayTest.php @@ -4,12 +4,15 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Plugins\Export; +use PhpMyAdmin\ConfigStorage\Relation; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportPhparray; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Transformations; use ReflectionMethod; use ReflectionProperty; @@ -43,7 +46,11 @@ class ExportPhparrayTest extends AbstractTestCase $GLOBALS['lang'] = 'en'; $GLOBALS['text_dir'] = 'ltr'; $GLOBALS['PMA_PHP_SELF'] = ''; - $this->object = new ExportPhparray(); + $this->object = new ExportPhparray( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportSqlTest.php b/test/classes/Plugins/Export/ExportSqlTest.php index 2e4424a55c..717fe4e46e 100644 --- a/test/classes/Plugins/Export/ExportSqlTest.php +++ b/test/classes/Plugins/Export/ExportSqlTest.php @@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\ConfigStorage\RelationParameters; use PhpMyAdmin\DatabaseInterface; +use PhpMyAdmin\Export; use PhpMyAdmin\FieldMetadata; use PhpMyAdmin\Plugins\Export\ExportSql; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; @@ -21,6 +22,7 @@ use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Table; use PhpMyAdmin\Tests\AbstractTestCase; use PhpMyAdmin\Tests\Stubs\DummyResult; +use PhpMyAdmin\Transformations; use ReflectionMethod; use stdClass; @@ -70,7 +72,11 @@ class ExportSqlTest extends AbstractTestCase $GLOBALS['sql_indexes'] = null; $GLOBALS['sql_auto_increments'] = null; - $this->object = new ExportSql(); + $this->object = new ExportSql( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportTexytextTest.php b/test/classes/Plugins/Export/ExportTexytextTest.php index 7b6482a5c1..3168a4187d 100644 --- a/test/classes/Plugins/Export/ExportTexytextTest.php +++ b/test/classes/Plugins/Export/ExportTexytextTest.php @@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Plugins\Export; use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\ConfigStorage\RelationParameters; use PhpMyAdmin\DatabaseInterface; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportTexytext; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; @@ -15,6 +16,7 @@ use PhpMyAdmin\Properties\Options\Items\RadioPropertyItem; use PhpMyAdmin\Properties\Options\Items\TextPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Transformations; use ReflectionMethod; use ReflectionProperty; @@ -51,7 +53,11 @@ class ExportTexytextTest extends AbstractTestCase $GLOBALS['text_dir'] = 'ltr'; $GLOBALS['PMA_PHP_SELF'] = ''; $GLOBALS['cfg']['Server']['DisableIS'] = true; - $this->object = new ExportTexytext(); + $this->object = new ExportTexytext( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** @@ -239,6 +245,7 @@ class ExportTexytextTest extends AbstractTestCase { $this->object = $this->getMockBuilder(ExportTexytext::class) ->onlyMethods(['formatOneColumnDefinition']) + ->setConstructorArgs([new Relation($GLOBALS['dbi']), new Export($GLOBALS['dbi']), new Transformations()]) ->getMock(); // case 1 diff --git a/test/classes/Plugins/Export/ExportXmlTest.php b/test/classes/Plugins/Export/ExportXmlTest.php index 9dda1d2ac7..7c5f04b82c 100644 --- a/test/classes/Plugins/Export/ExportXmlTest.php +++ b/test/classes/Plugins/Export/ExportXmlTest.php @@ -4,7 +4,9 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Plugins\Export; +use PhpMyAdmin\ConfigStorage\Relation; use PhpMyAdmin\DatabaseInterface; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportXml; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; @@ -13,6 +15,7 @@ use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Table; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Transformations; use ReflectionMethod; use ReflectionProperty; @@ -46,7 +49,11 @@ class ExportXmlTest extends AbstractTestCase $GLOBALS['db'] = 'db'; $GLOBALS['cfg']['Server']['DisableIS'] = true; $GLOBALS['crlf'] = "\n"; - $this->object = new ExportXml(); + $this->object = new ExportXml( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/Plugins/Export/ExportYamlTest.php b/test/classes/Plugins/Export/ExportYamlTest.php index 417ef9fecf..88769ba365 100644 --- a/test/classes/Plugins/Export/ExportYamlTest.php +++ b/test/classes/Plugins/Export/ExportYamlTest.php @@ -4,12 +4,15 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests\Plugins\Export; +use PhpMyAdmin\ConfigStorage\Relation; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins\Export\ExportYaml; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup; use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyRootGroup; use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem; use PhpMyAdmin\Properties\Plugins\ExportPluginProperties; use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Transformations; use ReflectionMethod; use ReflectionProperty; @@ -43,7 +46,11 @@ class ExportYamlTest extends AbstractTestCase $GLOBALS['lang'] = 'en'; $GLOBALS['text_dir'] = 'ltr'; $GLOBALS['PMA_PHP_SELF'] = ''; - $this->object = new ExportYaml(); + $this->object = new ExportYaml( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ); } /** diff --git a/test/classes/PluginsTest.php b/test/classes/PluginsTest.php index f107279b3a..6e6ef8d29d 100644 --- a/test/classes/PluginsTest.php +++ b/test/classes/PluginsTest.php @@ -4,7 +4,10 @@ declare(strict_types=1); namespace PhpMyAdmin\Tests; +use PhpMyAdmin\ConfigStorage\Relation; +use PhpMyAdmin\Export; use PhpMyAdmin\Plugins; +use PhpMyAdmin\Transformations; /** * @covers \PhpMyAdmin\Plugins @@ -99,10 +102,26 @@ class PluginsTest extends AbstractTestCase $GLOBALS['server'] = 1; $GLOBALS['plugin_param'] = ['export_type' => 'database', 'single_table' => false]; $exportList = [ - new Plugins\Export\ExportJson(), - new Plugins\Export\ExportOds(), - new Plugins\Export\ExportSql(), - new Plugins\Export\ExportXml(), + new Plugins\Export\ExportJson( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ), + new Plugins\Export\ExportOds( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ), + new Plugins\Export\ExportSql( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ), + new Plugins\Export\ExportXml( + new Relation($GLOBALS['dbi']), + new Export($GLOBALS['dbi']), + new Transformations() + ), ]; $actual = Plugins::getChoice($exportList, 'xml'); $expected = [