Merge pull request #17501 from pokemaobr/exportNew

Adjusting parameters in ExportPlugin class
This commit is contained in:
Maurício Meneghini Fauth 2022-04-28 16:41:39 -03:00 committed by GitHub
commit abf60329bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 216 additions and 68 deletions

View File

@ -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 .= '<li class="list-group-item">' . "\n";
$ret .= '<div class="form-check form-switch">' . "\n";
$ret .= '<input class="form-check-input" type="checkbox" role="switch" name="' . $plugin_name . '_'
. $propertyItem->getName() . '"'
. ' value="something" id="checkbox_' . $plugin_name . '_'
. $propertyItem->getName() . '"'
. ' '
. self::checkboxCheck(
$section,
$plugin_name . '_' . $propertyItem->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 .= '<label class="form-check-label" for="checkbox_' . $plugin_name . '_'
. $propertyItem->getName() . '">'
. self::getString($propertyItem->getText()) . '</label></div>';
. $propertyItem->getName() . '">'
. self::getString($propertyItem->getText()) . '</label></div>';
break;
case DocPropertyItem::class:
echo DocPropertyItem::class;
break;
case HiddenPropertyItem::class:
$ret .= '<li class="list-group-item"><input type="hidden" name="' . $plugin_name . '_'
. $propertyItem->getName() . '"'
. ' value="' . self::getDefault(
$section,
$plugin_name . '_' . $propertyItem->getName()
)
. $propertyItem->getName() . '"'
. ' value="' . self::getDefault(
$section,
$plugin_name . '_' . $propertyItem->getName()
)
. '"></li>';
break;
case MessageOnlyPropertyItem::class:
@ -455,8 +478,8 @@ class Plugins
}
$ret .= '><label class="form-check-label" for="radio_' . $plugin_name . '_'
. $pitem->getName() . '_' . $key . '">'
. self::getString($val) . '</label></div>';
. $pitem->getName() . '_' . $key . '">'
. self::getString($val) . '</label></div>';
}
$ret .= '</li>';
@ -469,12 +492,12 @@ class Plugins
$pitem = $propertyItem;
$ret .= '<li class="list-group-item">' . "\n";
$ret .= '<label for="select_' . $plugin_name . '_'
. $pitem->getName() . '" class="form-label">'
. self::getString($pitem->getText()) . '</label>';
. $pitem->getName() . '" class="form-label">'
. self::getString($pitem->getText()) . '</label>';
$ret .= '<select class="form-select" name="' . $plugin_name . '_'
. $pitem->getName() . '"'
. ' id="select_' . $plugin_name . '_'
. $pitem->getName() . '">';
. $pitem->getName() . '"'
. ' id="select_' . $plugin_name . '_'
. $pitem->getName() . '">';
$default = self::getDefault(
$section,
$plugin_name . '_' . $pitem->getName()
@ -497,22 +520,22 @@ class Plugins
$pitem = $propertyItem;
$ret .= '<li class="list-group-item">' . "\n";
$ret .= '<label for="text_' . $plugin_name . '_'
. $pitem->getName() . '" class="form-label">'
. self::getString($pitem->getText()) . '</label>';
. $pitem->getName() . '" class="form-label">'
. self::getString($pitem->getText()) . '</label>';
$ret .= '<input class="form-control" type="text" name="' . $plugin_name . '_'
. $pitem->getName() . '"'
. ' value="' . self::getDefault(
$section,
$plugin_name . '_' . $pitem->getName()
) . '"'
. $pitem->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']
);
}

View File

@ -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();
}

View File

@ -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)) {

View File

@ -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',

View File

@ -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()
);
}
/**

View File

@ -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()
);
}
/**

View File

@ -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()
);
}
/**

View File

@ -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 = [

View File

@ -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()
);
}
/**

View File

@ -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()
);
}
/**

View File

@ -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()
);
}
/**

View File

@ -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()
);
}
/**

View File

@ -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

View File

@ -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()
);
}
/**

View File

@ -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()
);
}
/**

View File

@ -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()
);
}
/**

View File

@ -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

View File

@ -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()
);
}
/**

View File

@ -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()
);
}
/**

View File

@ -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 = [