badparameters.phpt 6.0 KB

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