configuration.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * DO NOT EDIT: This file is automatically generated by configGenerator.php
  4. */
  5. class configTest extends PHPUnit_Framework_TestCase
  6. {
  7. private static $pasteid = '501f02e9eeb8bcec';
  8. private static $paste = array(
  9. 'data' => '{"iv":"EN39/wd5Nk8HAiSG2K5AsQ","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"QKN1DBXe5PI","ct":"8hA83xDdXjD7K2qfmw5NdA"}',
  10. 'meta' => array(
  11. 'postdate' => 1344803344,
  12. 'opendiscussion' => true,
  13. ),
  14. );
  15. private $_model;
  16. private $_conf;
  17. public function setUp()
  18. {
  19. /* Setup Routine */
  20. $this->_conf = PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini';
  21. if (!is_file($this->_conf . '.bak') && is_file($this->_conf))
  22. rename($this->_conf, $this->_conf . '.bak');
  23. $this->_model = zerobin_data::getInstance(array('dir' => PATH . 'data'));
  24. serversalt::setPath(PATH . 'data');
  25. $this->reset();
  26. }
  27. public function tearDown()
  28. {
  29. /* Tear Down Routine */
  30. rename($this->_conf . '.bak', $this->_conf);
  31. }
  32. public function reset($configuration = array())
  33. {
  34. $_POST = array();
  35. $_GET = array();
  36. $_SERVER = array();
  37. if ($this->_model->exists(self::$pasteid))
  38. $this->_model->delete(self::$pasteid);
  39. // generate configuration file
  40. if (count($configuration)) {
  41. @unlink($this->_conf);
  42. $c = fopen($this->_conf, 'a');
  43. foreach ($configuration as $section => $options) {
  44. fwrite($c, "[$section]" . PHP_EOL);
  45. foreach($options as $option => $setting) {
  46. if (is_string($setting)) {
  47. $setting = '"' . $setting . '"';
  48. } else {
  49. $setting = var_export($setting, true);
  50. }
  51. fwrite($c, "$option = $setting" . PHP_EOL);
  52. }
  53. fwrite($c, PHP_EOL);
  54. }
  55. fclose($c);
  56. }
  57. }
  58. /**
  59. * @runInSeparateProcess
  60. */
  61. public function testView0()
  62. {
  63. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => '10', 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  64. ob_start();
  65. new zerobin;
  66. $content = ob_get_contents();
  67. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  68. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'outputs stylesheet correctly');
  69. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'outputs javascript correctly');
  70. }
  71. /**
  72. * @runInSeparateProcess
  73. */
  74. public function testView1()
  75. {
  76. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => '10', 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  77. ob_start();
  78. new zerobin;
  79. $content = ob_get_contents();
  80. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  81. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'outputs stylesheet correctly');
  82. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'outputs javascript correctly');
  83. }
  84. /**
  85. * @runInSeparateProcess
  86. */
  87. public function testView2()
  88. {
  89. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => '10', 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  90. ob_start();
  91. new zerobin;
  92. $content = ob_get_contents();
  93. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  94. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'removes stylesheet correctly');
  95. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'removes javascript correctly');
  96. }
  97. /**
  98. * @runInSeparateProcess
  99. */
  100. public function testView3()
  101. {
  102. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => '10', 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  103. ob_start();
  104. new zerobin;
  105. $content = ob_get_contents();
  106. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  107. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'removes stylesheet correctly');
  108. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'removes javascript correctly');
  109. }
  110. }