public function test_safe_anchor() { $safe_anchor = ReflectionHelper::getPrivateMethodInvoker($this->obj, 'safe_anchor'); $actual = $safe_anchor('news/local/123', 'My News', array('title' => 'The best news!')); $expected = '<a href="http://localhost/index.php/news/local/123" title="The best news!">My News</a>'; $this->assertEquals($expected, $actual); $actual = $safe_anchor('news/local/123', '<s>abc</s>', array('<s>name</s>' => '<s>val</s>')); $expected = '<a href="http://localhost/index.php/news/local/123" <s>name</s>="<s>val</s>"><s>abc</s></a>'; $this->assertEquals($expected, $actual); }
public function setUp() { $twig = new Twig(); $loader = new Twig_Loader_Array(['base_url' => '{{ base_url(\'"><s>abc</s><a name="test\') }}', 'site_url' => '{{ site_url(\'"><s>abc</s><a name="test\') }}', 'anchor' => '{{ anchor(uri, title, attributes) }}']); $setLoader = ReflectionHelper::getPrivateMethodInvoker($twig, 'setLoader'); $setLoader($loader); $resetTwig = ReflectionHelper::getPrivateMethodInvoker($twig, 'resetTwig'); $resetTwig(); $addFunctions = ReflectionHelper::getPrivateMethodInvoker($twig, 'addFunctions'); $addFunctions(); $this->obj = $twig; $this->twig = $twig->getTwig(); }