Bug 34924: Add Koha::Checkout->attempt_auto_renew
[koha.git] / t / db_dependent / Illrequestattributes.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 File::Basename qw/basename/;
21 use Koha::Database;
22 use Koha::Patrons;
23 use t::lib::TestBuilder;
24
25 use Test::More tests => 3;
26
27 my $schema = Koha::Database->new->schema;
28 use_ok('Koha::Illrequestattribute');
29 use_ok('Koha::Illrequestattributes');
30
31 subtest 'Basic object tests' => sub {
32
33     plan tests => 6;
34
35     $schema->storage->txn_begin;
36
37     Koha::Illrequestattributes->search->delete;
38
39     my $builder = t::lib::TestBuilder->new;
40
41     my $illrqattr = $builder->build( { source => 'Illrequestattribute' } );
42
43     my $illrqattr_obj = Koha::Illrequestattributes->find(
44         $illrqattr->{illrequest_id},
45         $illrqattr->{backend},
46         $illrqattr->{type}
47     );
48     isa_ok(
49         $illrqattr_obj, 'Koha::Illrequestattribute',
50         "Correctly create and load an illrequestattribute object."
51     );
52     is(
53         $illrqattr_obj->illrequest_id, $illrqattr->{illrequest_id},
54         "Illrequest_id getter works."
55     );
56     is(
57         $illrqattr_obj->backend, $illrqattr->{backend},
58         "Backend getter works."
59     );
60     is(
61         $illrqattr_obj->type, $illrqattr->{type},
62         "Type getter works."
63     );
64     is(
65         $illrqattr_obj->value, $illrqattr->{value},
66         "Value getter works."
67     );
68
69     $illrqattr_obj->delete;
70
71     is(
72         Koha::Illrequestattributes->search->count, 0,
73         "No attributes found after delete."
74     );
75
76     $schema->storage->txn_rollback;
77 };
78
79 1;