From cd0f7b26ea95f280d952530a54f3a8af362818fb Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 26 Dec 2019 13:48:07 +0200 Subject: [PATCH] Added unit test for template lib --- tests/resources/template.tpl | 1 + tests/unit/Template/TemplateTest.php | 56 ++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 tests/resources/template.tpl create mode 100644 tests/unit/Template/TemplateTest.php 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