Hacking away to get coverage up
Finished up all the low hanging fruit (working the classes I already started that were just shy of 100% coverage). Just shy of 80% coverage at this point.
This commit is contained in:
parent
38d5b503c8
commit
62133dc1ca
4 changed files with 150 additions and 41 deletions
|
@ -11,7 +11,8 @@ $root = org\bovigo\vfs\vfsStream::setup('site');
|
|||
|
||||
if (!defined('SITE_PATH'))
|
||||
{
|
||||
define('SECURITY_LEVEL_USER', 10);
|
||||
define('SECURITY_LEVEL_USER', 10);
|
||||
define('SECURITY_LEVEL_ADMIN', 20);
|
||||
define('SITE_PATH', org\bovigo\vfs\vfsStream::url('site/'));
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
|||
$this->config->data['pickles']['disabled'] = false;
|
||||
$this->config->data['pickles']['profiler'] = false;
|
||||
$this->config->data['security']['levels'][10] = 'USER';
|
||||
$this->config->data['security']['levels'][20] = 'ADMIN';
|
||||
|
||||
setUpRequest('home');
|
||||
|
||||
|
@ -100,7 +101,90 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
file_put_contents(SITE_MODULE_PATH . 'notauth.php', $module);
|
||||
|
||||
@new Controller();
|
||||
new Controller();
|
||||
|
||||
// Compensates for an empty template due to exit() being skipped
|
||||
$this->expectOutputString('[]');
|
||||
|
||||
$this->assertTrue(in_array('Location: http://testsite.com/login', xdebug_get_headers()));
|
||||
}
|
||||
|
||||
public function testSecurityArray()
|
||||
{
|
||||
setUpRequest('securityarray');
|
||||
|
||||
$module = '<?php class securityarray extends Module { public $security = [SECURITY_LEVEL_USER, SECURITY_LEVEL_ADMIN]; } ?>';
|
||||
|
||||
file_put_contents(SITE_MODULE_PATH . 'securityarray.php', $module);
|
||||
|
||||
new Controller();
|
||||
|
||||
// Compensates for an empty template due to exit() being skipped
|
||||
$this->expectOutputString('[]');
|
||||
|
||||
$this->assertTrue(in_array('Location: http://testsite.com/login', xdebug_get_headers()));
|
||||
}
|
||||
|
||||
public function testSecurityArrayTypeString()
|
||||
{
|
||||
setUpRequest('securityarraytypestring');
|
||||
|
||||
$module = '<?php class securityarraytypestring extends Module { public $security = ["type" => "IS", "level" => SECURITY_LEVEL_USER]; } ?>';
|
||||
|
||||
file_put_contents(SITE_MODULE_PATH . 'securityarraytypestring.php', $module);
|
||||
|
||||
new Controller();
|
||||
|
||||
// Compensates for an empty template due to exit() being skipped
|
||||
$this->expectOutputString('[]');
|
||||
|
||||
$this->assertTrue(in_array('Location: http://testsite.com/login', xdebug_get_headers()));
|
||||
}
|
||||
|
||||
public function testSecurityArrayTypeArray()
|
||||
{
|
||||
setUpRequest('securityarraytypearray');
|
||||
|
||||
$module = '<?php class securityarraytypearray extends Module { public $security = ["type" => "IS", "level" => [SECURITY_LEVEL_USER, SECURITY_LEVEL_ADMIN]]; } ?>';
|
||||
|
||||
file_put_contents(SITE_MODULE_PATH . 'securityarraytypearray.php', $module);
|
||||
|
||||
new Controller();
|
||||
|
||||
// Compensates for an empty template due to exit() being skipped
|
||||
$this->expectOutputString('[]');
|
||||
|
||||
$this->assertTrue(in_array('Location: http://testsite.com/login', xdebug_get_headers()));
|
||||
}
|
||||
|
||||
public function testSecurityArrayTypeBetween()
|
||||
{
|
||||
setUpRequest('securityarraytypebetween');
|
||||
|
||||
$module = '<?php class securityarraytypebetween extends Module { public $security = ["type" => "BETWEEN", "levels" => [SECURITY_LEVEL_USER, SECURITY_LEVEL_ADMIN]]; } ?>';
|
||||
|
||||
file_put_contents(SITE_MODULE_PATH . 'securityarraytypebetween.php', $module);
|
||||
|
||||
new Controller();
|
||||
|
||||
// Compensates for an empty template due to exit() being skipped
|
||||
$this->expectOutputString('[]');
|
||||
|
||||
$this->assertTrue(in_array('Location: http://testsite.com/login', xdebug_get_headers()));
|
||||
}
|
||||
|
||||
public function testSecurityArrayTypeHas()
|
||||
{
|
||||
setUpRequest('securityarraytypehas');
|
||||
|
||||
$module = '<?php class securityarraytypehas extends Module { public $security = ["type" => "HAS", "level" => SECURITY_LEVEL_USER]; } ?>';
|
||||
|
||||
file_put_contents(SITE_MODULE_PATH . 'securityarraytypehas.php', $module);
|
||||
|
||||
new Controller();
|
||||
|
||||
// Compensates for an empty template due to exit() being skipped
|
||||
$this->expectOutputString('[]');
|
||||
|
||||
$this->assertTrue(in_array('Location: http://testsite.com/login', xdebug_get_headers()));
|
||||
}
|
||||
|
@ -153,16 +237,32 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
|||
$this->expectOutputString('{"user":"me"}');
|
||||
}
|
||||
|
||||
public function testBadRequestMethod()
|
||||
public function testValidRequestMethod()
|
||||
{
|
||||
setUpRequest('requestmethod');
|
||||
setUpRequest('validrequestmethod');
|
||||
|
||||
$module = '<?php class requestmethod extends Module { '
|
||||
$module = '<?php class validrequestmethod extends Module { '
|
||||
. 'public $method = "GET";'
|
||||
. 'public function __default() { return ["foo" => "bar"]; }'
|
||||
. '} ?>';
|
||||
|
||||
file_put_contents(SITE_MODULE_PATH . 'validrequestmethod.php', $module);
|
||||
|
||||
new Controller();
|
||||
|
||||
$this->expectOutputString('{"foo":"bar"}');
|
||||
}
|
||||
|
||||
public function testInvalidRequestMethod()
|
||||
{
|
||||
setUpRequest('invalidrequestmethod');
|
||||
|
||||
$module = '<?php class invalidrequestmethod extends Module { '
|
||||
. 'public $method = "POST";'
|
||||
. 'public function __default() { return ["foo" => "bar"]; }'
|
||||
. '} ?>';
|
||||
|
||||
file_put_contents(SITE_MODULE_PATH . 'requestmethod.php', $module);
|
||||
file_put_contents(SITE_MODULE_PATH . 'invalidrequestmethod.php', $module);
|
||||
|
||||
new Controller();
|
||||
|
||||
|
@ -215,6 +315,45 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
|||
|
||||
new Controller();
|
||||
}
|
||||
|
||||
public function testTwoValidTemplates()
|
||||
{
|
||||
$this->config->data['pickles']['profiler'] = true;
|
||||
|
||||
setUpRequest('validtemplates');
|
||||
|
||||
$module = '<?php class validtemplates extends Module { } ?>';
|
||||
|
||||
file_put_contents(SITE_MODULE_PATH . 'validtemplates.php', $module);
|
||||
|
||||
$child_template = SITE_TEMPLATE_PATH . 'validtemplates.phtml';
|
||||
file_put_contents($child_template, '<div>child template</div>');
|
||||
|
||||
// Vim syntax highlighting borks unless ----v
|
||||
$child = '<?php require $this->template; ?' . '>' . "\n";
|
||||
|
||||
$html = <<<HTML
|
||||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
<h1>parent template</h1>
|
||||
{$child}
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
|
||||
file_put_contents(SITE_TEMPLATE_PATH . '__shared/index.phtml', $html);
|
||||
|
||||
new Controller();
|
||||
|
||||
$this->expectOutputRegex('/^<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
<h1>parent template<\/h1>
|
||||
<div>child template<\/div>
|
||||
<\/body>
|
||||
<\/html>.+<style>/');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -62,35 +62,6 @@ class DisplayTest extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals($this->child_html, $this->display->render());
|
||||
}
|
||||
|
||||
public function testRenderTemplate()
|
||||
{
|
||||
$child_template = SITE_TEMPLATE_PATH . 'test.phtml';
|
||||
file_put_contents($child_template, $this->child_html);
|
||||
|
||||
// Vim syntax highlighting borks unless ----v
|
||||
$child = '<?php require $this->template; ?' . '>' . "\n";
|
||||
|
||||
$html = <<<HTML
|
||||
<!doctype html>
|
||||
<html>
|
||||
<body>
|
||||
<!-- BuySellAds Unstripped Comment -->
|
||||
<h1>parent template</h1>
|
||||
{$child}
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
|
||||
$parent_template = $this->shared_templates . 'index.phtml';
|
||||
file_put_contents($parent_template, $html);
|
||||
|
||||
$html = str_replace($child, $this->child_html, $html);
|
||||
$html = preg_replace(['/^[\s]+/m', '/<!--(?:(?!BuySellAds).)+-->/U'], '', $html);
|
||||
|
||||
$this->display->templates = [$parent_template, $child_template];
|
||||
$this->assertEquals($html, $this->display->render());
|
||||
}
|
||||
|
||||
public function testRenderJSON()
|
||||
{
|
||||
$this->assertEquals(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue