xref: /PHP-5.4/ext/phar/tests/badparameters.phpt (revision 3283b811)
1--TEST--
2Phar: bad parameters to various methods
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9ini_set('phar.readonly', 1);
10Phar::mungServer('hi');
11Phar::createDefaultStub(array());
12Phar::loadPhar(array());
13Phar::canCompress('hi');
14$a = new Phar(array());
15$a = new Phar(dirname(__FILE__) . '/files/frontcontroller10.phar');
16$a->convertToExecutable(array());
17$a->convertToData(array());
18$b = new PharData(dirname(__FILE__) . '/whatever.tar');
19$c = new PharData(dirname(__FILE__) . '/whatever.zip');
20$b->delete(array());
21try {
22$a->delete('oops');
23} catch (Exception $e) {
24echo $e->getMessage() . "\n";
25}
26try {
27$b->delete('oops');
28} catch (Exception $e) {
29echo $e->getMessage() . "\n";
30}
31echo $a->getPath() . "\n";
32try {
33$a->setAlias('oops');
34} catch (Exception $e) {
35echo $e->getMessage() . "\n";
36}
37try {
38$b->setAlias('oops');
39} catch (Exception $e) {
40echo $e->getMessage() . "\n";
41}
42ini_set('phar.readonly', 0);
43$a->setAlias(array());
44ini_set('phar.readonly', 1);
45try {
46$b->stopBuffering();
47} catch (Exception $e) {
48echo $e->getMessage() . "\n";
49}
50try {
51$a->setStub('oops');
52} catch (Exception $e) {
53echo $e->getMessage() . "\n";
54}
55try {
56$b->setStub('oops');
57} catch (Exception $e) {
58echo $e->getMessage() . "\n";
59}
60ini_set('phar.readonly', 0);
61$a->setStub(array());
62ini_set('phar.readonly', 1);
63try {
64$b->setDefaultStub('oops');
65} catch (Exception $e) {
66echo $e->getMessage() . "\n";
67}
68$a->setDefaultStub(array());
69try {
70$a->setDefaultStub('oops');
71} catch (Exception $e) {
72echo $e->getMessage() . "\n";
73}
74try {
75$a->setSignatureAlgorithm(Phar::MD5);
76} catch (Exception $e) {
77echo $e->getMessage() . "\n";
78}
79$a->compress(array());
80try {
81$a->compress(1);
82} catch (Exception $e) {
83echo $e->getMessage() . "\n";
84}
85$a->compressFiles(array());
86try {
87$a->decompressFiles();
88} catch (Exception $e) {
89echo $e->getMessage() . "\n";
90}
91$a->copy(array());
92try {
93$a->copy('a', 'b');
94} catch (Exception $e) {
95echo $e->getMessage() . "\n";
96}
97$a->offsetExists(array());
98$a->offsetGet(array());
99ini_set('phar.readonly', 0);
100$a->offsetSet(array());
101ini_set('phar.readonly', 1);
102$b->offsetUnset(array());
103try {
104$a->offsetUnset('a');
105} catch (Exception $e) {
106echo $e->getMessage() . "\n";
107}
108$a->addEmptyDir(array());
109$a->addFile(array());
110$a->addFromString(array());
111try {
112$a->setMetadata('a');
113} catch (Exception $e) {
114echo $e->getMessage() . "\n";
115}
116ini_set('phar.readonly', 0);
117$a->setMetadata(1,2);
118ini_set('phar.readonly', 1);
119try {
120$a->delMetadata();
121} catch (Exception $e) {
122echo $e->getMessage() . "\n";
123}
124?>
125===DONE===
126--EXPECTF--
127Warning: Phar::mungServer() expects parameter 1 to be array, %string given in %sbadparameters.php on line %d
128
129Warning: Phar::createDefaultStub() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
130
131Warning: Phar::loadPhar() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
132
133Warning: Phar::canCompress() expects parameter 1 to be long, %string given in %sbadparameters.php on line %d
134
135Warning: Phar::__construct() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
136
137Warning: Phar::convertToExecutable() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
138
139Warning: Phar::convertToData() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
140
141Warning: PharData::delete() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
142Cannot write out phar archive, phar is read-only
143Entry oops does not exist and cannot be deleted
144%sfiles/frontcontroller10.phar
145Cannot write out phar archive, phar is read-only
146A Phar alias cannot be set in a plain tar archive
147
148Warning: Phar::setAlias() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
149Cannot change stub, phar is read-only
150A Phar stub cannot be set in a plain tar archive
151
152Warning: Phar::setStub() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
153A Phar stub cannot be set in a plain tar archive
154
155Warning: Phar::setDefaultStub() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
156Cannot change stub: phar.readonly=1
157Cannot set signature algorithm, phar is read-only
158
159Warning: Phar::compress() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
160Cannot compress phar archive, phar is read-only
161
162Warning: Phar::compressFiles() expects parameter 1 to be long, array given in %sbadparameters.php on line %d
163Phar is readonly, cannot change compression
164
165Warning: Phar::copy() expects exactly 2 parameters, 1 given in %sbadparameters.php on line %d
166Cannot copy "a" to "b", phar is read-only
167
168Warning: Phar::offsetExists() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
169
170Warning: Phar::offsetGet() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
171
172Warning: Phar::offsetSet() expects exactly 2 parameters, 1 given in %sbadparameters.php on line %d
173
174Warning: PharData::offsetUnset() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
175Write operations disabled by the php.ini setting phar.readonly
176
177Warning: Phar::addEmptyDir() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
178
179Warning: Phar::addFile() expects parameter 1 to be %string, array given in %sbadparameters.php on line %d
180
181Warning: Phar::addFromString() expects exactly 2 parameters, 1 given in %sbadparameters.php on line %d
182Write operations disabled by the php.ini setting phar.readonly
183
184Warning: Phar::setMetadata() expects exactly 1 parameter, 2 given in %sbadparameters.php on line %d
185Write operations disabled by the php.ini setting phar.readonly
186===DONE===
187