@@ -17,6 +17,7 @@ public function setUp()
17
17
$ loader = new Twig_Loader_Array ([
18
18
'base_url ' => '{{ base_url( \'"><s>abc</s><a name="test \') }} ' ,
19
19
'site_url ' => '{{ site_url( \'"><s>abc</s><a name="test \') }} ' ,
20
+ 'anchor ' => '{{ anchor(uri, title, attributes) }} ' ,
20
21
]);
21
22
$ setLoader = ReflectionHelper::getPrivateMethodInvoker (
22
23
$ CI ->twig , 'setLoader '
@@ -28,17 +29,36 @@ public function setUp()
28
29
);
29
30
$ resetTwig ();
30
31
32
+ $ addFunctions = ReflectionHelper::getPrivateMethodInvoker (
33
+ $ CI ->twig , 'addFunctions '
34
+ );
35
+ $ addFunctions ();
36
+
31
37
$ this ->obj = $ CI ->twig ;
32
38
$ this ->twig = $ CI ->twig ->getTwig ();
33
39
}
34
40
35
- public function test_safe_anchor ()
41
+ public function test_anchor ()
36
42
{
37
- $ actual = $ this ->obj ->safe_anchor ('news/local/123 ' , 'My News ' , array ('title ' => 'The best news! ' ));
43
+ $ actual = $ this ->twig ->render (
44
+ 'anchor ' ,
45
+ [
46
+ 'uri ' => 'news/local/123 ' ,
47
+ 'title ' => 'My News ' ,
48
+ 'attributes ' => ['title ' => 'The best news! ' ]
49
+ ]
50
+ );
38
51
$ expected = '<a href="http://localhost/index.php/news/local/123" title="The best news!">My News</a> ' ;
39
52
$ this ->assertEquals ($ expected , $ actual );
40
-
41
- $ actual = $ this ->obj ->safe_anchor ('news/local/123 ' , '<s>abc</s> ' , array ('<s>name</s> ' => '<s>val</s> ' ));
53
+
54
+ $ actual = $ this ->twig ->render (
55
+ 'anchor ' ,
56
+ [
57
+ 'uri ' => 'news/local/123 ' ,
58
+ 'title ' => '<s>abc</s> ' ,
59
+ 'attributes ' => ['<s>name</s> ' => '<s>val</s> ' ]
60
+ ]
61
+ );
42
62
$ expected = '<a href="http://localhost/index.php/news/local/123" <s>name</s>="<s>val</s>"><s>abc</s></a> ' ;
43
63
$ this ->assertEquals ($ expected , $ actual );
44
64
}
0 commit comments