Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
16ffe7c888
@ -8,7 +8,6 @@
|
||||
namespace PhpMyAdmin\Controllers;
|
||||
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\Di\Container;
|
||||
use PhpMyAdmin\Response;
|
||||
|
||||
/**
|
||||
@ -29,19 +28,12 @@ abstract class Controller
|
||||
*/
|
||||
protected $dbi;
|
||||
|
||||
/**
|
||||
* @var \PhpMyAdmin\Di\Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($response, $dbi)
|
||||
{
|
||||
$container = Container::getDefaultContainer();
|
||||
$this->container = $container;
|
||||
$this->dbi = $this->container->get('dbi');
|
||||
$this->response = $this->container->get('response');
|
||||
$this->response = $response;
|
||||
$this->dbi = $dbi;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,9 +22,9 @@ abstract class DatabaseController extends Controller
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($response, $dbi, $db)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->container->get('db');
|
||||
parent::__construct($response, $dbi);
|
||||
$this->db = $db;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,9 +30,9 @@ class ServerBinlogController extends Controller
|
||||
/**
|
||||
* Constructs ServerBinlogController
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($response, $dbi)
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct($response, $dbi);
|
||||
$this->binary_logs = $this->dbi->fetchResult(
|
||||
'SHOW MASTER LOGS',
|
||||
'Log_name',
|
||||
|
||||
@ -28,9 +28,9 @@ class ServerPluginsController extends Controller
|
||||
/**
|
||||
* Constructs ServerPluginsController
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($response, $dbi)
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct($response, $dbi);
|
||||
$this->_setServerPlugins();
|
||||
}
|
||||
|
||||
|
||||
@ -32,9 +32,9 @@ class ServerVariablesController extends Controller
|
||||
/**
|
||||
* Constructs ServerVariablesController
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($response, $dbi)
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct($response, $dbi);
|
||||
|
||||
$this->variable_doc_links = $this->_getDocumentLinks();
|
||||
}
|
||||
|
||||
@ -43,9 +43,16 @@ class TableChartController extends TableController
|
||||
* @param string $url_query Query URL
|
||||
* @param array $cfg Configuration
|
||||
*/
|
||||
public function __construct($sql_query, $url_query, array $cfg)
|
||||
{
|
||||
parent::__construct();
|
||||
public function __construct(
|
||||
$response,
|
||||
$dbi,
|
||||
$db,
|
||||
$table,
|
||||
$sql_query,
|
||||
$url_query,
|
||||
array $cfg
|
||||
) {
|
||||
parent::__construct($response, $dbi, $db, $table);
|
||||
|
||||
$this->sql_query = $sql_query;
|
||||
$this->url_query = $url_query;
|
||||
|
||||
@ -55,13 +55,17 @@ class TableGisVisualizationController extends TableController
|
||||
* @param array $visualizationSettings visualization settings
|
||||
*/
|
||||
public function __construct(
|
||||
$response,
|
||||
$dbi,
|
||||
$db,
|
||||
$table,
|
||||
$sql_query,
|
||||
array $url_params,
|
||||
$goto,
|
||||
$back,
|
||||
array $visualizationSettings
|
||||
) {
|
||||
parent::__construct();
|
||||
parent::__construct($response, $dbi, $db, $table);
|
||||
|
||||
$this->sql_query = $sql_query;
|
||||
$this->url_params = $url_params;
|
||||
|
||||
@ -31,9 +31,14 @@ class TableIndexesController extends TableController
|
||||
*
|
||||
* @param Index $index Index
|
||||
*/
|
||||
public function __construct($index)
|
||||
{
|
||||
parent::__construct();
|
||||
public function __construct(
|
||||
$response,
|
||||
$dbi,
|
||||
$db,
|
||||
$table,
|
||||
$index
|
||||
) {
|
||||
parent::__construct($response, $dbi, $db, $table);
|
||||
|
||||
$this->index = $index;
|
||||
}
|
||||
|
||||
@ -63,10 +63,19 @@ class TableRelationController extends TableController
|
||||
* @param array|null $existrel_foreign External relations
|
||||
* @param string $upd_query Update query
|
||||
*/
|
||||
public function __construct($options_array, $cfgRelation, $tbl_storage_engine,
|
||||
$existrel, $existrel_foreign, $upd_query
|
||||
public function __construct(
|
||||
$response,
|
||||
$dbi,
|
||||
$db,
|
||||
$table,
|
||||
$options_array,
|
||||
$cfgRelation,
|
||||
$tbl_storage_engine,
|
||||
$existrel,
|
||||
$existrel_foreign,
|
||||
$upd_query
|
||||
) {
|
||||
parent::__construct();
|
||||
parent::__construct($response, $dbi, $db, $table);
|
||||
|
||||
$this->options_array = $options_array;
|
||||
$this->cfgRelation = $cfgRelation;
|
||||
|
||||
@ -86,9 +86,15 @@ class TableSearchController extends TableController
|
||||
* @param string $searchType Search type
|
||||
* @param string $url_query URL query
|
||||
*/
|
||||
public function __construct($searchType, $url_query)
|
||||
{
|
||||
parent::__construct();
|
||||
public function __construct(
|
||||
$response,
|
||||
$dbi,
|
||||
$db,
|
||||
$table,
|
||||
$searchType,
|
||||
$url_query
|
||||
) {
|
||||
parent::__construct($response, $dbi, $db, $table);
|
||||
|
||||
$this->url_query = $url_query;
|
||||
$this->_searchType = $searchType;
|
||||
|
||||
@ -71,9 +71,9 @@ class TableStructureController extends TableController
|
||||
/**
|
||||
* TableStructureController constructor
|
||||
*
|
||||
* @param string $type Indicate the db_structure or tbl_structure
|
||||
* @param string $db DB name
|
||||
* @param string $table Table name
|
||||
* @param string $type Indicate the db_structure or tbl_structure
|
||||
* @param int $num_tables Number of tables
|
||||
* @param int $pos Current position in the list
|
||||
* @param bool $db_is_system_schema DB is information_schema
|
||||
@ -87,11 +87,24 @@ class TableStructureController extends TableController
|
||||
* @param array $showtable Show table info
|
||||
*/
|
||||
public function __construct(
|
||||
$type, $db, $table, $num_tables, $pos, $db_is_system_schema,
|
||||
$total_num_tables, $tables, $is_show_stats, $tbl_is_view,
|
||||
$tbl_storage_engine, $table_info_num_rows, $tbl_collation, $showtable
|
||||
$response,
|
||||
$dbi,
|
||||
$db,
|
||||
$table,
|
||||
$type,
|
||||
$num_tables,
|
||||
$pos,
|
||||
$db_is_system_schema,
|
||||
$total_num_tables,
|
||||
$tables,
|
||||
$is_show_stats,
|
||||
$tbl_is_view,
|
||||
$tbl_storage_engine,
|
||||
$table_info_num_rows,
|
||||
$tbl_collation,
|
||||
$showtable
|
||||
) {
|
||||
parent::__construct();
|
||||
parent::__construct($response, $dbi, $db, $table);
|
||||
|
||||
$this->_db_is_system_schema = $db_is_system_schema;
|
||||
$this->_url_query = Url::getCommonRaw(array('db' => $db, 'table' => $table));
|
||||
|
||||
@ -27,10 +27,14 @@ abstract class TableController extends Controller
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = $this->container->get('db');
|
||||
$this->table = $this->container->get('table');
|
||||
public function __construct(
|
||||
$response,
|
||||
$dbi,
|
||||
$db,
|
||||
$table
|
||||
) {
|
||||
parent::__construct($response, $dbi);
|
||||
$this->db = $db;
|
||||
$this->table = $table;
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +99,9 @@ class DatabaseStructureControllerTest extends PmaTestCase
|
||||
$method = $class->getMethod('getValuesForInnodbTable');
|
||||
$method->setAccessible(true);
|
||||
$ctrl = new DatabaseStructureController(
|
||||
$GLOBALS['db'], null
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db')
|
||||
);
|
||||
// Showing statistics
|
||||
$property = $class->getProperty('_is_show_stats');
|
||||
@ -145,7 +147,9 @@ class DatabaseStructureControllerTest extends PmaTestCase
|
||||
// Not showing statistics
|
||||
$is_show_stats = false;
|
||||
$ctrl = new DatabaseStructureController(
|
||||
$GLOBALS['db'], null
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db')
|
||||
);
|
||||
|
||||
$current_table['ENGINE'] = 'InnoDB';
|
||||
@ -181,12 +185,15 @@ class DatabaseStructureControllerTest extends PmaTestCase
|
||||
*/
|
||||
public function testGetValuesForAriaTable()
|
||||
{
|
||||
$container = Container::getDefaultContainer();
|
||||
$class = new ReflectionClass('PhpMyAdmin\Controllers\Database\DatabaseStructureController');
|
||||
$method = $class->getMethod('getValuesForAriaTable');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$ctrl = new DatabaseStructureController(
|
||||
$GLOBALS['db'], null
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db')
|
||||
);
|
||||
// Showing statistics
|
||||
$property = $class->getProperty('_is_show_stats');
|
||||
@ -224,7 +231,9 @@ class DatabaseStructureControllerTest extends PmaTestCase
|
||||
|
||||
$is_show_stats = false;
|
||||
$ctrl = new DatabaseStructureController(
|
||||
$GLOBALS['db'], null
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db')
|
||||
);
|
||||
list($current_table,,,,,, $sum_size)
|
||||
= $method->invokeArgs($ctrl, array($current_table, 0, 0, 0, 0, 0, 0));
|
||||
@ -232,7 +241,9 @@ class DatabaseStructureControllerTest extends PmaTestCase
|
||||
|
||||
$db_is_system_schema = false;
|
||||
$ctrl = new DatabaseStructureController(
|
||||
$GLOBALS['db'], null
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db')
|
||||
);
|
||||
list($current_table,,,,,,)
|
||||
= $method->invokeArgs($ctrl, array($current_table, 0, 0, 0, 0, 0, 0,));
|
||||
@ -247,12 +258,15 @@ class DatabaseStructureControllerTest extends PmaTestCase
|
||||
*/
|
||||
public function testHasTable()
|
||||
{
|
||||
$container = Container::getDefaultContainer();
|
||||
$class = new ReflectionClass('PhpMyAdmin\Controllers\Database\DatabaseStructureController');
|
||||
$method = $class->getMethod('hasTable');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$ctrl = new DatabaseStructureController(
|
||||
$GLOBALS['db'], null
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db')
|
||||
);
|
||||
|
||||
// When parameter $db is empty
|
||||
@ -288,12 +302,15 @@ class DatabaseStructureControllerTest extends PmaTestCase
|
||||
*/
|
||||
public function testCheckFavoriteTable()
|
||||
{
|
||||
$container = Container::getDefaultContainer();
|
||||
$class = new ReflectionClass('PhpMyAdmin\Controllers\Database\DatabaseStructureController');
|
||||
$method = $class->getMethod('checkFavoriteTable');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$ctrl = new DatabaseStructureController(
|
||||
$GLOBALS['db'], null
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db')
|
||||
);
|
||||
|
||||
$_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] = array(
|
||||
@ -319,6 +336,7 @@ class DatabaseStructureControllerTest extends PmaTestCase
|
||||
*/
|
||||
public function testSynchronizeFavoriteTables()
|
||||
{
|
||||
$container = Container::getDefaultContainer();
|
||||
$fav_instance = $this->getMockBuilder('PhpMyAdmin\RecentFavoriteTable')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
@ -339,7 +357,9 @@ class DatabaseStructureControllerTest extends PmaTestCase
|
||||
$method->setAccessible(true);
|
||||
|
||||
$ctrl = new DatabaseStructureController(
|
||||
$GLOBALS['db'], null
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db')
|
||||
);
|
||||
|
||||
// The user hash for test
|
||||
@ -365,10 +385,13 @@ class DatabaseStructureControllerTest extends PmaTestCase
|
||||
*/
|
||||
public function testHandleRealRowCountRequestAction()
|
||||
{
|
||||
$container = Container::getDefaultContainer();
|
||||
$_REQUEST['table'] = 'table';
|
||||
|
||||
$ctrl = new DatabaseStructureController(
|
||||
$GLOBALS['db'], null
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db')
|
||||
);
|
||||
// Showing statistics
|
||||
$class = new ReflectionClass('PhpMyAdmin\Controllers\Database\DatabaseStructureController');
|
||||
|
||||
@ -71,6 +71,8 @@ class ServerBinlogControllerTest extends PmaTestCase
|
||||
*/
|
||||
public function testGetLogSelector()
|
||||
{
|
||||
$container = Container::getDefaultContainer();
|
||||
|
||||
$url_params = array();
|
||||
$url_params['log'] = "log";
|
||||
$url_params['dontlimitchars'] = 1;
|
||||
@ -79,7 +81,10 @@ class ServerBinlogControllerTest extends PmaTestCase
|
||||
$method = $class->getMethod('_getLogSelector');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$ctrl = new ServerBinlogController();
|
||||
$ctrl = new ServerBinlogController(
|
||||
$container->get('response'),
|
||||
$container->get('dbi')
|
||||
);
|
||||
$html = $method->invoke(
|
||||
$ctrl,
|
||||
$url_params
|
||||
@ -107,14 +112,16 @@ class ServerBinlogControllerTest extends PmaTestCase
|
||||
*/
|
||||
public function testGetLogInfo()
|
||||
{
|
||||
$container = Container::getDefaultContainer();
|
||||
$dbi = $container->get('dbi');
|
||||
|
||||
$class = new ReflectionClass('\PhpMyAdmin\Controllers\Server\ServerBinlogController');
|
||||
$method = $class->getMethod('_getLogInfo');
|
||||
$method->setAccessible(true);
|
||||
$ctrl = new ServerBinlogController();
|
||||
|
||||
//Mock DBI
|
||||
$container = Container::getDefaultContainer();
|
||||
$dbi = $container->get('dbi');
|
||||
$ctrl = new ServerBinlogController(
|
||||
$container->get('response'),
|
||||
$dbi
|
||||
);
|
||||
|
||||
//expects return value
|
||||
$result = array(
|
||||
@ -220,14 +227,16 @@ class ServerBinlogControllerTest extends PmaTestCase
|
||||
*/
|
||||
public function testGetAllLogItemInfo()
|
||||
{
|
||||
$container = Container::getDefaultContainer();
|
||||
$dbi = $container->get('dbi');
|
||||
|
||||
$class = new ReflectionClass('\PhpMyAdmin\Controllers\Server\ServerBinlogController');
|
||||
$method = $class->getMethod('_getAllLogItemInfo');
|
||||
$method->setAccessible(true);
|
||||
$ctrl = new ServerBinlogController();
|
||||
|
||||
//Mock DBI
|
||||
$container = Container::getDefaultContainer();
|
||||
$dbi = $container->get('dbi');
|
||||
$ctrl = new ServerBinlogController(
|
||||
$container->get('response'),
|
||||
$dbi
|
||||
);
|
||||
|
||||
$fetchAssoc = array(
|
||||
'Info' => 'Info',
|
||||
|
||||
@ -9,6 +9,7 @@ namespace PhpMyAdmin\Tests\Controllers\Server;
|
||||
|
||||
use PhpMyAdmin\Controllers\Server\ServerCollationsController;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Di\Container;
|
||||
use PhpMyAdmin\Tests\PmaTestCase;
|
||||
use PhpMyAdmin\Theme;
|
||||
use ReflectionClass;
|
||||
@ -84,11 +85,16 @@ class ServerCollationsControllerTest extends PmaTestCase
|
||||
"binary" => true,
|
||||
);
|
||||
|
||||
$container = Container::getDefaultContainer();
|
||||
|
||||
$class = new ReflectionClass('\PhpMyAdmin\Controllers\Server\ServerCollationsController');
|
||||
$method = $class->getMethod('_getHtmlForCharsets');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$ctrl = new ServerCollationsController();
|
||||
$ctrl = new ServerCollationsController(
|
||||
$container->get('response'),
|
||||
$container->get('dbi')
|
||||
);
|
||||
$html = $method->invoke(
|
||||
$ctrl,
|
||||
$mysql_charsets,
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
namespace PhpMyAdmin\Tests\Controllers\Server;
|
||||
|
||||
use PhpMyAdmin\Controllers\Server\ServerEnginesController;
|
||||
use PhpMyAdmin\Di\Container;
|
||||
use PhpMyAdmin\StorageEngine;
|
||||
use PhpMyAdmin\Tests\PmaTestCase;
|
||||
use PhpMyAdmin\Theme;
|
||||
@ -51,7 +52,12 @@ class ServerEnginesControllerTest extends PmaTestCase
|
||||
$method = $class->getMethod('_getHtmlForAllServerEngines');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$ctrl = new ServerEnginesController();
|
||||
$container = Container::getDefaultContainer();
|
||||
|
||||
$ctrl = new ServerEnginesController(
|
||||
$container->get('response'),
|
||||
$container->get('dbi')
|
||||
);
|
||||
$html = $method->invoke($ctrl);
|
||||
|
||||
//validate 1: Item header
|
||||
@ -112,8 +118,13 @@ class ServerEnginesControllerTest extends PmaTestCase
|
||||
$method = $class->getMethod('_getHtmlForServerEngine');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$container = Container::getDefaultContainer();
|
||||
|
||||
$engine_plugin = StorageEngine::getEngine("Pbxt");
|
||||
$ctrl = new ServerEnginesController();
|
||||
$ctrl = new ServerEnginesController(
|
||||
$container->get('response'),
|
||||
$container->get('dbi')
|
||||
);
|
||||
$html = $method->invoke($ctrl, $engine_plugin);
|
||||
|
||||
//validate 1: Engine title
|
||||
|
||||
@ -81,7 +81,10 @@ class ServerPluginsControllerTest extends PmaTestCase
|
||||
$method = $class->getMethod('_getPluginsHtml');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$ctrl = new ServerPluginsController();
|
||||
$ctrl = new ServerPluginsController(
|
||||
$container->get('response'),
|
||||
$container->get('dbi')
|
||||
);
|
||||
$html = $method->invoke($ctrl);
|
||||
|
||||
//validate 1:Items
|
||||
|
||||
@ -100,7 +100,13 @@ class TableIndexesControllerTest extends PmaTestCase
|
||||
$container->set('PhpMyAdmin\Response', $response);
|
||||
$container->alias('response', 'PhpMyAdmin\Response');
|
||||
|
||||
$ctrl = new TableIndexesController(null);
|
||||
$ctrl = new TableIndexesController(
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db'),
|
||||
$container->get('table'),
|
||||
null
|
||||
);
|
||||
|
||||
// Preview SQL
|
||||
$_REQUEST['preview_sql'] = true;
|
||||
@ -153,7 +159,13 @@ class TableIndexesControllerTest extends PmaTestCase
|
||||
$container->alias('response', 'PhpMyAdmin\Response');
|
||||
$index = new Index();
|
||||
|
||||
$ctrl = new TableIndexesController($index);
|
||||
$ctrl = new TableIndexesController(
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db'),
|
||||
$container->get('table'),
|
||||
$index
|
||||
);
|
||||
|
||||
$_REQUEST['create_index'] = true;
|
||||
$_REQUEST['added_fields'] = 3;
|
||||
|
||||
@ -114,7 +114,16 @@ class TableSearchControllerTest extends PmaTestCase
|
||||
*/
|
||||
public function testReplace()
|
||||
{
|
||||
$tableSearch = new TableSearchController("zoom", null);
|
||||
$container = Container::getDefaultContainer();
|
||||
|
||||
$tableSearch = new TableSearchController(
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db'),
|
||||
$container->get('table'),
|
||||
"zoom",
|
||||
null
|
||||
);
|
||||
$columnIndex = 0;
|
||||
$find = "Field";
|
||||
$replaceWith = "Column";
|
||||
@ -148,10 +157,19 @@ class TableSearchControllerTest extends PmaTestCase
|
||||
$_POST['order'] = "asc";
|
||||
$_POST['customWhereClause'] = "name='pma'";
|
||||
|
||||
$container = Container::getDefaultContainer();
|
||||
|
||||
$class = new ReflectionClass('PhpMyAdmin\Controllers\Table\TableSearchController');
|
||||
$method = $class->getMethod('_buildSqlQuery');
|
||||
$method->setAccessible(true);
|
||||
$tableSearch = new TableSearchController("zoom", null);
|
||||
$tableSearch = new TableSearchController(
|
||||
$container->get('response'),
|
||||
$container->get('dbi'),
|
||||
$container->get('db'),
|
||||
$container->get('table'),
|
||||
"zoom",
|
||||
null
|
||||
);
|
||||
|
||||
$sql = $method->invoke($tableSearch);
|
||||
$result = "SELECT DISTINCT * FROM `PMA` WHERE name='pma' "
|
||||
|
||||
Loading…
Reference in New Issue
Block a user