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' ) ); } 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