Added unit test for template lib
This commit is contained in:
parent
350321601d
commit
cd0f7b26ea
2 changed files with 57 additions and 0 deletions
1
tests/resources/template.tpl
Normal file
1
tests/resources/template.tpl
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Hello {{world}}
|
56
tests/unit/Template/TemplateTest.php
Normal file
56
tests/unit/Template/TemplateTest.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Tests;
|
||||||
|
|
||||||
|
use Template\Template;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class TemplateTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Cron
|
||||||
|
*/
|
||||||
|
protected $object = null;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->object = new Template(__DIR__.'/../../resources/template.tpl');
|
||||||
|
$this->object
|
||||||
|
->setParam('{{world}}', 'WORLD')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRender()
|
||||||
|
{
|
||||||
|
$this->assertEquals($this->object->render(), 'Hello WORLD');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testParseURL()
|
||||||
|
{
|
||||||
|
$url = $this->object->parseURL('https://appwrite.io/demo');
|
||||||
|
|
||||||
|
$this->assertEquals($url['scheme'], 'https');
|
||||||
|
$this->assertEquals($url['host'], 'appwrite.io');
|
||||||
|
$this->assertEquals($url['path'], '/demo');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUnParseURL()
|
||||||
|
{
|
||||||
|
$url = $this->object->parseURL('https://appwrite.io/demo');
|
||||||
|
|
||||||
|
$url['scheme'] = 'http';
|
||||||
|
$url['host'] = 'example.com';
|
||||||
|
$url['path'] = '/new';
|
||||||
|
|
||||||
|
$this->assertEquals($this->object->unParseURL($url), 'http://example.com/new');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMergeQuery()
|
||||||
|
{
|
||||||
|
$this->assertEquals($this->object->mergeQuery('key1=value1&key2=value2', ['key1' => 'value3', 'key4' => 'value4']), 'key1=value3&key2=value2&key4=value4');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue