From 2d0668af03fa05c6ea81cc55cebeaaa83745847a Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 29 Aug 2015 20:29:14 +0200 Subject: [PATCH] concluding work on configuration test generator for #16. Replaced a few die()s in the code with Exception, making it possible to test properly. Fixed some outdated unit tests. --- cfg/conf.ini | 2 +- lib/zerobin.php | 15 +- tst/configGenerator.php | 501 +- tst/configuration.php | 17235 +++++++++++++++++++++++++++++++++++++- tst/zerobin.php | 414 +- tst/zerobin/data.php | 4 +- tst/zerobin/db.php | 4 +- 7 files changed, 18005 insertions(+), 170 deletions(-) diff --git a/cfg/conf.ini b/cfg/conf.ini index a60d2dd0..cb86844a 100644 --- a/cfg/conf.ini +++ b/cfg/conf.ini @@ -17,7 +17,7 @@ syntaxhighlighting = true ; (optional) set a syntax highlighting theme, as found in css/prettify/ ; syntaxhighlightingtheme = "sons-of-obsidian" -; preselect the burn-after-reading feature by default, defaults to false +; preselect the burn-after-reading feature, defaults to false burnafterreadingselected = false ; size limit per paste or comment in bytes, defaults to 2 Mibibytes diff --git a/lib/zerobin.php b/lib/zerobin.php index ca17dc91..7d6b0c94 100644 --- a/lib/zerobin.php +++ b/lib/zerobin.php @@ -77,7 +77,7 @@ class zerobin public function __construct() { if (version_compare(PHP_VERSION, '5.2.6') < 0) - die('ZeroBin requires php 5.2.6 or above to work. Sorry.'); + throw new Exception('ZeroBin requires php 5.2.6 or above to work. Sorry.', 1); // in case stupid admin has left magic_quotes enabled in php.ini if (get_magic_quotes_gpc()) @@ -131,9 +131,9 @@ class zerobin $this->_conf = parse_ini_file(PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini', true); foreach (array('main', 'model') as $section) { - if (!array_key_exists($section, $this->_conf)) die( - "ZeroBin requires configuration section [$section] to be present in configuration file." - ); + if (!array_key_exists($section, $this->_conf)) { + throw new Exception("ZeroBin requires configuration section [$section] to be present in configuration file.", 2); + } } $this->_model = $this->_conf['model']['class']; } @@ -402,6 +402,9 @@ class zerobin return; } + // show the same error message if the paste expired or does not exist + $genericError = 'Paste does not exist, has expired or has been deleted.'; + // Check that paste exists. if ($this->_model()->exists($dataid)) { @@ -416,7 +419,7 @@ class zerobin { // Delete the paste $this->_model()->delete($dataid); - $this->_error = 'Paste does not exist, has expired or has been deleted.'; + $this->_error = $genericError; } // If no error, return the paste. else @@ -451,7 +454,7 @@ class zerobin } else { - $this->_error = 'Paste does not exist or has expired.'; + $this->_error = $genericError; } } diff --git a/tst/configGenerator.php b/tst/configGenerator.php index 54a90cfa..796f3a4a 100755 --- a/tst/configGenerator.php +++ b/tst/configGenerator.php @@ -11,12 +11,17 @@ */ include 'bootstrap.php'; + +$vrd = array('view', 'read', 'delete'); +$vcud = array('view', 'create', 'read', 'delete'); + new configurationTestGenerator(array( 'main/opendiscussion' => array( array( 'setting' => true, 'tests' => array( array( + 'conditions' => array('steps' => $vrd), 'type' => 'NotTag', 'args' => array( array( @@ -28,9 +33,26 @@ new configurationTestGenerator(array( '$content', 'outputs enabled discussion correctly' ), + ), array( + 'conditions' => array('steps' => array('create'), 'traffic/limit' => 10), + 'settings' => array('$_POST["opendiscussion"] = "neither 1 nor 0"'), + 'type' => 'Equals', + 'args' => array( + 1, + '$response["status"]', + 'when discussions are enabled, but invalid flag posted, fail to create paste' + ), + ), array( + 'conditions' => array('steps' => array('create'), 'traffic/limit' => 10), + 'settings' => array('$_POST["opendiscussion"] = "neither 1 nor 0"'), + 'type' => 'False', + 'args' => array( + '$this->_model->exists(self::$pasteid)', + 'when discussions are enabled, but invalid flag posted, paste is not created' + ), ), ), - 'affects' => array('view') + 'affects' => $vcud ), array( 'setting' => false, 'tests' => array( @@ -48,7 +70,7 @@ new configurationTestGenerator(array( ), ), ), - 'affects' => array('view') + 'affects' => $vrd ), ), 'main/syntaxhighlighting' => array( @@ -63,7 +85,7 @@ new configurationTestGenerator(array( 'attributes' => array( 'type' => 'text/css', 'rel' => 'stylesheet', - 'href' => 'regexp:#css/prettify/prettify.css#', + 'href' => 'regexp:#css/prettify/prettify\.css#', ), ), '$content', @@ -76,7 +98,7 @@ new configurationTestGenerator(array( 'tag' => 'script', 'attributes' => array( 'type' => 'text/javascript', - 'src' => 'regexp:#js/prettify.js#' + 'src' => 'regexp:#js/prettify\.js#' ), ), '$content', @@ -84,7 +106,7 @@ new configurationTestGenerator(array( ), ), ), - 'affects' => array('view'), + 'affects' => $vrd, ), array( 'setting' => false, 'tests' => array( @@ -96,7 +118,7 @@ new configurationTestGenerator(array( 'attributes' => array( 'type' => 'text/css', 'rel' => 'stylesheet', - 'href' => 'regexp:#css/prettify/prettify.css#', + 'href' => 'regexp:#css/prettify/prettify\.css#', ), ), '$content', @@ -109,7 +131,7 @@ new configurationTestGenerator(array( 'tag' => 'script', 'attributes' => array( 'type' => 'text/javascript', - 'src' => 'regexp:#js/prettify.js#', + 'src' => 'regexp:#js/prettify\.js#', ), ), '$content', @@ -117,7 +139,7 @@ new configurationTestGenerator(array( ), ), ), - 'affects' => array('view'), + 'affects' => $vrd, ), ), 'main/syntaxhighlightingtheme' => array( @@ -133,14 +155,13 @@ new configurationTestGenerator(array( 'attributes' => array( 'type' => 'text/css', 'rel' => 'stylesheet', - 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#', + 'href' => 'regexp:#css/prettify/sons-of-obsidian\.css#', ), ), '$content', 'outputs prettify theme stylesheet correctly', ), - ), - array( + ), array( 'conditions' => array('main/syntaxhighlighting' => false), 'type' => 'NotTag', 'args' => array( @@ -149,7 +170,7 @@ new configurationTestGenerator(array( 'attributes' => array( 'type' => 'text/css', 'rel' => 'stylesheet', - 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#', + 'href' => 'regexp:#css/prettify/sons-of-obsidian\.css#', ), ), '$content', @@ -157,7 +178,7 @@ new configurationTestGenerator(array( ), ), ), - 'affects' => array('view'), + 'affects' => $vrd, ), array( 'setting' => null, // option not set 'tests' => array( @@ -169,7 +190,7 @@ new configurationTestGenerator(array( 'attributes' => array( 'type' => 'text/css', 'rel' => 'stylesheet', - 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#', + 'href' => 'regexp:#css/prettify/sons-of-obsidian\.css#', ), ), '$content', @@ -177,7 +198,218 @@ new configurationTestGenerator(array( ), ), ), + 'affects' => $vrd, + ), + ), + 'main/burnafterreadingselected' => array( + array( + 'setting' => true, + 'tests' => array( + array( + 'type' => 'Tag', + 'args' => array( + array( + 'id' => 'burnafterreading', + 'attributes' => array( + 'checked' => 'checked', + ), + ), + '$content', + 'preselects burn after reading option', + ), + ), + ), 'affects' => array('view'), + ), array( + 'setting' => false, + 'tests' => array( + array( + 'type' => 'NotTag', + 'args' => array( + array( + 'id' => 'burnafterreading', + 'attributes' => array( + 'checked' => 'checked', + ), + ), + '$content', + 'burn after reading option is unchecked', + ), + ), + ), + 'affects' => array('view'), + ), + ), + 'main/template' => array( + array( + 'setting' => 'page', + 'tests' => array( + array( + 'type' => 'Tag', + 'args' => array( + array( + 'tag' => 'link', + 'attributes' => array( + 'type' => 'text/css', + 'rel' => 'stylesheet', + 'href' => 'regexp:#css/zerobin\.css#', + ), + ), + '$content', + 'outputs "page" stylesheet correctly', + ), + ), array( + 'type' => 'NotTag', + 'args' => array( + array( + 'tag' => 'link', + 'attributes' => array( + 'type' => 'text/css', + 'rel' => 'stylesheet', + 'href' => 'regexp:#css/bootstrap/bootstrap-\d[\d\.]+\d\.css#', + ), + ), + '$content', + 'removes "bootstrap" stylesheet correctly', + ), + ), + ), + 'affects' => $vrd, + ), array( + 'setting' => 'bootstrap', + 'tests' => array( + array( + 'type' => 'NotTag', + 'args' => array( + array( + 'tag' => 'link', + 'attributes' => array( + 'type' => 'text/css', + 'rel' => 'stylesheet', + 'href' => 'regexp:#css/zerobin.css#', + ), + ), + '$content', + 'removes "page" stylesheet correctly', + ), + ), array( + 'type' => 'Tag', + 'args' => array( + array( + 'tag' => 'link', + 'attributes' => array( + 'type' => 'text/css', + 'rel' => 'stylesheet', + 'href' => 'regexp:#css/bootstrap/bootstrap-\d[\d\.]+\d\.css#', + ), + ), + '$content', + 'outputs "bootstrap" stylesheet correctly', + ), + ), + ), + 'affects' => $vrd, + ), + ), + 'main/sizelimit' => array( + array( + 'setting' => 10, + 'tests' => array( + array( + 'conditions' => array('steps' => array('create'), 'traffic/limit' => 10), + 'type' => 'Equals', + 'args' => array( + 1, + '$response["status"]', + 'when sizelimit limit exceeded, fail to create paste' + ), + ), + ), + 'affects' => array('create') + ), array( + 'setting' => 2097152, + 'tests' => array( + array( + 'conditions' => array('steps' => array('create'), 'traffic/limit' => 0, 'main/burnafterreadingselected' => true), + 'settings' => array('sleep(3)'), + 'type' => 'Equals', + 'args' => array( + 0, + '$response["status"]', + 'when sizelimit limit is not reached, successfully create paste' + ), + ), array( + 'conditions' => array('steps' => array('create'), 'traffic/limit' => 0, 'main/burnafterreadingselected' => true), + 'settings' => array('sleep(3)'), + 'type' => 'True', + 'args' => array( + '$this->_model->exists($response["id"])', + 'when sizelimit limit is not reached, paste exists after posting data' + ), + ), + ), + 'affects' => array('create') + ), + ), + 'traffic/limit' => array( + array( + 'setting' => 0, + 'tests' => array( + array( + 'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152), + 'type' => 'Equals', + 'args' => array( + 0, + '$response["status"]', + 'when traffic limit is disabled, successfully create paste' + ), + ), array( + 'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152), + 'type' => 'True', + 'args' => array( + '$this->_model->exists($response["id"])', + 'when traffic limit is disabled, paste exists after posting data' + ), + ), + ), + 'affects' => array('create') + ), array( + 'setting' => 10, + 'tests' => array( + array( + 'conditions' => array('steps' => array('create')), + 'type' => 'Equals', + 'args' => array( + 1, + '$response["status"]', + 'when traffic limit is on and we do not wait, fail to create paste' + ), + ), + ), + 'affects' => array('create') + ), array( + 'setting' => 2, + 'tests' => array( + array( + 'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152), + 'settings' => array('sleep(3)'), + 'type' => 'Equals', + 'args' => array( + 0, + '$response["status"]', + 'when traffic limit is on and we wait, successfully create paste' + ), + ), array( + 'conditions' => array('steps' => array('create'), 'main/sizelimit' => 2097152), + 'settings' => array('sleep(3)'), + 'type' => 'True', + 'args' => array( + '$this->_model->exists($response["id"])', + 'when traffic limit is on and we wait, paste exists after posting data' + ), + ), + ), + 'affects' => array('create') ), ), )); @@ -233,115 +465,31 @@ class configurationTestGenerator $fullOptions = array_replace_recursive($defaultOptions, $conf['options']); $options = helper::var_export_min($fullOptions, true); foreach ($conf['affects'] as $step) { - $step = ucfirst($step); - switch ($step) { - case 'Create': - $code .= <<reset($options); - \$_POST = self::\$paste; - \$_SERVER['REMOTE_ADDR'] = '::1'; - ob_start(); - new zerobin; - \$content = ob_get_contents(); - - \$response = json_decode(\$content, true); - \$this->assertEquals(\$response['status'], 0, 'outputs status'); - \$this->assertEquals( - \$response['deletetoken'], - hash_hmac('sha1', \$response['id'], serversalt::get()), - 'outputs valid delete token' - ); - \$this->assertTrue(\$this->_model->exists(\$response['id']), 'paste exists after posting data'); - - -EOT; - break; - case 'Read': - $code .= <<reset($options); - \$this->_model->create(self::\$pasteid, self::\$paste); - \$_SERVER['QUERY_STRING'] = self::\$pasteid; - ob_start(); - new zerobin; - \$content = ob_get_contents(); - - \$this->assertTag( - array( - 'id' => 'cipherdata', - 'content' => htmlspecialchars(json_encode(self::\$paste), ENT_NOQUOTES) - ), - \$content, - 'outputs data correctly' - ); - - -EOT; - break; - case 'Delete': - $code .= <<reset($options); - \$this->_model->create(self::$\pasteid, self::$\paste); - \$this->assertTrue(\$this->_model->exists(self::$\pasteid), 'paste exists before deleting data'); - \$_GET['pasteid'] = self::$\pasteid; - \$_GET['deletetoken'] = hash_hmac('sha1', self::$\pasteid, serversalt::get()); - ob_start(); - new zerobin; - \$content = ob_get_contents(); - - \$this->assertTag( - array( - 'id' => 'status', - 'content' => 'Paste was properly deleted' - ), - \$content, - 'outputs deleted status correctly' - ); - \$this->assertFalse(\$this->_model->exists(self::\$pasteid), 'paste successfully deleted'); - - -EOT; - break; - // view - default: - $code .= <<reset($options); - ob_start(); - new zerobin; - \$content = ob_get_contents(); - - -EOT; - } + $testCode = $preCode = array(); foreach ($conf['tests'] as $tests) { - foreach ($tests as $test) { + foreach ($tests[0] as $test) { + // skip if test does not affect this step + if (!in_array($step, $tests[1])) { + continue; + } + // skip if not all test conditions are met if (array_key_exists('conditions', $test)) { - while(list($path, $setting) = each($test['conditions'])) { - list($section, $option) = explode('/', $path); - if ($fullOptions[$section][$option] !== $setting) { + while (list($path, $setting) = each($test['conditions'])) { + if ($path == 'steps' && !in_array($step, $setting)) { continue 2; + } elseif($path != 'steps') { + list($section, $option) = explode('/', $path); + if ($fullOptions[$section][$option] !== $setting) { + continue 2; + } } } } + if (array_key_exists('settings', $test)) { + foreach ($test['settings'] as $setting) { + $preCode[$setting] = $setting; + } + } $args = array(); foreach ($test['args'] as $arg) { if (is_string($arg) && strpos($arg, '$') === 0) { @@ -350,12 +498,12 @@ EOT; $args[] = helper::var_export_min($arg, true); } } - $type = $test['type']; - $args = implode(', ', $args); - $code .= " \$this->assert$type($args);" . PHP_EOL; + $testCode[] = array($test['type'], implode(', ', $args)); } } - $code .= ' }' . PHP_EOL . PHP_EOL; + $code .= $this->_getFunction( + ucfirst($step), $key, $options, $preCode, $testCode + ); } } $code .= '}' . PHP_EOL; @@ -376,7 +524,7 @@ EOT; */ class configurationTest extends PHPUnit_Framework_TestCase { - private static $pasteid = '501f02e9eeb8bcec'; + private static $pasteid = '5e9bc25c89fb3bf9'; private static $paste = array( 'data' => '{"iv":"EN39/wd5Nk8HAiSG2K5AsQ","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"QKN1DBXe5PI","ct":"8hA83xDdXjD7K2qfmw5NdA"}', @@ -418,9 +566,116 @@ class configurationTest extends PHPUnit_Framework_TestCase helper::createIniFile($this->_conf, $configuration); } + EOT; } + /** + * get unit tests function block + * + * @param string $step + * @param int $key + * @param array $options + * @param array $preCode + * @param array $testCode + * @return string + */ + private function _getFunction($step, $key, &$options, $preCode, $testCode) + { + if (count($testCode) == 0) { + echo "skipping creation of test$step$key, no valid tests found for configuration: $options". PHP_EOL; + return ''; + } + + $preString = $testString = ''; + foreach ($preCode as $setting) { + $preString .= " $setting;" . PHP_EOL; + } + foreach ($testCode as $test) { + $type = $test[0]; + $args = $test[1]; + $testString .= " \$this->assert$type($args);" . PHP_EOL; + } + $code = <<reset($options); +EOT; + + // step specific initialization + switch ($step) { + case 'Create': + $code .= PHP_EOL . <<<'EOT' + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; +EOT; + break; + case 'Read': + $code .= PHP_EOL . <<<'EOT' + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; +EOT; + break; + case 'Delete': + $code .= PHP_EOL . <<<'EOT' + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); +EOT; + break; + } + + // all steps + $code .= PHP_EOL . $preString; + $code .= <<<'EOT' + ob_start(); + new zerobin; + $content = ob_get_contents(); +EOT; + + // step specific tests + switch ($step) { + case 'Create': + $code .= <<<'EOT' + + $response = json_decode($content, true); +EOT; + break; + case 'Read': + $code .= <<<'EOT' + + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); +EOT; + break; + case 'Delete': + $code .= <<<'EOT' + + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); +EOT; + break; + } + return $code . PHP_EOL . PHP_EOL . $testString . ' }' . PHP_EOL . PHP_EOL; + } + /** * recursive function to generate configurations based on options * @@ -485,7 +740,7 @@ EOT; throw new Exception("Endless loop or error in options detected: option '$option' already exists with setting '$val' in one of the configurations!"); } $configuration['options'][$section][$option] = $setting['setting']; - $configuration['tests'][$option] = $setting['tests']; + $configuration['tests'][$option] = array($setting['tests'], $setting['affects']); foreach ($setting['affects'] as $affects) { if (!in_array($affects, $configuration['affects'])) { $configuration['affects'][] = $affects; diff --git a/tst/configuration.php b/tst/configuration.php index 03e53e22..eb247198 100644 --- a/tst/configuration.php +++ b/tst/configuration.php @@ -4,7 +4,7 @@ */ class configurationTest extends PHPUnit_Framework_TestCase { - private static $pasteid = '501f02e9eeb8bcec'; + private static $pasteid = '5e9bc25c89fb3bf9'; private static $paste = array( 'data' => '{"iv":"EN39/wd5Nk8HAiSG2K5AsQ","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"QKN1DBXe5PI","ct":"8hA83xDdXjD7K2qfmw5NdA"}', @@ -45,20 +45,83 @@ class configurationTest extends PHPUnit_Framework_TestCase $this->_model->delete(self::$pasteid); helper::createIniFile($this->_conf, $configuration); } + /** * @runInSeparateProcess */ public function testView0() { - $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); ob_start(); new zerobin; $content = ob_get_contents(); $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); - $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'outputs prettify stylesheet correctly'); - $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'outputs prettify javascript correctly'); - $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead0() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete0() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); } /** @@ -66,15 +129,77 @@ class configurationTest extends PHPUnit_Framework_TestCase */ public function testView1() { - $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); ob_start(); new zerobin; $content = ob_get_contents(); $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); - $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'outputs prettify stylesheet correctly'); - $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'outputs prettify javascript correctly'); - $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead1() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete1() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); } /** @@ -82,15 +207,77 @@ class configurationTest extends PHPUnit_Framework_TestCase */ public function testView2() { - $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); ob_start(); new zerobin; $content = ob_get_contents(); $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); - $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'removes prettify stylesheet correctly'); - $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'removes prettify javascript correctly'); - $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead2() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete2() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); } /** @@ -98,15 +285,77 @@ class configurationTest extends PHPUnit_Framework_TestCase */ public function testView3() { - $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); ob_start(); new zerobin; $content = ob_get_contents(); $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); - $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'removes prettify stylesheet correctly'); - $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'removes prettify javascript correctly'); - $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead3() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete3() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); } /** @@ -114,15 +363,77 @@ class configurationTest extends PHPUnit_Framework_TestCase */ public function testView4() { - $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); ob_start(); new zerobin; $content = ob_get_contents(); $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); - $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'outputs prettify stylesheet correctly'); - $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'outputs prettify javascript correctly'); - $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead4() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete4() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); } /** @@ -130,15 +441,77 @@ class configurationTest extends PHPUnit_Framework_TestCase */ public function testView5() { - $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); ob_start(); new zerobin; $content = ob_get_contents(); $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); - $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'outputs prettify stylesheet correctly'); - $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'outputs prettify javascript correctly'); - $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead5() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete5() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); } /** @@ -146,15 +519,77 @@ class configurationTest extends PHPUnit_Framework_TestCase */ public function testView6() { - $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); ob_start(); new zerobin; $content = ob_get_contents(); $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); - $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'removes prettify stylesheet correctly'); - $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'removes prettify javascript correctly'); - $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead6() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete6() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); } /** @@ -162,15 +597,16749 @@ class configurationTest extends PHPUnit_Framework_TestCase */ public function testView7() { - $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); ob_start(); new zerobin; $content = ob_get_contents(); $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); - $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify.css#')), $content, 'removes prettify stylesheet correctly'); - $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'removes prettify javascript correctly'); - $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead7() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete7() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView8() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead8() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete8() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView9() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead9() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete9() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView10() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead10() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete10() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView11() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead11() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete11() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView12() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead12() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete12() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView13() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead13() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete13() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView14() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead14() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete14() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView15() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead15() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete15() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView16() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead16() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete16() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView17() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead17() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete17() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView18() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead18() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete18() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView19() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead19() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete19() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView20() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead20() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete20() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView21() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead21() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete21() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView22() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead22() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete22() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView23() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead23() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete23() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView24() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead24() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete24() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView25() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead25() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete25() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView26() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead26() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete26() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView27() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead27() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete27() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView28() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead28() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete28() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView29() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead29() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete29() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView30() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead30() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete30() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView31() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead31() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete31() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView32() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate32() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead32() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete32() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView33() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate33() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead33() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete33() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView34() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate34() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead34() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete34() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView35() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate35() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead35() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete35() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView36() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate36() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead36() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete36() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView37() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate37() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead37() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete37() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView38() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate38() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead38() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete38() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView39() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate39() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead39() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete39() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView40() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate40() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead40() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete40() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView41() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate41() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead41() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete41() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView42() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate42() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead42() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete42() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView43() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate43() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead43() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete43() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView44() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate44() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead44() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete44() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView45() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate45() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead45() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete45() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView46() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate46() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead46() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete46() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView47() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate47() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead47() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete47() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView48() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate48() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead48() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete48() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView49() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate49() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead49() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete49() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView50() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate50() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead50() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete50() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView51() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate51() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead51() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete51() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView52() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate52() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead52() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete52() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView53() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate53() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead53() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete53() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView54() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate54() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead54() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete54() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView55() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate55() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data'); + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead55() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete55() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView56() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate56() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead56() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete56() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView57() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate57() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead57() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete57() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView58() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate58() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead58() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete58() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView59() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate59() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead59() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete59() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView60() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate60() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead60() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete60() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView61() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate61() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead61() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete61() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView62() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate62() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead62() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete62() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView63() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate63() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead63() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete63() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView64() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate64() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead64() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete64() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView65() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead65() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete65() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView66() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate66() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead66() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete66() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView67() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead67() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete67() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView68() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate68() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead68() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete68() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView69() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead69() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete69() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView70() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate70() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead70() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete70() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView71() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead71() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete71() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView72() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate72() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead72() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete72() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView73() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead73() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete73() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView74() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate74() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead74() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete74() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView75() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead75() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete75() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView76() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate76() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead76() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete76() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView77() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead77() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete77() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView78() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate78() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead78() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete78() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView79() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead79() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete79() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView80() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate80() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead80() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete80() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView81() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead81() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete81() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView82() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate82() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead82() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete82() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView83() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead83() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete83() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView84() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate84() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead84() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete84() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView85() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead85() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete85() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView86() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate86() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead86() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete86() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView87() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead87() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete87() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView88() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate88() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead88() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete88() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView89() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead89() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete89() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView90() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate90() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead90() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete90() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView91() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead91() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete91() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView92() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate92() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead92() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete92() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView93() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead93() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete93() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView94() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate94() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead94() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete94() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView95() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead95() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete95() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView96() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate96() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead96() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete96() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView97() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead97() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete97() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView98() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate98() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead98() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete98() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView99() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead99() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete99() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView100() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate100() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead100() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete100() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView101() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead101() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete101() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView102() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate102() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead102() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete102() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView103() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead103() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete103() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView104() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate104() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead104() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete104() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView105() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead105() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete105() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView106() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate106() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead106() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete106() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView107() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead107() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete107() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView108() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate108() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead108() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete108() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView109() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead109() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete109() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView110() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate110() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead110() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete110() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView111() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead111() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete111() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView112() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate112() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead112() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete112() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView113() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead113() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete113() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView114() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate114() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead114() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete114() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView115() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead115() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete115() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView116() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate116() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead116() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete116() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView117() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead117() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete117() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView118() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate118() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead118() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete118() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView119() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead119() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete119() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView120() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate120() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead120() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete120() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView121() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead121() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete121() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView122() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate122() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead122() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete122() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView123() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead123() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete123() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView124() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate124() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead124() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete124() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView125() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead125() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete125() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView126() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate126() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead126() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete126() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView127() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testRead127() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete127() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView128() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate128() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead128() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete128() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView129() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate129() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead129() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete129() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView130() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate130() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead130() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete130() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView131() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate131() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead131() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete131() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView132() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate132() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead132() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete132() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView133() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate133() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead133() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete133() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView134() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate134() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead134() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete134() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView135() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate135() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead135() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete135() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView136() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate136() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead136() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete136() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView137() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate137() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead137() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete137() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView138() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate138() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead138() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete138() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView139() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate139() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead139() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete139() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView140() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate140() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead140() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete140() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView141() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate141() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead141() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete141() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView142() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate142() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead142() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete142() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView143() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate143() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead143() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete143() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView144() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate144() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead144() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete144() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView145() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate145() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead145() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete145() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView146() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate146() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead146() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete146() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView147() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate147() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead147() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete147() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView148() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate148() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead148() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete148() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView149() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate149() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead149() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete149() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView150() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate150() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead150() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete150() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView151() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate151() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead151() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete151() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView152() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate152() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead152() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete152() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView153() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate153() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead153() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete153() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView154() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate154() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead154() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete154() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView155() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate155() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead155() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete155() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView156() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate156() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead156() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete156() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView157() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate157() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead157() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete157() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView158() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate158() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead158() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete158() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView159() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate159() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead159() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete159() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView160() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate160() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead160() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete160() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView161() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate161() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead161() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete161() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView162() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate162() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead162() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete162() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView163() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate163() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead163() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete163() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView164() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate164() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead164() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete164() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView165() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate165() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead165() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete165() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView166() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate166() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead166() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete166() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView167() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate167() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead167() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete167() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView168() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate168() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead168() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete168() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView169() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate169() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead169() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete169() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView170() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate170() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead170() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete170() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView171() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate171() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead171() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete171() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView172() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate172() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead172() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete172() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView173() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate173() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead173() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete173() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView174() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate174() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead174() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete174() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView175() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate175() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead175() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete175() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView176() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate176() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead176() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete176() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView177() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate177() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead177() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete177() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView178() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate178() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead178() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete178() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView179() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate179() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead179() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete179() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView180() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate180() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead180() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete180() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView181() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate181() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead181() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete181() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView182() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate182() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead182() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete182() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView183() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate183() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead183() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete183() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView184() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate184() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead184() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete184() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView185() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate185() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead185() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete185() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView186() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate186() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead186() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete186() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView187() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate187() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead187() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete187() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly'); + $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView188() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate188() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + $_POST["opendiscussion"] = "neither 1 nor 0"; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created'); + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead188() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete188() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView189() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate189() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead189() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete189() + { + $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView190() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate190() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste'); + } + + /** + * @runInSeparateProcess + */ + public function testRead190() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete190() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testView191() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + ob_start(); + new zerobin; + $content = ob_get_contents(); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testCreate191() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $_POST = self::$paste; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(3); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + + $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste'); + $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testRead191() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); + } + + /** + * @runInSeparateProcess + */ + public function testDelete191() + { + $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), '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' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data'))); + $this->_model->create(self::$pasteid, self::$paste); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data'); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get()); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'status', + 'content' => 'Paste was properly deleted' + ), + $content, + 'outputs deleted status correctly' + ); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); + + $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly'); + $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly'); + $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly'); + $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly'); } } diff --git a/tst/zerobin.php b/tst/zerobin.php index c4fab6e4..3f64ad41 100644 --- a/tst/zerobin.php +++ b/tst/zerobin.php @@ -1,7 +1,7 @@ '{"iv":"EN39/wd5Nk8HAiSG2K5AsQ","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"QKN1DBXe5PI","ct":"8hA83xDdXjD7K2qfmw5NdA"}', @@ -11,6 +11,17 @@ class zerobinTest extends PHPUnit_Framework_TestCase ), ); + private static $commentid = '5a52eebf11c4c94b'; + + private static $comment = array( + 'data' => '{"iv":"Pd4pOKWkmDTT9uPwVwd5Ag","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"6nOCU3peNDclDDpFtJEBKA"}', + 'meta' => array( + 'nickname' => '{"iv":"76MkAtOGC4oFogX/aSMxRA","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"b6Ae/U1xJdsX/+lATud4sQ"}', + 'vizhash' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGUlEQVQokWOsl5/94983CNKQMjnxaOePf98MeKwPfNjkLZ3AgARab6b9+PeNEVnDj3/ff/z7ZiHnzsDA8Pv7H2TVPJw8EAYLAwb48OaVgIgYKycLsrYv378wMDB8//qdCVMDRA9EKSsnCwRBxNsepaLboMFlyMDAICAi9uHNK24GITQ/MDAwoNhgIGMLtwGrzegaLjw5jMz9+vUdnN17uwDCQDhJgk0O07yvX9+teDX1x79v6DYIsIjgcgMaYGFgYOBg4kJx2JejkAiBxAw+PzAwMNz4dp6wDXDw4MdNNOl0rWYsNkD89OLXI/xmo9sgzatJjAYmBgYGDiauD3/ePP18nVgb4MF89+M5ZX6js293wUMpnr8KTQMAxsCJnJ30apMAAAAASUVORK5CYII=', + 'postdate' => 1344803528, + ), + ); + private $_model; public function setUp() @@ -33,6 +44,9 @@ class zerobinTest extends PHPUnit_Framework_TestCase $_SERVER = array(); if ($this->_model->exists(self::$pasteid)) $this->_model->delete(self::$pasteid); + $conf = PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini'; + if (is_file($conf . '.bak')) + rename($conf . '.bak', $conf); } /** @@ -54,6 +68,63 @@ class zerobinTest extends PHPUnit_Framework_TestCase ); } + /** + * @runInSeparateProcess + */ + public function testHtaccess() + { + $this->reset(); + $dirs = array('cfg', 'lib'); + foreach ($dirs as $dir) { + $file = PATH . $dir . DIRECTORY_SEPARATOR . '.htaccess'; + @unlink($file); + } + ob_start(); + new zerobin; + $content = ob_get_contents(); + foreach ($dirs as $dir) { + $file = PATH . $dir . DIRECTORY_SEPARATOR . '.htaccess'; + $this->assertFileExists( + $file, + "$dir htaccess recreated" + ); + } + } + + /** + * @expectedException Exception + * @expectedExceptionCode 2 + */ + public function testConf() + { + $this->reset(); + $conf = PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini'; + if (!is_file($conf . '.bak') && is_file($conf)) + rename($conf, $conf . '.bak'); + file_put_contents($conf, ''); + ob_start(); + new zerobin; + $content = ob_get_contents(); + } + + /** + * @runInSeparateProcess + */ + public function testConfMissingExpireLabel() + { + $this->reset(); + $conf = PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini'; + $options = parse_ini_file($conf, true); + $options['expire_options']['foobar123'] = 10; + if (!is_file($conf . '.bak') && is_file($conf)) + rename($conf, $conf . '.bak'); + helper::createIniFile($conf, $options); + ini_set('magic_quotes_gpc', 1); + ob_start(); + new zerobin; + $content = ob_get_contents(); + } + /** * @runInSeparateProcess */ @@ -66,15 +137,199 @@ class zerobinTest extends PHPUnit_Framework_TestCase new zerobin; $content = ob_get_contents(); $response = json_decode($content, true); - $this->assertEquals($response['status'], 0, 'outputs status'); + $this->assertEquals(0, $response['status'], 'outputs status'); $this->assertEquals( - $response['deletetoken'], hash_hmac('sha1', $response['id'], serversalt::get()), + $response['deletetoken'], 'outputs valid delete token' ); $this->assertTrue($this->_model->exists($response['id']), 'paste exists after posting data'); } + /** + * @runInSeparateProcess + */ + public function testCreateValidExpire() + { + $this->reset(); + $_POST = self::$paste; + $_POST['expire'] = '5min'; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(11); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + $this->assertEquals(0, $response['status'], 'outputs status'); + $this->assertEquals( + hash_hmac('sha1', $response['id'], serversalt::get()), + $response['deletetoken'], + 'outputs valid delete token' + ); + $this->assertTrue($this->_model->exists($response['id']), 'paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testCreateInvalidExpire() + { + $this->reset(); + $_POST = self::$paste; + $_POST['expire'] = 'foo'; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(11); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + $this->assertEquals(0, $response['status'], 'outputs status'); + $this->assertEquals( + hash_hmac('sha1', $response['id'], serversalt::get()), + $response['deletetoken'], + 'outputs valid delete token' + ); + $this->assertTrue($this->_model->exists($response['id']), 'paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testCreateInvalidBurn() + { + $this->reset(); + $_POST = self::$paste; + $_POST['burnafterreading'] = 'neither 1 nor 0'; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(11); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + $this->assertEquals(1, $response['status'], 'outputs error status'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testCreateInvalidOpenDiscussion() + { + $this->reset(); + $_POST = self::$paste; + $_POST['opendiscussion'] = 'neither 1 nor 0'; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(11); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + $this->assertEquals(1, $response['status'], 'outputs error status'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testCreateValidNick() + { + $this->reset(); + $_POST = self::$paste; + $_POST['nickname'] = self::$comment['meta']['nickname']; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(11); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + $this->assertEquals(0, $response['status'], 'outputs status'); + $this->assertEquals( + hash_hmac('sha1', $response['id'], serversalt::get()), + $response['deletetoken'], + 'outputs valid delete token' + ); + $this->assertTrue($this->_model->exists($response['id']), 'paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testCreateInvalidNick() + { + $this->reset(); + $_POST = self::$paste; + $_POST['nickname'] = 'foo'; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(11); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + $this->assertEquals(1, $response['status'], 'outputs error status'); + $this->assertFalse($this->_model->exists(self::$pasteid), 'paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testCreateComment() + { + $this->reset(); + $_POST = self::$comment; + $_POST['pasteid'] = self::$pasteid; + $_POST['parentid'] = self::$pasteid; + $_SERVER['REMOTE_ADDR'] = '::1'; + $this->_model->create(self::$pasteid, self::$paste); + sleep(11); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + $this->assertEquals(0, $response['status'], 'outputs status'); + $this->assertTrue($this->_model->existsComment(self::$pasteid, self::$pasteid, $response['id']), 'paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testCreateCommentDiscussionDisabled() + { + $this->reset(); + $_POST = self::$comment; + $_POST['pasteid'] = self::$pasteid; + $_POST['parentid'] = self::$pasteid; + $_SERVER['REMOTE_ADDR'] = '::1'; + $paste = self::$paste; + $paste['meta']['opendiscussion'] = false; + $this->_model->create(self::$pasteid, $paste); + sleep(11); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + $this->assertEquals(1, $response['status'], 'outputs error status'); + $this->assertFalse($this->_model->existsComment(self::$pasteid, self::$pasteid, self::$commentid), 'paste exists after posting data'); + } + + /** + * @runInSeparateProcess + */ + public function testCreateCommentInvalidPaste() + { + $this->reset(); + $_POST = self::$comment; + $_POST['pasteid'] = self::$pasteid; + $_POST['parentid'] = self::$pasteid; + $_SERVER['REMOTE_ADDR'] = '::1'; + sleep(11); + ob_start(); + new zerobin; + $content = ob_get_contents(); + $response = json_decode($content, true); + $this->assertEquals(1, $response['status'], 'outputs error status'); + $this->assertFalse($this->_model->existsComment(self::$pasteid, self::$pasteid, self::$commentid), 'paste exists after posting data'); + } + /** * @runInSeparateProcess */ @@ -96,6 +351,92 @@ class zerobinTest extends PHPUnit_Framework_TestCase ); } + /** + * @runInSeparateProcess + */ + public function testReadInvalidId() + { + $this->reset(); + $_SERVER['QUERY_STRING'] = 'foo'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'errormessage', + 'content' => 'Invalid paste ID' + ), + $content, + 'outputs error correctly' + ); + } + + /** + * @runInSeparateProcess + */ + public function testReadNonexisting() + { + $this->reset(); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'errormessage', + 'content' => 'Paste does not exist' + ), + $content, + 'outputs error correctly' + ); + } + + /** + * @runInSeparateProcess + */ + public function testReadExpired() + { + $this->reset(); + $expiredPaste = self::$paste; + $expiredPaste['meta']['expire_date'] = $expiredPaste['meta']['postdate']; + $this->_model->create(self::$pasteid, $expiredPaste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'errormessage', + 'content' => 'Paste does not exist' + ), + $content, + 'outputs error correctly' + ); + } + + /** + * @runInSeparateProcess + */ + public function testReadBurn() + { + $this->reset(); + $burnPaste = self::$paste; + $burnPaste['meta']['burnafterreading'] = true; + $this->_model->create(self::$pasteid, $burnPaste); + $_SERVER['QUERY_STRING'] = self::$pasteid; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'cipherdata', + 'content' => htmlspecialchars(json_encode($burnPaste), ENT_NOQUOTES) + ), + $content, + 'outputs data correctly' + ); + } + /** * @runInSeparateProcess */ @@ -119,4 +460,71 @@ class zerobinTest extends PHPUnit_Framework_TestCase ); $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted'); } + + /** + * @runInSeparateProcess + */ + public function testDeleteInvalidId() + { + $this->reset(); + $this->_model->create(self::$pasteid, self::$paste); + $_GET['pasteid'] = 'foo'; + $_GET['deletetoken'] = 'bar'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'errormessage', + 'content' => 'Invalid paste ID' + ), + $content, + 'outputs delete error correctly' + ); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists after failing to delete data'); + } + + /** + * @runInSeparateProcess + */ + public function testDeleteInexistantId() + { + $this->reset(); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = 'bar'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'errormessage', + 'content' => 'Paste does not exist' + ), + $content, + 'outputs delete error correctly' + ); + } + + /** + * @runInSeparateProcess + */ + public function testDeleteInvalidToken() + { + $this->reset(); + $this->_model->create(self::$pasteid, self::$paste); + $_GET['pasteid'] = self::$pasteid; + $_GET['deletetoken'] = 'bar'; + ob_start(); + new zerobin; + $content = ob_get_contents(); + $this->assertTag( + array( + 'id' => 'errormessage', + 'content' => 'Wrong deletion token' + ), + $content, + 'outputs delete error correctly' + ); + $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists after failing to delete data'); + } } \ No newline at end of file diff --git a/tst/zerobin/data.php b/tst/zerobin/data.php index 0dce94ef..3e49643a 100644 --- a/tst/zerobin/data.php +++ b/tst/zerobin/data.php @@ -1,7 +1,7 @@ '{"iv":"EN39/wd5Nk8HAiSG2K5AsQ","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"QKN1DBXe5PI","ct":"8hA83xDdXjD7K2qfmw5NdA"}', @@ -12,7 +12,7 @@ class zerobin_dataTest extends PHPUnit_Framework_TestCase ), ); - private static $commentid = 'c47efb4741195f42'; + private static $commentid = '5a52eebf11c4c94b'; private static $comment = array( 'data' => '{"iv":"Pd4pOKWkmDTT9uPwVwd5Ag","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"6nOCU3peNDclDDpFtJEBKA"}', diff --git a/tst/zerobin/db.php b/tst/zerobin/db.php index 94176da8..4bea54a5 100644 --- a/tst/zerobin/db.php +++ b/tst/zerobin/db.php @@ -1,7 +1,7 @@ '{"iv":"EN39/wd5Nk8HAiSG2K5AsQ","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"QKN1DBXe5PI","ct":"8hA83xDdXjD7K2qfmw5NdA"}', @@ -12,7 +12,7 @@ class zerobin_dbTest extends PHPUnit_Framework_TestCase ), ); - private static $commentid = 'c47efb4741195f42'; + private static $commentid = '5a52eebf11c4c94b'; private static $comment = array( 'data' => '{"iv":"Pd4pOKWkmDTT9uPwVwd5Ag","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"ZIUhFTliVz4","ct":"6nOCU3peNDclDDpFtJEBKA"}',