[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_3_6-9308-g388327d

Michal Čihař nijel at users.sourceforge.net
Mon Aug 30 15:25:46 CEST 2010


The branch, master has been updated
       via  388327d642714ff42e3dd7eb3cdc1c9b24efea2d (commit)
       via  b65e19a8b12428948c641672206c54e51a550268 (commit)
       via  e6bd28ea880bfa7b3b941efcb6b4bb54f12f9227 (commit)
       via  20800942f340465c6c4e3abaa69a00ed997224e2 (commit)
       via  8860f834665582f71e3b4612825a794fdcc10581 (commit)
       via  7f7bdf12bfd936f130355aab2ee44912f3dfaeb3 (commit)
       via  7ab207384a6d6bef8fd18b1fca65c3a7ec003eb9 (commit)
      from  42f04d4a7ece376c57d3c7a717e24bbcc6621425 (commit)


- Log -----------------------------------------------------------------
commit 388327d642714ff42e3dd7eb3cdc1c9b24efea2d
Author: Michal Čihař <mcihar at novell.com>
Date:   Mon Aug 30 15:24:07 2010 +0200

    Debug code was migrated to testcase.

commit b65e19a8b12428948c641672206c54e51a550268
Author: Michal Čihař <mcihar at novell.com>
Date:   Mon Aug 30 15:22:58 2010 +0200

    Fix another wrong count.

commit e6bd28ea880bfa7b3b941efcb6b4bb54f12f9227
Author: Michal Čihař <mcihar at novell.com>
Date:   Mon Aug 30 15:22:49 2010 +0200

    Test counts as well.

commit 20800942f340465c6c4e3abaa69a00ed997224e2
Author: Michal Čihař <mcihar at novell.com>
Date:   Mon Aug 30 15:20:09 2010 +0200

    Revert "Avoid precalculating counts."
    
    This reverts commit 42f04d4a7ece376c57d3c7a717e24bbcc6621425.
    
    We will stick with precalculated ones and check it in testcase.

commit 8860f834665582f71e3b4612825a794fdcc10581
Author: Michal Čihař <mcihar at novell.com>
Date:   Mon Aug 30 15:19:44 2010 +0200

    READS should be before READ_*.

commit 7f7bdf12bfd936f130355aab2ee44912f3dfaeb3
Author: Michal Čihař <mcihar at novell.com>
Date:   Mon Aug 30 15:19:03 2010 +0200

    Avoid duplicate NOW in keywords.

commit 7ab207384a6d6bef8fd18b1fca65c3a7ec003eb9
Author: Michal Čihař <mcihar at novell.com>
Date:   Mon Aug 30 15:18:30 2010 +0200

    Add testcase for validity of SQL parser data.

-----------------------------------------------------------------------

Summary of changes:
 libraries/sqlparser.data.php      |   49 ++++-----------------------
 test/AllTests.php                 |    1 +
 test/PMA_SQL_parser_data_test.php |   68 +++++++++++++++++++++++++++++++++++++
 3 files changed, 76 insertions(+), 42 deletions(-)
 create mode 100644 test/PMA_SQL_parser_data_test.php

diff --git a/libraries/sqlparser.data.php b/libraries/sqlparser.data.php
index 8f0c140..dffd6b1 100644
--- a/libraries/sqlparser.data.php
+++ b/libraries/sqlparser.data.php
@@ -17,7 +17,7 @@
  * (It's slower to have PHP do the count).
  *
  * It's easier to use only uppercase for proper sorting. In case of
- * doubt, use the DEBUG code after this function's definition.
+ * doubt, use the test case to verify.
  *
  * @package phpMyAdmin
  */
@@ -210,7 +210,6 @@ $PMA_SQPdata_function_name = array (
     'MOD',
     'MONTH',
     'MONTHNAME',
-    'NOW',
     'MPOINTFROMTEXT',           // MPointFromText()
     'MPOINTFROMWKB',            // MPointFromWKB()
     'MPOLYFROMTEXT',            // MPolyFromText()
@@ -338,18 +337,7 @@ $PMA_SQPdata_function_name = array (
  *
  * @global integer MySQL attributes count
  */
-$PMA_SQPdata_function_name_cnt = count($PMA_SQPdata_function_name);
-
-/*
- * DEBUG
-$test_PMA_SQPdata_function_name = $PMA_SQPdata_function_name;
-sort($PMA_SQPdata_function_name);
-if ($PMA_SQPdata_function_name != $test_PMA_SQPdata_function_name) {
-    echo 'sort properly like this<pre>';
-    print_r($PMA_SQPdata_function_name);
-    echo '</pre>';
-}
- */
+$PMA_SQPdata_function_name_cnt = 298;
 
 /**
  * @global array MySQL attributes
@@ -391,7 +379,7 @@ $PMA_SQPdata_column_attrib = array (
  *
  * @global integer MySQL attributes count
  */
-$PMA_SQPdata_column_attrib_cnt = count($PMA_SQPdata_column_attrib);
+$PMA_SQPdata_column_attrib_cnt = 30;
 
 /**
  * words that are reserved by MySQL and may not be used as identifiers without quotes
@@ -698,24 +686,7 @@ $PMA_SQPdata_reserved_word = array (
  *
  * @global integer MySQL reserved words count
  */
-$PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word);
-/**
- * The previous array must be sorted so that the binary search work.
- * Sometimes a word is not added in the correct order, so
- * this debugging code shows the problem. The same should be
- * done for all arrays.
- */
-/*
-$original = $PMA_SQPdata_reserved_word;
-sort($PMA_SQPdata_reserved_word);
-$difference = array_diff_assoc($original, $PMA_SQPdata_reserved_word);
-echo '<pre>';
-print_r($difference);
-echo '</pre>';
-echo '<pre>';
-print_r($PMA_SQPdata_reserved_word);
-echo '</pre>';
-*/
+$PMA_SQPdata_reserved_word_cnt = 289;
 
 /**
  * words forbidden to be used as column or table name wihtout quotes
@@ -1047,9 +1018,9 @@ $PMA_SQPdata_forbidden_word = array (
     'RAID_TYPE',
     'RANGE',                // 5.1
     'READ',
+    'READS',
     'READ_ONLY',            // 5.1
     'READ_WRITE',           // 5.1
-    'READS',
     'REAL',
     'RECOVER',
     'REDUNDANT',
@@ -1213,7 +1184,7 @@ $PMA_SQPdata_forbidden_word = array (
  *
  * @global integer MySQL forbidden words count
  */
-$PMA_SQPdata_forbidden_word_cnt = count($PMA_SQPdata_forbidden_word);
+$PMA_SQPdata_forbidden_word_cnt = 483;
 
 /**
  * the MySQL column/data types
@@ -1284,12 +1255,6 @@ $PMA_SQPdata_column_type = array (
  *
  * @global integer MySQL column types count
  */
-$PMA_SQPdata_column_type_cnt = count($PMA_SQPdata_column_type);
+$PMA_SQPdata_column_type_cnt = 54;
 
-/*
- * check counts
-foreach ($GLOBALS as $n => $a) {
-    echo is_array($a) ? $n . ': ' . count($a) . '<br />' : '';
-}
- */
 ?>
diff --git a/test/AllTests.php b/test/AllTests.php
index b77f3ec..338f83d 100644
--- a/test/AllTests.php
+++ b/test/AllTests.php
@@ -51,6 +51,7 @@ require_once './test/PMA_foreignKeySupported_test.php';
 require_once './test/PMA_headerLocation_test.php';
 require_once './test/PMA_Message_test.php';
 require_once './test/PMA_whichCrlf_test.php';
+require_once './test/PMA_SQL_parser_data_test.php';
 
 class AllTests
 {
diff --git a/test/PMA_SQL_parser_data_test.php b/test/PMA_SQL_parser_data_test.php
new file mode 100644
index 0000000..45fa07c
--- /dev/null
+++ b/test/PMA_SQL_parser_data_test.php
@@ -0,0 +1,68 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * tests for correctness of SQL parser data
+ *
+ * @package phpMyAdmin-test
+ */
+
+/**
+ * Tests core.
+ */
+require_once 'PHPUnit/Framework.php';
+
+define('PHPMYADMIN', 1);
+
+/**
+ * Include to test.
+ */
+require_once './libraries/sqlparser.data.php';
+
+/**
+ * Test for sorting of the arrays
+ *
+ * @package phpMyAdmin-test
+ */
+class PMA_SQL_parser_data_test extends PHPUnit_Framework_TestCase
+{
+    private function assertSorted($array)
+    {
+        $copy = $array;
+        sort($copy);
+        $difference = array_diff_assoc($array, $copy);
+        $this->assertEquals($difference, array());
+    }
+
+    private function assertParserData($name)
+    {
+        $this->assertSorted($GLOBALS[$name]);
+        $this->assertEquals(count($GLOBALS[$name]), $GLOBALS[$name . '_cnt']);
+    }
+
+    public function testPMA_SQPdata_function_name()
+    {
+        $this->assertParserData('PMA_SQPdata_function_name');
+    }
+
+    public function testPMA_SQPdata_column_attrib()
+    {
+        $this->assertParserData('PMA_SQPdata_column_attrib');
+    }
+
+    public function testPMA_SQPdata_reserved_word()
+    {
+        $this->assertParserData('PMA_SQPdata_reserved_word');
+    }
+
+    public function testPMA_SQPdata_forbidden_word()
+    {
+        $this->assertParserData('PMA_SQPdata_forbidden_word');
+    }
+
+    public function testPMA_SQPdata_column_type()
+    {
+        $this->assertParserData('PMA_SQPdata_column_type');
+    }
+
+}
+?>


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list