diff --git a/test/classes/PMA_Table_test.php b/test/classes/PMA_Table_test.php index 34b47a6da8..be631aefb6 100644 --- a/test/classes/PMA_Table_test.php +++ b/test/classes/PMA_Table_test.php @@ -187,6 +187,16 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValueMap($fetchResult)); + $dbi->expects($this->any())->method('fetchValue') + ->will( + $this->returnValue( + "CREATE TABLE `PMA`.`PMA_BookMark_2` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `username` text NOT NULL + )" + ) + ); + $databases = array(); $database_name = 'PMA'; $databases[$database_name]['SCHEMA_TABLES'] = 1; @@ -456,6 +466,17 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase array('type'=>'DATA_TYPE'), $show_create_table[0]['create_table_fields']['COLUMN_NAME'] ); + //not a view + $show_create_table = PMA_Table::analyzeStructure('PMA', 'PMA_BookMark_2'); + $this->assertEquals( + array('type'=>'INT', 'timestamp_not_null'=>false), + $show_create_table[0]['create_table_fields']['id'] + ); + $this->assertEquals( + array('type'=>'TEXT', 'timestamp_not_null'=>false), + $show_create_table[0]['create_table_fields']['username'] + ); + } /** @@ -776,6 +797,13 @@ class PMA_Table_Test extends PHPUnit_Framework_TestCase false, $is_define_property ); + + //getUiProp after removeUiProp + $is_define_property = $table->getUiProp($property); + $this->assertEquals( + false, + $is_define_property + ); } /** diff --git a/test/libraries/PMA_ip_allow_deny_test.php b/test/libraries/PMA_ip_allow_deny_test.php index 433728c6a1..682750ba4a 100644 --- a/test/libraries/PMA_ip_allow_deny_test.php +++ b/test/libraries/PMA_ip_allow_deny_test.php @@ -60,7 +60,18 @@ class PMA_Ip_Allow_Deny_Test extends PHPUnit_Framework_TestCase "101.0.0.25", PMA_getIp() ); - + + //proxy + $var_name = "direct_ip"; + $direct_ip = $_SERVER['REMOTE_ADDR']; + $GLOBALS['cfg']['TrustedProxies'][$direct_ip] = $var_name; + $_SERVER[$var_name] = "192.168.0.1"; + $this->assertEquals( + "192.168.0.1", + PMA_getIp() + ); + unset($_SERVER[$var_name]); + unset($GLOBALS['cfg']['TrustedProxies'][$direct_ip]); } /** diff --git a/test/libraries/PMA_relation_cleanup_test.php b/test/libraries/PMA_relation_cleanup_test.php index 88bb99edc0..f270a7af6e 100644 --- a/test/libraries/PMA_relation_cleanup_test.php +++ b/test/libraries/PMA_relation_cleanup_test.php @@ -86,10 +86,23 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase true, $cfgRelation['commwork'] ); + //validate PMA_getDbComments when commwork = true + $db_comments = PMA_getDbComments(); + $this->assertEquals( + array('db_name0' => 'comment0','db_name1' => 'comment1'), + $db_comments + ); + $this->assertEquals( true, $cfgRelation['displaywork'] ); + //validate PMA_getDisplayField when displaywork = true + $display_field = PMA_getDisplayField($db, $table); + $this->assertEquals( + 'PMA_display_field', + $display_field + ); $this->assertEquals( true, $cfgRelation['relwork'] @@ -308,10 +321,11 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase class DBI_PMA_Relation_Cleanup extends PMA_DatabaseInterface { var $index; + var $assocIndex; + var $totalNum; var $values = array(); var $indexs = array(); - /** * Constructor * @@ -319,6 +333,8 @@ class DBI_PMA_Relation_Cleanup extends PMA_DatabaseInterface public function __construct() { $this->index = 0; + $this->assocIndex = 0; + $this->totalNum = 2; $this->values = array( 'bookmark', 'relation', @@ -414,6 +430,7 @@ class DBI_PMA_Relation_Cleanup extends PMA_DatabaseInterface if (stripos($sql, "bookmark") !== false) { unset($GLOBALS [$this->indexs['bookmark']]); } + return true; } /** @@ -456,4 +473,62 @@ class DBI_PMA_Relation_Cleanup extends PMA_DatabaseInterface { return true; } + + /** + * returns only the first row from the result + * + * + * $sql = 'SELECT * FROM `user` WHERE `id` = 123'; + * $user = $GLOBALS['dbi']->fetchSingleRow($sql); + * // produces + * // $user = array('id' => 123, 'name' => 'John Doe') + * + * + * @param string|mysql_result $result query or mysql result + * @param string $type NUM|ASSOC|BOTH + * returned array should either numeric + * associativ or booth + * @param resource $link mysql link + * + * @return array|boolean first row from result + * or false if result is empty + */ + public function fetchSingleRow($result, $type = 'ASSOC', $link = null) + { + return array( + 'display_field' => "PMA_display_field" + ); + } + + /** + * returns array of rows with associative keys from $result + * + * @param object $result result set identifier + * + * @return array + */ + public function fetchAssoc($result) + { + if ($this->assocIndex < $this->totalNum) { + $assocResult['db_name'] = "db_name" . $this->assocIndex; + $assocResult['comment'] = "comment" . $this->assocIndex; + $this->assocIndex++; + return $assocResult; + } + + $this->assocIndex = 0; + return false; + } + + /** + * returns the number of rows returned by last query + * + * @param object $result result set identifier + * + * @return string|int + */ + public function numRows($result) + { + return $this->totalNum; + } } diff --git a/test/libraries/PMA_relation_test.php b/test/libraries/PMA_relation_test.php index e301222c35..a383195f1a 100644 --- a/test/libraries/PMA_relation_test.php +++ b/test/libraries/PMA_relation_test.php @@ -167,8 +167,7 @@ class PMA_Relation_Test extends PHPUnit_Framework_TestCase * @return void */ public function testPMA_getDisplayField() - { - + { $db = 'information_schema'; $table = 'CHARACTER_SETS'; $this->assertEquals(