From fc2a6415a9185f52f63521376123ff7d5ccf82bc Mon Sep 17 00:00:00 2001 From: Duncan Tyler Date: Fri, 9 Dec 2011 10:19:14 +1300 Subject: [PATCH] Added unit tests for Scrubber http://bugs.koha-community.org/show_bug.cgi?id=5327 Signed-off-by: Katrin Fischer Test passes. Signed-off-by: Paul Poulain (cherry picked from commit 47b514cf565f5eaccbefd256f24f82f38b5b4765) Signed-off-by: Chris Nighswonger --- t/Scrubber.t | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/t/Scrubber.t b/t/Scrubber.t index ce1503f0ab..0fe3a60e7d 100755 --- a/t/Scrubber.t +++ b/t/Scrubber.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 19; BEGIN { use FindBin; use lib $FindBin::Bin; @@ -20,7 +20,7 @@ sub pretty_line { my ($scrubber,$html,$result,@types,$collapse); $collapse = 1; -@types = qw(comment tag); +@types = qw(default comment tag staff); $html = q| @@ -58,7 +58,7 @@ $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($scrubber = C4::Scrubber->new($_), "testing 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: $_)" @@ -67,4 +67,22 @@ foreach(@types) { $collapse and $result =~ s/\s*\n\s*/\n/g; print pretty_line($_), $result, "\n", pretty_line(); } + +print "\n\n######################################################\nStart of invalid tests\n"; + +#Test for invalid new entry +eval{ + C4::Scrubber->new(""); + fail("test should fail on entry of ''\n"); +}; +pass("Test should have failed on entry of '' (empty string) and it did. YAY!\n"); + +eval{ + C4::Scrubber->new("Client"); + fail("test should fail on entry of 'Client'\n"); +}; +pass("Test should have failed on entry of 'Client' and it did. YAY!\n"); + +print "######################################################\n"; + diag "done.\n"; -- 2.39.5