Bug 18292: Remove return 1 statements in tests
[koha.git] / t / db_dependent / Patron / HouseboundProfiles.t
1 #!/usr/bin/perl
2
3 # This file is part of Koha.
4 #
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.
9 #
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.
14 #
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>.
17
18 use Modern::Perl;
19
20 use Test::More tests => 3;
21
22 use Koha::Database;
23 use Koha::Patron::HouseboundProfiles;
24
25 use t::lib::TestBuilder;
26
27 my $schema = Koha::Database->new->schema;
28 $schema->storage->txn_begin;
29
30 my $builder = t::lib::TestBuilder->new;
31
32 # Profile Tests
33
34 my $profile = $builder->build({ source => 'HouseboundProfile' });
35
36 is(
37     Koha::Patron::HouseboundProfiles
38           ->find($profile->{borrowernumber})->borrowernumber,
39     $profile->{borrowernumber},
40     "Find created profile."
41 );
42
43 my @profiles = Koha::Patron::HouseboundProfiles
44     ->search({ day => $profile->{day} });
45 my $found_profile = shift @profiles;
46 is(
47     $found_profile->borrowernumber,
48     $profile->{borrowernumber},
49     "Search for created profile."
50 );
51
52 # ->housebound_profile Tests
53
54 my $visit1 = $builder->build({
55     source => 'HouseboundVisit',
56     value  => {
57         borrowernumber => $profile->{borrowernumber},
58     },
59 });
60 my $visit2 = $builder->build({
61     source => 'HouseboundVisit',
62     value  => {
63         borrowernumber => $profile->{borrowernumber},
64     },
65 });
66
67 is(
68     scalar @{$found_profile->housebound_visits},
69     2,
70     "Fetch housebound_visits."
71 );
72
73 $schema->storage->txn_rollback;
74