Fix visibility of the methods
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
dc2b2d4f6c
commit
e9bc3e0cd5
@ -156,7 +156,7 @@ if ($total_rows <= 0) {
|
||||
'The central list of columns for the current database is empty.'
|
||||
) . '</fieldset>'
|
||||
);
|
||||
$columnAdd = $centralColumns->getHtmlForAddCentralColumn($GLOBALS['dbi'], $total_rows, $pos, $db);
|
||||
$columnAdd = $centralColumns->getHtmlForAddColumn($GLOBALS['dbi'], $total_rows, $pos, $db);
|
||||
$response->addHTML($columnAdd);
|
||||
exit;
|
||||
}
|
||||
@ -167,7 +167,7 @@ $table_navigation_html = $centralColumns->getHtmlForTableNavigation(
|
||||
$db
|
||||
);
|
||||
$response->addHTML($table_navigation_html);
|
||||
$columnAdd = $centralColumns->getHtmlForAddCentralColumn($GLOBALS['dbi'], $total_rows, $pos, $db);
|
||||
$columnAdd = $centralColumns->getHtmlForAddColumn($GLOBALS['dbi'], $total_rows, $pos, $db);
|
||||
$response->addHTML($columnAdd);
|
||||
$deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">'
|
||||
. Url::getHiddenInputs(
|
||||
@ -195,7 +195,7 @@ $result = $centralColumns->getColumnsList(
|
||||
);
|
||||
$row_num = 0;
|
||||
foreach ($result as $row) {
|
||||
$tableHtmlRow = $centralColumns->getHtmlForCentralColumnsTableRow(
|
||||
$tableHtmlRow = $centralColumns->getHtmlForTableRow(
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['MaxRows'],
|
||||
$GLOBALS['cfg']['CharEditing'],
|
||||
|
||||
@ -138,7 +138,7 @@ class CentralColumns
|
||||
*
|
||||
* @return array list of columns in central columns among given set of columns
|
||||
*/
|
||||
public function findExistingColNames(
|
||||
private function findExistingColNames(
|
||||
DatabaseInterface $dbi,
|
||||
$user,
|
||||
$db,
|
||||
@ -177,7 +177,7 @@ class CentralColumns
|
||||
*
|
||||
* @return Message
|
||||
*/
|
||||
public function configErrorMessage()
|
||||
private function configErrorMessage()
|
||||
{
|
||||
return Message::error(
|
||||
__(
|
||||
@ -200,7 +200,7 @@ class CentralColumns
|
||||
* @return string query string to insert the given column
|
||||
* with definition into central list
|
||||
*/
|
||||
public function getInsertQuery(
|
||||
private function getInsertQuery(
|
||||
DatabaseInterface $dbi,
|
||||
$column,
|
||||
array $def,
|
||||
@ -798,7 +798,7 @@ class CentralColumns
|
||||
*
|
||||
* @return string html for table header in central columns multi edit page
|
||||
*/
|
||||
public function getEditTableHeader(array $headers)
|
||||
private function getEditTableHeader(array $headers)
|
||||
{
|
||||
return Template::get(
|
||||
'database/central_columns/edit_table_header'
|
||||
@ -815,7 +815,7 @@ class CentralColumns
|
||||
*
|
||||
* @return string html dropdown for selecting table
|
||||
*/
|
||||
public function getHtmlForTableDropdown(DatabaseInterface $dbi, $db)
|
||||
private function getHtmlForTableDropdown(DatabaseInterface $dbi, $db)
|
||||
{
|
||||
$dbi->selectDb($db);
|
||||
$tables = $dbi->getTables($db);
|
||||
@ -873,7 +873,7 @@ class CentralColumns
|
||||
*
|
||||
* @return string html to add a column in the central list
|
||||
*/
|
||||
public function getHtmlForAddCentralColumn(
|
||||
public function getHtmlForAddColumn(
|
||||
DatabaseInterface $dbi,
|
||||
$total_rows,
|
||||
$pos,
|
||||
@ -921,7 +921,7 @@ class CentralColumns
|
||||
*
|
||||
* @return string html of a particular row in the central columns table.
|
||||
*/
|
||||
public function getHtmlForCentralColumnsTableRow(
|
||||
public function getHtmlForTableRow(
|
||||
DatabaseInterface $dbi,
|
||||
$maxRows,
|
||||
$charEditing,
|
||||
@ -1104,7 +1104,7 @@ class CentralColumns
|
||||
*
|
||||
* @return string html of a particular row in the central columns table.
|
||||
*/
|
||||
public function getHtmlForCentralColumnsEditTableRow(
|
||||
private function getHtmlForEditTableRow(
|
||||
DatabaseInterface $dbi,
|
||||
$maxRows,
|
||||
$charEditing,
|
||||
@ -1324,7 +1324,7 @@ class CentralColumns
|
||||
*
|
||||
* @return string html for table footer in central columns multi edit page
|
||||
*/
|
||||
public function getEditTableFooter()
|
||||
private function getEditTableFooter()
|
||||
{
|
||||
$html_output = '<fieldset class="tblFooters">'
|
||||
. '<input type="submit" '
|
||||
@ -1341,7 +1341,7 @@ class CentralColumns
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handleColumnExtra(array &$columns_list)
|
||||
private function handleColumnExtra(array &$columns_list)
|
||||
{
|
||||
foreach ($columns_list as &$row) {
|
||||
$vals = explode(',', $row['col_extra']);
|
||||
@ -1537,7 +1537,7 @@ class CentralColumns
|
||||
$list_detail_cols = $this->findExistingColNames($dbi, $user, $selected_db, $columns_list, true);
|
||||
$row_num = 0;
|
||||
foreach ($list_detail_cols as $row) {
|
||||
$tableHtmlRow = $this->getHtmlForCentralColumnsEditTableRow(
|
||||
$tableHtmlRow = $this->getHtmlForEditTableRow(
|
||||
$dbi,
|
||||
$maxRows,
|
||||
$charEditing,
|
||||
|
||||
@ -14,6 +14,7 @@ use PhpMyAdmin\Types;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionClass;
|
||||
|
||||
$GLOBALS['server'] = 1;
|
||||
|
||||
@ -131,6 +132,29 @@ class CentralColumnsTest extends TestCase
|
||||
$this->centralColumns = new CentralColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call protected functions by setting visibility to public.
|
||||
*
|
||||
* @param string $name method name
|
||||
* @param array $params parameters for the invocation
|
||||
* @param CentralColumns $object CentralColumns instance object
|
||||
*
|
||||
* @return mixed the output from the protected method.
|
||||
*/
|
||||
private function callProtectedMethod(
|
||||
$name,
|
||||
array $params = [],
|
||||
CentralColumns $object = null
|
||||
) {
|
||||
$class = new ReflectionClass(CentralColumns::class);
|
||||
$method = $class->getMethod($name);
|
||||
$method->setAccessible(true);
|
||||
return $method->invokeArgs(
|
||||
$object !== null ? $object : $this->centralColumns,
|
||||
$params
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getParams
|
||||
*
|
||||
@ -461,27 +485,39 @@ class CentralColumnsTest extends TestCase
|
||||
__('Collation'), __('Attributes'), __('Null'), __('A_I')
|
||||
);
|
||||
$this->assertContains(
|
||||
$this->centralColumns->getEditTableHeader($header_cells), $result
|
||||
$this->callProtectedMethod(
|
||||
'getEditTableHeader',
|
||||
[$header_cells]
|
||||
),
|
||||
$result
|
||||
);
|
||||
$list_detail_cols = $this->centralColumns->findExistingColNames(
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
'phpmyadmin',
|
||||
"'col1','col2'",
|
||||
true
|
||||
);
|
||||
$this->assertContains(
|
||||
$this->centralColumns->getHtmlForCentralColumnsEditTableRow(
|
||||
$list_detail_cols = $this->callProtectedMethod(
|
||||
'findExistingColNames',
|
||||
[
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['MaxRows'],
|
||||
$GLOBALS['cfg']['CharEditing'],
|
||||
$GLOBALS['cfg']['Server']['DisableIS'],
|
||||
$list_detail_cols[0],
|
||||
0
|
||||
), $result
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
'phpmyadmin',
|
||||
"'col1','col2'",
|
||||
true,
|
||||
]
|
||||
);
|
||||
$this->assertContains(
|
||||
$this->centralColumns->getEditTableFooter(), $result
|
||||
$this->callProtectedMethod(
|
||||
'getHtmlForEditTableRow',
|
||||
[
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['MaxRows'],
|
||||
$GLOBALS['cfg']['CharEditing'],
|
||||
$GLOBALS['cfg']['Server']['DisableIS'],
|
||||
$list_detail_cols[0],
|
||||
0,
|
||||
]
|
||||
),
|
||||
$result
|
||||
);
|
||||
$this->assertContains(
|
||||
$this->callProtectedMethod('getEditTableFooter'),
|
||||
$result
|
||||
);
|
||||
|
||||
}
|
||||
@ -655,7 +691,7 @@ class CentralColumnsTest extends TestCase
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
'PhpMyAdmin\Message',
|
||||
$this->centralColumns->configErrorMessage()
|
||||
$this->callProtectedMethod('configErrorMessage')
|
||||
);
|
||||
}
|
||||
|
||||
@ -678,12 +714,15 @@ class CentralColumnsTest extends TestCase
|
||||
);
|
||||
$this->assertEquals(
|
||||
array_slice($this->_modifiedColumnData, 1, 1),
|
||||
$this->centralColumns->findExistingColNames(
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
'phpmyadmin',
|
||||
"'col1'",
|
||||
true
|
||||
$this->callProtectedMethod(
|
||||
'findExistingColNames',
|
||||
[
|
||||
$GLOBALS['dbi'],
|
||||
$GLOBALS['cfg']['Server']['user'],
|
||||
'phpmyadmin',
|
||||
"'col1'",
|
||||
true,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -696,7 +735,13 @@ class CentralColumnsTest extends TestCase
|
||||
public function testPMAGetHTMLforTableDropdown()
|
||||
{
|
||||
$db = 'PMA_db';
|
||||
$result = $this->centralColumns->getHtmlForTableDropdown($GLOBALS['dbi'], $db);
|
||||
$result = $this->callProtectedMethod(
|
||||
'getHtmlForTableDropdown',
|
||||
[
|
||||
$GLOBALS['dbi'],
|
||||
$db,
|
||||
]
|
||||
);
|
||||
$this->assertContains(
|
||||
'<select name="table-select" id="table-select"',
|
||||
$result
|
||||
@ -730,13 +775,13 @@ class CentralColumnsTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getHtmlForAddCentralColumn
|
||||
* Test for getHtmlForAddColumn
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPMAGetHTMLforAddCentralColumn()
|
||||
public function testPMAGetHTMLforAddColumn()
|
||||
{
|
||||
$result = $this->centralColumns->getHtmlForAddCentralColumn($GLOBALS['dbi'], 20, 0, 'phpmyadmin');
|
||||
$result = $this->centralColumns->getHtmlForAddColumn($GLOBALS['dbi'], 20, 0, 'phpmyadmin');
|
||||
$this->assertContains(
|
||||
'<table',
|
||||
$result
|
||||
|
||||
Loading…
Reference in New Issue
Block a user