X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2FScrubber.t;h=9bcd003636ab8e67f3211763e9c3da220056fd8d;hb=6be54ad1206491fc9c449b03a8249f8a75c14713;hp=ce1503f0ab119f74a655d76281ae554daff3dc1c;hpb=2a3f7c141798121a75fc9ee670af0fdde431d9c2;p=koha.git diff --git a/t/Scrubber.t b/t/Scrubber.t index ce1503f0ab..9bcd003636 100755 --- a/t/Scrubber.t +++ b/t/Scrubber.t @@ -3,7 +3,10 @@ use strict; use warnings; -use Test::More tests => 11; +$| = 1; +use Test::More tests => 29; +use Test::Warn; + BEGIN { use FindBin; use lib $FindBin::Bin; @@ -20,7 +23,7 @@ sub pretty_line { my ($scrubber,$html,$result,@types,$collapse); $collapse = 1; -@types = qw(comment tag); +@types = qw(default comment tag staff); $html = q| @@ -43,28 +46,39 @@ $html = q| At the end here, I actually have some regular text. |; -print pretty_line("Original HTML:"), $html, "\n", pretty_line(); -$collapse and diag "Note: scrubber test output will have whitespace collapsed for readability\n"; ok($scrubber = C4::Scrubber->new(), "Constructor: C4::Scrubber->new()"); isa_ok($scrubber, 'HTML::Scrubber', 'Constructor returns HTML::Scrubber object'); -ok(printf("# scrubber settings: default %s, comment %s, process %s\n", - $scrubber->default(),$scrubber->comment(),$scrubber->process()), - "Outputting settings from scrubber object (type: [default])" -); +warning_like { $scrubber->default() } '', "\$scrubber->default ran without fault."; +warning_like { $scrubber->comment() } '', "\$scrubber->comment ran without fault."; +warning_like { $scrubber->process() } '', "\$scrubber->process ran without fault."; + ok($result = $scrubber->scrub($html), "Getting scrubbed text (type: [default])"); -$collapse and $result =~ s/\s*\n\s*/\n/g; -print pretty_line('default'), $result, "\n", pretty_line(); foreach(@types) { - ok($scrubber = C4::Scrubber->new($_), "Constructor: C4::Scrubber->new($_)"); - ok(printf("# scrubber settings: default %s, comment %s, process %s\n", - $scrubber->default(),$scrubber->comment(),$scrubber->process()), - "Outputting settings from scrubber object (type: $_)" - ); + ok($scrubber = C4::Scrubber->new($_), "testing Constructor: C4::Scrubber->new($_)"); + + warning_like { $scrubber->default() } '', "\$scrubber->default ran without fault."; + warning_like { $scrubber->comment() } '', "\$scrubber->comment ran without fault."; + warning_like { $scrubber->process() } '', "\$scrubber->process ran without fault."; + ok($result = $scrubber->scrub($html), "Getting scrubbed text (type: $_)"); - $collapse and $result =~ s/\s*\n\s*/\n/g; - print pretty_line($_), $result, "\n", pretty_line(); } -diag "done.\n"; + +#Test for invalid new entry +eval{ + C4::Scrubber->new(""); + fail("test should fail on entry of ''"); +}; +if ($@) { + pass("Test should have failed on entry of '' (empty string) and it did. YAY!"); +} + +eval{ + C4::Scrubber->new("Client"); + fail("test should fail on entry of 'Client'"); +}; +if ($@) { + pass("Test should have failed on entry of 'Client' and it did. YAY!"); +}