Annotation of embedaddon/php/ext/phar/tests/phar_convert_again.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Phar::conversion to other formats
3: --SKIPIF--
4: <?php if (!extension_loaded("phar")) die("skip"); ?>
5: <?php if (!extension_loaded("zlib")) die("skip no zlib"); ?>
6: <?php if (!extension_loaded("bz2")) die("skip no bz2"); ?>
7: --INI--
8: phar.require_hash=0
9: phar.readonly=0
10: --FILE--
11: <?php
12:
13: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
14: $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.tbz';
15: $pname = 'phar://' . $fname;
16: $stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
17: $file = $stub;
18:
19: $files = array();
20: $files['a'] = 'a';
21: $files['b'] = 'b';
22: $files['c'] = 'c';
23:
24: include 'files/phar_test.inc';
25:
26: $phar = new Phar($fname);
27: $zip = $phar->convertToData(Phar::ZIP);
28: echo $zip->getPath() . "\n";
29: $tgz = $phar->convertToData(Phar::TAR, Phar::GZ);
30: echo $tgz->getPath() . "\n";
31: $tbz = $phar->convertToData(Phar::TAR, Phar::BZ2);
32: echo $tbz->getPath() . "\n";
33: try {
34: $phar = $tbz->convertToExecutable(Phar::PHAR, Phar::NONE);
35: } catch (Exception $e) {
36: echo $e->getMessage() . "\n";
37: }
38: copy($tbz->getPath(), $fname2);
39: $tbz = new PharData($fname2);
40: $phar = $tbz->convertToExecutable(Phar::PHAR, Phar::NONE);
41: echo $phar->getPath() . "\n";
42: $phar['a'] = 'hi';
43: $phar['a']->setMetadata('hi');
44: $zip = $phar->convertToExecutable(Phar::ZIP);
45: echo $zip->getPath() . "\n";
46: echo $zip['a']->getMetadata() . "\n";
47: $data = $zip->convertToData();
48: echo $data->getPath() . "\n";
49: // extra code coverage
50: try {
51: $data->setStub('hi');
52: } catch (Exception $e) {
53: echo $e->getMessage() . "\n";
54: }
55: try {
56: $data->setDefaultStub();
57: } catch (Exception $e) {
58: echo $e->getMessage() . "\n";
59: }
60: try {
61: $data->setAlias('hi');
62: } catch (Exception $e) {
63: echo $e->getMessage() . "\n";
64: }
65: $tar = $phar->convertToExecutable(Phar::TAR);
66: echo $tar->getPath() . "\n";
67: $data = $tar->convertToData();
68: echo $data->getPath() . "\n";
69: $tgz = $tar->convertToExecutable(null, Phar::GZ);
70: echo $tgz->getPath() . "\n";
71: try {
72: $tgz->convertToExecutable(25);
73: } catch (Exception $e) {
74: echo $e->getMessage() . "\n";
75: }
76: try {
77: $tgz->convertToExecutable(Phar::ZIP, Phar::GZ);
78: } catch (Exception $e) {
79: echo $e->getMessage() . "\n";
80: }
81: try {
82: $tgz->convertToExecutable(Phar::ZIP, Phar::BZ2);
83: } catch (Exception $e) {
84: echo $e->getMessage() . "\n";
85: }
86: try {
87: $phar->convertToData();
88: } catch (Exception $e) {
89: echo $e->getMessage() . "\n";
90: }
91: try {
92: $tgz->convertToData(Phar::PHAR);
93: } catch (Exception $e) {
94: echo $e->getMessage() . "\n";
95: }
96: try {
97: $tgz->convertToData(25);
98: } catch (Exception $e) {
99: echo $e->getMessage() . "\n";
100: }
101: try {
102: $tgz->convertToData(Phar::ZIP, Phar::GZ);
103: } catch (Exception $e) {
104: echo $e->getMessage() . "\n";
105: }
106: try {
107: $tgz->convertToData(Phar::ZIP, Phar::BZ2);
108: } catch (Exception $e) {
109: echo $e->getMessage() . "\n";
110: }
111: try {
112: $tgz->convertToExecutable(Phar::TAR, 25);
113: } catch (Exception $e) {
114: echo $e->getMessage() . "\n";
115: }
116: try {
117: $tgz->convertToData(Phar::TAR, 25);
118: } catch (Exception $e) {
119: echo $e->getMessage() . "\n";
120: }
121: // extra code coverage
122: try {
123: $data->setStub('hi');
124: } catch (Exception $e) {
125: echo $e->getMessage() . "\n";
126: }
127: try {
128: $data->setAlias('hi');
129: } catch (Exception $e) {
130: echo $e->getMessage() . "\n";
131: }
132: try {
133: $data->setDefaultStub();
134: } catch (Exception $e) {
135: echo $e->getMessage() . "\n";
136: }
137: try {
138: $tgz->convertToData(Phar::TAR, Phar::GZ, '.phar.tgz.oops');
139: } catch (Exception $e) {
140: echo $e->getMessage() . "\n";
141: }
142:
143: try {
144: $phar->convertToExecutable(Phar::TAR, Phar::GZ, '.tgz.oops');
145: } catch (Exception $e) {
146: echo $e->getMessage() . "\n";
147: }
148:
149: try {
150: $tgz->convertToData(Phar::TAR, Phar::GZ, '.phar/.tgz.oops');
151: } catch (Exception $e) {
152: echo $e->getMessage() . "\n";
153: }
154: ?>
155: ===DONE===
156: --CLEAN--
157: <?php
158: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
159: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
160: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.gz');
161: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.zip');
162: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar.gz');
163: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
164: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar.bz2');
165: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.tbz');
166: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar');
167: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.tar');
168: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.tar');
169: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.zip');
170: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.zip');
171: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.tar.gz');
172: __HALT_COMPILER();
173: ?>
174: --EXPECTF--
175: %sphar_convert_again.zip
176: %sphar_convert_again.tar.gz
177: %sphar_convert_again.tar.bz2
178: Unable to add newly converted phar "%sphar_convert_again.phar" to the list of phars, a phar with that name already exists
179: %sphar_convert_again2.phar
180: %sphar_convert_again2.phar.zip
181: hi
182: %sphar_convert_again2.zip
183: A Phar stub cannot be set in a plain zip archive
184: A Phar stub cannot be set in a plain zip archive
185: A Phar alias cannot be set in a plain zip archive
186: %sphar_convert_again2.phar.tar
187: %sphar_convert_again2.tar
188: %sphar_convert_again2.phar.tar.gz
189: Unknown file format specified, please pass one of Phar::PHAR, Phar::TAR or Phar::ZIP
190: Cannot compress entire archive with gzip, zip archives do not support whole-archive compression
191: Cannot compress entire archive with bz2, zip archives do not support whole-archive compression
192: Cannot write out data phar archive, use Phar::TAR or Phar::ZIP
193: Cannot write out data phar archive, use Phar::TAR or Phar::ZIP
194: Unknown file format specified, please pass one of Phar::TAR or Phar::ZIP
195: Cannot compress entire archive with gzip, zip archives do not support whole-archive compression
196: Cannot compress entire archive with bz2, zip archives do not support whole-archive compression
197: Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2
198: Unknown compression specified, please pass one of Phar::GZ or Phar::BZ2
199: A Phar stub cannot be set in a plain tar archive
200: A Phar alias cannot be set in a plain tar archive
201: A Phar stub cannot be set in a plain tar archive
202: data phar "%sphar_convert_again2.phar.tgz.oops" has invalid extension phar.tgz.oops
203: phar "%sphar_convert_again2.tgz.oops" has invalid extension tgz.oops
204: data phar "%sphar_convert_again2.phar/.tgz.oops" has invalid extension phar/.tgz.oops
205: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>