Skip to content

Commit

Permalink
Various coding style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Sep 4, 2012
1 parent ff16e8b commit dff1f6a
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 97 deletions.
70 changes: 48 additions & 22 deletions test/classes/PMA_DBQbe_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ private function _callProtectedFunction($name, $params)
/**
* Test for getCommonFunctions
*/
public function testGetCommonFunctions(){
public function testGetCommonFunctions()
{
$this->assertInstanceOf(
'PMA_CommonFunctions',
$this->object->getCommonFunctions()
Expand All @@ -108,7 +109,8 @@ public function testGetCommonFunctions(){
/**
* Test for _getSortSelectCell
*/
public function testGetSortSelectCell(){
public function testGetSortSelectCell()
{
$this->assertEquals(
'<td class="center"><select style="width: 12ex" name="criteriaSort[1]" size="1"><option value="">&nbsp;</option><option value="ASC">Ascending</option><option value="DESC">Descending</option></select></td>',
$this->_callProtectedFunction(
Expand All @@ -121,7 +123,8 @@ public function testGetSortSelectCell(){
/**
* Test for _getSortRow
*/
public function testGetSortRow(){
public function testGetSortRow()
{
$this->assertEquals(
'<tr class="even noclick"><th>Sort:</th><td class="center"><select style="width: 12ex" name="criteriaSort[0]" size="1"><option value="">&nbsp;</option><option value="ASC">Ascending</option><option value="DESC">Descending</option></select></td><td class="center"><select style="width: 12ex" name="criteriaSort[1]" size="1"><option value="">&nbsp;</option><option value="ASC">Ascending</option><option value="DESC">Descending</option></select></td><td class="center"><select style="width: 12ex" name="criteriaSort[2]" size="1"><option value="">&nbsp;</option><option value="ASC">Ascending</option><option value="DESC">Descending</option></select></td></tr>',
$this->_callProtectedFunction(
Expand All @@ -134,7 +137,8 @@ public function testGetSortRow(){
/**
* Test for _getShowRow
*/
public function testGetShowRow(){
public function testGetShowRow()
{
$this->assertEquals(
'<tr class="odd noclick"><th>Show:</th><td class="center"><input type="checkbox" name="criteriaShow[0]" /></td><td class="center"><input type="checkbox" name="criteriaShow[1]" /></td><td class="center"><input type="checkbox" name="criteriaShow[2]" /></td></tr>',
$this->_callProtectedFunction(
Expand All @@ -147,7 +151,8 @@ public function testGetShowRow(){
/**
* Test for _getCriteriaInputboxRow
*/
public function testGetCriteriaInputboxRow(){
public function testGetCriteriaInputboxRow()
{
$this->assertEquals(
'<tr class="even noclick"><th>Criteria:</th><td class="center"><input type="hidden" name="prev_criteria[0]" value="" /><input type="text" name="criteria[0]" value="" class="textfield" style="width: 12ex" size="20" /></td><td class="center"><input type="hidden" name="prev_criteria[1]" value="" /><input type="text" name="criteria[1]" value="" class="textfield" style="width: 12ex" size="20" /></td><td class="center"><input type="hidden" name="prev_criteria[2]" value="" /><input type="text" name="criteria[2]" value="" class="textfield" style="width: 12ex" size="20" /></td></tr>',
$this->_callProtectedFunction(
Expand All @@ -160,7 +165,8 @@ public function testGetCriteriaInputboxRow(){
/**
* Test for _getFootersOptions
*/
public function testGetFootersOptions(){
public function testGetFootersOptions()
{
$this->assertEquals(
'<div class="floatleft">Add/Delete criteria rows:<select size="1" name="criteriaRowAdd"><option value="-3">-3</option><option value="-2">-2</option><option value="-1">-1</option><option value="0" selected="selected">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option></select></div>',
$this->_callProtectedFunction(
Expand All @@ -173,7 +179,8 @@ public function testGetFootersOptions(){
/**
* Test for _getTableFooters
*/
public function testGetTableFooters(){
public function testGetTableFooters()
{
$this->assertEquals(
'<fieldset class="tblFooters"><div class="floatleft">Add/Delete criteria rows:<select size="1" name="criteriaRowAdd"><option value="-3">-3</option><option value="-2">-2</option><option value="-1">-1</option><option value="0" selected="selected">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option></select></div><div class="floatleft">Add/Delete columns:<select size="1" name="criteriaColumnAdd"><option value="-3">-3</option><option value="-2">-2</option><option value="-1">-1</option><option value="0" selected="selected">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option></select></div><div class="floatleft"><input type="submit" name="modify"value="Update Query" /></div></fieldset>',
$this->_callProtectedFunction(
Expand All @@ -186,7 +193,8 @@ public function testGetTableFooters(){
/**
* Test for _getAndOrColCell
*/
public function testGetAndOrColCell(){
public function testGetAndOrColCell()
{
$this->assertEquals(
'<td class="center"><strong>Or:</strong><input type="radio" name="criteriaAndOrColumn[1]" value="or" />&nbsp;&nbsp;<strong>And:</strong><input type="radio" name="criteriaAndOrColumn[1]" value="and" /><br />Ins<input type="checkbox" name="criteriaColumnInsert[1]" />&nbsp;&nbsp;Del<input type="checkbox" name="criteriaColumnDelete[1]" /></td>',
$this->_callProtectedFunction(
Expand All @@ -199,7 +207,8 @@ public function testGetAndOrColCell(){
/**
* Test for _getModifyColumnsRow
*/
public function testGetModifyColumnsRow(){
public function testGetModifyColumnsRow()
{
$this->assertEquals(
'<tr class="even noclick"><th>Modify:</th><td class="center"><strong>Or:</strong><input type="radio" name="criteriaAndOrColumn[0]" value="or" />&nbsp;&nbsp;<strong>And:</strong><input type="radio" name="criteriaAndOrColumn[0]" value="and" checked="checked" /><br />Ins<input type="checkbox" name="criteriaColumnInsert[0]" />&nbsp;&nbsp;Del<input type="checkbox" name="criteriaColumnDelete[0]" /></td><td class="center"><strong>Or:</strong><input type="radio" name="criteriaAndOrColumn[1]" value="or" />&nbsp;&nbsp;<strong>And:</strong><input type="radio" name="criteriaAndOrColumn[1]" value="and" checked="checked" /><br />Ins<input type="checkbox" name="criteriaColumnInsert[1]" />&nbsp;&nbsp;Del<input type="checkbox" name="criteriaColumnDelete[1]" /></td><td class="center"><strong>Or:</strong><input type="radio" name="criteriaAndOrColumn[2]" value="or" />&nbsp;&nbsp;<strong>And:</strong><input type="radio" name="criteriaAndOrColumn[2]" value="and" checked="checked" /><br />Ins<input type="checkbox" name="criteriaColumnInsert[2]" />&nbsp;&nbsp;Del<input type="checkbox" name="criteriaColumnDelete[2]" /></td></tr>',
$this->_callProtectedFunction(
Expand All @@ -212,7 +221,8 @@ public function testGetModifyColumnsRow(){
/**
* Test for _getInsDelAndOrCell
*/
public function testGetInsDelAndOrCell(){
public function testGetInsDelAndOrCell()
{
$GLOBALS['cell_align_right'] = 'cellAlign';
$this->assertEquals(
'<td class="cellAlign nowrap"><!-- Row controls --><table class="nospacing nopadding"><tr><td class="cellAlign nowrap"><small>Ins:</small><input type="checkbox" name="criteriaRowInsert[3]" /></td><td class="cellAlign"><strong>And:</strong></td><td><input type="radio" name="criteriaAndOrRow[3]" value="and" /></td></tr><tr><td class="cellAlign nowrap"><small>Del:</small><input type="checkbox" name="criteriaRowDelete[3]" /></td><td class="cellAlign"><strong>Or:</strong></td><td><input type="radio" name="criteriaAndOrRow[3]" value="or" checked="checked" /></td></tr></table></td>',
Expand All @@ -226,7 +236,8 @@ public function testGetInsDelAndOrCell(){
/**
* Test for _getInputboxRow
*/
public function testGetInputboxRow(){
public function testGetInputboxRow()
{
$this->assertEquals(
'<td class="center"><input type="text" name="Or2[0]" value="" class="textfield" style="width: 12ex" size="20" /></td><td class="center"><input type="text" name="Or2[1]" value="" class="textfield" style="width: 12ex" size="20" /></td><td class="center"><input type="text" name="Or2[2]" value="" class="textfield" style="width: 12ex" size="20" /></td>',
$this->_callProtectedFunction(
Expand All @@ -239,7 +250,8 @@ public function testGetInputboxRow(){
/**
* Test for _getInsDelAndOrCriteriaRows
*/
public function testGetInsDelAndOrCriteriaRows(){
public function testGetInsDelAndOrCriteriaRows()
{
$this->assertEquals(
'<tr class="odd noclick"><td class="cellAlign nowrap"><!-- Row controls --><table class="nospacing nopadding"><tr><td class="cellAlign nowrap"><small>Ins:</small><input type="checkbox" name="criteriaRowInsert[0]" /></td><td class="cellAlign"><strong>And:</strong></td><td><input type="radio" name="criteriaAndOrRow[0]" value="and" /></td></tr><tr><td class="cellAlign nowrap"><small>Del:</small><input type="checkbox" name="criteriaRowDelete[0]" /></td><td class="cellAlign"><strong>Or:</strong></td><td><input type="radio" name="criteriaAndOrRow[0]" value="or" checked="checked" /></td></tr></table></td><td class="center"><input type="text" name="Or0[0]" value="" class="textfield" style="width: 12ex" size="20" /></td><td class="center"><input type="text" name="Or0[1]" value="" class="textfield" style="width: 12ex" size="20" /></td><td class="center"><input type="text" name="Or0[2]" value="" class="textfield" style="width: 12ex" size="20" /></td></tr>',
$this->_callProtectedFunction(
Expand All @@ -252,7 +264,8 @@ public function testGetInsDelAndOrCriteriaRows(){
/**
* Test for _getSelectClause
*/
public function testGetSelectClause(){
public function testGetSelectClause()
{
$this->assertEquals(
'',
$this->_callProtectedFunction(
Expand All @@ -265,7 +278,8 @@ public function testGetSelectClause(){
/**
* Test for _getWhereClause
*/
public function testGetWhereClause(){
public function testGetWhereClause()
{
$this->assertEquals(
'',
$this->_callProtectedFunction(
Expand All @@ -278,7 +292,8 @@ public function testGetWhereClause(){
/**
* Test for _getOrderByClause
*/
public function testGetOrderByClause(){
public function testGetOrderByClause()
{
$this->assertEquals(
'',
$this->_callProtectedFunction(
Expand All @@ -291,7 +306,8 @@ public function testGetOrderByClause(){
/**
* Test for _getIndexes
*/
public function testGetIndexes(){
public function testGetIndexes()
{
if (! function_exists('PMA_DBI_get_table_indexes')) {
function PMA_DBI_get_table_indexes()
{
Expand All @@ -317,7 +333,8 @@ function PMA_DBI_get_table_indexes()
/**
* Test for _getLeftJoinColumnCandidates
*/
public function test_getLeftJoinColumnCandidates(){
public function test_getLeftJoinColumnCandidates()
{
if (! function_exists('PMA_DBI_select_db')) {
function PMA_DBI_select_db()
{
Expand All @@ -342,7 +359,8 @@ function PMA_DBI_select_db()
/**
* Test for _getMasterTable
*/
public function test_getMasterTable(){
public function test_getMasterTable()
{
$this->assertEquals(
0,
$this->_callProtectedFunction(
Expand All @@ -360,8 +378,14 @@ public function test_getMasterTable(){
/**
* Test for _getWhereClauseTablesAndColumns
*/
public function test_getWhereClauseTablesAndColumns(){
$_POST['criteriaColumn'] = array('table1.id', 'table1.value', 'table1.name', 'table1.deleted');
public function test_getWhereClauseTablesAndColumns()
{
$_POST['criteriaColumn'] = array(
'table1.id',
'table1.value',
'table1.name',
'table1.deleted'
);
$this->assertEquals(
array(
'where_clause_tables' => array(),
Expand All @@ -377,7 +401,8 @@ public function test_getWhereClauseTablesAndColumns(){
/**
* Test for _getFromClause
*/
public function testGetFromClause(){
public function testGetFromClause()
{
$this->assertEquals(
'table1',
$this->_callProtectedFunction(
Expand All @@ -390,7 +415,8 @@ public function testGetFromClause(){
/**
* Test for _getSQLQuery
*/
public function test_getSQLQuery(){
public function test_getSQLQuery()
{
$this->assertEquals(
'FROM table1
',
Expand Down
27 changes: 19 additions & 8 deletions test/classes/PMA_DbSearch_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ function PMA_DBI_get_tables()
);
}
}
$this->object = $this->getMockForAbstractClass('PMA_DbSearch', array('pma'));
$this->object = $this->getMockForAbstractClass(
'PMA_DbSearch',
array('pma')
);
}

/**
Expand Down Expand Up @@ -75,7 +78,8 @@ private function _callProtectedFunction($name, $params)
/**
* Test for getCommonFunctions
*/
public function testGetCommonFunctions(){
public function testGetCommonFunctions()
{
$this->assertInstanceOf(
'PMA_CommonFunctions',
$this->object->getCommonFunctions()
Expand All @@ -85,7 +89,8 @@ public function testGetCommonFunctions(){
/**
* Test for _getSearchSqls
*/
public function testGetSearchSqls(){
public function testGetSearchSqls()
{

$GLOBALS['db'] = 'pma';
if (! function_exists('PMA_DBI_get_columns')) {
Expand Down Expand Up @@ -114,7 +119,8 @@ function PMA_DBI_get_columns()
/**
* Test for getSearchResults
*/
public function testGetSearchResults(){
public function testGetSearchResults()
{
$this->assertEquals(
'<br /><table class="data"><caption class="tblHeaders">Search results for "<i></i>" :</caption></table>',
$this->object->getSearchResults()
Expand All @@ -130,7 +136,9 @@ public function testGetSearchResults(){
*
* @dataProvider providerForTestGetResultsRow
*/
public function testGetResultsRow($each_table, $newsearchsqls, $odd_row, $output){
public function testGetResultsRow(
$each_table, $newsearchsqls, $odd_row, $output
){

if (! function_exists('PMA_DBI_fetch_value')) {
function PMA_DBI_fetch_value()
Expand All @@ -151,7 +159,8 @@ function PMA_DBI_fetch_value()
/**
* @return array provider for testGetResultsRow
*/
public function providerForTestGetResultsRow(){
public function providerForTestGetResultsRow()
{
return array(
array(
'table1',
Expand All @@ -171,7 +180,8 @@ public function providerForTestGetResultsRow(){
/**
* Test for getSelectionForm
*/
public function testGetSelectionForm(){
public function testGetSelectionForm()
{
$_SESSION[' PMA_token '] = 'token';
$_SESSION['PMA_Theme'] = new PMA_Theme();
$GLOBALS['pmaThemeImage'] = 'themes/dot.gif';
Expand All @@ -193,7 +203,8 @@ public function testGetSelectionForm(){
/**
* Test for _getResultDivs
*/
public function testGetResultDivs(){
public function testGetResultDivs()
{
$this->assertEquals(
'<!-- These two table-image and table-link elements display the table name in browse search results --><div id="table-info"><a class="item" id="table-link" ></a></div><div id="browse-results"><!-- this browse-results div is used to load the browse and delete results in the db search --></div><br class="clearfloat" /><div id="sqlqueryform"><!-- this sqlqueryform div is used to load the delete form in the db search --></div><!-- toggle query box link--><a id="togglequerybox"></a>',
$this->_callProtectedFunction(
Expand Down
5 changes: 4 additions & 1 deletion test/classes/PMA_Theme_Manager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public function testPerServerCookieName()
public function testHtmlSelectBox()
{
$tm = new PMA_Theme_Manager();
$this->assertContains('<option value="pmahomme" selected="selected">', $tm->getHtmlSelectBox());
$this->assertContains(
'<option value="pmahomme" selected="selected">',
$tm->getHtmlSelectBox()
);
}

/**
Expand Down
1 change: 1 addition & 0 deletions test/classes/gis/PMA_GIS_Linestring_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public function testPrepareRowAsPng($spatial, $label, $line_color,
$return = $this->object->prepareRowAsPng(
$spatial, $label, $line_color, $scale_data, $image
);
/* TODO: this never fails */
$this->assertTrue(true);
}

Expand Down
41 changes: 28 additions & 13 deletions test/classes/gis/PMA_GIS_Multilinestring_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,14 @@ public function providerForTestScaleRow()
*
*@dataProvider providerForPrepareRowAsPng
*/
public function testPrepareRowAsPng($spatial, $label, $line_color, $scale_data, $image, $output)
{
public function testPrepareRowAsPng(
$spatial, $label, $line_color, $scale_data, $image, $output
) {

$return = $this->object->prepareRowAsPng($spatial, $label, $line_color, $scale_data, $image);
$return = $this->object->prepareRowAsPng(
$spatial, $label, $line_color, $scale_data, $image
);
/* TODO: this never fails */
$this->assertTrue(true);
}

Expand Down Expand Up @@ -272,10 +276,13 @@ public function providerForPrepareRowAsPng(){
*
*@dataProvider providerForPrepareRowAsPdf
*/
public function testPrepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
{
public function testPrepareRowAsPdf(
$spatial, $label, $line_color, $scale_data, $pdf
) {

$return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf);
$return = $this->object->prepareRowAsPdf(
$spatial, $label, $line_color, $scale_data, $pdf
);
$this->assertInstanceOf('TCPDF', $return);
}

Expand Down Expand Up @@ -307,12 +314,14 @@ public function providerForPrepareRowAsPdf(){
*
*@dataProvider providerForPrepareRowAsSvg
*/
public function testPrepareRowAsSvg($spatial, $label, $line_color, $scale_data, $output)
{
public function testPrepareRowAsSvg(
$spatial, $label, $line_color, $scale_data, $output
) {

$string = $this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data);
$string = $this->object->prepareRowAsSvg(
$spatial, $label, $line_color, $scale_data
);
$this->assertEquals(1, preg_match($output, $string));
//$this->assertEquals($this->object->prepareRowAsSvg($spatial, $label, $line_color, $scale_data) , $output);
}

public function providerForPrepareRowAsSvg(){
Expand Down Expand Up @@ -344,10 +353,16 @@ public function providerForPrepareRowAsSvg(){
*
*@dataProvider providerForPrepareRowAsOl
*/
public function testPrepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data, $output)
{
public function testPrepareRowAsOl(
$spatial, $srid, $label, $line_color, $scale_data, $output
) {

$this->assertEquals($this->object->prepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data), $output);
$this->assertEquals(
$output,
$this->object->prepareRowAsOl(
$spatial, $srid, $label, $line_color, $scale_data
)
);
}

public function providerForPrepareRowAsOl(){
Expand Down
Loading

0 comments on commit dff1f6a

Please sign in to comment.