Bug 26384: Fix executable flags
[koha.git] / t / db_dependent / Koha / Subscription / Routinglists.t
blob1eff86ca54232ed4a730607d63205f6a153f6327
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 # WIT HOUT 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 Test::More tests => 1;
21 use t::lib::TestBuilder;
23 use C4::Biblio;
25 use Koha::Database;
26 use Koha::Patrons;
27 use Koha::Subscriptions;
28 use Koha::Subscription::Routinglists;
30 my $schema = Koha::Database->new->schema;
31 my $builder = t::lib::TestBuilder->new;
33 subtest 'new() tests' => sub {
34 plan tests => 4;
36 $schema->storage->txn_begin;
38 my $biblio = Koha::Biblio->new()->store();
39 my $subscription = Koha::Subscription->new({
40 biblionumber => $biblio->biblionumber,
42 )->store;
44 my $library = $builder->build_object({ class => 'Koha::Libraries' });
45 my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library->id } });
47 my $routinglist_count = Koha::Subscription::Routinglists->count;
48 my $routinglist = Koha::Subscription::Routinglist->new({
49 borrowernumber => $patron->borrowernumber,
50 ranking => 1,
51 subscriptionid => $subscription->subscriptionid
52 })->store;
54 is( Koha::Subscription::Routinglists->search->count, $routinglist_count +1, 'One routing list added' );
56 my $retrieved_routinglist = Koha::Subscription::Routinglists->find( $routinglist->routingid );
57 is ( $retrieved_routinglist->routingid, $routinglist->routingid, "Find a routing list by id returns the correct routing list");
59 $routinglist->ranking(4)->update;
60 is ( $routinglist->ranking, 4, "Routing list ranking has been updated");
62 $routinglist->delete;
63 is ( Koha::Subscription::Routinglists->search->count, $routinglist_count, 'One subscription list deleted' );
67 $schema->storage->txn_rollback;