From 86f43b063bce46d56f2685899eef050b272e9523 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 24 Jun 2015 13:34:53 +0530 Subject: [PATCH] New tests for insert/edit form changes based on column privileges Signed-off-by: Madhura Jayaratne --- test/libraries/PMA_insert_edit_test.php | 104 ++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/test/libraries/PMA_insert_edit_test.php b/test/libraries/PMA_insert_edit_test.php index 5acf111464..3b669fe273 100644 --- a/test/libraries/PMA_insert_edit_test.php +++ b/test/libraries/PMA_insert_edit_test.php @@ -2980,5 +2980,109 @@ class PMA_InsertEditTest extends PHPUnit_Framework_TestCase $actual ); } + + /** + * Test for PMA_getHtmlForInsertEditRow based on the column privilges + * + * @return void + */ + public function testGetHtmlForInsertEditRowBasedOnColumnPrivileges() + { + $o_rows = 0; + $tabindex = 0; + $GLOBALS['plugin_scripts'] = array(); + $GLOBALS['cfg']['LongtextDoubleTextarea'] = true; + $GLOBALS['cfg']['CharEditing'] = true; + + // edit + $table_columns = array( + array( + 'Field' => 'foo', + 'Type' => 'longtext', + 'Null' => 'Yes', + 'pma_type' => 'longtext', + 'True_Type' => 'longtext', + 'Privileges' => 'select,insert,update,references', + ), + array( + 'Field' => 'bar', + 'Type' => 'longtext', + 'Null' => 'Yes', + 'pma_type' => 'longtext', + 'True_Type' => 'longtext', + 'Privileges' => 'select,insert,references', + ) + ); + $actual = PMA_getHtmlForInsertEditRow( + array(), $table_columns, array(), false, array(), '', '', + '', false, array(), $o_rows, $tabindex, 1, false, 0, + array(), 0, 0, 'table', 'db', 0, array(), 0, '', + array(), array('wc') + ); + $this->assertContains( + 'foo', + $actual + ); + $this->assertNotContains( + 'bar', + $actual + ); + + // insert + $table_columns = array( + array( + 'Field' => 'foo', + 'Type' => 'longtext', + 'Null' => 'Yes', + 'pma_type' => 'longtext', + 'True_Type' => 'longtext', + 'Privileges' => 'select,insert,update,references', + ), + array( + 'Field' => 'bar', + 'Type' => 'longtext', + 'Null' => 'Yes', + 'pma_type' => 'longtext', + 'True_Type' => 'longtext', + 'Privileges' => 'select,update,references', + ) + ); + $actual = PMA_getHtmlForInsertEditRow( + array(), $table_columns, array(), false, array(), '', '', + '', true, array(), $o_rows, $tabindex, 1, false, 0, + array(), 0, 0, 'table', 'db', 0, array(), 0, '', + array(), array('wc') + ); + $this->assertContains( + 'foo', + $actual + ); + $this->assertNotContains( + 'bar', + $actual + ); + + // Drizzle + $table_columns = array( + array( + 'Field' => 'foo', + 'Type' => 'longtext', + 'Null' => 'Yes', + 'pma_type' => 'longtext', + 'True_Type' => 'longtext', + 'Privileges' => null, + ) + ); + $actual = PMA_getHtmlForInsertEditRow( + array(), $table_columns, array(), false, array(), '', '', + '', false, array(), $o_rows, $tabindex, 1, false, 0, + array(), 0, 0, 'table', 'db', 0, array(), 0, '', + array(), array('wc') + ); + $this->assertContains( + 'foo', + $actual + ); + } } ?>