Extract dependencies from Transformations class

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
Maurício Meneghini Fauth 2025-06-21 14:28:41 -03:00
parent 2d92804e37
commit 37cbc4b3f3
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
59 changed files with 248 additions and 252 deletions

View File

@ -219,7 +219,8 @@ return [
'class' => TrackingChecker::class,
'arguments' => ['$dbi' => '@dbi', '$relation' => '@relation'],
],
'transformations' => ['class' => Transformations::class],
'transformations' => ['class' => Transformations::class, 'arguments' => ['@dbi', '@relation']],
Transformations::class => 'transformations',
'triggers' => ['class' => Triggers::class, 'arguments' => ['@dbi']],
'user_password' => [
'class' => UserPassword::class,

View File

@ -14967,15 +14967,6 @@ parameters:
count: 1
path: src/Tracking/Tracking.php
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
Use dependency injection instead\.$#
'''
identifier: staticMethod.deprecated
count: 3
path: src/Transformations.php
-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
identifier: notEqual.notAllowed

View File

@ -8990,11 +8990,6 @@
</PossiblyNullArgument>
</file>
<file src="src/Transformations.php">
<DeprecatedMethod>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
</DeprecatedMethod>
<LessSpecificReturnStatement>
<code><![CDATA['PhpMyAdmin\\Plugins\\Transformations\\' . str_replace('/', '\\', explode('.php', $filename)[0])]]></code>
</LessSpecificReturnStatement>

View File

@ -80,7 +80,7 @@ class MultiTableQuery
$dbi,
$relation,
new RelationCleanup($dbi, $relation),
new Transformations(),
new Transformations($dbi, $relation),
new Template(),
$bookmarkRepository,
Config::getInstance(),

View File

@ -217,7 +217,7 @@ class Results
private readonly string $sqlQuery,
) {
$this->relation = new Relation($this->dbi);
$this->transformations = new Transformations();
$this->transformations = new Transformations($this->dbi, $this->relation);
$this->template = new Template();
$this->setDefaultTransformations();

View File

@ -90,8 +90,9 @@ class Pdf extends PdfLib
) {
parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache, $pdfa);
$this->relation = new Relation(DatabaseInterface::getInstance());
$this->transformations = new Transformations();
$dbi = DatabaseInterface::getInstance();
$this->relation = new Relation($dbi);
$this->transformations = new Transformations($dbi, $this->relation);
}
/**

View File

@ -39,7 +39,7 @@ abstract class ExportPlugin implements Plugin
final public function __construct(
public Relation $relation,
protected Export $export,
protected Transformations $transformations,
public Transformations $transformations,
) {
$this->init();
$this->properties = $this->setProperties();

View File

@ -85,13 +85,15 @@ class PdfRelationSchema extends ExportRelationSchema
private Transformations $transformations;
private Pdf $pdf;
private DatabaseInterface $dbi;
/** @see Pdf */
public function __construct(Relation $relation, DatabaseName $db)
{
parent::__construct($relation, $db);
$this->transformations = new Transformations();
$this->dbi = DatabaseInterface::getInstance();
$this->transformations = new Transformations($this->dbi, $relation);
$this->setShowGrid(isset($_REQUEST['pdf_show_grid']));
$this->setShowColor(isset($_REQUEST['pdf_show_color']));
@ -447,7 +449,6 @@ class PdfRelationSchema extends ExportRelationSchema
$this->pdf->Cell(0, 9, __('Table of contents'), 1, 0, 'C');
$this->pdf->Ln(15);
$i = 1;
$dbi = DatabaseInterface::getInstance();
foreach ($alltables as $table) {
$this->pdf->customLinks['doc'][$table]['-'] = $this->pdf->AddLink();
$this->pdf->setX(10);
@ -465,7 +466,7 @@ class PdfRelationSchema extends ExportRelationSchema
$this->pdf->setX(10);
$this->pdf->Cell(0, 6, $i . ' ' . $table, 0, 1, 'L', false, $this->pdf->customLinks['doc'][$table]['-']);
// $this->diagram->Ln(1);
$fields = $dbi->getColumns($this->db->getName(), $table);
$fields = $this->dbi->getColumns($this->db->getName(), $table);
foreach ($fields as $row) {
$this->pdf->setX(20);
$fieldName = $row->field;
@ -521,7 +522,7 @@ class PdfRelationSchema extends ExportRelationSchema
$mimeMap = $this->transformations->getMime($this->db->getName(), $table, true);
}
$showTable = $dbi->getTable($this->db->getName(), $table)->getStatusInfo();
$showTable = $this->dbi->getTable($this->db->getName(), $table)->getStatusInfo();
$showComment = $showTable['Comment'] ?? '';
$createTime = isset($showTable['Create_time'])
? Util::localisedDate(new DateTimeImmutable($showTable['Create_time']))
@ -536,7 +537,7 @@ class PdfRelationSchema extends ExportRelationSchema
/**
* Gets fields properties
*/
$columns = $dbi->getColumns($this->db->getName(), $table);
$columns = $this->dbi->getColumns($this->db->getName(), $table);
// Find which tables are related with the current one and write it in
// an array

View File

@ -52,6 +52,10 @@ class Transformations
/** @var string[][]|null */
private static array|null $availableMimeTypesStack = null;
public function __construct(private readonly DatabaseInterface $dbi, private readonly Relation $relation)
{
}
/**
* Returns array of options from string with options separated by comma,
* removes quotes
@ -283,9 +287,7 @@ class Transformations
*/
public function getMime(string $db, string $table, bool $strict = false, bool $fullName = false): array|null
{
$dbi = DatabaseInterface::getInstance();
$relation = new Relation($dbi);
$browserTransformationFeature = $relation->getRelationParameters()->browserTransformationFeature;
$browserTransformationFeature = $this->relation->getRelationParameters()->browserTransformationFeature;
if ($browserTransformationFeature === null) {
return null;
}
@ -303,8 +305,8 @@ class Transformations
. '`input_transformation_options`'
. ' FROM ' . Util::backquote($browserTransformationFeature->database) . '.'
. Util::backquote($browserTransformationFeature->columnInfo)
. ' WHERE `db_name` = ' . $dbi->quoteString($db, ConnectionType::ControlUser)
. ' AND `table_name` = ' . $dbi->quoteString($table, ConnectionType::ControlUser)
. ' WHERE `db_name` = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser)
. ' AND `table_name` = ' . $this->dbi->quoteString($table, ConnectionType::ControlUser)
. ' AND ( `mimetype` != \'\'' . (! $strict ?
' OR `transformation` != \'\''
. ' OR `transformation_options` != \'\''
@ -321,7 +323,7 @@ class Transformations
* input_transformation_options: string
* }> $result
*/
$result = $dbi->fetchResult($comQry, 'column_name', null, ConnectionType::ControlUser);
$result = $this->dbi->fetchResult($comQry, 'column_name', null, ConnectionType::ControlUser);
foreach ($result as $column => $values) {
// convert mimetype to new format (f.e. Text_Plain, etc)
@ -370,9 +372,7 @@ class Transformations
string $inputTransformOpts,
bool $forcedelete = false,
): bool {
$dbi = DatabaseInterface::getInstance();
$relation = new Relation($dbi);
$browserTransformationFeature = $relation->getRelationParameters()->browserTransformationFeature;
$browserTransformationFeature = $this->relation->getRelationParameters()->browserTransformationFeature;
if ($browserTransformationFeature === null) {
return false;
}
@ -394,11 +394,11 @@ class Transformations
`comment`
FROM ' . Util::backquote($browserTransformationFeature->database) . '.'
. Util::backquote($browserTransformationFeature->columnInfo) . '
WHERE `db_name` = ' . $dbi->quoteString($db, ConnectionType::ControlUser) . '
AND `table_name` = ' . $dbi->quoteString($table, ConnectionType::ControlUser) . '
AND `column_name` = ' . $dbi->quoteString($key, ConnectionType::ControlUser);
WHERE `db_name` = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser) . '
AND `table_name` = ' . $this->dbi->quoteString($table, ConnectionType::ControlUser) . '
AND `column_name` = ' . $this->dbi->quoteString($key, ConnectionType::ControlUser);
$testRs = $dbi->queryAsControlUser($testQry);
$testRs = $this->dbi->queryAsControlUser($testQry);
if ($testRs->numRows() > 0) {
$row = $testRs->fetchAssoc();
@ -409,15 +409,15 @@ class Transformations
. Util::backquote($browserTransformationFeature->columnInfo)
. ' SET '
. '`mimetype` = '
. $dbi->quoteString($mimetype, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($mimetype, ConnectionType::ControlUser) . ', '
. '`transformation` = '
. $dbi->quoteString($transformation, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($transformation, ConnectionType::ControlUser) . ', '
. '`transformation_options` = '
. $dbi->quoteString($transformationOpts, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($transformationOpts, ConnectionType::ControlUser) . ', '
. '`input_transformation` = '
. $dbi->quoteString($inputTransform, ConnectionType::ControlUser) . ', '
. $this->dbi->quoteString($inputTransform, ConnectionType::ControlUser) . ', '
. '`input_transformation_options` = '
. $dbi->quoteString($inputTransformOpts, ConnectionType::ControlUser);
. $this->dbi->quoteString($inputTransformOpts, ConnectionType::ControlUser);
} else {
$updQuery = 'DELETE FROM '
. Util::backquote($browserTransformationFeature->database)
@ -425,9 +425,9 @@ class Transformations
}
$updQuery .= '
WHERE `db_name` = ' . $dbi->quoteString($db, ConnectionType::ControlUser) . '
AND `table_name` = ' . $dbi->quoteString($table, ConnectionType::ControlUser) . '
AND `column_name` = ' . $dbi->quoteString($key, ConnectionType::ControlUser);
WHERE `db_name` = ' . $this->dbi->quoteString($db, ConnectionType::ControlUser) . '
AND `table_name` = ' . $this->dbi->quoteString($table, ConnectionType::ControlUser) . '
AND `column_name` = ' . $this->dbi->quoteString($key, ConnectionType::ControlUser);
} elseif ($hasValue) {
$updQuery = 'INSERT INTO '
. Util::backquote($browserTransformationFeature->database)
@ -436,18 +436,18 @@ class Transformations
. 'transformation, transformation_options, '
. 'input_transformation, input_transformation_options) '
. ' VALUES('
. $dbi->quoteString($db, ConnectionType::ControlUser) . ','
. $dbi->quoteString($table, ConnectionType::ControlUser) . ','
. $dbi->quoteString($key, ConnectionType::ControlUser) . ','
. $dbi->quoteString($mimetype, ConnectionType::ControlUser) . ','
. $dbi->quoteString($transformation, ConnectionType::ControlUser) . ','
. $dbi->quoteString($transformationOpts, ConnectionType::ControlUser) . ','
. $dbi->quoteString($inputTransform, ConnectionType::ControlUser) . ','
. $dbi->quoteString($inputTransformOpts, ConnectionType::ControlUser) . ')';
. $this->dbi->quoteString($db, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($table, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($key, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($mimetype, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($transformation, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($transformationOpts, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($inputTransform, ConnectionType::ControlUser) . ','
. $this->dbi->quoteString($inputTransformOpts, ConnectionType::ControlUser) . ')';
}
if (isset($updQuery)) {
return (bool) $dbi->queryAsControlUser($updQuery);
return (bool) $this->dbi->queryAsControlUser($updQuery);
}
return false;
@ -467,9 +467,7 @@ class Transformations
*/
public function clear(string $db, string $table = '', string $column = ''): bool
{
$dbi = DatabaseInterface::getInstance();
$relation = new Relation($dbi);
$browserTransformationFeature = $relation->getRelationParameters()->browserTransformationFeature;
$browserTransformationFeature = $this->relation->getRelationParameters()->browserTransformationFeature;
if ($browserTransformationFeature === null) {
return false;
}
@ -490,6 +488,6 @@ class Transformations
$deleteSql .= '`db_name` = \'' . $db . '\' ';
}
return (bool) $dbi->tryQuery($deleteSql);
return (bool) $this->dbi->tryQuery($deleteSql);
}
}

View File

@ -17,17 +17,9 @@ class TransformationsExtension extends AbstractExtension
*/
public function getFunctions(): array
{
$transformations = new Transformations();
return [
new TwigFunction(
'get_description',
$transformations->getDescription(...),
),
new TwigFunction(
'get_name',
$transformations->getName(...),
),
new TwigFunction('get_description', [Transformations::class, 'getDescription']),
new TwigFunction('get_name', [Transformations::class, 'getName']),
];
}
}

View File

@ -34,9 +34,10 @@ class AddNewPrimaryControllerTest extends AbstractTestCase
$response = new ResponseRenderer();
$template = new Template();
$relation = new Relation($dbi);
$controller = new AddNewPrimaryController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
new UserPrivilegesFactory($dbi),
);
$controller(self::createStub(ServerRequest::class));

View File

@ -35,9 +35,10 @@ class CreateNewColumnControllerTest extends AbstractTestCase
$template = new Template();
$request = self::createStub(ServerRequest::class);
$relation = new Relation($dbi);
$controller = new CreateNewColumnController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
new UserPrivilegesFactory($dbi),
);
$controller($request);

View File

@ -37,9 +37,10 @@ class FirstStepControllerTest extends AbstractTestCase
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['normalizeTo' => $normalizeTo]);
$relation = new Relation($dbi);
$controller = new FirstStepController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller($request);

View File

@ -32,9 +32,10 @@ class FourthStepControllerTest extends AbstractTestCase
$response = new ResponseRenderer();
$template = new Template();
$relation = new Relation($dbi);
$controller = new FourthStepController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller(self::createStub(ServerRequest::class));

View File

@ -29,9 +29,10 @@ class SecondStepControllerTest extends AbstractTestCase
$response = new ResponseRenderer();
$template = new Template();
$relation = new Relation($dbi);
$controller = new SecondStepController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller(self::createStub(ServerRequest::class));

View File

@ -32,9 +32,10 @@ class ThirdStepControllerTest extends AbstractTestCase
$response = new ResponseRenderer();
$template = new Template();
$relation = new Relation($dbi);
$controller = new ThirdStepController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller(self::createStub(ServerRequest::class));

View File

@ -32,9 +32,10 @@ class GetColumnsControllerTest extends AbstractTestCase
$response = new ResponseRenderer();
$template = new Template();
$relation = new Relation($dbi);
$controller = new GetColumnsController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller(self::createStub(ServerRequest::class));

View File

@ -47,9 +47,10 @@ class MoveRepeatingGroupTest extends AbstractTestCase
'primary_columns' => 'id,col1',
]);
$relation = new Relation($dbi);
$controller = new MoveRepeatingGroup(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller($request);

View File

@ -40,9 +40,10 @@ class PartialDependenciesControllerTest extends AbstractTestCase
$response = new ResponseRenderer();
$template = new Template();
$relation = new Relation($dbi);
$controller = new PartialDependenciesController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller(self::createStub(ServerRequest::class));

View File

@ -42,9 +42,10 @@ class CreateNewTablesControllerTest extends AbstractTestCase
'newTablesName' => json_encode(['ID, task' => 'batch_log2', 'task' => 'table2']),
]);
$relation = new Relation($dbi);
$controller = new CreateNewTablesController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller($request);

View File

@ -29,9 +29,10 @@ class FirstStepControllerTest extends AbstractTestCase
$response = new ResponseRenderer();
$template = new Template();
$relation = new Relation($dbi);
$controller = new FirstStepController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller(self::createStub(ServerRequest::class));

View File

@ -34,9 +34,10 @@ class NewTablesControllerTest extends AbstractTestCase
->withParsedBody([
'pd' => json_encode(['ID, task' => [], 'task' => ['timestamp']]),
]);
$relation = new Relation($dbi);
$controller = new NewTablesController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller($request);

View File

@ -56,9 +56,10 @@ class CreateNewTablesControllerTest extends AbstractTestCase
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['newTables' => $newTables]);
$relation = new Relation($dbi);
$controller = new CreateNewTablesController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller($request);

View File

@ -34,9 +34,10 @@ class FirstStepControllerTest extends AbstractTestCase
$request = self::createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([['tables', null, ['test_table']]]);
$relation = new Relation($dbi);
$controller = new FirstStepController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller($request);

View File

@ -45,9 +45,10 @@ class NewTablesControllerTest extends AbstractTestCase
'pd' => $pd,
]);
$relation = new Relation($dbi);
$controller = new NewTablesController(
$response,
new Normalization($dbi, new Relation($dbi), new Transformations(), $template),
new Normalization($dbi, $relation, new Transformations($dbi, $relation), $template),
);
$controller($request);

View File

@ -39,11 +39,12 @@ class DestroyControllerTest extends AbstractTestCase
$config = Config::getInstance();
$config->settings['AllowUserDropDatabase'] = true;
$relation = new Relation($dbi);
$controller = new DestroyController(
$response,
$dbi,
new Transformations(),
new RelationCleanup($dbi, new Relation($dbi)),
new Transformations($dbi, $relation),
new RelationCleanup($dbi, $relation),
new UserPrivilegesFactory($dbi),
$config,
);

View File

@ -257,7 +257,7 @@ class AddFieldControllerTest extends AbstractTestCase
->withQueryParams(['db' => 'test_db', 'table' => 'test_table'])
->withParsedBody(['num_fields' => '1']);
$transformations = new Transformations();
$transformations = new Transformations($dbi, $relation);
(new AddFieldController(
$response,
$transformations,

View File

@ -59,10 +59,19 @@ final class ChangeControllerTest extends AbstractTestCase
$relation = new Relation($dbi);
$template = new Template();
$insertEdit = new InsertEdit(
$dbi,
$relation,
new Transformations($dbi, $relation),
new FileListing(),
$template,
$config,
);
(new ChangeController(
$response,
$template,
new InsertEdit($dbi, $relation, new Transformations(), new FileListing(), $template, $config),
$insertEdit,
$relation,
$pageSettings,
new DbTableExists($dbi),
@ -162,10 +171,19 @@ final class ChangeControllerTest extends AbstractTestCase
$relation = new Relation($dbi);
$template = new Template();
$insertEdit = new InsertEdit(
$dbi,
$relation,
new Transformations($dbi, $relation),
new FileListing(),
$template,
$config,
);
(new ChangeController(
$response,
$template,
new InsertEdit($dbi, $relation, new Transformations(), new FileListing(), $template, $config),
$insertEdit,
$relation,
$pageSettings,
new DbTableExists($dbi),

View File

@ -272,7 +272,7 @@ class CreateControllerTest extends AbstractTestCase
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
->withParsedBody(['num_fields' => '2']);
$transformations = new Transformations();
$transformations = new Transformations($dbi, $relation);
(new CreateController(
$response,
$transformations,

View File

@ -66,7 +66,7 @@ class DeleteRowsControllerTest extends AbstractTestCase
$dbi,
$relation,
new RelationCleanup($dbi, $relation),
new Transformations(),
new Transformations($dbi, $relation),
new Template($config),
new BookmarkRepository($dbi, $relation),
$config,

View File

@ -95,7 +95,7 @@ class ReplaceControllerTest extends AbstractTestCase
$dummyDbi = $this->createDbiDummy();
$dbi = $this->createDatabaseInterface($dummyDbi);
$relation = new Relation($dbi);
$transformations = new Transformations();
$transformations = new Transformations($dbi, $relation);
$template = new Template();
$response = new ResponseRenderer();

View File

@ -51,7 +51,7 @@ final class SearchControllerTest extends AbstractTestCase
$dbi,
$relation,
new RelationCleanup($dbi, $relation),
new Transformations(),
new Transformations($dbi, $relation),
$template,
new BookmarkRepository($dbi, $relation),
$config,

View File

@ -46,10 +46,11 @@ class ChangeControllerTest extends AbstractTestCase
$class = new ReflectionClass(ChangeController::class);
$method = $class->getMethod('displayHtmlForColumnChange');
$relation = new Relation($this->dbi);
$ctrl = new ChangeController(
$response,
$this->dbi,
new ColumnsDefinition($this->dbi, new Relation($this->dbi), new Transformations()),
new ColumnsDefinition($this->dbi, $relation, new Transformations($this->dbi, $relation)),
new UserPrivilegesFactory($this->dbi),
);

View File

@ -94,10 +94,11 @@ class SaveControllerTest extends AbstractTestCase
$mock->expects(self::once())->method('__invoke')->with($request)
->willReturn(ResponseFactory::create()->createResponse());
$relation = new Relation($dbi);
(new SaveController(
new ResponseRenderer(),
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
$dbi,
$mock,
new UserPrivilegesFactory($dbi),
@ -117,10 +118,11 @@ class SaveControllerTest extends AbstractTestCase
$class = new ReflectionClass(SaveController::class);
$method = $class->getMethod('adjustColumnPrivileges');
$relation = new Relation($dbi);
$ctrl = new SaveController(
new ResponseRenderer(),
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
$dbi,
self::createStub(StructureController::class),
new UserPrivilegesFactory($dbi),

View File

@ -99,7 +99,7 @@ class StructureControllerTest extends AbstractTestCase
$response,
$template,
$relation,
new Transformations(),
new Transformations($this->dbi, $relation),
$this->dbi,
$pageSettings,
new DbTableExists($this->dbi),

View File

@ -4,9 +4,9 @@ declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers\Transformation;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Controllers\Transformation\OverviewController;
use PhpMyAdmin\Current;
use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
@ -27,8 +27,6 @@ class OverviewControllerTest extends AbstractTestCase
$this->setGlobalConfig();
DatabaseInterface::$instance = $this->createDatabaseInterface();
Current::$database = 'db';
Current::$table = 'table';
}
@ -37,7 +35,8 @@ class OverviewControllerTest extends AbstractTestCase
{
$response = new ResponseRenderer();
$controller = new OverviewController($response, new Transformations());
$dbi = $this->createDatabaseInterface();
$controller = new OverviewController($response, new Transformations($dbi, new Relation($dbi)));
$controller(self::createStub(ServerRequest::class));
$actual = $response->getHTMLResult();

View File

@ -700,7 +700,7 @@ class ResultsTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
$transformations = new Transformations();
$transformations = new Transformations($dbi, new Relation($dbi));
(new ReflectionProperty(DisplayResults::class, 'mediaTypeMap'))->setValue(
$this->object,
$transformations->getMime('db', 'table'),

View File

@ -67,11 +67,8 @@ class ExportTest extends AbstractTestCase
$dbi = $this->createDatabaseInterface();
DatabaseInterface::$instance = $dbi;
$export = new Export($dbi);
$exportPlugin = new ExportPhparray(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$exportPlugin = new ExportPhparray($relation, new Export($dbi), new Transformations($dbi, $relation));
$finalFileName = $export->getFinalFilename($exportPlugin, 'zip', 'myfilename');
self::assertSame('myfilename.php.zip', $finalFileName);
$finalFileName = $export->getFinalFilename($exportPlugin, 'gzip', 'myfilename');
@ -85,11 +82,8 @@ class ExportTest extends AbstractTestCase
$dbi = $this->createDatabaseInterface();
DatabaseInterface::$instance = $dbi;
$export = new Export($dbi);
$exportPlugin = new ExportPhparray(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$exportPlugin = new ExportPhparray($relation, new Export($dbi), new Transformations($dbi, $relation));
$mimeType = $export->getMimeType($exportPlugin, 'zip');
self::assertSame('application/zip', $mimeType);
$mimeType = $export->getMimeType($exportPlugin, 'gzip');
@ -131,12 +125,13 @@ class ExportTest extends AbstractTestCase
$export = new Export($dbi);
ExportPlugin::$exportType = ExportType::Database;
$relation = new Relation($dbi);
$export->exportDatabase(
DatabaseName::from('test_db'),
['test_table'],
['test_table'],
['test_table'],
new ExportSql(new Relation($dbi), $export, new Transformations()),
new ExportSql($relation, $export, new Transformations($dbi, $relation)),
[],
'',
);
@ -205,9 +200,10 @@ SQL;
DatabaseInterface::$instance = $dbi;
$export = new Export($dbi);
$relation = new Relation($dbi);
$export->exportServer(
['test_db'],
new ExportSql(new Relation($dbi), $export, new Transformations()),
new ExportSql($relation, $export, new Transformations($dbi, $relation)),
[],
'',
);

View File

@ -94,10 +94,11 @@ class InsertEditTest extends AbstractTestCase
$config->settings['Confirm'] = true;
$config->settings['LoginCookieValidity'] = 1440;
$config->settings['enable_drag_drop_import'] = true;
$relation = new Relation($this->dbi);
$this->insertEdit = new InsertEdit(
$this->dbi,
new Relation($this->dbi),
new Transformations(),
$relation,
new Transformations($this->dbi, $relation),
new FileListing(),
new Template(),
$config,
@ -207,10 +208,11 @@ class InsertEditTest extends AbstractTestCase
->willReturn([], []);
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -252,10 +254,11 @@ class InsertEditTest extends AbstractTestCase
->willReturn([$meta]);
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -287,10 +290,11 @@ class InsertEditTest extends AbstractTestCase
->willReturn($resultStub);
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -1026,10 +1030,11 @@ class InsertEditTest extends AbstractTestCase
->getMock();
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -1241,10 +1246,11 @@ class InsertEditTest extends AbstractTestCase
DatabaseInterface::$instance = $dbi;
Current::$database = 'db';
Current::$table = 'table';
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -1324,10 +1330,11 @@ class InsertEditTest extends AbstractTestCase
$_POST['submit_type'] = '';
$dbi = DatabaseInterface::getInstance();
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -1347,10 +1354,11 @@ class InsertEditTest extends AbstractTestCase
$_POST['submit_type'] = '';
$dbi = DatabaseInterface::getInstance();
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -1379,10 +1387,11 @@ class InsertEditTest extends AbstractTestCase
->willReturn($warnings);
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -1429,10 +1438,11 @@ class InsertEditTest extends AbstractTestCase
->willReturn('2');
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -2169,10 +2179,11 @@ class InsertEditTest extends AbstractTestCase
->willReturn(false, '123', '2013-08-28 06:34:14');
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -2217,10 +2228,11 @@ class InsertEditTest extends AbstractTestCase
->willReturn($columns);
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -2272,10 +2284,11 @@ class InsertEditTest extends AbstractTestCase
$response = new ReflectionProperty(ResponseRenderer::class, 'instance');
$response->setValue(null, $responseMock);
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),
@ -2325,10 +2338,11 @@ class InsertEditTest extends AbstractTestCase
->willReturn(new Table('table', 'db', $dbi));
DatabaseInterface::$instance = $dbi;
$relation = new Relation($dbi);
$this->insertEdit = new InsertEdit(
$dbi,
new Relation($dbi),
new Transformations(),
$relation,
new Transformations($dbi, $relation),
new FileListing(),
new Template(),
Config::getInstance(),

View File

@ -97,7 +97,8 @@ class NormalizationTest extends AbstractTestCase
->method('fetchSingleRow')
->willReturn(['`id`_cnt' => 0, '`col1`_cnt' => 0, '`col2`_cnt' => 0]);
$this->normalization = new Normalization($dbi, new Relation($dbi), new Transformations(), new Template());
$relation = new Relation($dbi);
$this->normalization = new Normalization($dbi, $relation, new Transformations($dbi, $relation), new Template());
}
/**
@ -131,10 +132,11 @@ class NormalizationTest extends AbstractTestCase
$db = 'testdb';
$table = 'mytable';
$numFields = 1;
$relation = new Relation($this->dbi);
$normalization = new Normalization(
$this->dbi,
new Relation($this->dbi),
new Transformations(),
$relation,
new Transformations($this->dbi, $relation),
new Template(),
);
$result = $normalization->getHtmlForCreateNewColumn($userPrivileges, $numFields, $db, $table);

View File

@ -39,11 +39,8 @@ class ExportCodegenTest extends AbstractTestCase
$dbi = $this->createDatabaseInterface();
DatabaseInterface::$instance = $dbi;
$this->object = new ExportCodegen(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportCodegen($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**

View File

@ -46,11 +46,8 @@ class ExportCsvTest extends AbstractTestCase
Current::$lang = '';
Export::$saveFilename = '';
$this->object = new ExportCsv(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportCsv($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**

View File

@ -41,11 +41,8 @@ class ExportExcelTest extends AbstractTestCase
$dbi = $this->createDatabaseInterface();
DatabaseInterface::$instance = $dbi;
$this->object = new ExportExcel(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportExcel($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**

View File

@ -57,10 +57,11 @@ class ExportHtmlwordTest extends AbstractTestCase
$this->dummyDbi = $this->createDbiDummy();
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
DatabaseInterface::$instance = $this->dbi;
$relation = new Relation($this->dbi);
$this->object = new ExportHtmlword(
new Relation($this->dbi),
$relation,
new Export($this->dbi),
new Transformations(),
new Transformations($this->dbi, $relation),
);
Export::$outputKanjiConversion = false;
Export::$outputCharsetConversion = false;
@ -375,9 +376,10 @@ class ExportHtmlwordTest extends AbstractTestCase
public function testGetTableDef(): void
{
$relation = new Relation($this->dbi);
$this->object = $this->getMockBuilder(ExportHtmlword::class)
->onlyMethods(['formatOneColumnDefinition'])
->setConstructorArgs([new Relation($this->dbi), new Export($this->dbi), new Transformations()])
->setConstructorArgs([$relation, new Export($this->dbi), new Transformations($this->dbi, $relation)])
->getMock();
$keys = [['Non_unique' => 0, 'Column_name' => 'name1'], ['Non_unique' => 1, 'Column_name' => 'name2']];
@ -421,7 +423,9 @@ class ExportHtmlwordTest extends AbstractTestCase
->willReturn(['comment' => 'testComment']);
DatabaseInterface::$instance = $dbi;
$this->object->relation = new Relation($dbi);
$relation = new Relation($dbi);
$this->object->relation = $relation;
$this->object->transformations = new Transformations($dbi, $relation);
$this->object->expects(self::exactly(3))
->method('formatOneColumnDefinition')
@ -497,7 +501,9 @@ class ExportHtmlwordTest extends AbstractTestCase
->willReturn(['comment' => 'testComment']);
DatabaseInterface::$instance = $dbi;
$this->object->relation = new Relation($dbi);
$relation = new Relation($dbi);
$this->object->relation = $relation;
$this->object->transformations = new Transformations($dbi, $relation);
$relationParameters = RelationParameters::fromArray([
'relwork' => true,

View File

@ -40,11 +40,8 @@ class ExportJsonTest extends AbstractTestCase
Export::$bufferNeeded = false;
Export::$asFile = true;
Export::$saveOnServer = false;
$this->object = new ExportJson(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportJson($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**

View File

@ -58,11 +58,8 @@ class ExportLatexTest extends AbstractTestCase
ExportPlugin::$singleTable = false;
Current::$database = 'db';
Current::$table = 'table';
$this->object = new ExportLatex(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportLatex($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**
@ -606,7 +603,9 @@ class ExportLatexTest extends AbstractTestCase
->willReturn(['comment' => 'testComment']);
DatabaseInterface::$instance = $dbi;
$this->object->relation = new Relation($dbi);
$relation = new Relation($dbi);
$this->object->relation = $relation;
$this->object->transformations = new Transformations($dbi, $relation);
$relationParameters = RelationParameters::fromArray([
'relwork' => true,
@ -689,7 +688,9 @@ class ExportLatexTest extends AbstractTestCase
->willReturn(['comment' => 'testComment']);
DatabaseInterface::$instance = $dbi;
$this->object->relation = new Relation($dbi);
$relation = new Relation($dbi);
$this->object->relation = $relation;
$this->object->transformations = new Transformations($dbi, $relation);
$relationParameters = RelationParameters::fromArray([
'relwork' => true,

View File

@ -51,11 +51,8 @@ class ExportMediawikiTest extends AbstractTestCase
Current::$database = '';
Current::$table = '';
Current::$lang = 'en';
$this->object = new ExportMediawiki(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportMediawiki($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**

View File

@ -57,11 +57,8 @@ class ExportOdsTest extends AbstractTestCase
Export::$bufferNeeded = false;
Export::$asFile = true;
Export::$saveOnServer = false;
$this->object = new ExportOds(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportOds($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**

View File

@ -75,11 +75,8 @@ class ExportOdtTest extends AbstractTestCase
ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
Config::getInstance()->selectedServer['DisableIS'] = true;
$this->object = new ExportOdt(
new Relation($this->dbi),
new Export($this->dbi),
new Transformations(),
);
$relation = new Relation($this->dbi);
$this->object = new ExportOdt($relation, new Export($this->dbi), new Transformations($this->dbi, $relation));
}
/**
@ -574,9 +571,10 @@ class ExportOdtTest extends AbstractTestCase
public function testGetTableDef(): void
{
$relation = new Relation($this->dbi);
$this->object = $this->getMockBuilder(ExportOdt::class)
->onlyMethods(['formatOneColumnDefinition'])
->setConstructorArgs([new Relation($this->dbi), new Export($this->dbi), new Transformations()])
->setConstructorArgs([$relation, new Export($this->dbi), new Transformations($this->dbi, $relation)])
->getMock();
// case 1
@ -613,7 +611,9 @@ class ExportOdtTest extends AbstractTestCase
->willReturn(['comment' => 'testComment']);
DatabaseInterface::$instance = $dbi;
$this->object->relation = new Relation($dbi);
$relation = new Relation($dbi);
$this->object->relation = $relation;
$this->object->transformations = new Transformations($dbi, $relation);
$this->object->expects(self::exactly(2))
->method('formatOneColumnDefinition')
@ -694,7 +694,9 @@ class ExportOdtTest extends AbstractTestCase
->willReturn(['comment' => 'testComment']);
DatabaseInterface::$instance = $dbi;
$this->object->relation = new Relation($dbi);
$relation = new Relation($dbi);
$this->object->relation = $relation;
$this->object->transformations = new Transformations($dbi, $relation);
$this->object->buffer = '';
$relationParameters = RelationParameters::fromArray([
'relwork' => true,

View File

@ -43,11 +43,8 @@ class ExportPdfTest extends AbstractTestCase
Export::$bufferNeeded = false;
Export::$asFile = true;
Export::$saveOnServer = false;
$this->object = new ExportPdf(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportPdf($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**

View File

@ -46,11 +46,8 @@ class ExportPhparrayTest extends AbstractTestCase
Current::$database = '';
Current::$table = '';
Current::$lang = 'en';
$this->object = new ExportPhparray(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportPhparray($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**

View File

@ -74,11 +74,8 @@ class ExportSqlTest extends AbstractTestCase
ExportPlugin::$exportType = ExportType::Table;
ExportPlugin::$singleTable = false;
$this->object = new ExportSql(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportSql($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object->useSqlBackquotes(false);
}
@ -889,7 +886,9 @@ SQL;
);
DatabaseInterface::$instance = $dbi;
$this->object->relation = new Relation($dbi);
$relation = new Relation($dbi);
$this->object = new ExportSql($relation, new Export($dbi), new Transformations($dbi, $relation));
$this->object->useSqlBackquotes(false);
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['sql_relation' => 'On', 'sql_mime' => 'On', 'sql_include_comments' => 'On']);

View File

@ -68,10 +68,11 @@ class ExportTexytextTest extends AbstractTestCase
Current::$table = '';
Current::$lang = 'en';
Config::getInstance()->selectedServer['DisableIS'] = true;
$relation = new Relation($this->dbi);
$this->object = new ExportTexytext(
new Relation($this->dbi),
$relation,
new Export($this->dbi),
new Transformations(),
new Transformations($this->dbi, $relation),
);
}
@ -259,9 +260,10 @@ class ExportTexytextTest extends AbstractTestCase
public function testGetTableDef(): void
{
$relation = new Relation($this->dbi);
$this->object = $this->getMockBuilder(ExportTexytext::class)
->onlyMethods(['formatOneColumnDefinition'])
->setConstructorArgs([new Relation($this->dbi), new Export($this->dbi), new Transformations()])
->setConstructorArgs([$relation, new Export($this->dbi), new Transformations($this->dbi, $relation)])
->getMock();
// case 1
@ -297,7 +299,9 @@ class ExportTexytextTest extends AbstractTestCase
]);
DatabaseInterface::$instance = $dbi;
$this->object->relation = new Relation($dbi);
$relation = new Relation($dbi);
$this->object->relation = $relation;
$this->object->transformations = new Transformations($dbi, $relation);
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
->withParsedBody(['texytext_relation' => 'On', 'texytext_mime' => 'On', 'texytext_comments' => 'On']);

View File

@ -51,11 +51,8 @@ class ExportXmlTest extends AbstractTestCase
ExportPlugin::$singleTable = false;
Current::$database = 'db';
Config::getInstance()->selectedServer['DisableIS'] = true;
$this->object = new ExportXml(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportXml($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**

View File

@ -45,11 +45,8 @@ class ExportYamlTest extends AbstractTestCase
Current::$database = '';
Current::$table = '';
Current::$lang = 'en';
$this->object = new ExportYaml(
new Relation($dbi),
new Export($dbi),
new Transformations(),
);
$relation = new Relation($dbi);
$this->object = new ExportYaml($relation, new Export($dbi), new Transformations($dbi, $relation));
}
/**

View File

@ -99,27 +99,14 @@ class PluginsTest extends AbstractTestCase
public function testGetChoice(): void
{
$dbi = DatabaseInterface::getInstance();
$relation = new Relation($dbi);
$transformations = new Transformations($dbi, $relation);
$export = new Export($dbi);
$exportList = [
new Plugins\Export\ExportJson(
new Relation($dbi),
new Export($dbi),
new Transformations(),
),
new Plugins\Export\ExportOds(
new Relation($dbi),
new Export($dbi),
new Transformations(),
),
new Plugins\Export\ExportSql(
new Relation($dbi),
new Export($dbi),
new Transformations(),
),
new Plugins\Export\ExportXml(
new Relation($dbi),
new Export($dbi),
new Transformations(),
),
new Plugins\Export\ExportJson($relation, $export, $transformations),
new Plugins\Export\ExportOds($relation, $export, $transformations),
new Plugins\Export\ExportSql($relation, $export, $transformations),
new Plugins\Export\ExportXml($relation, $export, $transformations),
];
$actual = Plugins::getChoice($exportList, 'xml');
$expected = [

View File

@ -66,7 +66,7 @@ class SqlTest extends AbstractTestCase
$this->dbi,
$relation,
new RelationCleanup($this->dbi, $relation),
new Transformations(),
new Transformations($this->dbi, $relation),
new Template(),
new BookmarkRepository($this->dbi, $relation),
Config::getInstance(),

View File

@ -80,7 +80,7 @@ SQL;
);
$relation = new Relation($dbi);
$columnsDefinition = new ColumnsDefinition($dbi, $relation, new Transformations());
$columnsDefinition = new ColumnsDefinition($dbi, $relation, new Transformations($dbi, $relation));
Current::$database = 'sakila';
Current::$table = 'actor';

View File

@ -27,7 +27,7 @@ class TransformationsTest extends AbstractTestCase
{
parent::setUp();
DatabaseInterface::$instance = $this->createDatabaseInterface();
$dbi = DatabaseInterface::$instance = $this->createDatabaseInterface();
Current::$table = 'table';
Current::$database = 'db';
$config = Config::getInstance();
@ -40,7 +40,7 @@ class TransformationsTest extends AbstractTestCase
$config->selectedServer['table_coords'] = '';
$config->selectedServer['column_info'] = 'column_info';
$this->transformations = new Transformations();
$this->transformations = new Transformations($dbi, new Relation($dbi));
}
/**
@ -207,10 +207,10 @@ class TransformationsTest extends AbstractTestCase
$dbi->expects(self::any())
->method('tryQuery')
->willReturn(self::createStub(DummyResult::class));
DatabaseInterface::$instance = $dbi;
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, null);
$this->transformations = new Transformations($dbi, new Relation($dbi));
// Case 1 : no configuration storage
$actual = $this->transformations->clear('db');
self::assertFalse($actual);