Lines 3-9
Link Here
|
3 |
use strict; |
3 |
use strict; |
4 |
use warnings; |
4 |
use warnings; |
5 |
|
5 |
|
6 |
use Test::More tests => 19; |
6 |
$| = 1; |
|
|
7 |
use Test::More tests => 29; |
8 |
use Test::Warn; |
9 |
|
7 |
BEGIN { |
10 |
BEGIN { |
8 |
use FindBin; |
11 |
use FindBin; |
9 |
use lib $FindBin::Bin; |
12 |
use lib $FindBin::Bin; |
Lines 43-88
$html = q|
Link Here
|
43 |
At the end here, I actually have some regular text. |
46 |
At the end here, I actually have some regular text. |
44 |
|; |
47 |
|; |
45 |
|
48 |
|
46 |
print pretty_line("Original HTML:"), $html, "\n", pretty_line(); |
|
|
47 |
$collapse and print "Note: scrubber test output will have whitespace collapsed for readability\n"; |
48 |
ok($scrubber = C4::Scrubber->new(), "Constructor: C4::Scrubber->new()"); |
49 |
ok($scrubber = C4::Scrubber->new(), "Constructor: C4::Scrubber->new()"); |
49 |
|
50 |
|
50 |
isa_ok($scrubber, 'HTML::Scrubber', 'Constructor returns HTML::Scrubber object'); |
51 |
isa_ok($scrubber, 'HTML::Scrubber', 'Constructor returns HTML::Scrubber object'); |
51 |
|
52 |
|
52 |
ok(printf("# scrubber settings: default %s, comment %s, process %s\n", |
53 |
warning_like { $scrubber->default() } '', "\$scrubber->default ran without fault."; |
53 |
$scrubber->default(),$scrubber->comment(),$scrubber->process()), |
54 |
warning_like { $scrubber->comment() } '', "\$scrubber->comment ran without fault."; |
54 |
"Outputting settings from scrubber object (type: [default])" |
55 |
warning_like { $scrubber->process() } '', "\$scrubber->process ran without fault."; |
55 |
); |
56 |
|
56 |
ok($result = $scrubber->scrub($html), "Getting scrubbed text (type: [default])"); |
57 |
ok($result = $scrubber->scrub($html), "Getting scrubbed text (type: [default])"); |
57 |
$collapse and $result =~ s/\s*\n\s*/\n/g; |
|
|
58 |
print pretty_line('default'), $result, "\n", pretty_line(); |
59 |
|
58 |
|
60 |
foreach(@types) { |
59 |
foreach(@types) { |
61 |
ok($scrubber = C4::Scrubber->new($_), "testing Constructor: C4::Scrubber->new($_)"); |
60 |
ok($scrubber = C4::Scrubber->new($_), "testing Constructor: C4::Scrubber->new($_)"); |
62 |
ok(printf("# scrubber settings: default %s, comment %s, process %s\n", |
61 |
|
63 |
$scrubber->default(),$scrubber->comment(),$scrubber->process()), |
62 |
warning_like { $scrubber->default() } '', "\$scrubber->default ran without fault."; |
64 |
"Outputting settings from scrubber object (type: $_)" |
63 |
warning_like { $scrubber->comment() } '', "\$scrubber->comment ran without fault."; |
65 |
); |
64 |
warning_like { $scrubber->process() } '', "\$scrubber->process ran without fault."; |
|
|
65 |
|
66 |
ok($result = $scrubber->scrub($html), "Getting scrubbed text (type: $_)"); |
66 |
ok($result = $scrubber->scrub($html), "Getting scrubbed text (type: $_)"); |
67 |
$collapse and $result =~ s/\s*\n\s*/\n/g; |
|
|
68 |
print pretty_line($_), $result, "\n", pretty_line(); |
69 |
} |
67 |
} |
70 |
|
68 |
|
71 |
print "\n\n######################################################\nStart of invalid tests\n"; |
|
|
72 |
|
73 |
#Test for invalid new entry |
69 |
#Test for invalid new entry |
74 |
eval{ |
70 |
eval{ |
75 |
C4::Scrubber->new(""); |
71 |
C4::Scrubber->new(""); |
76 |
fail("test should fail on entry of ''\n"); |
72 |
fail("test should fail on entry of ''"); |
77 |
}; |
73 |
}; |
78 |
pass("Test should have failed on entry of '' (empty string) and it did. YAY!\n"); |
74 |
if ($@) { |
|
|
75 |
pass("Test should have failed on entry of '' (empty string) and it did. YAY!"); |
76 |
} |
79 |
|
77 |
|
80 |
eval{ |
78 |
eval{ |
81 |
C4::Scrubber->new("Client"); |
79 |
C4::Scrubber->new("Client"); |
82 |
fail("test should fail on entry of 'Client'\n"); |
80 |
fail("test should fail on entry of 'Client'"); |
83 |
}; |
81 |
}; |
84 |
pass("Test should have failed on entry of 'Client' and it did. YAY!\n"); |
82 |
if ($@) { |
85 |
|
83 |
pass("Test should have failed on entry of 'Client' and it did. YAY!"); |
86 |
print "######################################################\n"; |
84 |
} |
87 |
|
|
|
88 |
print "done.\n"; |
89 |
- |
|
|