Bug 7317: Interlibrary loans framework for Koha.
[koha-equinox.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 under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 #
18
19 use Modern::Perl;
20
21 use File::Basename qw/basename/;
22 use Koha::Database;
23 use Koha::Patrons;
24 use t::lib::TestBuilder;
25
26 use Test::More tests => 3;
27
28 my $schema = Koha::Database->new->schema;
29 use_ok('Koha::Illrequestattribute');
30 use_ok('Koha::Illrequestattributes');
31
32 subtest 'Basic object tests' => sub {
33
34     plan tests => 5;
35
36     $schema->storage->txn_begin;
37
38     my $builder = t::lib::TestBuilder->new;
39
40     my $illrqattr = $builder->build({ source => 'Illrequestattribute' });
41
42     my $illrqattr_obj = Koha::Illrequestattributes->find(
43         $illrqattr->{illrequest_id},
44         $illrqattr->{type}
45     );
46     isa_ok($illrqattr_obj, 'Koha::Illrequestattribute',
47         "Correctly create and load an illrequestattribute object.");
48     is($illrqattr_obj->illrequest_id, $illrqattr->{illrequest_id},
49        "Illrequest_id getter works.");
50     is($illrqattr_obj->type, $illrqattr->{type},
51        "Type getter works.");
52     is($illrqattr_obj->value, $illrqattr->{value},
53        "Value getter works.");
54
55     $illrqattr_obj->delete;
56
57     is(Koha::Illrequestattributes->search->count, 0,
58         "No attributes found after delete.");
59
60     $schema->storage->txn_rollback;
61 };
62
63 1;