1--TEST--
2Phar::convertToZip|Tar|Phar() repeated (phar_based archives)
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10
11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
12$pname = 'phar://' . $fname;
13$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
14$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
15$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
16$file = $stub;
17
18$files = array();
19$files['a'] = 'a';
20$files['b'] = 'b';
21$files['c'] = 'c';
22
23include 'files/phar_test.inc';
24
25echo "=================== new Phar() =======================\n";
26$phar = new Phar($fname);
27var_dump($phar->isFileFormat(Phar::PHAR));
28var_dump($phar->isFileFormat(Phar::TAR));
29var_dump($phar->isFileFormat(Phar::ZIP));
30var_dump($phar->getStub());
31var_dump($phar->getAlias());
32
33echo "================= convertToTar() =====================\n";
34
35$phar = $phar->convertToExecutable(Phar::TAR);
36var_dump($phar->isFileFormat(Phar::PHAR));
37var_dump($phar->isFileFormat(Phar::TAR));
38var_dump($phar->isFileFormat(Phar::ZIP));
39var_dump($phar->getStub());
40var_dump($phar->getAlias());
41
42echo "================= convertToZip() =====================\n";
43
44$phar = $phar->convertToExecutable(Phar::ZIP);
45var_dump($phar->isFileFormat(Phar::PHAR));
46var_dump($phar->isFileFormat(Phar::TAR));
47var_dump($phar->isFileFormat(Phar::ZIP));
48var_dump($phar->getStub());
49var_dump($phar->getAlias());
50
51echo "================= convertToPhar() ====================\n";
52
53$phar = $phar->convertToExecutable(Phar::PHAR, Phar::NONE, '.2.phar');
54var_dump($phar->isFileFormat(Phar::PHAR));
55var_dump($phar->isFileFormat(Phar::TAR));
56var_dump($phar->isFileFormat(Phar::ZIP));
57var_dump(strlen($phar->getStub()));
58var_dump($phar->getAlias());
59
60echo "================= convertToZip() =====================\n";
61
62$phar = $phar->convertToExecutable(Phar::ZIP, Phar::NONE, '.2.phar.zip');
63var_dump($phar->isFileFormat(Phar::PHAR));
64var_dump($phar->isFileFormat(Phar::TAR));
65var_dump($phar->isFileFormat(Phar::ZIP));
66var_dump($phar->getStub());
67var_dump($phar->getAlias());
68
69echo "================= convertToTar() =====================\n";
70
71$phar = $phar->convertToExecutable(Phar::TAR, Phar::NONE, '2.phar.tar');
72var_dump($phar->isFileFormat(Phar::PHAR));
73var_dump($phar->isFileFormat(Phar::TAR));
74var_dump($phar->isFileFormat(Phar::ZIP));
75var_dump($phar->getStub());
76var_dump($phar->getAlias());
77
78echo "================= convertToZip() =====================\n";
79
80$phar = $phar->convertToExecutable(Phar::ZIP, Phar::NONE, '3.phar.zip');
81var_dump($phar->isFileFormat(Phar::PHAR));
82var_dump($phar->isFileFormat(Phar::TAR));
83var_dump($phar->isFileFormat(Phar::ZIP));
84var_dump($phar->getStub());
85var_dump($phar->getAlias());
86
87?>
88===DONE===
89--CLEAN--
90<?php
91unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
92unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
93unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
94unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.2.phar.zip');
95unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.2.2.phar.tar');
96unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.phar');
97unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.2.2.3.phar.zip');
98unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.phar.tar');
99unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.phar');
100?>
101--EXPECTF--
102=================== new Phar() =======================
103bool(true)
104bool(false)
105bool(false)
106string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
107string(3) "hio"
108================= convertToTar() =====================
109bool(false)
110bool(true)
111bool(false)
112string(60) "<?php // tar-based phar archive stub file
113__HALT_COMPILER();"
114string(%d) "%sphar_convert_repeated.phar.tar"
115================= convertToZip() =====================
116bool(false)
117bool(false)
118bool(true)
119string(60) "<?php // zip-based phar archive stub file
120__HALT_COMPILER();"
121NULL
122================= convertToPhar() ====================
123bool(true)
124bool(false)
125bool(false)
126int(6641)
127NULL
128================= convertToZip() =====================
129bool(false)
130bool(false)
131bool(true)
132string(60) "<?php // zip-based phar archive stub file
133__HALT_COMPILER();"
134NULL
135================= convertToTar() =====================
136bool(false)
137bool(true)
138bool(false)
139string(60) "<?php // tar-based phar archive stub file
140__HALT_COMPILER();"
141NULL
142================= convertToZip() =====================
143bool(false)
144bool(false)
145bool(true)
146string(60) "<?php // zip-based phar archive stub file
147__HALT_COMPILER();"
148NULL
149===DONE===
150