3 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * tests for PMA_File class
7 * @package phpMyAdmin-test
13 require_once 'libraries/common.lib.php';
14 require_once 'libraries/File.class.php';
16 class PMA_File_test
extends PHPUnit_Framework_TestCase
18 public function setup()
20 $GLOBALS['cfg']['BZipDump'] = true;
21 $GLOBALS['cfg']['GZipDump'] = true;
22 $GLOBALS['cfg']['ZipDump'] = true;
23 $GLOBALS['charset_conversion'] = false;
27 * @dataProvider compressedFiles
29 public function testMIME($file, $mime)
31 $arr = new PMA_File($file);
32 $this->assertEquals($mime, $arr->getCompression());
36 * @dataProvider compressedFiles
38 public function testContent($file, $mime)
40 $orig = file_get_contents('./test/test_data/test.file');
41 $file = new PMA_File($file);
42 $file->setDecompressContent(true);
43 $this->assertTrue($file->open());
44 if ($mime == 'application/zip') {
45 $this->assertEquals($orig, $file->content_uncompressed
);
47 $this->assertEquals($orig, $file->getNextChunk());
52 * @dataProvider compressedFiles
54 public function testBinaryContent($file, $mime)
56 $data = '0x' . bin2hex(file_get_contents($file));
57 $file = new PMA_File($file);
58 $this->assertEquals($data, $file->getContent());
61 public function compressedFiles() {
63 array('./test/test_data/test.gz', 'application/gzip'),
64 array('./test/test_data/test.bz2', 'application/bzip2'),
65 array('./test/test_data/test.zip', 'application/zip'),