File: filter_text.t

package info (click to toggle)
libhtml-restrict-perl 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: perl: 842; makefile: 7
file content (45 lines) | stat: -rw-r--r-- 970 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!perl

use strict;
use warnings;

use HTML::Restrict ();
use Test::More;

my $hr               = HTML::Restrict->new( debug => 0 );
my $hr_no_processing = HTML::Restrict->new( debug => 0, filter_text => 0 );
my $hr_code_ref
    = HTML::Restrict->new( debug => 0, filter_text => \&code_ref );

my $string = 'Terms & Conditions';
my $html   = "<h2>$string</h2>";

#plain text tests
is(
    $hr->process($string), 'Terms &amp; Conditions',
    'Plain Text being processed'
);
is(
    $hr_no_processing->process($string), $string,
    'Plain Text not being processed'
);

#html tests
is( $hr->process($html), 'Terms &amp; Conditions', 'HTML being processed' );
is(
    $hr_no_processing->process($html), 'Terms & Conditions',
    'HTML not being processed'
);

#code ref test
is(
    $hr_code_ref->process($html), 'foobarbat Terms & Conditions',
    'Code Ref used to process'
);

done_testing();

sub code_ref {
    my $text = shift @_;
    return 'foobarbat ' . $text;
}