1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
|
--TEST--
Phar: bad parameters to various methods
--EXTENSIONS--
phar
--INI--
phar.readonly=0
--FILE--
<?php
ini_set('phar.readonly', 1);
try {
Phar::mungServer('hi');
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
Phar::createDefaultStub(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
Phar::loadPhar(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
Phar::canCompress('hi');
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a = new Phar(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a = new Phar(__DIR__ . '/files/frontcontroller10.phar');
} catch (PharException $e) {
echo $e->getMessage(), "\n";
}
try {
$a->convertToExecutable(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->convertToData(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$b = new PharData(__DIR__ . '/whatever.tar');
} catch (PharException $e) {
echo $e->getMessage(), "\n";
}
try {
$c = new PharData(__DIR__ . '/whatever.zip');
} catch (PharException $e) {
echo $e->getMessage(), "\n";
}
try {
$b->delete(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->delete('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$b->delete('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
echo $a->getPath() . "\n";
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->setAlias('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$b->setAlias('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
ini_set('phar.readonly', 0);
try {
$a->setAlias(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
ini_set('phar.readonly', 1);
try {
$b->stopBuffering();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$a->setStub('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$b->setStub('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
ini_set('phar.readonly', 0);
try {
$a->setStub(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
ini_set('phar.readonly', 1);
try {
$b->setDefaultStub('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$a->setDefaultStub(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->setDefaultStub('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$a->setSignatureAlgorithm(Phar::MD5);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$a->compress(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->compress(1);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$a->compressFiles(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->decompressFiles();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$a->copy(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->copy('a', 'b');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$a->offsetExists(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->offsetGet(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
ini_set('phar.readonly', 0);
try {
$a->offsetSet(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
ini_set('phar.readonly', 1);
try {
$b->offsetUnset(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->offsetUnset('a');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
$a->addEmptyDir(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->addFile(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->addFromString(array());
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
$a->setMetadata('a');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
ini_set('phar.readonly', 0);
try {
$a->setMetadata(1,2);
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
ini_set('phar.readonly', 1);
try {
$a->delMetadata();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECTF--
Phar::mungServer(): Argument #1 ($variables) must be of type array, string given
Phar::createDefaultStub(): Argument #1 ($index) must be of type ?string, array given
Phar::loadPhar(): Argument #1 ($filename) must be of type string, array given
Phar::canCompress(): Argument #1 ($compression) must be of type int, string given
Phar::__construct(): Argument #1 ($filename) must be of type string, array given
Phar::convertToExecutable(): Argument #1 ($format) must be of type ?int, array given
Phar::convertToData(): Argument #1 ($format) must be of type ?int, array given
PharData::delete(): Argument #1 ($localName) must be of type string, array given
Cannot write out phar archive, phar is read-only
Entry oops does not exist and cannot be deleted
%sfrontcontroller10.phar
Cannot write out phar archive, phar is read-only
A Phar alias cannot be set in a plain tar archive
Phar::setAlias(): Argument #1 ($alias) must be of type string, array given
Cannot change stub, phar is read-only
A Phar stub cannot be set in a plain tar archive
Phar::setStub(): Argument #1 ($stub) must be of type string, array given
A Phar stub cannot be set in a plain tar archive
Phar::setDefaultStub(): Argument #1 ($index) must be of type ?string, array given
Cannot change stub: phar.readonly=1
Cannot set signature algorithm, phar is read-only
Phar::compress(): Argument #1 ($compression) must be of type int, array given
Cannot compress phar archive, phar is read-only
Phar::compressFiles(): Argument #1 ($compression) must be of type int, array given
Phar is readonly, cannot change compression
Phar::copy() expects exactly 2 arguments, 1 given
Cannot copy "a" to "b", phar is read-only
Phar::offsetExists(): Argument #1 ($localName) must be of type string, array given
Phar::offsetGet(): Argument #1 ($localName) must be of type string, array given
Phar::offsetSet() expects exactly 2 arguments, 1 given
PharData::offsetUnset(): Argument #1 ($localName) must be of type string, array given
Write operations disabled by the php.ini setting phar.readonly
Phar::addEmptyDir(): Argument #1 ($directory) must be of type string, array given
Phar::addFile(): Argument #1 ($filename) must be of type string, array given
Phar::addFromString() expects exactly 2 arguments, 1 given
Write operations disabled by the php.ini setting phar.readonly
Phar::setMetadata() expects exactly 1 argument, 2 given
Write operations disabled by the php.ini setting phar.readonly
|