Bug 13928: Clean up noisy t/Borrower.t tests
authorMark Tompsett <mtompset@hotmail.com>
Mon, 30 Mar 2015 13:04:41 +0000 (09:04 -0400)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Wed, 8 Apr 2015 15:09:01 +0000 (12:09 -0300)
While testing bug 13882, noisy messages were noticed. Also,
Test::Warn was used, but no catching attempts were made. This
patch solves that problem.

TEST PLAN
---------
1) prove -v t/Borrowers.t
   -- There should be three noisy lines.
2) apply patch
3) prove -v t/Borrowers.t
   -- There will be 3 more tests and no noisy lines.
4) Run koha qa test tool
   -- There should be no issues.

NOTE: This will conflict with bug 13882 if either gets pushed
      to master, but fixing the conflict should be easy enough.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Works as expected

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
t/Borrower.t

index 8da4d88..2118d59 100755 (executable)
@@ -17,7 +17,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 13;
+use Test::More tests => 16;
 use Test::Warn;
 
 use Koha::Database;
@@ -46,11 +46,13 @@ ok( ref($ret) eq 'Koha::Borrower', "Set returns object on success" );
 is( $object2->surname(), "Test Borrower Surname 3", "Set sets first field correctly" );
 is( $object2->firstname(), "Test Firstname", "Set sets second field correctly" );
 
-$ret = $object->set({ surname => "Test Borrower Surname 4", bork => "bork" });
+warning_is { $ret = $object->set({ surname => "Test Borrower Surname 4", bork => "bork" }) } "No property bork!", "Expected 'No property bork!' caught";
 is( $object2->surname(), "Test Borrower Surname 3", "Bad Set does not set field" );
 is( $ret, 0, "Set returns 0 when passed a bad property" );
 
-ok( ! defined $object->bork(), 'Bad getter returns undef' );
-ok( ! defined $object->bork('bork'), 'Bad setter returns undef' );
+warning_is { $ret = $object->bork() } 'No method bork!', "Expected 'No method bork!' caught for getter.";
+ok( ! defined $ret, 'Bad getter returns undef' );
+warning_is { $ret = $object->bork('bork') } 'No method bork!', "Expected 'No method bork!' caught for setter.";
+ok( ! defined $ret, 'Bad setter returns undef' );
 
 1;