badparameters.phpt 6.7 KB

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