3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Test
::More tests
=> 13;
26 use_ok
('Koha::Object');
27 use_ok
('Koha::Borrower');
30 my $object = Koha
::Borrower
->new( { surname
=> 'Test Borrower' } );
32 is
( $object->surname(), 'Test Borrower', "Accessor returns correct value" );
34 $object->surname('Test Borrower Surname');
35 is
( $object->surname(), 'Test Borrower Surname', "Accessor returns correct value after set" );
37 my $object2 = Koha
::Borrower
->new( { surname
=> 'Test Borrower 2' } );
38 is
( $object2->surname(), 'Test Borrower 2', "Accessor returns correct value" );
40 $object2->surname('Test Borrower Surname 2');
41 is
( $object2->surname(), 'Test Borrower Surname 2', "Accessor returns correct value after set" );
44 $ret = $object2->set({ surname
=> "Test Borrower Surname 3", firstname
=> "Test Firstname" });
45 ok
( ref($ret) eq 'Koha::Borrower', "Set returns object on success" );
46 is
( $object2->surname(), "Test Borrower Surname 3", "Set sets first field correctly" );
47 is
( $object2->firstname(), "Test Firstname", "Set sets second field correctly" );
49 $ret = $object->set({ surname
=> "Test Borrower Surname 4", bork
=> "bork" });
50 is
( $object2->surname(), "Test Borrower Surname 3", "Bad Set does not set field" );
51 is
( $ret, 0, "Set returns 0 when passed a bad property" );
53 ok
( ! defined $object->bork(), 'Bad getter returns undef' );
54 ok
( ! defined $object->bork('bork'), 'Bad setter returns undef' );