fenom/tests/cases/Aspect/RenderTest.php

51 lines
1.3 KiB
PHP
Raw Normal View History

2013-01-25 18:36:16 +04:00
<?php
namespace Aspect;
use Aspect,
Aspect\Render;
class RenderTest extends \PHPUnit_Framework_TestCase {
/**
* @var Render
*/
public static $render;
public static function setUpBeforeClass() {
self::$render = new Render("render.tpl", function ($tpl) {
echo "It is render function ".$tpl["render"];
});
}
public function testCreate() {
$r = new Render("test.render.tpl", function () {
echo "Test render";
});
$this->assertSame("Test render", $r->fetch(array()));
}
public function testDisplay() {
ob_start();
self::$render->display(array("render" => "display"));
$out = ob_get_clean();
$this->assertSame("It is render function display", $out);
}
public function testFetch() {
$this->assertSame("It is render function fetch", self::$render->fetch(array("render" => "fetch")));
}
/**
* @expectedException RuntimeException
* @expectedExceptionMessage template error
*/
public function testFetchException() {
$render = new Render("render.tpl", function ($tpl) {
echo "error";
throw new \RuntimeException("template error");
});
$render->fetch(array());
}
}