mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
To PSR-x format
This commit is contained in:
@@ -3,87 +3,97 @@ namespace Fenom;
|
||||
use Fenom;
|
||||
use Fenom\TestCase;
|
||||
|
||||
class ProviderTest extends TestCase {
|
||||
class ProviderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Provider
|
||||
*/
|
||||
public $provider;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->tpl("template1.tpl", 'Template 1 {$a}');
|
||||
$this->tpl("template2.tpl", 'Template 2 {$a}');
|
||||
$this->tpl("sub/template3.tpl", 'Template 3 {$a}');
|
||||
$this->provider = new Provider(FENOM_RESOURCES.'/template');
|
||||
$this->provider = new Provider(FENOM_RESOURCES . '/template');
|
||||
clearstatcache();
|
||||
}
|
||||
|
||||
public function testIsTemplateExists() {
|
||||
public function testIsTemplateExists()
|
||||
{
|
||||
clearstatcache();
|
||||
$this->assertTrue($this->provider->templateExists("template1.tpl"));
|
||||
$this->assertFalse($this->provider->templateExists("unexists.tpl"));
|
||||
}
|
||||
|
||||
public function testGetSource() {
|
||||
public function testGetSource()
|
||||
{
|
||||
clearstatcache();
|
||||
$src = $this->provider->getSource("template1.tpl", $time);
|
||||
clearstatcache();
|
||||
$this->assertEquals(file_get_contents(FENOM_RESOURCES.'/template/template1.tpl'), $src);
|
||||
$this->assertEquals(filemtime(FENOM_RESOURCES.'/template/template1.tpl'), $time);
|
||||
$this->assertEquals(file_get_contents(FENOM_RESOURCES . '/template/template1.tpl'), $src);
|
||||
$this->assertEquals(filemtime(FENOM_RESOURCES . '/template/template1.tpl'), $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testGetSourceInvalid() {
|
||||
public function testGetSourceInvalid()
|
||||
{
|
||||
$this->provider->getSource("unexists.tpl", $time);
|
||||
}
|
||||
|
||||
public function testGetLastModified() {
|
||||
public function testGetLastModified()
|
||||
{
|
||||
$time = $this->provider->getLastModified("template1.tpl");
|
||||
clearstatcache();
|
||||
$this->assertEquals(filemtime(FENOM_RESOURCES.'/template/template1.tpl'), $time);
|
||||
$this->assertEquals(filemtime(FENOM_RESOURCES . '/template/template1.tpl'), $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testGetLastModifiedInvalid() {
|
||||
public function testGetLastModifiedInvalid()
|
||||
{
|
||||
$this->provider->getLastModified("unexists.tpl");
|
||||
}
|
||||
|
||||
public function testVerify() {
|
||||
public function testVerify()
|
||||
{
|
||||
$templates = array(
|
||||
"template1.tpl" => filemtime(FENOM_RESOURCES.'/template/template1.tpl'),
|
||||
"template2.tpl" => filemtime(FENOM_RESOURCES.'/template/template2.tpl')
|
||||
"template1.tpl" => filemtime(FENOM_RESOURCES . '/template/template1.tpl'),
|
||||
"template2.tpl" => filemtime(FENOM_RESOURCES . '/template/template2.tpl')
|
||||
);
|
||||
clearstatcache();
|
||||
$this->assertTrue($this->provider->verify($templates));
|
||||
clearstatcache();
|
||||
$templates = array(
|
||||
"template2.tpl" => filemtime(FENOM_RESOURCES.'/template/template2.tpl'),
|
||||
"template1.tpl" => filemtime(FENOM_RESOURCES.'/template/template1.tpl')
|
||||
"template2.tpl" => filemtime(FENOM_RESOURCES . '/template/template2.tpl'),
|
||||
"template1.tpl" => filemtime(FENOM_RESOURCES . '/template/template1.tpl')
|
||||
);
|
||||
clearstatcache();
|
||||
$this->assertTrue($this->provider->verify($templates));
|
||||
}
|
||||
|
||||
public function testVerifyInvalid() {
|
||||
public function testVerifyInvalid()
|
||||
{
|
||||
$templates = array(
|
||||
"template1.tpl" => filemtime(FENOM_RESOURCES.'/template/template1.tpl'),
|
||||
"template2.tpl" => filemtime(FENOM_RESOURCES.'/template/template2.tpl') + 1
|
||||
"template1.tpl" => filemtime(FENOM_RESOURCES . '/template/template1.tpl'),
|
||||
"template2.tpl" => filemtime(FENOM_RESOURCES . '/template/template2.tpl') + 1
|
||||
);
|
||||
clearstatcache();
|
||||
$this->assertFalse($this->provider->verify($templates));
|
||||
clearstatcache();
|
||||
$templates = array(
|
||||
"template1.tpl" => filemtime(FENOM_RESOURCES.'/template/template1.tpl'),
|
||||
"template1.tpl" => filemtime(FENOM_RESOURCES . '/template/template1.tpl'),
|
||||
"unexists.tpl" => 1234567890
|
||||
);
|
||||
$this->assertFalse($this->provider->verify($templates));
|
||||
}
|
||||
|
||||
public function testGetAll() {
|
||||
public function testGetAll()
|
||||
{
|
||||
$list = $this->provider->getList();
|
||||
sort($list);
|
||||
$this->assertSame(array(
|
||||
|
||||
Reference in New Issue
Block a user