Fixed: Not selecting a datalabel used to issue a notice(undefined offset)
[phpmyadmin/ammaryasirr.git] / test / classes / PMA_File_test.php
blob63bf80ad1005c4a07663e72b4fbd1eca3596c441
2 <?php
3 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 /**
5 * tests for PMA_File class
7 * @package phpMyAdmin-test
8 */
11 * Include to 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;
26 /**
27 * @dataProvider compressedFiles
29 public function testMIME($file, $mime)
31 $arr = new PMA_File($file);
32 $this->assertEquals($mime, $arr->getCompression());
35 /**
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);
46 } else {
47 $this->assertEquals($orig, $file->getNextChunk());
51 /**
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() {
62 return array(
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'),