From c0ae72cc08af29d6c28f0975d0a000687a22965a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 Jan 2013 15:08:25 +0100 Subject: [PATCH 1/5] Use include in function --- test/classes/PMA_DisplayResults_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/classes/PMA_DisplayResults_test.php b/test/classes/PMA_DisplayResults_test.php index 948add1f9e..73ee2b4145 100644 --- a/test/classes/PMA_DisplayResults_test.php +++ b/test/classes/PMA_DisplayResults_test.php @@ -44,7 +44,7 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase $GLOBALS['lang'] = 'en'; $GLOBALS['server'] = 0; $GLOBALS['text_dir'] = 'ltr'; - require_once 'libraries/Response.class.php'; + include_once 'libraries/Response.class.php'; } /** @@ -78,8 +78,8 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase /** * Test for setting display mode * - * @param string $the_disp_mode the synthetic value for display_mode (see a - * few lines above for explanations) + * @param string $the_disp_mode the synthetic value for display_mode (see + * a few lines above for explanations) * @param integer $the_total the total number of rows returned by the SQL * query without any programmatically appended * LIMIT clause From b7cdf5aeea487f2dc3cb53001fb3f6acaf8366d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 Jan 2013 15:12:47 +0100 Subject: [PATCH 2/5] Merge identical testcases --- test/classes/PMA_DisplayResults_test.php | 111 ++--------------------- 1 file changed, 6 insertions(+), 105 deletions(-) diff --git a/test/classes/PMA_DisplayResults_test.php b/test/classes/PMA_DisplayResults_test.php index 73ee2b4145..4af5418023 100644 --- a/test/classes/PMA_DisplayResults_test.php +++ b/test/classes/PMA_DisplayResults_test.php @@ -554,11 +554,11 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase } /** - * Provide data for testGetOperationLinksForVerticleTableCase1 + * Provide data for testGetOperationLinksForVerticleTable * * @return array parameters and output */ - public function dataProviderForTestGetOperationLinksForVerticleTableCase1() + public function dataProviderForTestGetOperationLinksForVerticleTable() { return array( array( @@ -566,132 +566,33 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase ' ' - ) - ); - } - - /** - * Test for _getOperationLinksForVerticleTable - case 1 - * - * @param string $operation edit/copy/delete - * @param string $output output of _getOperationLinksForVerticleTable - * - * @return void - * - * @dataProvider dataProviderForTestGetOperationLinksForVerticleTableCase1 - */ - public function testGetOperationLinksForVerticleTableCase1( - $operation, $output - ) { - $vertical_display = array( - 'row_delete' => array(), - 'textbtn' => '\n \n \n', - 'edit' => array(), - 'copy' => array( - '\nCopy Copy\n\nCopy Copy\n array( - '\n\n\nCopy Copy\n\nCopy Copy\n ' - ) - ); - } - - /** - * Test for _getOperationLinksForVerticleTable - case 2 - * - * @param string $operation edit/copy/delete - * @param string $output output of _getOperationLinksForVerticleTable - * - * @return void - * - * @dataProvider dataProviderForTestGetOperationLinksForVerticleTableCase2 - */ - public function testGetOperationLinksForVerticleTableCase2( - $operation, $output - ) { - $vertical_display = array( - 'row_delete' => array(), - 'textbtn' => '\n \n \n', - 'edit' => array(), - 'copy' => array( - '\nCopy Copy\n\nCopy Copy\n array( - '\n\n\n\n Delete Delete
DELETE FROM `data`.`new` WHERE `new`.`id` = 1
' - ) - ); - } - - /** - * Test for _getCheckboxAndLinks - case 1 - * - * @param string $position the position of the checkbox and links - * @param string $del_url delete url - * @param array $is_display array with explicit indexes for all the - * display elements - * @param string $row_no row number - * @param string $where_clause where clause - * @param string $where_clause_html url encoded where clause - * @param array $condition_array array of conditions in the where clause - * @param string $del_query delete query - * @param string $id_suffix suffix for the id - * @param string $edit_url edit url - * @param string $copy_url copy url - * @param string $class css classes for the td elements - * @param string $edit_str text for the edit link - * @param string $copy_str text for the copy link - * @param string $del_str text for the delete link - * @param string $js_conf text for the JS confirmation - * @param string $output output of _getCheckboxAndLinks - * - * @return void - * - * @dataProvider dataProviderForGetCheckboxAndLinksCase1 - */ - public function testGetCheckboxAndLinksCase1( - $position, $del_url, $is_display, $row_no, $where_clause, - $where_clause_html, $condition_array, $del_query, $id_suffix, $edit_url, - $copy_url, $class, $edit_str, $copy_str, $del_str, $js_conf, $output - ) { - $this->assertEquals( - $output, - $this->_callPrivateFunction( - '_getCheckboxAndLinks', - array( - $position, $del_url, $is_display, $row_no, $where_clause, - $where_clause_html, $condition_array, $del_query, - $id_suffix, $edit_url, $copy_url, $class, $edit_str, - $copy_str, $del_str, $js_conf - ) - ) - ); - } - - /** - * Data provider for testGetCheckboxAndLinksCase2 - * - * @return array parameters and output - */ - public function dataProviderForGetCheckboxAndLinksCase2() - { - return array( + ), array( PMA_DisplayResults::POSITION_RIGHT, 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3Dnew%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure.php%26token%3Dae4c6d18375f446dfa068420c1f6a4e8&token=ae4c6d18375f446dfa068420c1f6a4e8', @@ -1090,63 +1034,7 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase
Edit Edit ' - ) - ); - } - - /** - * Test for _getCheckboxAndLinks - case 2 - * - * @param string $position the position of the checkbox and links - * @param string $del_url delete url - * @param array $is_display array with explicit indexes for all the - * display elements - * @param string $row_no row number - * @param string $where_clause where clause - * @param string $where_clause_html url encoded where clause - * @param array $condition_array array of conditions in the where clause - * @param string $del_query delete query - * @param string $id_suffix suffix for the id - * @param string $edit_url edit url - * @param string $copy_url copy url - * @param string $class css classes for the td elements - * @param string $edit_str text for the edit link - * @param string $copy_str text for the copy link - * @param string $del_str text for the delete link - * @param string $js_conf text for the JS confirmation - * @param string $output output of _getCheckboxAndLinks - * - * @return void - * - * @dataProvider dataProviderForGetCheckboxAndLinksCase2 - */ - public function testGetCheckboxAndLinksCase2( - $position, $del_url, $is_display, $row_no, $where_clause, - $where_clause_html, $condition_array, $del_query, $id_suffix, $edit_url, - $copy_url, $class, $edit_str, $copy_str, $del_str, $js_conf, $output - ) { - $this->assertEquals( - $output, - $this->_callPrivateFunction( - '_getCheckboxAndLinks', - array( - $position, $del_url, $is_display, $row_no, $where_clause, - $where_clause_html, $condition_array, $del_query, - $id_suffix, $edit_url, $copy_url, $class, $edit_str, - $copy_str, $del_str, $js_conf - ) - ) - ); - } - - /** - * Data provider for testGetCheckboxAndLinksCase3 - * - * @return array parameters and output - */ - public function dataProviderForGetCheckboxAndLinksCase3() - { - return array( + ), array( PMA_DisplayResults::POSITION_NONE, 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show=The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3Dnew%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_structure.php%26token%3Dae4c6d18375f446dfa068420c1f6a4e8&token=ae4c6d18375f446dfa068420c1f6a4e8', @@ -1176,12 +1064,12 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase 'Delete Delete', 'DELETE FROM `data`.`new` WHERE `new`.`id` = 1', ' ' - ) + ), ); } /** - * Test for _getCheckboxAndLinks - case 3 + * Test for _getCheckboxAndLinks * * @param string $position the position of the checkbox and links * @param string $del_url delete url @@ -1204,9 +1092,9 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase * * @return void * - * @dataProvider dataProviderForGetCheckboxAndLinksCase3 + * @dataProvider dataProviderForGetCheckboxAndLinks */ - public function testGetCheckboxAndLinksCase3( + public function testGetCheckboxAndLinks( $position, $del_url, $is_display, $row_no, $where_clause, $where_clause_html, $condition_array, $del_query, $id_suffix, $edit_url, $copy_url, $class, $edit_str, $copy_str, $del_str, $js_conf, $output From af1e8598459ee69a4008dba0dd973e363470c90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 11 Jan 2013 15:18:50 +0100 Subject: [PATCH 5/5] Use mock values instead of mock html --- test/classes/PMA_DisplayResults_test.php | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/test/classes/PMA_DisplayResults_test.php b/test/classes/PMA_DisplayResults_test.php index fee022c195..657836056c 100644 --- a/test/classes/PMA_DisplayResults_test.php +++ b/test/classes/PMA_DisplayResults_test.php @@ -569,15 +569,11 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase ), array( 'copy', - ' -\nCopy Copy\n\nCopy Copy\n -' + "\nCOPY1COPY2\n" ), array( 'delete', - ' -\n\n\nDELETE1DELETE2\n" ), ); } @@ -599,14 +595,8 @@ class PMA_DisplayResults_Test extends PHPUnit_Framework_TestCase 'row_delete' => array(), 'textbtn' => '\n \n \n', 'edit' => array(), - 'copy' => array( - '\nCopy Copy\n\nCopy Copy\n array( - '\n\n