From 2df16b3187c06272e2b82e63e59ba91e36ceb091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 10 Aug 2011 09:48:42 +0200 Subject: [PATCH 1/4] Start testcases for PMA_File class --- test/libraries/PMA_File_test.php | 41 +++++++++++++++++++++++++++++++ test/test_data/test.bz2 | Bin 0 -> 49 bytes test/test_data/test.file | 1 + test/test_data/test.gz | Bin 0 -> 40 bytes test/test_data/test.zip | Bin 0 -> 178 bytes 5 files changed, 42 insertions(+) create mode 100644 test/libraries/PMA_File_test.php create mode 100644 test/test_data/test.bz2 create mode 100644 test/test_data/test.file create mode 100644 test/test_data/test.gz create mode 100644 test/test_data/test.zip diff --git a/test/libraries/PMA_File_test.php b/test/libraries/PMA_File_test.php new file mode 100644 index 0000000000..ecd7f2bd58 --- /dev/null +++ b/test/libraries/PMA_File_test.php @@ -0,0 +1,41 @@ + +assertEquals('application/gzip', $arr->getCompression()); + } + + public function testZip() + { + $arr = new PMA_File('./test/test_data/test.zip'); + $this->assertEquals('application/zip', $arr->getCompression()); + } + + public function testBzip() + { + $arr = new PMA_File('./test/test_data/test.bz2'); + $this->assertEquals('application/bzip2', $arr->getCompression()); + } +} +?> diff --git a/test/test_data/test.bz2 b/test/test_data/test.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..971a07874553dae911f29f61b37891b288e9fc35 GIT binary patch literal 49 zcmZ>Y%CIzaj8qGb+_m#$5d#CuH3kL&2L@&p9tH&lC1$A>17*+7V{&>=x(XI5mKINX F0svCQ4*mcD literal 0 HcmV?d00001 diff --git a/test/test_data/test.file b/test/test_data/test.file new file mode 100644 index 0000000000..fafd745150 --- /dev/null +++ b/test/test_data/test.file @@ -0,0 +1 @@ +TEST FILE diff --git a/test/test_data/test.gz b/test/test_data/test.gz new file mode 100644 index 0000000000000000000000000000000000000000..6d25ca8c3a70efc7dbf220d7339479c91733bdcc GIT binary patch literal 40 vcmb2|=HL)Bck*LkE=ese(M!wBNoC+JT=w!Sq+fz~Ak4`i!%&i1T%wnjnUfkC!pXoaX71z%!lf1542&$( z)fpIAQh*9WT!TXt+&q0;xdOZyndF#p87Bc$%fP@0#7i1MEF{BOA%>$F9N^8$22#if Mg#JL<7sO!z0Nc78Qvd(} literal 0 HcmV?d00001 From f1e2897da00c035c6ec9c725cac8817f719f9606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 10 Aug 2011 10:04:17 +0200 Subject: [PATCH 2/4] Return true on succsess --- libraries/File.class.php | 2 +- test/libraries/PMA_File_test.php | 40 +++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/libraries/File.class.php b/libraries/File.class.php index 5a6d59f834..332c8ea2ac 100644 --- a/libraries/File.class.php +++ b/libraries/File.class.php @@ -643,7 +643,7 @@ class PMA_File break; } - + return true; } function getCharset() diff --git a/test/libraries/PMA_File_test.php b/test/libraries/PMA_File_test.php index ecd7f2bd58..b43135cc4e 100644 --- a/test/libraries/PMA_File_test.php +++ b/test/libraries/PMA_File_test.php @@ -17,25 +17,43 @@ class PMA_File_test extends PHPUnit_Framework_TestCase { public function setup() { - $GLOBALS['cfg']['Server']['only_db'] = array('single\\_db'); + $GLOBALS['cfg']['BZipDump'] = true; + $GLOBALS['cfg']['GZipDump'] = true; + $GLOBALS['cfg']['ZipDump'] = true; + $GLOBALS['charset_conversion'] = false; } - public function testGzip() + /** + * @dataProvider compressedFiles + */ + public function testMIME($file, $mime) { - $arr = new PMA_File('./test/test_data/test.gz'); - $this->assertEquals('application/gzip', $arr->getCompression()); + $arr = new PMA_File($file); + $this->assertEquals($mime, $arr->getCompression()); } - public function testZip() + /** + * @dataProvider compressedFiles + */ + public function testContent($file, $mime) { - $arr = new PMA_File('./test/test_data/test.zip'); - $this->assertEquals('application/zip', $arr->getCompression()); + $orig = file_get_contents('./test/test_data/test.file'); + $file = new PMA_File($file); + $file->setDecompressContent(true); + $this->assertTrue($file->open()); + if ($mime == 'application/zip') { + $this->assertEquals($orig, $file->content_uncompressed); + } else { + $this->assertEquals($orig, $file->getNextChunk()); + } } - public function testBzip() - { - $arr = new PMA_File('./test/test_data/test.bz2'); - $this->assertEquals('application/bzip2', $arr->getCompression()); + public function compressedFiles() { + return array( + array('./test/test_data/test.gz', 'application/gzip'), + array('./test/test_data/test.bz2', 'application/bzip2'), + array('./test/test_data/test.zip', 'application/zip'), + ); } } ?> From 096d06eda002b6f47a455e4d144538355ce66274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 10 Aug 2011 10:06:54 +0200 Subject: [PATCH 3/4] Move class tests to test/classes --- test/{libraries => classes}/PMA_File_test.php | 0 test/{libraries => classes}/PMA_List_Database_test.php | 0 test/{libraries => classes}/PMA_Theme_Manager_test.php | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename test/{libraries => classes}/PMA_File_test.php (100%) rename test/{libraries => classes}/PMA_List_Database_test.php (100%) rename test/{libraries => classes}/PMA_Theme_Manager_test.php (100%) diff --git a/test/libraries/PMA_File_test.php b/test/classes/PMA_File_test.php similarity index 100% rename from test/libraries/PMA_File_test.php rename to test/classes/PMA_File_test.php diff --git a/test/libraries/PMA_List_Database_test.php b/test/classes/PMA_List_Database_test.php similarity index 100% rename from test/libraries/PMA_List_Database_test.php rename to test/classes/PMA_List_Database_test.php diff --git a/test/libraries/PMA_Theme_Manager_test.php b/test/classes/PMA_Theme_Manager_test.php similarity index 100% rename from test/libraries/PMA_Theme_Manager_test.php rename to test/classes/PMA_Theme_Manager_test.php From f9e2218d9622f7184b4b1a42b96618f082da76c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 10 Aug 2011 10:09:02 +0200 Subject: [PATCH 4/4] Fix doc --- test/classes/PMA_List_Database_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/classes/PMA_List_Database_test.php b/test/classes/PMA_List_Database_test.php index 00691e818a..6eb3e7e5cc 100644 --- a/test/classes/PMA_List_Database_test.php +++ b/test/classes/PMA_List_Database_test.php @@ -1,7 +1,7 @@