1--TEST--
2Phar::convertToZip|Tar|Phar() repeated (phar_based archives)
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10
11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar';
12$pname = 'phar://' . $fname;
13$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip';
14$fname3 = __DIR__ . '/' . 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--CLEAN--
89<?php
90unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
91unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
92unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');
93unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.2.phar.zip');
94unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.2.2.phar.tar');
95unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.phar');
96unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.2.2.3.phar.zip');
97?>
98--EXPECTF--
99=================== new Phar() =======================
100bool(true)
101bool(false)
102bool(false)
103string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
104string(3) "hio"
105================= convertToTar() =====================
106bool(false)
107bool(true)
108bool(false)
109string(60) "<?php // tar-based phar archive stub file
110__HALT_COMPILER();"
111string(%d) "%sphar_convert_repeated.phar.tar"
112================= convertToZip() =====================
113bool(false)
114bool(false)
115bool(true)
116string(60) "<?php // zip-based phar archive stub file
117__HALT_COMPILER();"
118NULL
119================= convertToPhar() ====================
120bool(true)
121bool(false)
122bool(false)
123int(6641)
124NULL
125================= convertToZip() =====================
126bool(false)
127bool(false)
128bool(true)
129string(60) "<?php // zip-based phar archive stub file
130__HALT_COMPILER();"
131NULL
132================= convertToTar() =====================
133bool(false)
134bool(true)
135bool(false)
136string(60) "<?php // tar-based phar archive stub file
137__HALT_COMPILER();"
138NULL
139================= convertToZip() =====================
140bool(false)
141bool(false)
142bool(true)
143string(60) "<?php // zip-based phar archive stub file
144__HALT_COMPILER();"
145NULL
146