Refactor browse_foreigners functions to static methods

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
Maurício Meneghini Fauth 2017-09-11 20:11:26 -03:00
parent a2b08bae7b
commit 11ff8cee11
4 changed files with 385 additions and 375 deletions

View File

@ -5,12 +5,13 @@
*
* @package PhpMyAdmin
*/
use PhpMyAdmin\BrowseForeigners;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Response;
use PhpMyAdmin\Util;
require_once 'libraries/common.inc.php';
require_once 'libraries/browse_foreigners.lib.php';
/**
* Sets globals from $_REQUEST
@ -39,7 +40,7 @@ $header->setBodyId('body_browse_foreigners');
*/
$foreigners = Relation::getForeigners($db, $table);
$foreign_limit = PMA_getForeignLimit(
$foreign_limit = BrowseForeigners::getForeignLimit(
isset($_REQUEST['foreign_showAll']) ? $_REQUEST['foreign_showAll'] : null
);
@ -53,7 +54,7 @@ $foreignData = Relation::getForeignData(
);
// HTML output
$html = PMA_getHtmlForRelationalFieldSelection(
$html = BrowseForeigners::getHtmlForRelationalFieldSelection(
$db, $table, $_REQUEST['field'], $foreignData,
isset($fieldkey) ? $fieldkey : null,
isset($data) ? $data : null

View File

@ -1,341 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Contains functions used by browse_foreigners.php
*
* @package PhpMyAdmin
*/
use PhpMyAdmin\Url;
/**
* Function to get html for one relational key
*
* @param integer $horizontal_count the current horizontal count
* @param string $header table header
* @param array $keys all the keys
* @param integer $indexByKeyname index by keyname
* @param array $descriptions descriptions
* @param integer $indexByDescription index by description
* @param string $current_value current value on the edit form
*
* @return string $html the generated html
*/
function PMA_getHtmlForOneKey($horizontal_count, $header, $keys,
$indexByKeyname, $descriptions, $indexByDescription, $current_value
) {
$horizontal_count++;
$output = '';
// whether the key name corresponds to the selected value in the form
$rightKeynameIsSelected = false;
$leftKeynameIsSelected = false;
if ($GLOBALS['cfg']['RepeatCells'] > 0
&& $horizontal_count > $GLOBALS['cfg']['RepeatCells']
) {
$output .= $header;
$horizontal_count = 0;
}
// key names and descriptions for the left section,
// sorted by key names
$leftKeyname = $keys[$indexByKeyname];
list(
$leftDescription,
$leftDescriptionTitle
) = PMA_getDescriptionAndTitle($descriptions[$indexByKeyname]);
// key names and descriptions for the right section,
// sorted by descriptions
$rightKeyname = $keys[$indexByDescription];
list(
$rightDescription,
$rightDescriptionTitle
) = PMA_getDescriptionAndTitle($descriptions[$indexByDescription]);
$indexByDescription++;
if (! empty($current_value)) {
$rightKeynameIsSelected = $rightKeyname == $current_value;
$leftKeynameIsSelected = $leftKeyname == $current_value;
}
$output .= '<tr class="noclick">';
$output .= PMA_getHtmlForColumnElement(
'class="nowrap"', $leftKeynameIsSelected,
$leftKeyname, $leftDescription,
$leftDescriptionTitle
);
$output .= PMA_getHtmlForColumnElement(
'', $leftKeynameIsSelected, $leftKeyname,
$leftDescription, $leftDescriptionTitle
);
$output .= '<td width="20%">'
. '<img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png" alt=""'
. ' width="1" height="1" /></td>';
$output .= PMA_getHtmlForColumnElement(
'', $rightKeynameIsSelected, $rightKeyname,
$rightDescription, $rightDescriptionTitle
);
$output .= PMA_getHtmlForColumnElement(
'class="nowrap"', $rightKeynameIsSelected,
$rightKeyname, $rightDescription,
$rightDescriptionTitle
);
$output .= '</tr>';
return array($output, $horizontal_count, $indexByDescription);
}
/**
* Function to get html for relational field selection
*
* @param string $db current database
* @param string $table current table
* @param string $field field
* @param array $foreignData foreign column data
* @param string $fieldkey field key
* @param string $current_value current columns's value
*
* @return string
*/
function PMA_getHtmlForRelationalFieldSelection($db, $table, $field, $foreignData,
$fieldkey, $current_value
) {
$gotopage = PMA_getHtmlForGotoPage($foreignData);
$showall = PMA_getHtmlForShowAll($foreignData);
$output = '<form class="ajax" '
. 'id="browse_foreign_form" name="browse_foreign_from" '
. 'action="browse_foreigners.php" method="post">'
. '<fieldset>'
. Url::getHiddenInputs($db, $table)
. '<input type="hidden" name="field" value="' . htmlspecialchars($field)
. '" />'
. '<input type="hidden" name="fieldkey" value="'
. (isset($fieldkey) ? htmlspecialchars($fieldkey) : '') . '" />';
if (isset($_REQUEST['rownumber'])) {
$output .= '<input type="hidden" name="rownumber" value="'
. htmlspecialchars($_REQUEST['rownumber']) . '" />';
}
$filter_value = (isset($_REQUEST['foreign_filter'])
? htmlspecialchars($_REQUEST['foreign_filter'])
: '');
$output .= '<span class="formelement">'
. '<label for="input_foreign_filter">' . __('Search:') . '</label>'
. '<input type="text" name="foreign_filter" '
. 'id="input_foreign_filter" '
. 'value="' . $filter_value . '" data-old="' . $filter_value . '" '
. '/>'
. '<input type="submit" name="submit_foreign_filter" value="'
. __('Go') . '" />'
. '</span>'
. '<span class="formelement">' . $gotopage . '</span>'
. '<span class="formelement">' . $showall . '</span>'
. '</fieldset>'
. '</form>';
$output .= '<table width="100%" id="browse_foreign_table">';
if (!is_array($foreignData['disp_row'])) {
$output .= '</tbody>'
. '</table>';
return $output;
}
$header = '<tr>
<th>' . __('Keyname') . '</th>
<th>' . __('Description') . '</th>
<td width="20%"></td>
<th>' . __('Description') . '</th>
<th>' . __('Keyname') . '</th>
</tr>';
$output .= '<thead>' . $header . '</thead>' . "\n"
. '<tfoot>' . $header . '</tfoot>' . "\n"
. '<tbody>' . "\n";
$descriptions = array();
$keys = array();
foreach ($foreignData['disp_row'] as $relrow) {
if ($foreignData['foreign_display'] != false) {
$descriptions[] = $relrow[$foreignData['foreign_display']];
} else {
$descriptions[] = '';
}
$keys[] = $relrow[$foreignData['foreign_field']];
}
asort($keys);
$horizontal_count = 0;
$indexByDescription = 0;
foreach ($keys as $indexByKeyname => $value) {
list(
$html,
$horizontal_count,
$indexByDescription
) = PMA_getHtmlForOneKey(
$horizontal_count, $header, $keys, $indexByKeyname,
$descriptions, $indexByDescription, $current_value
);
$output .= $html;
}
$output .= '</tbody>'
. '</table>';
return $output;
}
/**
* Get the description (possibly truncated) and the title
*
* @param string $description the key name's description
*
* @return array the new description and title
*/
function PMA_getDescriptionAndTitle($description)
{
$limitChars = $GLOBALS['cfg']['LimitChars'];
if (mb_strlen($description) <= $limitChars) {
$description = htmlspecialchars(
$description
);
$descriptionTitle = '';
} else {
$descriptionTitle = htmlspecialchars(
$description
);
$description = htmlspecialchars(
mb_substr(
$description, 0, $limitChars
)
. '...'
);
}
return array($description, $descriptionTitle);
}
/**
* Function to get html for each column element
*
* @param string $cssClass class="nowrap" or ''
* @param bool $isSelected whether current equals form's value
* @param string $keyname current key
* @param string $description current value
* @param string $title current title
*
* @return string
*/
function PMA_getHtmlForColumnElement($cssClass, $isSelected, $keyname,
$description, $title
) {
$keyname = htmlspecialchars($keyname);
$output = '<td';
if (! empty($cssClass)) {
$output .= ' ' . $cssClass;
}
$output .= '>'
. ($isSelected ? '<strong>' : '')
. '<a class="foreign_value" data-key="' . $keyname . '" '
. 'href="#" title="' . __('Use this value')
. ($title != ''
? ': ' . $title
: '')
. '">';
if ($cssClass !== '') {
$output .= $keyname;
} else {
$output .= $description;
}
$output .= '</a>' . ($isSelected ? '</strong>' : '') . '</td>';
return $output;
}
/**
* Function to get html for show all case
*
* @param array $foreignData foreign data
*
* @return string
*/
function PMA_getHtmlForShowAll($foreignData)
{
$showall = '';
if (is_array($foreignData['disp_row'])) {
if ($GLOBALS['cfg']['ShowAll']
&& ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows'])
) {
$showall = '<input type="submit" id="foreign_showAll" '
. 'name="foreign_showAll" '
. 'value="' . __('Show all') . '" />';
}
}
return $showall;
}
/**
* Function to get html for the goto page option
*
* @param array $foreignData foreign data
*
* @return string
*/
function PMA_getHtmlForGotoPage($foreignData)
{
$gotopage = '';
isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : $pos = 0;
if (!is_array($foreignData['disp_row'])) {
return $gotopage;
}
$session_max_rows = $GLOBALS['cfg']['MaxRows'];
$pageNow = @floor($pos / $session_max_rows) + 1;
$nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows);
if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) {
$gotopage = PhpMyAdmin\Util::pageselector(
'pos',
$session_max_rows,
$pageNow,
$nbTotalPage,
200,
5,
5,
20,
10,
__('Page number:')
);
}
return $gotopage;
}
/**
* Function to get foreign limit
*
* @param string $foreign_showAll foreign navigation
*
* @return string
*/
function PMA_getForeignLimit($foreign_showAll)
{
if (isset($foreign_showAll) && $foreign_showAll == __('Show all')) {
return null;
}
isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : $pos = 0;
return 'LIMIT ' . $pos . ', ' . intval($GLOBALS['cfg']['MaxRows']) . ' ';
}

View File

@ -0,0 +1,352 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Contains functions used by browse_foreigners.php
*
* @package PhpMyAdmin
*/
namespace PhpMyAdmin;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
/**
* PhpMyAdmin\BrowseForeigners class
*
* @package PhpMyAdmin
*/
class BrowseForeigners
{
/**
* Function to get html for one relational key
*
* @param integer $horizontal_count the current horizontal count
* @param string $header table header
* @param array $keys all the keys
* @param integer $indexByKeyname index by keyname
* @param array $descriptions descriptions
* @param integer $indexByDescription index by description
* @param string $current_value current value on the edit form
*
* @return string $html the generated html
*/
public static function getHtmlForOneKey($horizontal_count, $header, $keys,
$indexByKeyname, $descriptions, $indexByDescription, $current_value
) {
$horizontal_count++;
$output = '';
// whether the key name corresponds to the selected value in the form
$rightKeynameIsSelected = false;
$leftKeynameIsSelected = false;
if ($GLOBALS['cfg']['RepeatCells'] > 0
&& $horizontal_count > $GLOBALS['cfg']['RepeatCells']
) {
$output .= $header;
$horizontal_count = 0;
}
// key names and descriptions for the left section,
// sorted by key names
$leftKeyname = $keys[$indexByKeyname];
list(
$leftDescription,
$leftDescriptionTitle
) = self::getDescriptionAndTitle($descriptions[$indexByKeyname]);
// key names and descriptions for the right section,
// sorted by descriptions
$rightKeyname = $keys[$indexByDescription];
list(
$rightDescription,
$rightDescriptionTitle
) = self::getDescriptionAndTitle($descriptions[$indexByDescription]);
$indexByDescription++;
if (! empty($current_value)) {
$rightKeynameIsSelected = $rightKeyname == $current_value;
$leftKeynameIsSelected = $leftKeyname == $current_value;
}
$output .= '<tr class="noclick">';
$output .= self::getHtmlForColumnElement(
'class="nowrap"', $leftKeynameIsSelected,
$leftKeyname, $leftDescription,
$leftDescriptionTitle
);
$output .= self::getHtmlForColumnElement(
'', $leftKeynameIsSelected, $leftKeyname,
$leftDescription, $leftDescriptionTitle
);
$output .= '<td width="20%">'
. '<img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png" alt=""'
. ' width="1" height="1" /></td>';
$output .= self::getHtmlForColumnElement(
'', $rightKeynameIsSelected, $rightKeyname,
$rightDescription, $rightDescriptionTitle
);
$output .= self::getHtmlForColumnElement(
'class="nowrap"', $rightKeynameIsSelected,
$rightKeyname, $rightDescription,
$rightDescriptionTitle
);
$output .= '</tr>';
return array($output, $horizontal_count, $indexByDescription);
}
/**
* Function to get html for relational field selection
*
* @param string $db current database
* @param string $table current table
* @param string $field field
* @param array $foreignData foreign column data
* @param string $fieldkey field key
* @param string $current_value current columns's value
*
* @return string
*/
public static function getHtmlForRelationalFieldSelection($db, $table, $field, $foreignData,
$fieldkey, $current_value
) {
$gotopage = self::getHtmlForGotoPage($foreignData);
$showall = self::getHtmlForShowAll($foreignData);
$output = '<form class="ajax" '
. 'id="browse_foreign_form" name="browse_foreign_from" '
. 'action="browse_foreigners.php" method="post">'
. '<fieldset>'
. Url::getHiddenInputs($db, $table)
. '<input type="hidden" name="field" value="' . htmlspecialchars($field)
. '" />'
. '<input type="hidden" name="fieldkey" value="'
. (isset($fieldkey) ? htmlspecialchars($fieldkey) : '') . '" />';
if (isset($_REQUEST['rownumber'])) {
$output .= '<input type="hidden" name="rownumber" value="'
. htmlspecialchars($_REQUEST['rownumber']) . '" />';
}
$filter_value = (isset($_REQUEST['foreign_filter'])
? htmlspecialchars($_REQUEST['foreign_filter'])
: '');
$output .= '<span class="formelement">'
. '<label for="input_foreign_filter">' . __('Search:') . '</label>'
. '<input type="text" name="foreign_filter" '
. 'id="input_foreign_filter" '
. 'value="' . $filter_value . '" data-old="' . $filter_value . '" '
. '/>'
. '<input type="submit" name="submit_foreign_filter" value="'
. __('Go') . '" />'
. '</span>'
. '<span class="formelement">' . $gotopage . '</span>'
. '<span class="formelement">' . $showall . '</span>'
. '</fieldset>'
. '</form>';
$output .= '<table width="100%" id="browse_foreign_table">';
if (!is_array($foreignData['disp_row'])) {
$output .= '</tbody>'
. '</table>';
return $output;
}
$header = '<tr>
<th>' . __('Keyname') . '</th>
<th>' . __('Description') . '</th>
<td width="20%"></td>
<th>' . __('Description') . '</th>
<th>' . __('Keyname') . '</th>
</tr>';
$output .= '<thead>' . $header . '</thead>' . "\n"
. '<tfoot>' . $header . '</tfoot>' . "\n"
. '<tbody>' . "\n";
$descriptions = array();
$keys = array();
foreach ($foreignData['disp_row'] as $relrow) {
if ($foreignData['foreign_display'] != false) {
$descriptions[] = $relrow[$foreignData['foreign_display']];
} else {
$descriptions[] = '';
}
$keys[] = $relrow[$foreignData['foreign_field']];
}
asort($keys);
$horizontal_count = 0;
$indexByDescription = 0;
foreach ($keys as $indexByKeyname => $value) {
list(
$html,
$horizontal_count,
$indexByDescription
) = self::getHtmlForOneKey(
$horizontal_count, $header, $keys, $indexByKeyname,
$descriptions, $indexByDescription, $current_value
);
$output .= $html;
}
$output .= '</tbody>'
. '</table>';
return $output;
}
/**
* Get the description (possibly truncated) and the title
*
* @param string $description the key name's description
*
* @return array the new description and title
*/
public static function getDescriptionAndTitle($description)
{
$limitChars = $GLOBALS['cfg']['LimitChars'];
if (mb_strlen($description) <= $limitChars) {
$description = htmlspecialchars(
$description
);
$descriptionTitle = '';
} else {
$descriptionTitle = htmlspecialchars(
$description
);
$description = htmlspecialchars(
mb_substr(
$description, 0, $limitChars
)
. '...'
);
}
return array($description, $descriptionTitle);
}
/**
* Function to get html for each column element
*
* @param string $cssClass class="nowrap" or ''
* @param bool $isSelected whether current equals form's value
* @param string $keyname current key
* @param string $description current value
* @param string $title current title
*
* @return string
*/
public static function getHtmlForColumnElement($cssClass, $isSelected, $keyname,
$description, $title
) {
$keyname = htmlspecialchars($keyname);
$output = '<td';
if (! empty($cssClass)) {
$output .= ' ' . $cssClass;
}
$output .= '>'
. ($isSelected ? '<strong>' : '')
. '<a class="foreign_value" data-key="' . $keyname . '" '
. 'href="#" title="' . __('Use this value')
. ($title != ''
? ': ' . $title
: '')
. '">';
if ($cssClass !== '') {
$output .= $keyname;
} else {
$output .= $description;
}
$output .= '</a>' . ($isSelected ? '</strong>' : '') . '</td>';
return $output;
}
/**
* Function to get html for show all case
*
* @param array $foreignData foreign data
*
* @return string
*/
public static function getHtmlForShowAll($foreignData)
{
$showall = '';
if (is_array($foreignData['disp_row'])) {
if ($GLOBALS['cfg']['ShowAll']
&& ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows'])
) {
$showall = '<input type="submit" id="foreign_showAll" '
. 'name="foreign_showAll" '
. 'value="' . __('Show all') . '" />';
}
}
return $showall;
}
/**
* Function to get html for the goto page option
*
* @param array $foreignData foreign data
*
* @return string
*/
public static function getHtmlForGotoPage($foreignData)
{
$gotopage = '';
isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : $pos = 0;
if (!is_array($foreignData['disp_row'])) {
return $gotopage;
}
$session_max_rows = $GLOBALS['cfg']['MaxRows'];
$pageNow = @floor($pos / $session_max_rows) + 1;
$nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows);
if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) {
$gotopage = Util::pageselector(
'pos',
$session_max_rows,
$pageNow,
$nbTotalPage,
200,
5,
5,
20,
10,
__('Page number:')
);
}
return $gotopage;
}
/**
* Function to get foreign limit
*
* @param string $foreign_showAll foreign navigation
*
* @return string
*/
public static function getForeignLimit($foreign_showAll)
{
if (isset($foreign_showAll) && $foreign_showAll == __('Show all')) {
return null;
}
isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : $pos = 0;
return 'LIMIT ' . $pos . ', ' . intval($GLOBALS['cfg']['MaxRows']) . ' ';
}
}

View File

@ -1,22 +1,20 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Tests for libraries/browse_foreigners.lib.php
* Tests for PhpMyAdmin\BrowseForeigners
*
* @package PhpMyAdmin-test
*/
namespace PhpMyAdmin\Tests;
/*
* Include to test.
*/
require_once 'libraries/browse_foreigners.lib.php';
use PhpMyAdmin\BrowseForeigners;
/**
* Tests for libraries/browse_foreigners.lib.php
* Tests for PhpMyAdmin\BrowseForeigners
*
* @package PhpMyAdmin-test
*/
class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
class BrowseForeignersTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup for test cases
@ -29,43 +27,43 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_getForeignLimit
* Test for BrowseForeigners::getForeignLimit
*
* @return void
*/
function testGetForeignLimit()
{
$this->assertNull(
PMA_getForeignLimit('Show all')
BrowseForeigners::getForeignLimit('Show all')
);
$this->assertEquals(
'LIMIT 0, 25 ',
PMA_getForeignLimit(null)
BrowseForeigners::getForeignLimit(null)
);
$_REQUEST['pos'] = 10;
$this->assertEquals(
'LIMIT 10, 25 ',
PMA_getForeignLimit(null)
BrowseForeigners::getForeignLimit(null)
);
$GLOBALS['cfg']['MaxRows'] = 50;
$this->assertEquals(
'LIMIT 10, 50 ',
PMA_getForeignLimit(null)
BrowseForeigners::getForeignLimit(null)
);
$this->assertEquals(
'LIMIT 10, 50 ',
PMA_getForeignLimit('xyz')
BrowseForeigners::getForeignLimit('xyz')
);
}
/**
* Test for PMA_getHtmlForShowAll
* Test for BrowseForeigners::getHtmlForShowAll
*
* @return void
*/
@ -73,7 +71,7 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
{
$this->assertEquals(
'',
PMA_getHtmlForShowAll(null)
BrowseForeigners::getHtmlForShowAll(null)
);
$foreignData = array();
@ -82,7 +80,7 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
$this->assertEquals(
'',
PMA_getHtmlForShowAll($foreignData)
BrowseForeigners::getHtmlForShowAll($foreignData)
);
$GLOBALS['cfg']['ShowAll'] = true;
@ -90,7 +88,7 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
$this->assertEquals(
'',
PMA_getHtmlForShowAll($foreignData)
BrowseForeigners::getHtmlForShowAll($foreignData)
);
$foreignData['the_total'] = 30;
@ -99,12 +97,12 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
'<input type="submit" id="foreign_showAll" '
. 'name="foreign_showAll" '
. 'value="' . 'Show all' . '" />',
PMA_getHtmlForShowAll($foreignData)
BrowseForeigners::getHtmlForShowAll($foreignData)
);
}
/**
* Test for PMA_getHtmlForGotoPage
* Test for BrowseForeigners::getHtmlForGotoPage
*
* @return void
*/
@ -112,7 +110,7 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
{
$this->assertEquals(
'',
PMA_getHtmlForGotoPage(null)
BrowseForeigners::getHtmlForGotoPage(null)
);
$_REQUEST['pos'] = 15;
@ -122,11 +120,11 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
$this->assertEquals(
'',
PMA_getHtmlForGotoPage($foreignData)
BrowseForeigners::getHtmlForGotoPage($foreignData)
);
$foreignData['the_total'] = 30;
$result = PMA_getHtmlForGotoPage($foreignData);
$result = BrowseForeigners::getHtmlForGotoPage($foreignData);
$this->assertStringStartsWith(
'Page number:',
@ -156,7 +154,7 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_getHtmlForColumnElement
* Test for BrowseForeigners::getHtmlForColumnElement
*
* @return void
*/
@ -167,7 +165,7 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
$keyname = '';
$description = 'foo';
$title = '';
$result = PMA_getHtmlForColumnElement(
$result = BrowseForeigners::getHtmlForColumnElement(
$cssClass, $isSelected, $keyname,
$description, $title
);
@ -187,7 +185,7 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
$isSelected = true;
$keyname = 'bar';
$title = 'foo';
$result = PMA_getHtmlForColumnElement(
$result = BrowseForeigners::getHtmlForColumnElement(
$cssClass, $isSelected, $keyname,
$description, $title
);
@ -210,7 +208,7 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_getDescriptionAndTitle
* Test for BrowseForeigners::getDescriptionAndTitle
*
* @return void
*/
@ -221,19 +219,19 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
$this->assertEquals(
array('foobar&lt;baz', ''),
PMA_getDescriptionAndTitle($desc)
BrowseForeigners::getDescriptionAndTitle($desc)
);
$GLOBALS['cfg']['LimitChars'] = 5;
$this->assertEquals(
array('fooba...', 'foobar&lt;baz'),
PMA_getDescriptionAndTitle($desc)
BrowseForeigners::getDescriptionAndTitle($desc)
);
}
/**
* Test for PMA_getHtmlForRelationalFieldSelection
* Test for BrowseForeigners::getHtmlForRelationalFieldSelection
*
* @return void
*/
@ -248,7 +246,7 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
$current_value = '';
$_REQUEST['rownumber'] = 1;
$_REQUEST['foreign_filter'] = '5';
$result = PMA_getHtmlForRelationalFieldSelection(
$result = BrowseForeigners::getHtmlForRelationalFieldSelection(
$db, $table, $field, $foreignData, $fieldkey, $current_value
);
@ -315,7 +313,7 @@ class PMA_BrowseForeignersTest extends PHPUnit_Framework_TestCase
$foreignData['disp_row'] = array();
$foreignData['the_total'] = 5;
$GLOBALS['cfg']['ShowAll'] = false;
$result = PMA_getHtmlForRelationalFieldSelection(
$result = BrowseForeigners::getHtmlForRelationalFieldSelection(
$db, $table, $field, $foreignData, $fieldkey, $current_value
);