From b130268c31c93fdc3fe8f234a0e2ce1a40d4bdec Mon Sep 17 00:00:00 2001 From: Yasitha Pandithawatta Date: Sun, 19 Aug 2012 13:17:18 +0530 Subject: [PATCH 1/2] Test class for zip_extension.lib.php --- test/libraries/PMA_zip_extension_test.php | 150 ++++++++++++++++++ .../{PMA_Zip_test.php => PMA_zip_test.php} | 2 +- 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 test/libraries/PMA_zip_extension_test.php rename test/libraries/{PMA_Zip_test.php => PMA_zip_test.php} (97%) diff --git a/test/libraries/PMA_zip_extension_test.php b/test/libraries/PMA_zip_extension_test.php new file mode 100644 index 0000000000..358c5bb57c --- /dev/null +++ b/test/libraries/PMA_zip_extension_test.php @@ -0,0 +1,150 @@ +assertEquals( + PMA_getZipContents($file, $specific_entry), + $output + ); + } + + /** + * Provider for testGetZipContents + */ + public function providerForTestGetZipContents(){ + return array( + array( + './test/test_data/test.zip', + null, + array( + 'error' => '', + 'data' => 'TEST FILE'. "\n" + ) + ), + array( + './test/test_data/test.zip', + 'test', + array( + 'error' => 'Error in ZIP archive: Could not find "test"', + 'data' => '' + ) + ) + ); + } + + /** + * @param string $file_regexp regular expression for the file name to match + * @param string $file zip archive + * @param $output + * + * @dataProvider providerForTestFindFileFromZipArchive + */ + public function testFindFileFromZipArchive($file_regexp, $file, $output){ + $this->assertEquals( + PMA_findFileFromZipArchive($file_regexp, $file), + $output + ); + } + + /** + * Provider for testFindFileFromZipArchive + */ + public function providerForTestFindFileFromZipArchive(){ + return array( + array( + '/test/', + './test/test_data/test.zip', + 'test.file' + ) + ); + } + + /** + * Test for PMA_getNoOfFilesInZip + */ + public function testGetNoOfFilesInZip(){ + $this->assertEquals( + PMA_getNoOfFilesInZip('./test/test_data/test.zip'), + 1 + ); + } + + /** + * Test for PMA_zipExtract + */ + public function testZipExtract(){ + $this->assertEquals( + PMA_zipExtract('./test/test_data/test.zip', './test/test_data/', 'wrongName'), + true + ); + } + + /** + * Test for PMA_getZipError + * + * @param $code error code + * @param $output + * + * @dataProvider providerForTestGetZipError + */ + public function testGetZipError($code, $output){ + $this->assertEquals( + PMA_getZipError($code), + $output + ); + } + + /** + * Provider for testGetZipError + */ + public function providerForTestGetZipError(){ + return array( + array( + 1, + 'Multi-disk zip archives not supported' + ), + array( + 5, + 'Read error' + ), + array( + 7, + 'CRC error' + ), + array( + 19, + 'Not a zip archive' + ), + array( + 21, + 'Zip archive inconsistent' + ), + array( + 404, + 404 + ) + ); + } +} + +?> diff --git a/test/libraries/PMA_Zip_test.php b/test/libraries/PMA_zip_test.php similarity index 97% rename from test/libraries/PMA_Zip_test.php rename to test/libraries/PMA_zip_test.php index 12f28a545b..263ec8598b 100644 --- a/test/libraries/PMA_Zip_test.php +++ b/test/libraries/PMA_zip_test.php @@ -11,7 +11,7 @@ require_once 'libraries/zip.lib.php'; -class PMA_Zip_test extends PHPUnit_Framework_TestCase +class PMA_zip_test extends PHPUnit_Framework_TestCase { /** * @access protected From 73e7c52ad272bc02bf33bf6f892c675fd79af878 Mon Sep 17 00:00:00 2001 From: Yasitha Pandithawatta Date: Sun, 19 Aug 2012 13:26:31 +0530 Subject: [PATCH 2/2] Fixed failing test cases of Display Results --- 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 e0e3be8426..29cc524881 100644 --- a/test/classes/PMA_DisplayResults_test.php +++ b/test/classes/PMA_DisplayResults_test.php @@ -1555,7 +1555,7 @@ class PMA_DisplayResults_test extends PHPUnit_Framework_TestCase 'routine_type' => 'FUNCTION' ), 'routine_name', - 'db_routines.php?item_name=circumference&db=data&execute_dialog=1&item_type=FUNCTION&lang=en&token=token' + 'db_routines.php?item_name=circumference&db=data&execute_dialog=1&item_type=FUNCTION&server=0&lang=en&token=token' ), array( 'information_schema', @@ -1567,7 +1567,7 @@ class PMA_DisplayResults_test extends PHPUnit_Framework_TestCase 'routine_type' => 'PROCEDURE' ), 'routine_name', - 'db_routines.php?item_name=area&db=data&execute_routine=1&item_type=PROCEDURE&lang=en&token=token' + 'db_routines.php?item_name=area&db=data&execute_routine=1&item_type=PROCEDURE&server=0&lang=en&token=token' ), array( 'information_schema', @@ -1578,7 +1578,7 @@ class PMA_DisplayResults_test extends PHPUnit_Framework_TestCase 'table_name' => 'CHARACTER_SETS' ), 'column_name', - 'index.php?sql_query=SELECT+%60CHARACTER_SET_NAME%60+FROM+%60information_schema%60.%60CHARACTER_SETS%60&db=information_schema&test_name=value&lang=en&token=token' + 'index.php?sql_query=SELECT+%60CHARACTER_SET_NAME%60+FROM+%60information_schema%60.%60CHARACTER_SETS%60&db=information_schema&test_name=value&server=0&lang=en&token=token' ) ); }