From d233182d3bde131387eed703c366788538bdfd91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 4 Sep 2012 15:07:38 +0200 Subject: [PATCH 1/5] Pass correct parameters to _getInsDelAndOrCell --- test/classes/PMA_DBQbe_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/classes/PMA_DBQbe_test.php b/test/classes/PMA_DBQbe_test.php index 5139837180..300f0beaae 100644 --- a/test/classes/PMA_DBQbe_test.php +++ b/test/classes/PMA_DBQbe_test.php @@ -212,10 +212,10 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase public function testGetInsDelAndOrCell(){ $GLOBALS['cell_align_right'] = 'cellAlign'; $this->assertEquals( - '
Ins:And:
Del:Or:
', + '
Ins:And:
Del:Or:
', $this->_callProtectedFunction( '_getInsDelAndOrCell', - array(3, 'checked') + array(3, array('and' => '', 'or' => ' checked="checked"')) ) ); } From ff9b0d088cae1c12f39de22b153c2dfbe12e74db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 4 Sep 2012 15:09:11 +0200 Subject: [PATCH 2/5] Pass correct parameters to _getFromClause --- test/classes/PMA_DBQbe_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/classes/PMA_DBQbe_test.php b/test/classes/PMA_DBQbe_test.php index 300f0beaae..32d6e14d6a 100644 --- a/test/classes/PMA_DBQbe_test.php +++ b/test/classes/PMA_DBQbe_test.php @@ -376,10 +376,10 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase */ public function testGetFromClause(){ $this->assertEquals( - '`table1`', + 'table1', $this->_callProtectedFunction( '_getFromClause', - array('relation') + array(array('relwork' => False)) ) ); } From 5ef6f6a98cc6fe5991faa75f1fcc2b4b17b8781c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 4 Sep 2012 15:09:50 +0200 Subject: [PATCH 3/5] Pass correct parameters to _getSQLQuery --- test/classes/PMA_DBQbe_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/classes/PMA_DBQbe_test.php b/test/classes/PMA_DBQbe_test.php index 32d6e14d6a..0e408b203d 100644 --- a/test/classes/PMA_DBQbe_test.php +++ b/test/classes/PMA_DBQbe_test.php @@ -389,11 +389,11 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase */ public function test_getSQLQuery(){ $this->assertEquals( - 'FROM `table1` + 'FROM table1 ', $this->_callProtectedFunction( '_getSQLQuery', - array('relation') + array(array('relwork' => False)) ) ); } From ff16e8bdd003a06ed8b4a69b97d84fe4d94ac5df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 4 Sep 2012 15:16:09 +0200 Subject: [PATCH 4/5] Use assertInstanceOf instead of manual testing --- test/classes/PMA_DBQbe_test.php | 5 ++++- test/classes/PMA_DbSearch_test.php | 5 ++++- test/classes/PMA_Theme_Manager_test.php | 5 ++++- test/classes/gis/PMA_GIS_Geometrycollection_test.php | 2 +- test/classes/gis/PMA_GIS_Linestring_test.php | 2 +- test/classes/gis/PMA_GIS_Multilinestring_test.php | 2 +- test/classes/gis/PMA_GIS_Multipoint_test.php | 2 +- test/classes/gis/PMA_GIS_Multipolygon_test.php | 2 +- test/classes/gis/PMA_GIS_Point_test.php | 2 +- test/classes/gis/PMA_GIS_Polygon_test.php | 2 +- 10 files changed, 19 insertions(+), 10 deletions(-) diff --git a/test/classes/PMA_DBQbe_test.php b/test/classes/PMA_DBQbe_test.php index 0e408b203d..6985cdc83b 100644 --- a/test/classes/PMA_DBQbe_test.php +++ b/test/classes/PMA_DBQbe_test.php @@ -99,7 +99,10 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase * Test for getCommonFunctions */ public function testGetCommonFunctions(){ - $this->assertTrue($this->object->getCommonFunctions() instanceof PMA_CommonFunctions); + $this->assertInstanceOf( + 'PMA_CommonFunctions', + $this->object->getCommonFunctions() + ); } /** diff --git a/test/classes/PMA_DbSearch_test.php b/test/classes/PMA_DbSearch_test.php index 4bcb52bd8e..1d3b0e4087 100644 --- a/test/classes/PMA_DbSearch_test.php +++ b/test/classes/PMA_DbSearch_test.php @@ -76,7 +76,10 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase * Test for getCommonFunctions */ public function testGetCommonFunctions(){ - $this->assertTrue($this->object->getCommonFunctions() instanceof PMA_CommonFunctions); + $this->assertInstanceOf( + 'PMA_CommonFunctions', + $this->object->getCommonFunctions() + ); } /** diff --git a/test/classes/PMA_Theme_Manager_test.php b/test/classes/PMA_Theme_Manager_test.php index 7e20d743cd..8b7c897ca3 100644 --- a/test/classes/PMA_Theme_Manager_test.php +++ b/test/classes/PMA_Theme_Manager_test.php @@ -101,7 +101,10 @@ class PMA_Theme_Manager_test extends PHPUnit_Framework_TestCase */ public function testGetFallBackTheme(){ $tm = new PMA_Theme_Manager(); - $this->assertTrue($tm->getFallBackTheme() instanceof PMA_Theme); + $this->assertInstanceOf( + 'PMA_theme', + $tm->getFallBackTheme() + ); } } diff --git a/test/classes/gis/PMA_GIS_Geometrycollection_test.php b/test/classes/gis/PMA_GIS_Geometrycollection_test.php index 0ea797bdeb..7b7e640fc9 100644 --- a/test/classes/gis/PMA_GIS_Geometrycollection_test.php +++ b/test/classes/gis/PMA_GIS_Geometrycollection_test.php @@ -236,7 +236,7 @@ class PMA_GIS_Geometrycollection_test extends PHPUnit_Framework_TestCase $return = $this->object->prepareRowAsPdf( $spatial, $label, $line_color, $scale_data, $pdf ); - $this->assertTrue($return instanceof TCPDF); + $this->assertInstanceOf('TCPDF', $return); } public function providerForPrepareRowAsPdf() diff --git a/test/classes/gis/PMA_GIS_Linestring_test.php b/test/classes/gis/PMA_GIS_Linestring_test.php index 6a12feaa85..eb2530df22 100644 --- a/test/classes/gis/PMA_GIS_Linestring_test.php +++ b/test/classes/gis/PMA_GIS_Linestring_test.php @@ -220,7 +220,7 @@ class PMA_GIS_LinestringTest extends PMA_GIS_GeomTest $return = $this->object->prepareRowAsPdf( $spatial, $label, $line_color, $scale_data, $pdf ); - $this->assertTrue($return instanceof TCPDF); + $this->assertInstanceOf('TCPDF', $return); } public function providerForPrepareRowAsPdf() diff --git a/test/classes/gis/PMA_GIS_Multilinestring_test.php b/test/classes/gis/PMA_GIS_Multilinestring_test.php index 7547d634ea..30e52a8343 100644 --- a/test/classes/gis/PMA_GIS_Multilinestring_test.php +++ b/test/classes/gis/PMA_GIS_Multilinestring_test.php @@ -276,7 +276,7 @@ class PMA_GIS_MultilinestringTest extends PMA_GIS_GeomTest { $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); - $this->assertTrue($return instanceof TCPDF); + $this->assertInstanceOf('TCPDF', $return); } public function providerForPrepareRowAsPdf(){ diff --git a/test/classes/gis/PMA_GIS_Multipoint_test.php b/test/classes/gis/PMA_GIS_Multipoint_test.php index eaff4559e2..5e94d24641 100644 --- a/test/classes/gis/PMA_GIS_Multipoint_test.php +++ b/test/classes/gis/PMA_GIS_Multipoint_test.php @@ -220,7 +220,7 @@ class PMA_GIS_MultipointTest extends PMA_GIS_GeomTest { $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); - $this->assertTrue($return instanceof TCPDF); + $this->assertInstanceOf('TCPDF', $return); } public function providerForPrepareRowAsPdf(){ diff --git a/test/classes/gis/PMA_GIS_Multipolygon_test.php b/test/classes/gis/PMA_GIS_Multipolygon_test.php index c62959a43e..821db4ce8a 100644 --- a/test/classes/gis/PMA_GIS_Multipolygon_test.php +++ b/test/classes/gis/PMA_GIS_Multipolygon_test.php @@ -314,7 +314,7 @@ class PMA_GIS_MultipolygonTest extends PMA_GIS_GeomTest { $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); - $this->assertTrue($return instanceof TCPDF); + $this->assertInstanceOf('TCPDF', $return); } public function providerForPrepareRowAsPdf(){ diff --git a/test/classes/gis/PMA_GIS_Point_test.php b/test/classes/gis/PMA_GIS_Point_test.php index 35908d7f35..f218640ab4 100644 --- a/test/classes/gis/PMA_GIS_Point_test.php +++ b/test/classes/gis/PMA_GIS_Point_test.php @@ -222,7 +222,7 @@ class PMA_GIS_PointTest extends PMA_GIS_GeomTest { $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); - $this->assertTrue($return instanceof TCPDF); + $this->assertInstanceOf('TCPDF', $return); } public function providerForPrepareRowAsPdf(){ diff --git a/test/classes/gis/PMA_GIS_Polygon_test.php b/test/classes/gis/PMA_GIS_Polygon_test.php index 1b852c8d71..1c15749269 100644 --- a/test/classes/gis/PMA_GIS_Polygon_test.php +++ b/test/classes/gis/PMA_GIS_Polygon_test.php @@ -402,7 +402,7 @@ class PMA_GIS_PolygonTest extends PMA_GIS_GeomTest { $return = $this->object->prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf); - $this->assertTrue($return instanceof TCPDF); + $this->assertInstanceOf('TCPDF', $return); } public function providerForPrepareRowAsPdf(){ From dff1f6afc3632c924c9be684bb4f24d1f0bc4eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 4 Sep 2012 15:28:21 +0200 Subject: [PATCH 5/5] Various coding style improvements --- test/classes/PMA_DBQbe_test.php | 70 +++++++++++++------ test/classes/PMA_DbSearch_test.php | 27 ++++--- test/classes/PMA_Theme_Manager_test.php | 5 +- test/classes/gis/PMA_GIS_Linestring_test.php | 1 + .../gis/PMA_GIS_Multilinestring_test.php | 41 +++++++---- test/classes/gis/PMA_GIS_Multipoint_test.php | 41 +++++++---- .../classes/gis/PMA_GIS_Multipolygon_test.php | 41 +++++++---- test/classes/gis/PMA_GIS_Point_test.php | 44 ++++++++---- test/classes/gis/PMA_GIS_Polygon_test.php | 41 +++++++---- 9 files changed, 215 insertions(+), 96 deletions(-) diff --git a/test/classes/PMA_DBQbe_test.php b/test/classes/PMA_DBQbe_test.php index 6985cdc83b..c96b9752e6 100644 --- a/test/classes/PMA_DBQbe_test.php +++ b/test/classes/PMA_DBQbe_test.php @@ -98,7 +98,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for getCommonFunctions */ - public function testGetCommonFunctions(){ + public function testGetCommonFunctions() + { $this->assertInstanceOf( 'PMA_CommonFunctions', $this->object->getCommonFunctions() @@ -108,7 +109,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getSortSelectCell */ - public function testGetSortSelectCell(){ + public function testGetSortSelectCell() + { $this->assertEquals( '', $this->_callProtectedFunction( @@ -121,7 +123,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getSortRow */ - public function testGetSortRow(){ + public function testGetSortRow() + { $this->assertEquals( 'Sort:', $this->_callProtectedFunction( @@ -134,7 +137,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getShowRow */ - public function testGetShowRow(){ + public function testGetShowRow() + { $this->assertEquals( 'Show:', $this->_callProtectedFunction( @@ -147,7 +151,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getCriteriaInputboxRow */ - public function testGetCriteriaInputboxRow(){ + public function testGetCriteriaInputboxRow() + { $this->assertEquals( 'Criteria:', $this->_callProtectedFunction( @@ -160,7 +165,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getFootersOptions */ - public function testGetFootersOptions(){ + public function testGetFootersOptions() + { $this->assertEquals( '
Add/Delete criteria rows:
', $this->_callProtectedFunction( @@ -173,7 +179,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getTableFooters */ - public function testGetTableFooters(){ + public function testGetTableFooters() + { $this->assertEquals( '
Add/Delete criteria rows:
Add/Delete columns:
', $this->_callProtectedFunction( @@ -186,7 +193,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getAndOrColCell */ - public function testGetAndOrColCell(){ + public function testGetAndOrColCell() + { $this->assertEquals( 'Or:  And:
Ins  Del', $this->_callProtectedFunction( @@ -199,7 +207,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getModifyColumnsRow */ - public function testGetModifyColumnsRow(){ + public function testGetModifyColumnsRow() + { $this->assertEquals( 'Modify:Or:  And:
Ins  DelOr:  And:
Ins  DelOr:  And:
Ins  Del', $this->_callProtectedFunction( @@ -212,7 +221,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getInsDelAndOrCell */ - public function testGetInsDelAndOrCell(){ + public function testGetInsDelAndOrCell() + { $GLOBALS['cell_align_right'] = 'cellAlign'; $this->assertEquals( '
Ins:And:
Del:Or:
', @@ -226,7 +236,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getInputboxRow */ - public function testGetInputboxRow(){ + public function testGetInputboxRow() + { $this->assertEquals( '', $this->_callProtectedFunction( @@ -239,7 +250,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getInsDelAndOrCriteriaRows */ - public function testGetInsDelAndOrCriteriaRows(){ + public function testGetInsDelAndOrCriteriaRows() + { $this->assertEquals( '
Ins:And:
Del:Or:
', $this->_callProtectedFunction( @@ -252,7 +264,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getSelectClause */ - public function testGetSelectClause(){ + public function testGetSelectClause() + { $this->assertEquals( '', $this->_callProtectedFunction( @@ -265,7 +278,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getWhereClause */ - public function testGetWhereClause(){ + public function testGetWhereClause() + { $this->assertEquals( '', $this->_callProtectedFunction( @@ -278,7 +292,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getOrderByClause */ - public function testGetOrderByClause(){ + public function testGetOrderByClause() + { $this->assertEquals( '', $this->_callProtectedFunction( @@ -291,7 +306,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getIndexes */ - public function testGetIndexes(){ + public function testGetIndexes() + { if (! function_exists('PMA_DBI_get_table_indexes')) { function PMA_DBI_get_table_indexes() { @@ -317,7 +333,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getLeftJoinColumnCandidates */ - public function test_getLeftJoinColumnCandidates(){ + public function test_getLeftJoinColumnCandidates() + { if (! function_exists('PMA_DBI_select_db')) { function PMA_DBI_select_db() { @@ -342,7 +359,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getMasterTable */ - public function test_getMasterTable(){ + public function test_getMasterTable() + { $this->assertEquals( 0, $this->_callProtectedFunction( @@ -360,8 +378,14 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * 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(), @@ -377,7 +401,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getFromClause */ - public function testGetFromClause(){ + public function testGetFromClause() + { $this->assertEquals( 'table1', $this->_callProtectedFunction( @@ -390,7 +415,8 @@ class PMA_DBQbe_test extends PHPUnit_Framework_TestCase /** * Test for _getSQLQuery */ - public function test_getSQLQuery(){ + public function test_getSQLQuery() + { $this->assertEquals( 'FROM table1 ', diff --git a/test/classes/PMA_DbSearch_test.php b/test/classes/PMA_DbSearch_test.php index 1d3b0e4087..e55ab196a8 100644 --- a/test/classes/PMA_DbSearch_test.php +++ b/test/classes/PMA_DbSearch_test.php @@ -41,7 +41,10 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase ); } } - $this->object = $this->getMockForAbstractClass('PMA_DbSearch', array('pma')); + $this->object = $this->getMockForAbstractClass( + 'PMA_DbSearch', + array('pma') + ); } /** @@ -75,7 +78,8 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase /** * Test for getCommonFunctions */ - public function testGetCommonFunctions(){ + public function testGetCommonFunctions() + { $this->assertInstanceOf( 'PMA_CommonFunctions', $this->object->getCommonFunctions() @@ -85,7 +89,8 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase /** * Test for _getSearchSqls */ - public function testGetSearchSqls(){ + public function testGetSearchSqls() + { $GLOBALS['db'] = 'pma'; if (! function_exists('PMA_DBI_get_columns')) { @@ -114,7 +119,8 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase /** * Test for getSearchResults */ - public function testGetSearchResults(){ + public function testGetSearchResults() + { $this->assertEquals( '
Search results for "" :
', $this->object->getSearchResults() @@ -130,7 +136,9 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase * * @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() @@ -151,7 +159,8 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase /** * @return array provider for testGetResultsRow */ - public function providerForTestGetResultsRow(){ + public function providerForTestGetResultsRow() + { return array( array( 'table1', @@ -171,7 +180,8 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase /** * Test for getSelectionForm */ - public function testGetSelectionForm(){ + public function testGetSelectionForm() + { $_SESSION[' PMA_token '] = 'token'; $_SESSION['PMA_Theme'] = new PMA_Theme(); $GLOBALS['pmaThemeImage'] = 'themes/dot.gif'; @@ -193,7 +203,8 @@ class PMA_DbSearch_test extends PHPUnit_Framework_TestCase /** * Test for _getResultDivs */ - public function testGetResultDivs(){ + public function testGetResultDivs() + { $this->assertEquals( '

', $this->_callProtectedFunction( diff --git a/test/classes/PMA_Theme_Manager_test.php b/test/classes/PMA_Theme_Manager_test.php index 8b7c897ca3..833ce22efa 100644 --- a/test/classes/PMA_Theme_Manager_test.php +++ b/test/classes/PMA_Theme_Manager_test.php @@ -48,7 +48,10 @@ class PMA_Theme_Manager_test extends PHPUnit_Framework_TestCase public function testHtmlSelectBox() { $tm = new PMA_Theme_Manager(); - $this->assertContains('