|
Line 0
Link Here
|
| 0 |
- |
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 |
# 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. |
| 14 |
# |
| 15 |
# You vcshould have received a copy of the GNU General Public License |
| 16 |
# al ong with Koha; if not, see <http://www.gnu.org/licenses>. |
| 17 |
|
| 18 |
use Modern::Perl; |
| 19 |
|
| 20 |
use Test::More tests => 1; |
| 21 |
use t::lib::TestBuilder; |
| 22 |
|
| 23 |
use C4::Biblio; |
| 24 |
|
| 25 |
use Koha::Database; |
| 26 |
use Koha::Patrons; |
| 27 |
use Koha::Subscriptions; |
| 28 |
use Koha::Subscription::Routinglists; |
| 29 |
|
| 30 |
my $schema = Koha::Database->new->schema; |
| 31 |
$schema->storage->txn_begin; |
| 32 |
|
| 33 |
my $biblio = Koha::Biblio->new()->store(); |
| 34 |
my $subscription = Koha::Subscription->new({ |
| 35 |
biblionumber => $biblio->biblionumber, |
| 36 |
} |
| 37 |
)->store; |
| 38 |
|
| 39 |
my $builder = t::lib::TestBuilder->new; |
| 40 |
my $library = $builder->build({source => 'Branch' }); |
| 41 |
my $category = $builder->build({source => 'Category' }); |
| 42 |
|
| 43 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 44 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
| 45 |
|
| 46 |
subtest 'new() tests' => sub { |
| 47 |
plan tests => 4; |
| 48 |
|
| 49 |
my $routinglist_count = Koha::Subscription::Routinglists->count; |
| 50 |
my $routinglist = Koha::Subscription::Routinglist->new({ |
| 51 |
borrowernumber => $patron->borrowernumber, |
| 52 |
ranking => 1, |
| 53 |
subscriptionid => $subscription->subscriptionid |
| 54 |
})->store; |
| 55 |
|
| 56 |
is( Koha::Subscription::Routinglists->search->count, $routinglist_count +1, 'One routing list added' ); |
| 57 |
|
| 58 |
my $retrieved_routinglist = Koha::Subscription::Routinglists->find( $routinglist->routingid ); |
| 59 |
is ( $retrieved_routinglist->routingid, $routinglist->routingid, "Find a routing list by id returns the correct routing list"); |
| 60 |
|
| 61 |
$routinglist->ranking(4)->update; |
| 62 |
is ( $routinglist->ranking, 4, "Routing list ranking has been updated"); |
| 63 |
|
| 64 |
$routinglist->delete; |
| 65 |
is ( Koha::Subscription::Routinglists->search->count, $routinglist_count, 'One subscription list deleted' ); |
| 66 |
|
| 67 |
}; |
| 68 |
|
| 69 |
$schema->storage->txn_rollback; |