9 use Test::More tests => 6;
11 use_ok('Koha::Patron');
13 use t::lib::TestBuilder;
16 my $schema = Koha::Database->new->schema;
17 $schema->storage->txn_begin;
19 my $builder = t::lib::TestBuilder->new;
21 my $patron = $builder->build({ source => 'Borrower' });
22 my $profile = $builder->build({
23 source => 'HouseboundProfile',
25 borrowernumber => $patron->{borrowernumber},
29 # Test housebound_profile
31 Koha::Patrons->find($patron->{borrowernumber})
32 ->housebound_profile->frequency,
33 $profile->{frequency},
34 "Fetch housebound_profile."
37 # patron_choosers and patron_deliverers Tests
39 # Current Patron Chooser / Deliverer count
40 my $orig_del_count = Koha::Patrons->search_housebound_deliverers->count;
41 my $orig_cho_count = Koha::Patrons->search_housebound_choosers->count;
43 # We add one, just in case the above is 0, so we're guaranteed one of each.
44 my $patron_chooser = $builder->build({ source => 'Borrower' });
46 source => 'BorrowerAttribute',
48 borrowernumber => $patron_chooser->{borrowernumber},
55 my $patron_deliverer = $builder->build({ source => 'Borrower' });
57 source => 'BorrowerAttribute',
59 borrowernumber => $patron_deliverer->{borrowernumber},
66 # Test search_housebound_choosers
67 is(Koha::Patrons->search_housebound_choosers->count, $orig_cho_count + 1, "Correct count of choosers.");
68 is(Koha::Patrons->search_housebound_deliverers->count, $orig_del_count + 1, "Correct count of deliverers");
70 isa_ok(Koha::Patrons->search_housebound_choosers->next, "Koha::Patron");
71 isa_ok(Koha::Patrons->search_housebound_deliverers->next, "Koha::Patron");
73 $schema->storage->txn_rollback;