Skip to content

Commit 21754c5

Browse files
committed
Add tests
1 parent 26ca10b commit 21754c5

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

ci_instance.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767

6868
load_class('Loader', 'core');
6969
load_class('Router', 'core');
70+
load_class('Output', 'core');
7071
load_class('Input', 'core');
7172
load_class('Lang', 'core');
7273

tests/libraries/TwigTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
class TwigTest extends PHPUnit_Framework_TestCase
4+
{
5+
public static function setUpBeforeClass()
6+
{
7+
parent::setUpBeforeClass();
8+
$CI =& get_instance();
9+
$CI->load->library('Twig');
10+
$CI->load->helper('url_helper');
11+
$CI->load->helper('form_helper');
12+
}
13+
14+
public function testRedner()
15+
{
16+
$obj = new Twig(['paths' => __DIR__ . '/../templates/']);
17+
18+
$data = [
19+
'name' => 'CodeIgniter',
20+
];
21+
$output = $obj->render('welcome', $data);
22+
$this->assertEquals('Hello CodeIgniter!'."\n", $output);
23+
}
24+
25+
public function testDisplay()
26+
{
27+
$obj = new Twig(['paths' => __DIR__ . '/../templates/']);
28+
29+
$data = [
30+
'name' => 'CodeIgniter',
31+
];
32+
$obj->display('welcome', $data);
33+
$CI =& get_instance();
34+
$output = $CI->output->get_output();
35+
$this->assertEquals('Hello CodeIgniter!'."\n", $output);
36+
}
37+
}

tests/templates/welcome.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello {{ name }}!

0 commit comments

Comments
 (0)