Translated using Weblate (Indonesian)
[phpmyadmin.git] / test / libraries / PMA_zip_extension_test.php
blob54049a8ee778309b659b167f4f6a1ba4dfc282bc
1 <?php
2 /**
3 * Tests for displaying results
5 * @package PhpMyAdmin-test
6 */
8 /*
9 * Include to test.
12 require_once 'libraries/zip_extension.lib.php';
13 require_once 'libraries/php-gettext/gettext.inc';
15 class PMA_zip_extension_test extends PHPUnit_Framework_TestCase
17 /**
18 * Test zip file content
20 * @param string $file zip file
21 * @param string $specific_entry regular expression to match a file
22 * @param mixed $output expected output
24 * @dataProvider providerForTestGetZipContents
25 * @return void
27 public function testGetZipContents($file, $specific_entry, $output)
29 $this->assertEquals(
30 PMA_getZipContents($file, $specific_entry),
31 $output
35 /**
36 * Provider for testGetZipContents
38 * @return array
40 public function providerForTestGetZipContents()
42 return array(
43 array(
44 './test/test_data/test.zip',
45 null,
46 array(
47 'error' => '',
48 'data' => 'TEST FILE'. "\n"
51 array(
52 './test/test_data/test.zip',
53 'test',
54 array(
55 'error' => 'Error in ZIP archive: Could not find "test"',
56 'data' => ''
62 /**
63 * Test Find file in Zip Archive
65 * @param string $file_regexp regular expression for the file name to match
66 * @param string $file zip archive
67 * @param mixed $output expected output
69 * @dataProvider providerForTestFindFileFromZipArchive
70 * @return void
72 public function testFindFileFromZipArchive($file_regexp, $file, $output)
74 $this->assertEquals(
75 PMA_findFileFromZipArchive($file_regexp, $file),
76 $output
80 /**
81 * Provider for testFindFileFromZipArchive
83 * @return void
85 public function providerForTestFindFileFromZipArchive()
87 return array(
88 array(
89 '/test/',
90 './test/test_data/test.zip',
91 'test.file'
96 /**
97 * Test for PMA_getNoOfFilesInZip
99 * @return void
101 public function testGetNoOfFilesInZip()
103 $this->assertEquals(
104 PMA_getNoOfFilesInZip('./test/test_data/test.zip'),
110 * Test for PMA_zipExtract
112 * @return void
114 public function testZipExtract()
116 $this->assertEquals(
117 PMA_zipExtract(
118 './test/test_data/test.zip', './test/test_data/', 'wrongName'
120 true
125 * Test for PMA_getZipError
127 * @param int $code error code
128 * @param mixed $output expected output
130 * @dataProvider providerForTestGetZipError
131 * @return void
133 public function testGetZipError($code, $output)
135 $this->assertEquals(
136 PMA_getZipError($code),
137 $output
142 * Provider for testGetZipError
144 * @return array
146 public function providerForTestGetZipError()
148 return array(
149 array(
151 'Multi-disk zip archives not supported'
153 array(
155 'Read error'
157 array(
159 'CRC error'
161 array(
163 'Not a zip archive'
165 array(
167 'Zip archive inconsistent'
169 array(
170 404,