paste.chapril.org-privatebin/tst/configuration.php

127 lines
7.9 KiB
PHP

<?php
/**
* DO NOT EDIT: This file is automatically generated by configGenerator.php
*/
class configTest extends PHPUnit_Framework_TestCase
{
private static $pasteid = '501f02e9eeb8bcec';
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"}',
'meta' => array(
'postdate' => 1344803344,
'opendiscussion' => true,
),
);
private $_model;
private $_conf;
public function setUp()
{
/* Setup Routine */
$this->_conf = PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini';
if (!is_file($this->_conf . '.bak') && is_file($this->_conf))
rename($this->_conf, $this->_conf . '.bak');
$this->_model = zerobin_data::getInstance(array('dir' => PATH . 'data'));
serversalt::setPath(PATH . 'data');
$this->reset();
}
public function tearDown()
{
/* Tear Down Routine */
rename($this->_conf . '.bak', $this->_conf);
}
public function reset($configuration = array())
{
$_POST = array();
$_GET = array();
$_SERVER = array();
if ($this->_model->exists(self::$pasteid))
$this->_model->delete(self::$pasteid);
// generate configuration file
if (count($configuration)) {
@unlink($this->_conf);
$c = fopen($this->_conf, 'a');
foreach ($configuration as $section => $options) {
fwrite($c, "[$section]" . PHP_EOL);
foreach($options as $option => $setting) {
if (is_string($setting)) {
$setting = '"' . $setting . '"';
} else {
$setting = var_export($setting, true);
}
fwrite($c, "$option = $setting" . PHP_EOL);
}
fwrite($c, PHP_EOL);
}
fclose($c);
}
}
/**
* @runInSeparateProcess
*/
public function testView0()
{
$this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => '10', 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
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 stylesheet correctly');
$this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'outputs javascript correctly');
}
/**
* @runInSeparateProcess
*/
public function testView1()
{
$this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => '10', 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
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 stylesheet correctly');
$this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'outputs javascript correctly');
}
/**
* @runInSeparateProcess
*/
public function testView2()
{
$this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => '10', 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
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 stylesheet correctly');
$this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'removes javascript correctly');
}
/**
* @runInSeparateProcess
*/
public function testView3()
{
$this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => '', 'sizelimit' => '2097152', 'template' => 'bootstrap', 'base64version' => '2.1.9'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => '10', 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
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 stylesheet correctly');
$this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify.js#')), $content, 'removes javascript correctly');
}
}