1#!perl -T 2 3use strict; 4use warnings; 5use Test::More; 6use Tenjin; 7 8my $t = Tenjin->new({ path => ['t/data/utils'] }); 9ok($t, 'Got a proper Tenjin instance'); 10 11# the encode_url method 12is( 13 $t->render('encode_url.html', { url => "http://www.google.com/search?q=tenjin&ie=utf-8&oe=utf-8&aq=t" }), 14 "http%3A//www.google.com/search%3Fq%3Dtenjin%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt", 15 'encode_url() works' 16); 17 18# the escape_xml() and unescape_xml() methods 19is( 20 $t->render('escape_xml.html', { 21 escape => "<a href=\"http://localhost:3000/?key=value&value=key\">test\"test</a>", 22 unescape => "<a href=\"http://localhost:3000/?key=value&value=key\">test"test</a>" 23 }), 24 "<a href="http://localhost:3000/?key=value&value=key">test"test</a>\n<a href=\"http://localhost:3000/?key=value&value=key\">test\"test</a>", 25 '(un)escape_xml() works' 26); 27 28# the p() and P() methods 29is( 30 $t->render('pP.html', { p => "whaddup?", P => "encode & me" }), 31 "<`#whaddup?#`>\n<`\$encode & me\$`>", 32 'p() and P() work' 33); 34 35done_testing(); 36