diff --git a/tests/resources/template.tpl b/tests/resources/template.tpl new file mode 100644 index 000000000..3a12d0d83 --- /dev/null +++ b/tests/resources/template.tpl @@ -0,0 +1 @@ +Hello {{world}} \ No newline at end of file diff --git a/tests/unit/Template/TemplateTest.php b/tests/unit/Template/TemplateTest.php new file mode 100644 index 000000000..cb16c9873 --- /dev/null +++ b/tests/unit/Template/TemplateTest.php @@ -0,0 +1,56 @@ +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'); + } +} \ No newline at end of file