Bug 26922: Regression tests
[koha.git] / t / db_dependent / Illrequestattributes.t
blobd81215fdc27f5fc777ba20e76519734a1d0188fb
1 #!/usr/bin/perl
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>.
18 use Modern::Perl;
20 use File::Basename qw/basename/;
21 use Koha::Database;
22 use Koha::Patrons;
23 use t::lib::TestBuilder;
25 use Test::More tests => 3;
27 my $schema = Koha::Database->new->schema;
28 use_ok('Koha::Illrequestattribute');
29 use_ok('Koha::Illrequestattributes');
31 subtest 'Basic object tests' => sub {
33 plan tests => 5;
35 $schema->storage->txn_begin;
37 Koha::Illrequestattributes->search->delete;
39 my $builder = t::lib::TestBuilder->new;
41 my $illrqattr = $builder->build({ source => 'Illrequestattribute' });
43 my $illrqattr_obj = Koha::Illrequestattributes->find(
44 $illrqattr->{illrequest_id},
45 $illrqattr->{type}
47 isa_ok($illrqattr_obj, 'Koha::Illrequestattribute',
48 "Correctly create and load an illrequestattribute object.");
49 is($illrqattr_obj->illrequest_id, $illrqattr->{illrequest_id},
50 "Illrequest_id getter works.");
51 is($illrqattr_obj->type, $illrqattr->{type},
52 "Type getter works.");
53 is($illrqattr_obj->value, $illrqattr->{value},
54 "Value getter works.");
56 $illrqattr_obj->delete;
58 is(Koha::Illrequestattributes->search->count, 0,
59 "No attributes found after delete.");
61 $schema->storage->txn_rollback;