e8b8fb3519
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>
58 lines
2.3 KiB
Perl
Executable file
58 lines
2.3 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# This file is part of Koha.
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
|
|
|
use Modern::Perl;
|
|
|
|
use Test::More tests => 16;
|
|
use Test::Warn;
|
|
|
|
use Koha::Database;
|
|
|
|
BEGIN {
|
|
use_ok('Koha::Object');
|
|
use_ok('Koha::Borrower');
|
|
}
|
|
|
|
my $object = Koha::Borrower->new( { surname => 'Test Borrower' } );
|
|
|
|
is( $object->surname(), 'Test Borrower', "Accessor returns correct value" );
|
|
|
|
$object->surname('Test Borrower Surname');
|
|
is( $object->surname(), 'Test Borrower Surname', "Accessor returns correct value after set" );
|
|
|
|
my $object2 = Koha::Borrower->new( { surname => 'Test Borrower 2' } );
|
|
is( $object2->surname(), 'Test Borrower 2', "Accessor returns correct value" );
|
|
|
|
$object2->surname('Test Borrower Surname 2');
|
|
is( $object2->surname(), 'Test Borrower Surname 2', "Accessor returns correct value after set" );
|
|
|
|
my $ret;
|
|
$ret = $object2->set({ surname => "Test Borrower Surname 3", firstname => "Test Firstname" });
|
|
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" );
|
|
|
|
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" );
|
|
|
|
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;
|