updated View test to test every available template instead of just the page one
This commit is contained in:
parent
228280e3d6
commit
06496f2ede
@ -27,7 +27,7 @@ class ViewTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
private static $version = 'Version 1.2.3';
|
private static $version = 'Version 1.2.3';
|
||||||
|
|
||||||
private $_content;
|
private $_content = array();
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
@ -56,10 +56,17 @@ class ViewTest extends PHPUnit_Framework_TestCase
|
|||||||
$page->assign('EXPIREDEFAULT', self::$expire_default);
|
$page->assign('EXPIREDEFAULT', self::$expire_default);
|
||||||
$page->assign('EXPIRECLONE', true);
|
$page->assign('EXPIRECLONE', true);
|
||||||
$page->assign('URLSHORTENER', '');
|
$page->assign('URLSHORTENER', '');
|
||||||
ob_start();
|
|
||||||
$page->draw('page');
|
$dir = dir(PATH . 'tpl');
|
||||||
$this->_content = ob_get_contents();
|
while (false !== ($file = $dir->read())) {
|
||||||
ob_end_clean();
|
if (substr($file, -4) === '.php') {
|
||||||
|
$template = substr($file, 0, -4);
|
||||||
|
ob_start();
|
||||||
|
$page->draw($template);
|
||||||
|
$this->_content[$template] = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
@ -69,39 +76,41 @@ class ViewTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testTemplateRendersCorrectly()
|
public function testTemplateRendersCorrectly()
|
||||||
{
|
{
|
||||||
$this->assertContains(
|
foreach ($this->_content as $template => $content) {
|
||||||
'<div id="cipherdata" class="hidden">' .
|
$this->assertContains(
|
||||||
htmlspecialchars(Helper::getPaste()['data'], ENT_NOQUOTES) .
|
'<div id="cipherdata" class="hidden">' .
|
||||||
'</div>',
|
htmlspecialchars(Helper::getPaste()['data'], ENT_NOQUOTES) .
|
||||||
$this->_content,
|
'</div>',
|
||||||
'outputs data correctly'
|
$content,
|
||||||
);
|
$template . ': outputs data correctly'
|
||||||
$this->assertRegExp(
|
);
|
||||||
'#<div[^>]+id="errormessage"[^>]*>.*' . self::$error . '</div>#',
|
$this->assertRegExp(
|
||||||
$this->_content,
|
'#<div[^>]+id="errormessage"[^>]*>.*' . self::$error . '</div>#',
|
||||||
'outputs error correctly'
|
$content,
|
||||||
);
|
$template . ': outputs error correctly'
|
||||||
$this->assertRegExp(
|
);
|
||||||
'#<[^>]+id="password"[^>]*>#',
|
$this->assertRegExp(
|
||||||
$this->_content,
|
'#<[^>]+id="password"[^>]*>#',
|
||||||
'password available if configured'
|
$content,
|
||||||
);
|
$template . ': password available if configured'
|
||||||
$this->assertRegExp(
|
);
|
||||||
'#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
|
$this->assertRegExp(
|
||||||
$this->_content,
|
'#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
|
||||||
'checked discussion if configured'
|
$content,
|
||||||
);
|
$template . ': checked discussion if configured'
|
||||||
$this->assertRegExp(
|
);
|
||||||
'#<[^>]+id="opendisc"[^>]*>#',
|
$this->assertRegExp(
|
||||||
$this->_content,
|
'#<[^>]+id="opendisc"[^>]*>#',
|
||||||
'discussions available if configured'
|
$content,
|
||||||
);
|
$template . ': discussions available if configured'
|
||||||
// testing version number in JS address, since other instances may not be present in different templates
|
);
|
||||||
$this->assertRegExp(
|
// testing version number in JS address, since other instances may not be present in different templates
|
||||||
'#<script[^>]+src="js/privatebin.js\\?' . rawurlencode(self::$version) . '"[^>]*>#',
|
$this->assertRegExp(
|
||||||
$this->_content,
|
'#<script[^>]+src="js/privatebin.js\\?' . rawurlencode(self::$version) . '"[^>]*>#',
|
||||||
'outputs version correctly'
|
$content,
|
||||||
);
|
$template . ': outputs version correctly'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user