2015-08-15 12:32:31 -04:00
|
|
|
<?php
|
|
|
|
class RainTPLTest extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
private static $error = 'foo bar';
|
|
|
|
|
|
|
|
private static $status = '!*#@?$+';
|
|
|
|
|
|
|
|
private static $expire = array(
|
|
|
|
'5min' => '5 minutes',
|
|
|
|
'1hour' => '1 hour',
|
|
|
|
'never' => 'Never',
|
|
|
|
);
|
|
|
|
|
|
|
|
private static $expire_default = '1hour';
|
|
|
|
|
|
|
|
private static $version = 'Version 1.2.3';
|
|
|
|
|
|
|
|
private $_content;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
/* Setup Routine */
|
|
|
|
$page = new RainTPL;
|
|
|
|
$page::configure(array('cache_dir' => 'tmp/'));
|
2015-08-16 06:27:06 -04:00
|
|
|
$page::$path_replace = false;
|
2015-08-15 12:32:31 -04:00
|
|
|
|
|
|
|
// We escape it here because ENT_NOQUOTES can't be used in RainTPL templates.
|
2015-09-21 16:32:52 -04:00
|
|
|
$page->assign('CIPHERDATA', htmlspecialchars(helper::getPaste()['data'], ENT_NOQUOTES));
|
2015-08-15 12:32:31 -04:00
|
|
|
$page->assign('ERROR', self::$error);
|
|
|
|
$page->assign('STATUS', self::$status);
|
|
|
|
$page->assign('VERSION', self::$version);
|
2015-08-30 18:01:35 -04:00
|
|
|
$page->assign('DISCUSSION', true);
|
|
|
|
$page->assign('OPENDISCUSSION', true);
|
2015-09-12 11:33:16 -04:00
|
|
|
$page->assign('MARKDOWN', true);
|
2015-08-15 12:32:31 -04:00
|
|
|
$page->assign('SYNTAXHIGHLIGHTING', true);
|
2015-08-17 17:18:33 -04:00
|
|
|
$page->assign('SYNTAXHIGHLIGHTINGTHEME', 'sons-of-obsidian');
|
2015-08-30 18:01:35 -04:00
|
|
|
$page->assign('BURNAFTERREADINGSELECTED', false);
|
|
|
|
$page->assign('PASSWORD', true);
|
2015-09-16 16:51:48 -04:00
|
|
|
$page->assign('FILEUPLOAD', false);
|
2015-08-16 06:27:06 -04:00
|
|
|
$page->assign('BASE64JSVERSION', '2.1.9');
|
2015-08-17 17:18:33 -04:00
|
|
|
$page->assign('NOTICE', 'example');
|
2015-09-19 11:23:10 -04:00
|
|
|
$page->assign('LANGUAGESELECTION', '');
|
|
|
|
$page->assign('LANGUAGES', i18n::getLanguageLabels(i18n::getAvailableLanguages()));
|
2015-08-15 12:32:31 -04:00
|
|
|
$page->assign('EXPIRE', self::$expire);
|
|
|
|
$page->assign('EXPIREDEFAULT', self::$expire_default);
|
|
|
|
ob_start();
|
|
|
|
$page->draw('page');
|
|
|
|
$this->_content = ob_get_contents();
|
|
|
|
// run a second time from cache
|
|
|
|
$page->cache('page');
|
|
|
|
$page->draw('page');
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
/* Tear Down Routine */
|
|
|
|
helper::rmdir(PATH . 'tmp');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testTemplateRendersCorrectly()
|
|
|
|
{
|
|
|
|
$this->assertTag(
|
|
|
|
array(
|
|
|
|
'id' => 'cipherdata',
|
2015-09-21 16:32:52 -04:00
|
|
|
'content' => htmlspecialchars(helper::getPaste()['data'], ENT_NOQUOTES)
|
2015-08-15 12:32:31 -04:00
|
|
|
),
|
|
|
|
$this->_content,
|
|
|
|
'outputs data correctly'
|
|
|
|
);
|
|
|
|
$this->assertTag(
|
|
|
|
array(
|
|
|
|
'id' => 'errormessage',
|
|
|
|
'content' => self::$error
|
|
|
|
),
|
|
|
|
$this->_content,
|
|
|
|
'outputs error correctly'
|
|
|
|
);
|
2015-08-30 18:01:35 -04:00
|
|
|
$this->assertTag(
|
|
|
|
array(
|
|
|
|
'id' => 'password',
|
|
|
|
),
|
|
|
|
$this->_content,
|
|
|
|
'password available if configured'
|
|
|
|
);
|
2015-08-15 12:32:31 -04:00
|
|
|
$this->assertTag(
|
|
|
|
array(
|
|
|
|
'id' => 'opendiscussion',
|
|
|
|
'attributes' => array(
|
2015-08-30 18:01:35 -04:00
|
|
|
'checked' => 'checked'
|
2015-08-15 12:32:31 -04:00
|
|
|
),
|
|
|
|
),
|
|
|
|
$this->_content,
|
2015-08-30 18:01:35 -04:00
|
|
|
'checked discussion if configured'
|
|
|
|
);
|
|
|
|
$this->assertTag(
|
|
|
|
array(
|
|
|
|
'id' => 'opendisc',
|
|
|
|
),
|
|
|
|
$this->_content,
|
|
|
|
'discussions available if configured'
|
2015-08-15 12:32:31 -04:00
|
|
|
);
|
|
|
|
// testing version number in JS address, since other instances may not be present in different templates
|
|
|
|
$this->assertTag(
|
|
|
|
array(
|
|
|
|
'tag' => 'script',
|
|
|
|
'attributes' => array(
|
|
|
|
'src' => 'js/zerobin.js?' . rawurlencode(self::$version)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
$this->_content,
|
|
|
|
'outputs version correctly'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException RainTpl_Exception
|
|
|
|
*/
|
|
|
|
public function testMissingTemplate()
|
|
|
|
{
|
|
|
|
$test = new RainTPL;
|
|
|
|
$test->draw('123456789 does not exist!');
|
|
|
|
}
|
|
|
|
}
|