badparameters.phpt 5.7 KB

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