Adjust tests
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
c756e7e424
commit
0ef9362596
@ -20034,36 +20034,12 @@ parameters:
|
||||
count: 9
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Class PhpMyAdmin\\Column constructor invoked with 6 parameters, 9 required\.$#'
|
||||
identifier: arguments.count
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 2
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#3 \$collation of class PhpMyAdmin\\Column constructor expects string\|null, false given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#4 \$isNull of class PhpMyAdmin\\Column constructor expects bool, string given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#5 \$key of class PhpMyAdmin\\Column constructor expects string, null given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Export/ExportSqlTest.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\{host\: string, port\: 80, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\.$#'
|
||||
identifier: assign.propertyType
|
||||
|
||||
@ -12311,10 +12311,6 @@
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<InvalidArgument>
|
||||
<code><![CDATA['']]></code>
|
||||
<code><![CDATA[false]]></code>
|
||||
</InvalidArgument>
|
||||
<InvalidPropertyAssignmentValue>
|
||||
<code><![CDATA[$config->selectedServer]]></code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
@ -12325,14 +12321,6 @@
|
||||
<code><![CDATA[$result]]></code>
|
||||
<code><![CDATA[$result]]></code>
|
||||
</MixedAssignment>
|
||||
<NullArgument>
|
||||
<code><![CDATA[null]]></code>
|
||||
</NullArgument>
|
||||
<TooFewArguments>
|
||||
<code><![CDATA[new Column('cname', 'int', false, '', null, '')]]></code>
|
||||
<code><![CDATA[new Column('cname', 'int', false, '', null, '')]]></code>
|
||||
<code><![CDATA[new Column('cname', 'int', false, '', null, '')]]></code>
|
||||
</TooFewArguments>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Export/ExportTexytextTest.php">
|
||||
<DeprecatedMethod>
|
||||
|
||||
@ -57,7 +57,16 @@ class RelationTest extends AbstractTestCase
|
||||
$relation->getDisplayField($db, $table),
|
||||
);
|
||||
|
||||
$dummyDbi->addResult('SHOW COLUMNS FROM `information_schema`.`PMA`', []);
|
||||
$dummyDbi->addResult(
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'information_schema\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'PMA\'',
|
||||
[],
|
||||
);
|
||||
|
||||
$db = 'information_schema';
|
||||
$table = 'PMA';
|
||||
@ -92,7 +101,16 @@ class RelationTest extends AbstractTestCase
|
||||
. ' WHERE `db_name` = \'information_schema\' AND `table_name` = \'NON_EXISTING_TABLE\'',
|
||||
[],
|
||||
);
|
||||
$dummyDbi->addResult('SHOW COLUMNS FROM `information_schema`.`NON_EXISTING_TABLE`', []);
|
||||
$dummyDbi->addResult(
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'information_schema\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'NON_EXISTING_TABLE\'',
|
||||
[],
|
||||
);
|
||||
$db = 'information_schema';
|
||||
$table = 'NON_EXISTING_TABLE';
|
||||
self::assertSame(
|
||||
|
||||
@ -40,6 +40,7 @@ final class BrowseForeignersControllerTest extends AbstractTestCase
|
||||
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
$dbiDummy->removeDefaultResults();
|
||||
$dbiDummy->addResult('SELECT @@lower_case_table_names', [['0']]);
|
||||
$dbiDummy->addResult(
|
||||
'SHOW CREATE TABLE `sakila`.`film_actor`',
|
||||
[
|
||||
@ -66,14 +67,21 @@ final class BrowseForeignersControllerTest extends AbstractTestCase
|
||||
);
|
||||
$dbiDummy->addResult('SELECT `actor_id` FROM .`actor` LIMIT 100', [['71'], ['173'], ['125']], ['actor_id']);
|
||||
$dbiDummy->addResult(
|
||||
'SHOW COLUMNS FROM .`actor`',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`,'
|
||||
. ' `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'\' AND `TABLE_NAME`'
|
||||
. ' COLLATE utf8_bin = \'actor\'',
|
||||
[
|
||||
['actor_id', 'smallint(5) unsigned', 'NO', 'PRI', null, 'auto_increment' ],
|
||||
['first_name', 'varchar(45)', 'NO', '', null, '' ],
|
||||
['last_name', 'varchar(45)', 'NO', 'MUL', null, '' ],
|
||||
['last_update', 'timestamp', 'NO', '', 'current_timestamp()', 'on update current_timestamp()'],
|
||||
['actor_id', 'smallint(5) unsigned', null, 'NO', 'PRI', null, 'auto_increment', '', ''],
|
||||
['first_name', 'varchar(45)', null, 'NO', '', null, '', '', ''],
|
||||
['last_name', 'varchar(45)', null, 'NO', 'MUL', null, '', '', ''],
|
||||
['last_update', 'timestamp', null, 'NO', '', 'current_timestamp()', 'on update current_timestamp()', '', ''],
|
||||
],
|
||||
['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
);
|
||||
$dbiDummy->addResult('SHOW INDEXES FROM .`actor`', []);
|
||||
// phpcs:enable
|
||||
|
||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Controllers;
|
||||
|
||||
use PhpMyAdmin\Controllers\ColumnController;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
@ -20,6 +21,7 @@ final class ColumnControllerTest extends AbstractTestCase
|
||||
->withParsedBody(['db' => 'test_db', 'table' => 'test_table']);
|
||||
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$controller = new ColumnController($responseRenderer, $dbi);
|
||||
$controller($request);
|
||||
|
||||
@ -79,7 +79,13 @@ class ImportControllerTest extends AbstractTestCase
|
||||
);
|
||||
|
||||
$this->dummyDbi->addResult(
|
||||
'SHOW FULL COLUMNS FROM `pma_test`.`table1`',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'pma_test\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'table1\'',
|
||||
[],
|
||||
);
|
||||
|
||||
|
||||
@ -38,7 +38,14 @@ class EnumValuesControllerTest extends AbstractTestCase
|
||||
|
||||
public function testGetEnumValuesError(): void
|
||||
{
|
||||
$this->dummyDbi->addResult('SHOW COLUMNS FROM `cvv`.`enums` LIKE \'set\'', false);
|
||||
$this->dummyDbi->addResult('SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`,'
|
||||
. ' `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'cvv\' AND `TABLE_NAME`'
|
||||
. ' COLLATE utf8_bin = \'enums\' AND `COLUMN_NAME` = \'set\'', false);
|
||||
$this->dummyDbi->addResult('SHOW INDEXES FROM `cvv`.`enums`', false);
|
||||
|
||||
Current::$database = 'cvv';
|
||||
@ -77,18 +84,27 @@ class EnumValuesControllerTest extends AbstractTestCase
|
||||
public function testGetEnumValuesSuccess(): void
|
||||
{
|
||||
$this->dummyDbi->addResult(
|
||||
'SHOW COLUMNS FROM `cvv`.`enums` LIKE \'set\'',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'cvv\' AND `TABLE_NAME` COLLATE utf8_bin = \'enums\''
|
||||
. ' AND `COLUMN_NAME` = \'set\'',
|
||||
[
|
||||
[
|
||||
'set',
|
||||
"set('<script>alert(\"ok\")</script>','a&b','b&c','vrai&','','漢字','''','\\\\','\"\\\\''')",
|
||||
null,
|
||||
'No',
|
||||
'',
|
||||
'NULL',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
],
|
||||
],
|
||||
['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
);
|
||||
$this->dummyDbi->addResult('SHOW INDEXES FROM `cvv`.`enums`', []);
|
||||
|
||||
|
||||
@ -38,7 +38,14 @@ class SetValuesControllerTest extends AbstractTestCase
|
||||
|
||||
public function testError(): void
|
||||
{
|
||||
$this->dummyDbi->addResult('SHOW COLUMNS FROM `cvv`.`enums` LIKE \'set\'', false);
|
||||
$this->dummyDbi->addResult('SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`,'
|
||||
. ' `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'cvv\' AND `TABLE_NAME`'
|
||||
. ' COLLATE utf8_bin = \'enums\' AND `COLUMN_NAME` = \'set\'', false);
|
||||
$this->dummyDbi->addResult('SHOW INDEXES FROM `cvv`.`enums`', false);
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
@ -77,18 +84,27 @@ class SetValuesControllerTest extends AbstractTestCase
|
||||
public function testSuccess(): void
|
||||
{
|
||||
$this->dummyDbi->addResult(
|
||||
'SHOW COLUMNS FROM `cvv`.`enums` LIKE \'set\'',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'cvv\' AND `TABLE_NAME` COLLATE utf8_bin = \'enums\''
|
||||
. ' AND `COLUMN_NAME` = \'set\'',
|
||||
[
|
||||
[
|
||||
'set',
|
||||
'set(\'<script>alert("ok")</script>\',\'a&b\',\'b&c\',\'vrai&\',\'\')',
|
||||
null,
|
||||
'No',
|
||||
'',
|
||||
'NULL',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
],
|
||||
],
|
||||
['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
);
|
||||
$this->dummyDbi->addResult('SHOW INDEXES FROM `cvv`.`enums`', []);
|
||||
|
||||
|
||||
@ -33,8 +33,26 @@ class CreateControllerTest extends AbstractTestCase
|
||||
|
||||
$dummyDbi = $this->createDbiDummy();
|
||||
$dummyDbi->addSelectDb('test_db');
|
||||
$dummyDbi->addResult('SHOW COLUMNS FROM `test_db`.`new_test_table`', false);
|
||||
$dummyDbi->addResult('SHOW FULL COLUMNS FROM `test_db`.`new_test_table`', false);
|
||||
$dummyDbi->addResult(
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'test_db\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'new_test_table\'',
|
||||
false,
|
||||
);
|
||||
$dummyDbi->addResult(
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'test_db\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'new_test_table\'',
|
||||
false,
|
||||
);
|
||||
$dummyDbi->addResult('SHOW CREATE TABLE `test_db`.`new_test_table`', false);
|
||||
$dbi = $this->createDatabaseInterface($dummyDbi);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Tests\Controllers\Table;
|
||||
|
||||
use PhpMyAdmin\Controllers\Table\FindReplaceController;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\DbTableExists;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Template;
|
||||
@ -28,6 +29,7 @@ final class FindReplaceControllerTest extends AbstractTestCase
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$dbiDummy->addResult('UPDATE `test_table` SET `id` = REPLACE(`id`, \'Field\', \'Column\') WHERE `id` LIKE \'%Field%\' COLLATE utf8mb4_bin', true);
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$controller = new FindReplaceController(
|
||||
@ -73,6 +75,7 @@ final class FindReplaceControllerTest extends AbstractTestCase
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$dbiDummy->addResult('UPDATE `test_table` SET `id` = `id` WHERE `id` RLIKE \'Field\' COLLATE utf8mb4_bin', true);
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$controller = new FindReplaceController(
|
||||
|
||||
@ -36,9 +36,18 @@ class GetFieldControllerTest extends AbstractTestCase
|
||||
$dummyDbi = $this->createDbiDummy();
|
||||
$dummyDbi->addSelectDb('test_db');
|
||||
$dummyDbi->addResult(
|
||||
'SHOW COLUMNS FROM `test_db`.`table_with_blob`',
|
||||
[['id', 'int(11)', 'NO', 'PRI', null, 'auto_increment'], ['file', 'blob', 'NO', '', null, '']],
|
||||
['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'test_db\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'table_with_blob\'',
|
||||
[
|
||||
['id', 'int(11)', null, 'NO', 'PRI', null, 'auto_increment', '', ''],
|
||||
['file', 'blob', null, 'NO', '', null, '', '', ''],
|
||||
],
|
||||
['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
);
|
||||
$dummyDbi->addResult(
|
||||
'SHOW INDEXES FROM `test_db`.`table_with_blob`',
|
||||
|
||||
@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Controllers\Table;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\Table\SearchController;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\DbTableExists;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Table\Search;
|
||||
@ -31,6 +32,7 @@ final class SearchControllerTest extends AbstractTestCase
|
||||
[['1', '2']],
|
||||
);
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$_POST['range_search'] = '1';
|
||||
$_POST['column'] = 'column';
|
||||
|
||||
@ -8,6 +8,7 @@ use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\Table\ZoomSearchController;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\DbTableExists;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Table\Search;
|
||||
@ -30,6 +31,7 @@ final class ZoomSearchControllerTest extends AbstractTestCase
|
||||
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$dbiDummy->addSelectDb('test_db');
|
||||
$dbiDummy->addResult('SELECT 1 FROM `test_db`.`test_table` LIMIT 1;', [['1']]);
|
||||
@ -76,6 +78,7 @@ final class ZoomSearchControllerTest extends AbstractTestCase
|
||||
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$dbiDummy->addSelectDb('test_db');
|
||||
$dbiDummy->addResult('SELECT 1 FROM `test_db`.`test_table` LIMIT 1;', [['1']]);
|
||||
|
||||
@ -858,9 +858,16 @@ class DatabaseInterfaceTest extends AbstractTestCase
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
$dbiDummy->removeDefaultResults();
|
||||
$dbiDummy->addResult(
|
||||
'SHOW COLUMNS FROM `test_db`.`test_table` LIKE \'test\\\\_column\'',
|
||||
[['test_column', 'varchar(45)', 'NO', '', null, '']],
|
||||
['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'test_db\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'test_table\''
|
||||
. ' AND `COLUMN_NAME` = \'test_column\'',
|
||||
[['test_column', 'varchar(45)', null, 'NO', '', null, '', '', '']],
|
||||
['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
);
|
||||
$dbiDummy->addResult('SHOW INDEXES FROM `test_db`.`test_table`', []);
|
||||
$dbi = $this->createDatabaseInterface($dbiDummy);
|
||||
@ -875,7 +882,14 @@ class DatabaseInterfaceTest extends AbstractTestCase
|
||||
$dbiDummy = $this->createDbiDummy();
|
||||
$dbiDummy->removeDefaultResults();
|
||||
$dbiDummy->addResult(
|
||||
'SHOW FULL COLUMNS FROM `test_db`.`test_table` LIKE \'test\\\\_column\'',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'test_db\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'test_table\''
|
||||
. ' AND `COLUMN_NAME` = \'test_column\'',
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
[['test_column', 'varchar(45)', 'utf8mb4_general_ci', 'NO', '', null, '', 'select,insert,update,references', '']],
|
||||
['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
|
||||
@ -2372,7 +2372,7 @@ class InsertEditTest extends AbstractTestCase
|
||||
|
||||
$dbi->expects(self::once())
|
||||
->method('getColumns')
|
||||
->with('db', 'table', true)
|
||||
->with('db', 'table')
|
||||
->willReturn([new Column('d', 'd', null, false, '', null, '', '', 'b')]);
|
||||
|
||||
$dbi->expects(self::any())
|
||||
|
||||
@ -652,7 +652,7 @@ class ExportSqlTest extends AbstractTestCase
|
||||
$dbi->expects(self::once())
|
||||
->method('getColumns')
|
||||
->with('db', 'view')
|
||||
->willReturn([new Column('cname', 'int', false, '', null, '')]);
|
||||
->willReturn([new Column('cname', 'int', null, false, '', null, '', '', '')]);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
|
||||
@ -288,14 +288,12 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
->method('fetchValue')
|
||||
->willReturn('SELECT a FROM b');
|
||||
|
||||
$column = new Column('fname', '', null, false, '', null, '', '', '');
|
||||
$columnFull = new Column('fname', '', null, false, '', null, '', '', 'comm');
|
||||
|
||||
$dbi->expects(self::exactly(2))
|
||||
->method('getColumns')
|
||||
->willReturnMap([
|
||||
['db', 'table', false, ConnectionType::User, [$column]],
|
||||
['db', 'table', true, ConnectionType::User, [$columnFull]],
|
||||
['db', 'table', ConnectionType::User, [$columnFull]],
|
||||
]);
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
@ -308,7 +306,7 @@ class ExportTexytextTest extends AbstractTestCase
|
||||
|
||||
$this->object->expects(self::exactly(1))
|
||||
->method('formatOneColumnDefinition')
|
||||
->with($column, ['cname'])
|
||||
->with($columnFull, ['cname'])
|
||||
->willReturn('1');
|
||||
|
||||
$relationParameters = RelationParameters::fromArray([
|
||||
|
||||
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Query;
|
||||
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Query\Generator;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
@ -13,34 +14,53 @@ class GeneratorTest extends AbstractTestCase
|
||||
{
|
||||
public function testGetColumnsSql(): void
|
||||
{
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
self::assertSame(
|
||||
'SHOW COLUMNS FROM `mydb`.`mytable`',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`, `COLUMN_DEFAULT` AS `Default`,'
|
||||
. ' `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'mydb\''
|
||||
. ' AND `TABLE_NAME` COLLATE utf8_bin = \'mytable\'',
|
||||
Generator::getColumns(
|
||||
'mydb',
|
||||
'mytable',
|
||||
"'mydb'",
|
||||
"'mytable'",
|
||||
),
|
||||
);
|
||||
self::assertSame(
|
||||
'SHOW COLUMNS FROM `mydb`.`mytable` LIKE \'_idcolumn\'',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`, `COLUMN_DEFAULT` AS `Default`,'
|
||||
. ' `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'mydb\''
|
||||
. ' AND `TABLE_NAME` COLLATE utf8_bin = \'mytable\' AND `COLUMN_NAME` = \'_idcolumn\'',
|
||||
Generator::getColumns(
|
||||
'mydb',
|
||||
'mytable',
|
||||
"'mydb'",
|
||||
"'mytable'",
|
||||
"'_idcolumn'",
|
||||
),
|
||||
);
|
||||
self::assertSame(
|
||||
'SHOW FULL COLUMNS FROM `mydb`.`mytable`',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`, `COLUMN_DEFAULT` AS `Default`,'
|
||||
. ' `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'mydb\''
|
||||
. ' AND `TABLE_NAME` COLLATE utf8_bin = \'mytable\'',
|
||||
Generator::getColumns(
|
||||
'mydb',
|
||||
'mytable',
|
||||
"'mydb'",
|
||||
"'mytable'",
|
||||
null,
|
||||
),
|
||||
);
|
||||
self::assertSame(
|
||||
'SHOW FULL COLUMNS FROM `mydb`.`mytable` LIKE \'_idcolumn\'',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`, `COLUMN_DEFAULT` AS `Default`,'
|
||||
. ' `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'mydb\''
|
||||
. ' AND `TABLE_NAME` COLLATE utf8_bin = \'mytable\' AND `COLUMN_NAME` = \'_idcolumn\'',
|
||||
Generator::getColumns(
|
||||
'mydb',
|
||||
'mytable',
|
||||
"'mydb'",
|
||||
"'mytable'",
|
||||
"'_idcolumn'",
|
||||
),
|
||||
);
|
||||
|
||||
@ -538,7 +538,13 @@ class SqlTest extends AbstractTestCase
|
||||
);
|
||||
$this->dummyDbi->addResult('SELECT COUNT(*) FROM `sakila`.`country`', [['109']]);
|
||||
$this->dummyDbi->addResult(
|
||||
'SHOW FULL COLUMNS FROM `sakila`.`country`',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'sakila\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'country\'',
|
||||
[
|
||||
[
|
||||
'country_id',
|
||||
@ -577,13 +583,29 @@ class SqlTest extends AbstractTestCase
|
||||
['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
);
|
||||
$this->dummyDbi->addResult(
|
||||
'SHOW COLUMNS FROM `sakila`.`country`',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'sakila\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'country\'',
|
||||
[
|
||||
['country_id', 'smallint(5) unsigned', 'NO', 'PRI', null, 'auto_increment'],
|
||||
['country', 'varchar(50)', 'NO', '', null, ''],
|
||||
['last_update', 'timestamp', 'NO', '', 'current_timestamp()', 'on update current_timestamp()'],
|
||||
['country_id', 'smallint(5) unsigned', null, 'NO', 'PRI', null, 'auto_increment', '', ''],
|
||||
['country', 'varchar(50)', null, 'NO', '', null, '', '', ''],
|
||||
[
|
||||
'last_update',
|
||||
'timestamp',
|
||||
null,
|
||||
'NO',
|
||||
'',
|
||||
'current_timestamp()',
|
||||
'on update current_timestamp()',
|
||||
'',
|
||||
'',
|
||||
],
|
||||
],
|
||||
['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
);
|
||||
$this->dummyDbi->addResult(
|
||||
'SHOW INDEXES FROM `sakila`.`country`',
|
||||
|
||||
@ -434,30 +434,42 @@ class DbiDummy implements DbiExtension
|
||||
['query' => 'SHOW TABLES FROM `pma_test`;', 'result' => [['table1'], ['table2']]],
|
||||
['query' => 'SHOW TABLES FROM `pmadb`', 'result' => [['column_info']]],
|
||||
[
|
||||
'query' => 'SHOW COLUMNS FROM `pma_test`.`table1`',
|
||||
'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
'query' => 'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'pma_test\' AND `TABLE_NAME` COLLATE utf8_bin = \'table1\'',
|
||||
'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
'result' => [
|
||||
['i', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'],
|
||||
['o', 'int(11)', 'NO', 'MUL', 'NULL', ''],
|
||||
['i', 'int(11)', null, 'NO', 'PRI', 'NULL', 'auto_increment', '', ''],
|
||||
['o', 'int(11)', null, 'NO', 'MUL', 'NULL', '', '', ''],
|
||||
],
|
||||
],
|
||||
['query' => 'SHOW INDEXES FROM `pma_test`.`table1` WHERE (Non_unique = 0)', 'result' => []],
|
||||
[
|
||||
'query' => 'SHOW COLUMNS FROM `pma_test`.`table2`',
|
||||
'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
'query' => 'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'pma_test\' AND `TABLE_NAME` COLLATE utf8_bin = \'table2\'',
|
||||
'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
'result' => [
|
||||
['i', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'],
|
||||
['o', 'int(11)', 'NO', 'MUL', 'NULL', ''],
|
||||
['i', 'int(11)', null, 'NO', 'PRI', 'NULL', 'auto_increment', '', ''],
|
||||
['o', 'int(11)', null, 'NO', 'MUL', 'NULL', '', '', ''],
|
||||
],
|
||||
],
|
||||
['query' => 'SHOW INDEXES FROM `pma_test`.`table1`', 'result' => []],
|
||||
['query' => 'SHOW INDEXES FROM `pma_test`.`table2`', 'result' => []],
|
||||
[
|
||||
'query' => 'SHOW COLUMNS FROM `pma`.`table1`',
|
||||
'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
'query' => 'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'pma\' AND `TABLE_NAME` COLLATE utf8_bin = \'table1\'',
|
||||
'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
'result' => [
|
||||
['i', 'int(11)', 'NO', 'PRI', 'NULL', 'auto_increment'],
|
||||
['o', 'varchar(100)', 'NO', 'MUL', 'NULL', ''],
|
||||
['i', 'int(11)', null, 'NO', 'PRI', 'NULL', 'auto_increment', '', ''],
|
||||
['o', 'varchar(100)', null, 'NO', 'MUL', 'NULL', '', '', ''],
|
||||
],
|
||||
],
|
||||
[
|
||||
@ -1338,7 +1350,14 @@ class DbiDummy implements DbiExtension
|
||||
'columns' => ['Table_priv'],
|
||||
'result' => [['Select,Insert,Update,References,Create View,Show view']],
|
||||
],
|
||||
['query' => 'SHOW COLUMNS FROM `my_db`.`test_tbl`', 'result' => []],
|
||||
[
|
||||
'query' => 'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'my_db\' AND `TABLE_NAME` COLLATE utf8_bin = \'test_tbl\'',
|
||||
'result' => [],
|
||||
],
|
||||
[
|
||||
'query' => 'SHOW COLUMNS FROM `mysql`.`tables_priv` LIKE \'Table_priv\';',
|
||||
'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
@ -1353,6 +1372,19 @@ class DbiDummy implements DbiExtension
|
||||
['datetimefield', 'datetime', 'NO', '', null, ''],
|
||||
],
|
||||
],
|
||||
[
|
||||
'query' => 'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'PMA_db\' AND `TABLE_NAME` COLLATE utf8_bin = \'PMA_table\'',
|
||||
'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
'result' => [
|
||||
['id', 'int(11)', null, 'NO', 'PRI', null, 'auto_increment', '', ''],
|
||||
['name', 'varchar(20)', null, 'NO', '', null, '', '', ''],
|
||||
['datetimefield', 'datetime', null, 'NO', '', null, '', '', ''],
|
||||
],
|
||||
],
|
||||
[
|
||||
'query' => 'SELECT `Column_name`, `Column_priv` FROM `mysql`.`columns_priv`'
|
||||
. ' WHERE `User` = \'PMA_username\' AND `Host` = \'PMA_hostname\' AND'
|
||||
@ -1455,9 +1487,13 @@ class DbiDummy implements DbiExtension
|
||||
],
|
||||
['query' => 'SHOW ALL SLAVES STATUS', 'result' => []],
|
||||
[
|
||||
'query' => 'SHOW COLUMNS FROM `mysql`.`user`',
|
||||
'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
'result' => [['host', 'char(60)', 'NO', '', null, '']],
|
||||
'query' => 'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'mysql\' AND `TABLE_NAME` COLLATE utf8_bin = \'user\'',
|
||||
'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
'result' => [['host', 'char(60)', null, 'NO', '', null, '', '', '']],
|
||||
],
|
||||
['query' => 'SHOW INDEXES FROM `mysql`.`user`', 'result' => []],
|
||||
['query' => 'SHOW INDEXES FROM `my_db`.`test_tbl`', 'result' => []],
|
||||
@ -1578,7 +1614,11 @@ class DbiDummy implements DbiExtension
|
||||
'result' => [['_id', 'tinyint(4)', null, 'NO', '', null, '', 'select,insert,update,references', '']],
|
||||
],
|
||||
[
|
||||
'query' => 'SHOW FULL COLUMNS FROM `testdb`.`mytable`',
|
||||
'query' => 'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'testdb\' AND `TABLE_NAME` COLLATE utf8_bin = \'mytable\'',
|
||||
'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
'result' => [
|
||||
['aid', 'tinyint(4)', null, 'NO', 'PRI', null, '', 'select,insert,update,references', ''],
|
||||
@ -1615,6 +1655,15 @@ class DbiDummy implements DbiExtension
|
||||
['datetimefield', 'datetime', 'NO', '', 'NULL', ''],
|
||||
],
|
||||
],
|
||||
[
|
||||
'query' => 'SELECT `COLUMN_NAME`, `COLUMN_TYPE` FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'test_db\' AND `TABLE_NAME` COLLATE utf8_bin = \'test_table\'',
|
||||
'columns' => ['COLUMN_NAME', 'COLUMN_TYPE'],
|
||||
'result' => [
|
||||
['id', 'int(11)'],
|
||||
['name', 'varchar(20)'],
|
||||
['datetimefield', 'datetime'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'query' => 'SHOW FULL COLUMNS FROM `test_db`.`test_table`',
|
||||
'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
@ -1624,6 +1673,19 @@ class DbiDummy implements DbiExtension
|
||||
['datetimefield', 'datetime', null, 'NO', '', 'NULL', '', '', ''],
|
||||
],
|
||||
],
|
||||
[
|
||||
'query' => 'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`, `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'test_db\' AND `TABLE_NAME` COLLATE utf8_bin = \'test_table\'',
|
||||
'columns' => ['Field', 'Type', 'Collation', 'Null', 'Key', 'Default', 'Extra', 'Privileges', 'Comment'],
|
||||
'result' => [
|
||||
['id', 'int(11)', null, 'NO', 'PRI', 'NULL', 'auto_increment', '', ''],
|
||||
['name', 'varchar(20)', null, 'NO', '', 'NULL', '', '', ''],
|
||||
['datetimefield', 'datetime', null, 'NO', '', 'NULL', '', '', ''],
|
||||
],
|
||||
],
|
||||
[
|
||||
'query' => 'DESC `test_db`.`test_table`',
|
||||
'columns' => ['Field', 'Type', 'Null', 'Key', 'Default', 'Extra'],
|
||||
|
||||
@ -33,7 +33,13 @@ class ColumnsDefinitionTest extends AbstractTestCase
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
$columnMeta = ['Field' => 'actor_id', 'Type' => 'smallint(5) unsigned', 'Collation' => null, 'Null' => 'NO', 'Key' => 'PRI', 'Default' => null, 'Extra' => 'auto_increment', 'Privileges' => 'select,insert,update,references', 'Comment' => ''];
|
||||
$dummyDbi->addResult(
|
||||
'SHOW FULL COLUMNS FROM `sakila`.`actor`',
|
||||
'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,'
|
||||
. ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,'
|
||||
. ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,'
|
||||
. ' `COLUMN_COMMENT` AS `Comment`'
|
||||
. ' FROM `information_schema`.`COLUMNS`'
|
||||
. ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'sakila\' AND'
|
||||
. ' `TABLE_NAME` COLLATE utf8_bin = \'actor\'',
|
||||
[
|
||||
['actor_id', 'smallint(5) unsigned', null, 'NO', 'PRI', null, 'auto_increment', 'select,insert,update,references', ''],
|
||||
['first_name', 'varchar(45)', 'utf8mb4_general_ci', 'NO', '', null, '', 'select,insert,update,references', ''],
|
||||
|
||||
@ -267,6 +267,16 @@ class TableTest extends AbstractTestCase
|
||||
$dbi->expects(self::any())->method('getCache')
|
||||
->willReturn($cache);
|
||||
|
||||
$dbi->expects(self::any())->method('getColumnNames')
|
||||
->willReturnMap([
|
||||
[
|
||||
'PMA',
|
||||
'PMA_BookMark',
|
||||
ConnectionType::User,
|
||||
['column1', 'column3', 'column5', 'ACCESSIBLE', 'ADD', 'ALL'],
|
||||
],
|
||||
]);
|
||||
|
||||
$databases = [];
|
||||
$databaseName = 'PMA';
|
||||
$databases[$databaseName]['SCHEMA_TABLES'] = 1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user